Total Complexity | 13 |
Total Lines | 56 |
Duplicated Lines | 0 % |
Coverage | 53.56% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
8 | trait SpacecraftCrewTrait |
||
9 | { |
||
10 | use SpacecraftTrait; |
||
11 | use HasSpacecraftSystemTrait; |
||
12 | |||
13 | 7 | public function getNeededCrewCount(): int |
|
14 | { |
||
15 | 7 | $buildplan = $this->getThis()->getBuildplan(); |
|
16 | 7 | if ($buildplan === null) { |
|
17 | return 0; |
||
18 | } |
||
19 | |||
20 | 7 | return $buildplan->getCrew(); |
|
21 | } |
||
22 | |||
23 | 12 | public function getCrewCount(): int |
|
24 | { |
||
25 | 12 | return $this->getThis()->getCrewAssignments()->count(); |
|
26 | } |
||
27 | |||
28 | 6 | public function getExcessCrewCount(): int |
|
29 | { |
||
30 | 6 | return $this->getCrewCount() - $this->getNeededCrewCount(); |
|
31 | } |
||
32 | |||
33 | 3 | public function hasEnoughCrew(?GameControllerInterface $game = null): bool |
|
34 | { |
||
35 | 3 | $buildplan = $this->getThis()->getBuildplan(); |
|
36 | |||
37 | 3 | if ($buildplan === null) { |
|
38 | if ($game !== null) { |
||
39 | $game->addInformation(_("Keine Crew vorhanden")); |
||
40 | } |
||
41 | return false; |
||
42 | } |
||
43 | |||
44 | 3 | $result = $buildplan->getCrew() <= 0 |
|
45 | 3 | || $this->getCrewCount() >= $buildplan->getCrew(); |
|
46 | |||
47 | 3 | if (!$result && $game !== null) { |
|
48 | $game->addInformationf( |
||
49 | _("Es werden %d Crewmitglieder benötigt"), |
||
50 | $buildplan->getCrew() |
||
51 | ); |
||
52 | } |
||
53 | |||
54 | 3 | return $result; |
|
55 | } |
||
56 | |||
57 | public function canMan(): bool |
||
64 | } |
||
65 | } |
||
66 |