|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Stu\Orm\Entity; |
|
6
|
|
|
|
|
7
|
|
|
use Doctrine\ORM\Mapping\Column; |
|
8
|
|
|
use Doctrine\ORM\Mapping\Entity; |
|
9
|
|
|
use Doctrine\ORM\Mapping\GeneratedValue; |
|
10
|
|
|
use Doctrine\ORM\Mapping\Id; |
|
11
|
|
|
use Doctrine\ORM\Mapping\Index; |
|
12
|
|
|
use Doctrine\ORM\Mapping\Table; |
|
13
|
|
|
use Stu\Module\Commodity\CommodityTypeConstants; |
|
|
|
|
|
|
14
|
|
|
use Stu\Orm\Repository\CommodityRepository; |
|
15
|
|
|
|
|
16
|
|
|
#[Table(name: 'stu_commodity')] |
|
17
|
|
|
#[Index(name: 'commodity_sort_idx', columns: ['sort'])] |
|
18
|
|
|
#[Entity(repositoryClass: CommodityRepository::class)] |
|
19
|
|
|
class Commodity |
|
20
|
|
|
{ |
|
21
|
|
|
#[Id] |
|
22
|
|
|
#[Column(type: 'integer')] |
|
23
|
|
|
#[GeneratedValue(strategy: 'IDENTITY')] |
|
24
|
|
|
private int $id; |
|
25
|
|
|
|
|
26
|
|
|
#[Column(type: 'string')] |
|
27
|
|
|
private string $name = ''; |
|
28
|
|
|
|
|
29
|
|
|
#[Column(type: 'smallint')] |
|
30
|
|
|
private int $sort = 0; |
|
31
|
|
|
|
|
32
|
|
|
#[Column(type: 'boolean')] |
|
33
|
|
|
private bool $view = true; |
|
34
|
|
|
|
|
35
|
|
|
#[Column(type: 'smallint')] |
|
36
|
|
|
private int $type = CommodityTypeConstants::COMMODITY_TYPE_STANDARD; |
|
37
|
|
|
|
|
38
|
|
|
#[Column(type: 'boolean')] |
|
39
|
|
|
private bool $npc_commodity = false; |
|
40
|
|
|
|
|
41
|
|
|
#[Column(type: 'boolean')] |
|
42
|
|
|
private bool $bound = false; |
|
43
|
|
|
|
|
44
|
|
|
#[Column(type: 'boolean', nullable: true)] |
|
45
|
|
|
private ?bool $cheatable = null; |
|
46
|
|
|
|
|
47
|
37 |
|
public function getId(): int |
|
48
|
|
|
{ |
|
49
|
37 |
|
return $this->id; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
34 |
|
public function getName(): string |
|
53
|
|
|
{ |
|
54
|
34 |
|
return $this->name; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
public function setName(string $name): Commodity |
|
58
|
|
|
{ |
|
59
|
|
|
$this->name = $name; |
|
60
|
|
|
|
|
61
|
|
|
return $this; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
9 |
|
public function getSort(): int |
|
65
|
|
|
{ |
|
66
|
9 |
|
return $this->sort; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
public function setSort(int $sort): Commodity |
|
70
|
|
|
{ |
|
71
|
|
|
$this->sort = $sort; |
|
72
|
|
|
|
|
73
|
|
|
return $this; |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
12 |
|
public function getView(): bool |
|
77
|
|
|
{ |
|
78
|
12 |
|
return $this->view; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
public function setView(bool $view): Commodity |
|
82
|
|
|
{ |
|
83
|
|
|
$this->view = $view; |
|
84
|
|
|
|
|
85
|
|
|
return $this; |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
19 |
|
public function getType(): int |
|
89
|
|
|
{ |
|
90
|
19 |
|
return $this->type; |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
public function setType(int $typeId): Commodity |
|
94
|
|
|
{ |
|
95
|
|
|
$this->type = $typeId; |
|
96
|
|
|
|
|
97
|
|
|
return $this; |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
public function getCheatable(): ?bool |
|
101
|
|
|
{ |
|
102
|
|
|
return $this->cheatable; |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
public function setCheatable(?bool $cheatable): Commodity |
|
106
|
|
|
{ |
|
107
|
|
|
$this->cheatable = $cheatable; |
|
108
|
|
|
|
|
109
|
|
|
return $this; |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
1 |
|
public function isTradeable(): bool |
|
113
|
|
|
{ |
|
114
|
1 |
|
return $this->isBeamable() && $this->npc_commodity === false; |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
12 |
|
public function isBeamable(?User $user = null, ?User $targetUser = null): bool |
|
118
|
|
|
{ |
|
119
|
12 |
|
$isBound = $user !== null && $targetUser !== null && $this->isBoundToAccount() && $user->getId() !== $targetUser->getId(); |
|
120
|
|
|
|
|
121
|
12 |
|
return $this->getType() === CommodityTypeConstants::COMMODITY_TYPE_STANDARD && $this->getView() === true && !$isBound; |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
1 |
|
public function isSaveable(): bool |
|
125
|
|
|
{ |
|
126
|
1 |
|
return $this->getType() === CommodityTypeConstants::COMMODITY_TYPE_STANDARD; |
|
127
|
|
|
} |
|
128
|
|
|
|
|
129
|
1 |
|
public function isBoundToAccount(): bool |
|
130
|
|
|
{ |
|
131
|
1 |
|
return $this->bound; |
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
2 |
|
public function isShuttle(): bool |
|
135
|
|
|
{ |
|
136
|
2 |
|
return in_array(intdiv($this->getId(), 10) * 10, CommodityTypeConstants::BASE_IDS_SHUTTLE); |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
public function isWorkbee(): bool |
|
140
|
|
|
{ |
|
141
|
|
|
return intdiv($this->getId(), 10) * 10 === CommodityTypeConstants::BASE_ID_WORKBEE; |
|
142
|
|
|
} |
|
143
|
|
|
|
|
144
|
1 |
|
public function isBouy(): bool |
|
145
|
|
|
{ |
|
146
|
1 |
|
return $this->getId() === CommodityTypeConstants::BASE_ID_BUOY; |
|
147
|
|
|
} |
|
148
|
|
|
|
|
149
|
|
|
public function getTransferCount(): int |
|
150
|
|
|
{ |
|
151
|
|
|
// @todo Anzahl Waren pro Energieeinheit |
|
152
|
|
|
// Möglicherweise einstellbar nach Warentyp |
|
153
|
|
|
return 1; |
|
154
|
|
|
} |
|
155
|
|
|
} |
|
156
|
|
|
|
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