|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Stu\Component\Ship\System\Data; |
|
6
|
|
|
|
|
7
|
|
|
use Stu\Component\Ship\System\ShipSystemTypeEnum; |
|
8
|
|
|
use Stu\Orm\Entity\TholianWebInterface; |
|
9
|
|
|
use Stu\Orm\Repository\ShipSystemRepositoryInterface; |
|
10
|
|
|
use Stu\Orm\Repository\TholianWebRepositoryInterface; |
|
11
|
|
|
|
|
12
|
|
|
class WebEmitterSystemData extends AbstractSystemData |
|
13
|
|
|
{ |
|
14
|
|
|
public ?int $webUnderConstructionId = null; |
|
15
|
|
|
public ?int $ownedWebId = null; |
|
16
|
|
|
|
|
17
|
|
|
public function __construct( |
|
18
|
|
|
ShipSystemRepositoryInterface $shipSystemRepository, |
|
19
|
|
|
private TholianWebRepositoryInterface $tholianWebRepository |
|
20
|
|
|
) { |
|
21
|
|
|
parent::__construct($shipSystemRepository); |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
function getSystemType(): ShipSystemTypeEnum |
|
|
|
|
|
|
25
|
|
|
{ |
|
26
|
|
|
return ShipSystemTypeEnum::SYSTEM_THOLIAN_WEB; |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
public function getWebUnderConstruction(): ?TholianWebInterface |
|
30
|
|
|
{ |
|
31
|
|
|
if ($this->webUnderConstructionId === null) { |
|
32
|
|
|
return null; |
|
33
|
|
|
} |
|
34
|
|
|
return $this->tholianWebRepository->find($this->webUnderConstructionId); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
public function getOwnedTholianWeb(): ?TholianWebInterface |
|
38
|
|
|
{ |
|
39
|
|
|
if ($this->ownedWebId === null) { |
|
40
|
|
|
return null; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
return $this->tholianWebRepository->find($this->ownedWebId); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
public function setWebUnderConstructionId(?int $webId): WebEmitterSystemData |
|
47
|
|
|
{ |
|
48
|
|
|
$this->webUnderConstructionId = $webId; |
|
49
|
|
|
return $this; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
public function setOwnedWebId(?int $webId): WebEmitterSystemData |
|
53
|
|
|
{ |
|
54
|
|
|
$this->ownedWebId = $webId; |
|
55
|
|
|
return $this; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
public function getCooldown(): ?int |
|
59
|
|
|
{ |
|
60
|
|
|
return $this->ship->getShipSystem(ShipSystemTypeEnum::SYSTEM_THOLIAN_WEB)->getCooldown(); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
public function isUseable(): bool |
|
64
|
|
|
{ |
|
65
|
|
|
if ($this->webUnderConstructionId !== null) { |
|
66
|
|
|
return false; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
$cooldown = $this->getCooldown(); |
|
70
|
|
|
|
|
71
|
|
|
return $cooldown === null ? true : $cooldown < time(); |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.