|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Stu\Module\Colony\View\ShowModuleFab; |
|
6
|
|
|
|
|
7
|
|
|
use Stu\Orm\Entity\ColonyInterface; |
|
8
|
|
|
use Stu\Orm\Entity\ModuleCostInterface; |
|
9
|
|
|
use Stu\Orm\Entity\ModuleInterface; |
|
10
|
|
|
use Stu\Orm\Repository\ModuleQueueRepositoryInterface; |
|
11
|
|
|
|
|
12
|
|
|
final class ModuleFabricationListItem |
|
13
|
|
|
{ |
|
14
|
|
|
public function __construct( |
|
15
|
|
|
private ModuleQueueRepositoryInterface $moduleQueueRepository, |
|
16
|
|
|
private ModuleInterface $module, |
|
17
|
|
|
private ColonyInterface $colony |
|
18
|
|
|
) { |
|
19
|
|
|
} |
|
20
|
|
|
|
|
21
|
|
|
public function getModule(): ModuleInterface |
|
22
|
|
|
{ |
|
23
|
|
|
return $this->module; |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
public function getModuleId(): int |
|
27
|
|
|
{ |
|
28
|
|
|
return $this->module->getId(); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
public function getCommodityId(): int |
|
32
|
|
|
{ |
|
33
|
|
|
return $this->module->getCommodityId(); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
public function getName(): string |
|
37
|
|
|
{ |
|
38
|
|
|
return $this->module->getName(); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function getEnergyCost(): int |
|
42
|
|
|
{ |
|
43
|
|
|
return $this->module->getEcost(); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** @return array<int, ModuleCostInterface> */ |
|
47
|
|
|
public function getConstructionCosts(): array |
|
48
|
|
|
{ |
|
49
|
|
|
return $this->module->getCostSorted(); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
public function getAmountQueued(): int |
|
53
|
|
|
{ |
|
54
|
|
|
return $this->moduleQueueRepository->getAmountByColonyAndModule( |
|
55
|
|
|
$this->colony->getId(), |
|
56
|
|
|
$this->module->getId() |
|
57
|
|
|
); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
public function getAmountInStock(): int |
|
61
|
|
|
{ |
|
62
|
|
|
$result = $this->colony->getStorage()[$this->getCommodityId()] ?? null; |
|
63
|
|
|
|
|
64
|
|
|
if ($result === null) { |
|
65
|
|
|
return 0; |
|
66
|
|
|
} |
|
67
|
|
|
return $result->getAmount(); |
|
68
|
|
|
} |
|
69
|
|
|
} |
|
70
|
|
|
|