|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Stu\Module\Ship\Action\ActivateRPGModule; |
|
6
|
|
|
|
|
7
|
|
|
use request; |
|
8
|
|
|
use Stu\Component\Ship\System\ShipSystemTypeEnum; |
|
9
|
|
|
use Stu\Module\Control\ActionControllerInterface; |
|
10
|
|
|
use Stu\Module\Control\GameControllerInterface; |
|
11
|
|
|
use Stu\Module\Ship\Lib\ActivatorDeactivatorHelperInterface; |
|
12
|
|
|
use Stu\Module\Ship\View\ShowShip\ShowShip; |
|
13
|
|
|
use Stu\Module\Ship\Lib\ShipLoaderInterface; |
|
14
|
|
|
use Stu\Orm\Repository\ShipRepositoryInterface; |
|
15
|
|
|
|
|
16
|
|
|
final class ActivateRPGModule implements ActionControllerInterface |
|
17
|
|
|
{ |
|
18
|
|
|
public const ACTION_IDENTIFIER = 'B_ACTIVATE_RPG_MODULE'; |
|
19
|
|
|
|
|
20
|
|
|
private ActivatorDeactivatorHelperInterface $helper; |
|
21
|
|
|
|
|
22
|
|
|
private ShipLoaderInterface $shipLoader; |
|
23
|
|
|
|
|
24
|
|
|
private ShipRepositoryInterface $shipRepository; |
|
25
|
|
|
|
|
26
|
|
|
public function __construct( |
|
27
|
|
|
ShipLoaderInterface $shipLoader, |
|
28
|
|
|
ShipRepositoryInterface $shipRepository, |
|
29
|
|
|
ActivatorDeactivatorHelperInterface $helper |
|
30
|
|
|
) { |
|
31
|
|
|
$this->shipLoader = $shipLoader; |
|
32
|
|
|
$this->shipRepository = $shipRepository; |
|
33
|
|
|
$this->helper = $helper; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
public function handle(GameControllerInterface $game): void |
|
37
|
|
|
{ |
|
38
|
|
|
$game->setView(ShowShip::VIEW_IDENTIFIER); |
|
39
|
|
|
|
|
40
|
|
|
$userId = $game->getUser()->getId(); |
|
41
|
|
|
|
|
42
|
|
|
$this->helper->activate(request::indInt('id'), ShipSystemTypeEnum::SYSTEM_RPG_MODULE, $game, true); |
|
43
|
|
|
|
|
44
|
|
|
$ship = $this->shipLoader->getByIdAndUser( |
|
45
|
|
|
request::indInt('id'), |
|
46
|
|
|
$userId |
|
47
|
|
|
); |
|
48
|
|
|
|
|
49
|
|
|
|
|
50
|
|
|
$ship->setCanBeDisabled(true); |
|
51
|
|
|
|
|
52
|
|
|
$this->shipRepository->save($ship); |
|
53
|
|
|
|
|
54
|
|
|
$game->addInformation("Das RPG Modul wurde aktiviert"); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
public function performSessionCheck(): bool |
|
58
|
|
|
{ |
|
59
|
|
|
return true; |
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
|