Total Complexity | 6 |
Total Lines | 43 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 0 |
1 | <?php |
||
13 | final class SplitReactorOutput implements ActionControllerInterface |
||
14 | { |
||
15 | public const ACTION_IDENTIFIER = 'B_SPLIT_REACTOR_OUTPUT'; |
||
16 | |||
17 | private ShipLoaderInterface $shipLoader; |
||
18 | |||
19 | public function __construct( |
||
20 | ShipLoaderInterface $shipLoader |
||
21 | ) { |
||
22 | $this->shipLoader = $shipLoader; |
||
23 | } |
||
24 | |||
25 | public function handle(GameControllerInterface $game): void |
||
26 | { |
||
27 | $game->setView(ShowShip::VIEW_IDENTIFIER); |
||
28 | |||
29 | $userId = $game->getUser()->getId(); |
||
30 | |||
31 | |||
32 | $wrapper = $this->shipLoader->getWrapperByIdAndUser( |
||
33 | request::indInt('id'), |
||
34 | $userId |
||
35 | ); |
||
36 | |||
37 | $systemData = $wrapper->getWarpDriveSystemData(); |
||
38 | if ($systemData === null) { |
||
39 | return; |
||
40 | } |
||
41 | |||
42 | $value = request::postInt('value'); |
||
43 | if ($value < 0) { |
||
44 | $value = 0; |
||
45 | } |
||
46 | if ($value > 100) { |
||
47 | $value = 100; |
||
48 | } |
||
49 | |||
50 | $systemData->setWarpDriveSplit($value)->update(); |
||
51 | } |
||
52 | |||
53 | public function performSessionCheck(): bool |
||
56 | } |
||
57 | } |
||
58 |