1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Stu\Module\Admin\Action\Map\EditPassable; |
6
|
|
|
|
7
|
|
|
use Stu\Module\Admin\View\Map\Noop\Noop; |
8
|
|
|
use Stu\Module\Control\ActionControllerInterface; |
9
|
|
|
use Stu\Module\Control\GameControllerInterface; |
10
|
|
|
use Stu\Orm\Entity\Map; |
11
|
|
|
use Stu\Orm\Repository\MapRegionRepositoryInterface; |
12
|
|
|
use Stu\Orm\Repository\MapRepositoryInterface; |
13
|
|
|
use Stu\Orm\Repository\MapFieldTypeRepositoryInterface; |
14
|
|
|
|
15
|
|
|
final class EditPassable implements ActionControllerInterface |
16
|
|
|
{ |
17
|
|
|
public const ACTION_IDENTIFIER = 'B_EDIT_PASSABLE'; |
18
|
|
|
|
19
|
|
|
private EditPassableRequestInterface $editPassableRequest; |
20
|
|
|
|
21
|
|
|
private MapRegionRepositoryInterface $mapRegionRepository; |
22
|
|
|
|
23
|
|
|
private MapRepositoryInterface $mapRepository; |
24
|
|
|
|
25
|
|
|
private MapFieldTypeRepositoryInterface $mapFieldTypeRepository; |
26
|
|
|
|
27
|
|
|
public function __construct( |
28
|
|
|
EditPassableRequestInterface $editPassableRequest, |
29
|
|
|
MapRegionRepositoryInterface $mapRegionRepository, |
30
|
|
|
MapFieldTypeRepositoryInterface $mapFieldTypeRepository, |
31
|
|
|
MapRepositoryInterface $mapRepository |
32
|
|
|
) { |
33
|
|
|
$this->editPassableRequest = $editPassableRequest; |
34
|
|
|
$this->mapRegionRepository = $mapRegionRepository; |
35
|
|
|
$this->mapFieldTypeRepository = $mapFieldTypeRepository; |
36
|
|
|
$this->mapRepository = $mapRepository; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
public function handle(GameControllerInterface $game): void |
40
|
|
|
{ |
41
|
|
|
$selectedField = $this->mapRepository->find($this->editPassableRequest->getFieldId()); |
42
|
|
|
|
43
|
|
|
if ($selectedField === null) { |
44
|
|
|
return; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
$selectedMapFType = $selectedField->getFieldType(); |
48
|
|
|
|
49
|
|
|
$passable = $this->editPassableRequest->getPassable(); |
50
|
|
|
|
51
|
|
|
if ($passable === 1) { |
52
|
|
|
$selectedMapFType->setPassable(true); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
if ($passable === 2) { |
56
|
|
|
$selectedMapFType->setPassable(false); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
$this->mapFieldTypeRepository->save($selectedMapFType); |
60
|
|
|
|
61
|
|
|
$game->setView(Noop::VIEW_IDENTIFIER); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
public function performSessionCheck(): bool |
65
|
|
|
{ |
66
|
|
|
return false; |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|