Conditions | 7 |
Paths | 7 |
Total Lines | 35 |
Code Lines | 20 |
Lines | 0 |
Ratio | 0 % |
Tests | 21 |
CRAP Score | 7 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
15 | 18 | public function check( |
|
16 | ShipWrapperInterface $wrapper, |
||
17 | FlightRouteInterface $flightRoute, |
||
18 | ConditionCheckResult $conditionCheckResult |
||
19 | ): void { |
||
20 | |||
21 | 18 | $routeMode = $flightRoute->getRouteMode(); |
|
22 | 18 | if ($routeMode !== RouteModeEnum::ROUTE_MODE_FLIGHT) { |
|
23 | 10 | return; |
|
24 | } |
||
25 | |||
26 | 8 | if ($flightRoute->getNextWaypoint() instanceof StarSystemMapInterface) { |
|
27 | 2 | return; |
|
28 | } |
||
29 | |||
30 | 6 | $warpdriveSystem = $wrapper->getWarpDriveSystemData(); |
|
31 | 6 | if ($warpdriveSystem === null) { |
|
32 | 2 | return; |
|
33 | } |
||
34 | |||
35 | 4 | $ship = $wrapper->get(); |
|
36 | |||
37 | 4 | $neededWarpDrive = 1; |
|
38 | 4 | if ($ship->isTractoring()) { |
|
39 | 2 | $neededWarpDrive += 2; |
|
40 | } |
||
41 | |||
42 | 4 | if ($warpdriveSystem->getWarpDrive() < $neededWarpDrive) { |
|
43 | 2 | $conditionCheckResult->addBlockedShip( |
|
44 | 2 | $ship, |
|
45 | 2 | sprintf( |
|
46 | 2 | 'Die %s hat nicht genug Warpantriebsenergie für den %s (%d benötigt)', |
|
47 | 2 | $ship->getName(), |
|
48 | 2 | $ship->isTractoring() ? 'Traktor-Flug' : 'Flug', |
|
49 | 2 | $neededWarpDrive |
|
50 | 2 | ) |
|
55 |