1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Stu\Module\Colony\Lib\Gui\Component; |
4
|
|
|
|
5
|
|
|
use Stu\Component\Crew\CrewCountRetrieverInterface; |
6
|
|
|
use Stu\Lib\Colony\PlanetFieldHostInterface; |
7
|
|
|
use Stu\Module\Colony\Lib\ColonyLibFactoryInterface; |
8
|
|
|
use Stu\Module\Control\GameControllerInterface; |
9
|
|
|
use Stu\Orm\Entity\ColonyInterface; |
10
|
|
|
|
11
|
|
|
final class AcademyProvider implements GuiComponentProviderInterface |
12
|
|
|
{ |
13
|
|
|
private CrewCountRetrieverInterface $crewCountRetriever; |
14
|
|
|
|
15
|
|
|
private ColonyLibFactoryInterface $colonyLibFactory; |
16
|
|
|
|
17
|
|
|
public function __construct( |
18
|
|
|
ColonyLibFactoryInterface $colonyLibFactory, |
19
|
|
|
CrewCountRetrieverInterface $crewCountRetriever |
20
|
|
|
) { |
21
|
|
|
$this->crewCountRetriever = $crewCountRetriever; |
22
|
|
|
$this->colonyLibFactory = $colonyLibFactory; |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
/** @param ColonyInterface&PlanetFieldHostInterface $host */ |
26
|
|
|
public function setTemplateVariables( |
27
|
|
|
PlanetFieldHostInterface $host, |
28
|
|
|
GameControllerInterface $game |
29
|
|
|
): void { |
30
|
|
|
$user = $game->getUser(); |
31
|
|
|
|
32
|
|
|
$crewInTrainingCount = $this->crewCountRetriever->getInTrainingCount($user); |
33
|
|
|
$crewRemainingCount = $this->crewCountRetriever->getRemainingCount($user); |
34
|
|
|
$crewTrainableCount = $this->crewCountRetriever->getTrainableCount($user); |
35
|
|
|
|
36
|
|
|
$trainableCrew = $crewTrainableCount - $crewInTrainingCount; |
37
|
|
|
if ($trainableCrew > $crewRemainingCount) { |
38
|
|
|
$trainableCrew = $crewRemainingCount; |
39
|
|
|
} |
40
|
|
|
if ($trainableCrew < 0) { |
41
|
|
|
$trainableCrew = 0; |
42
|
|
|
} |
43
|
|
|
if ($trainableCrew > $host->getWorkless()) { |
|
|
|
|
44
|
|
|
$trainableCrew = $host->getWorkless(); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
$freeAssignmentCount = $this->colonyLibFactory->createColonyPopulationCalculator( |
48
|
|
|
$host |
49
|
|
|
)->getFreeAssignmentCount(); |
50
|
|
|
|
51
|
|
|
if ($trainableCrew > $freeAssignmentCount) { |
52
|
|
|
$trainableCrew = $freeAssignmentCount; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
$game->setTemplateVar('TRAINABLE_CREW_COUNT_PER_TICK', $trainableCrew); |
56
|
|
|
$game->setTemplateVar( |
57
|
|
|
'CREW_COUNT_TRAINING', |
58
|
|
|
$crewInTrainingCount |
59
|
|
|
); |
60
|
|
|
$game->setTemplateVar( |
61
|
|
|
'CREW_COUNT_REMAINING', |
62
|
|
|
$crewRemainingCount |
63
|
|
|
); |
64
|
|
|
$game->setTemplateVar( |
65
|
|
|
'CREW_COUNT_TRAINABLE', |
66
|
|
|
$crewTrainableCount |
67
|
|
|
); |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.