1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Stu\Module\Colony\Lib\Gui\Component; |
4
|
|
|
|
5
|
|
|
use Override; |
|
|
|
|
6
|
|
|
use Stu\Component\Crew\CrewCountRetrieverInterface; |
7
|
|
|
use Stu\Lib\Colony\PlanetFieldHostInterface; |
8
|
|
|
use Stu\Module\Colony\Lib\ColonyLibFactoryInterface; |
9
|
|
|
use Stu\Module\Control\GameControllerInterface; |
10
|
|
|
use Stu\Orm\Entity\ColonyInterface; |
11
|
|
|
|
12
|
|
|
final class AcademyProvider implements PlanetFieldHostComponentInterface |
13
|
|
|
{ |
14
|
1 |
|
public function __construct(private ColonyLibFactoryInterface $colonyLibFactory, private CrewCountRetrieverInterface $crewCountRetriever) {} |
15
|
|
|
|
16
|
|
|
/** @param ColonyInterface&PlanetFieldHostInterface $entity */ |
17
|
1 |
|
#[Override] |
18
|
|
|
public function setTemplateVariables( |
19
|
|
|
$entity, |
20
|
|
|
GameControllerInterface $game |
21
|
|
|
): void { |
22
|
1 |
|
$user = $game->getUser(); |
23
|
|
|
|
24
|
1 |
|
$crewInTrainingCount = $this->crewCountRetriever->getInTrainingCount($user); |
25
|
1 |
|
$crewRemainingCount = $this->crewCountRetriever->getRemainingCount($user); |
26
|
1 |
|
$crewTrainableCount = $this->crewCountRetriever->getTrainableCount($user); |
27
|
|
|
|
28
|
1 |
|
$trainableCrew = $crewTrainableCount - $crewInTrainingCount; |
29
|
1 |
|
if ($trainableCrew > $crewRemainingCount) { |
30
|
1 |
|
$trainableCrew = $crewRemainingCount; |
31
|
|
|
} |
32
|
|
|
|
33
|
1 |
|
if ($trainableCrew > $entity->getWorkless()) { |
34
|
|
|
$trainableCrew = $entity->getWorkless(); |
35
|
|
|
} |
36
|
|
|
|
37
|
1 |
|
$freeAssignmentCount = $this->colonyLibFactory->createColonyPopulationCalculator( |
38
|
1 |
|
$entity |
39
|
1 |
|
)->getFreeAssignmentCount(); |
40
|
|
|
|
41
|
1 |
|
$localcrewlimit = $this->colonyLibFactory->createColonyPopulationCalculator( |
42
|
1 |
|
$entity |
43
|
1 |
|
)->getCrewLimit(); |
44
|
|
|
|
45
|
1 |
|
$crewinlocalpool = $entity->getCrewAssignmentAmount(); |
46
|
|
|
|
47
|
1 |
|
if ($localcrewlimit - $crewinlocalpool < $trainableCrew) { |
48
|
|
|
$trainableCrew = $localcrewlimit - $crewinlocalpool; |
49
|
|
|
} |
50
|
|
|
|
51
|
1 |
|
if ($trainableCrew > $freeAssignmentCount) { |
52
|
|
|
$trainableCrew = $freeAssignmentCount; |
53
|
|
|
} |
54
|
|
|
|
55
|
1 |
|
if ($trainableCrew < 0) { |
56
|
|
|
$trainableCrew = 0; |
57
|
|
|
} |
58
|
|
|
|
59
|
1 |
|
$game->setTemplateVar('TRAINABLE_CREW_COUNT_PER_TICK', $trainableCrew); |
60
|
1 |
|
$game->setTemplateVar( |
61
|
1 |
|
'CREW_COUNT_TRAINING', |
62
|
1 |
|
$crewInTrainingCount |
63
|
1 |
|
); |
64
|
1 |
|
$game->setTemplateVar( |
65
|
1 |
|
'CREW_COUNT_REMAINING', |
66
|
1 |
|
$crewRemainingCount |
67
|
1 |
|
); |
68
|
1 |
|
$game->setTemplateVar( |
69
|
1 |
|
'CREW_COUNT_TRAINABLE', |
70
|
1 |
|
$crewTrainableCount |
71
|
1 |
|
); |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths