1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace VideoGamesRecords\CoreBundle\Entity; |
4
|
|
|
|
5
|
|
|
use ApiPlatform\Core\Annotation\ApiResource; |
6
|
|
|
use Doctrine\ORM\Mapping as ORM; |
7
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
|
|
|
|
8
|
|
|
use VideoGamesRecords\CoreBundle\Contracts\BadgeInterface; |
9
|
|
|
use VideoGamesRecords\CoreBundle\Model\Entity\NbPlayerTrait; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Badge |
13
|
|
|
* @ORM\Table( |
14
|
|
|
* name="vgr_badge", |
15
|
|
|
* indexes={ |
16
|
|
|
* @ORM\Index(name="idx_type", columns={"type"}), |
17
|
|
|
* @ORM\Index(name="idx_value", columns={"value"}) |
18
|
|
|
* } |
19
|
|
|
* ) |
20
|
|
|
* @ORM\Entity(repositoryClass="VideoGamesRecords\CoreBundle\Repository\BadgeRepository") |
21
|
|
|
* @ApiResource(attributes={"order"={"type", "value"}}) |
22
|
|
|
*/ |
23
|
|
|
class Badge implements BadgeInterface |
24
|
|
|
{ |
25
|
|
|
use NbPlayerTrait; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @ORM\Column(name="id", type="integer") |
29
|
|
|
* @ORM\Id |
30
|
|
|
* @ORM\GeneratedValue(strategy="IDENTITY") |
31
|
|
|
*/ |
32
|
|
|
private ?int $id = null; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @Assert\Length(max="50") |
36
|
|
|
* @ORM\Column(name="type", type="string", length=50, nullable=false) |
37
|
|
|
*/ |
38
|
|
|
private string $type; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @Assert\Length(max="100") |
42
|
|
|
* @ORM\Column(name="picture", type="string", length=100, nullable=false, options={"default" : "default.gif"}) |
43
|
|
|
*/ |
44
|
|
|
private string $picture; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @ORM\Column(name="value", type="integer", nullable=false, options={"default":0}) |
48
|
|
|
*/ |
49
|
|
|
private int $value = 0; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @ORM\OneToOne(targetEntity="VideoGamesRecords\CoreBundle\Entity\Game", mappedBy="badge") |
53
|
|
|
*/ |
54
|
|
|
private ?Game $game; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @ORM\OneToOne(targetEntity="VideoGamesRecords\CoreBundle\Entity\Country", mappedBy="badge") |
58
|
|
|
*/ |
59
|
|
|
private ?Country $country; |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @ORM\OneToOne(targetEntity="VideoGamesRecords\CoreBundle\Entity\Platform", mappedBy="badge") |
63
|
|
|
*/ |
64
|
|
|
private ?Platform $platform; |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @return string |
68
|
|
|
*/ |
69
|
|
|
public function __toString() |
70
|
|
|
{ |
71
|
|
|
return sprintf('%s / %s [%s]', $this->getType(), $this->getPicture(), $this->getId()); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Set id |
77
|
|
|
* @param integer $id |
78
|
|
|
* @return Badge |
79
|
|
|
*/ |
80
|
|
|
public function setId(int $id): Badge |
81
|
|
|
{ |
82
|
|
|
$this->id = $id; |
83
|
|
|
return $this; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* Get id |
88
|
|
|
* @return integer |
89
|
|
|
*/ |
90
|
|
|
public function getId(): ?int |
91
|
|
|
{ |
92
|
|
|
return $this->id; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* Set type |
97
|
|
|
* @param string $type |
98
|
|
|
* @return Badge |
99
|
|
|
*/ |
100
|
|
|
public function setType(string $type): Badge |
101
|
|
|
{ |
102
|
|
|
$this->type = $type; |
103
|
|
|
|
104
|
|
|
return $this; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* Get type |
109
|
|
|
* @return string |
110
|
|
|
*/ |
111
|
|
|
public function getType(): string |
112
|
|
|
{ |
113
|
|
|
return $this->type; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* Set picture |
119
|
|
|
* @param string $picture |
120
|
|
|
* @return Badge |
121
|
|
|
*/ |
122
|
|
|
public function setPicture(string $picture): Badge |
123
|
|
|
{ |
124
|
|
|
$this->picture = $picture; |
125
|
|
|
|
126
|
|
|
return $this; |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* Get picture |
131
|
|
|
* @return string |
132
|
|
|
*/ |
133
|
|
|
public function getPicture(): ?string |
134
|
|
|
{ |
135
|
|
|
return $this->picture; |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
/** |
139
|
|
|
* Set value |
140
|
|
|
* @param integer $value |
141
|
|
|
* @return Badge |
142
|
|
|
*/ |
143
|
|
|
public function setValue(int $value): Badge |
144
|
|
|
{ |
145
|
|
|
$this->value = $value; |
146
|
|
|
|
147
|
|
|
return $this; |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* Get value |
152
|
|
|
* @return int |
153
|
|
|
*/ |
154
|
|
|
public function getValue(): int |
155
|
|
|
{ |
156
|
|
|
return $this->value; |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* Get game |
161
|
|
|
* @return Game|null |
162
|
|
|
*/ |
163
|
|
|
public function getGame(): ?Game |
164
|
|
|
{ |
165
|
|
|
return $this->game; |
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
/** |
169
|
|
|
* Get country |
170
|
|
|
* @return Country|null |
171
|
|
|
*/ |
172
|
|
|
public function getCountry(): ?Country |
173
|
|
|
{ |
174
|
|
|
return $this->country; |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
/** |
178
|
|
|
* Get platform |
179
|
|
|
* @return Platform|null |
180
|
|
|
*/ |
181
|
|
|
public function getPlatform(): ?Platform |
182
|
|
|
{ |
183
|
|
|
return $this->platform; |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
|
187
|
|
|
/** |
188
|
|
|
* @return array |
189
|
|
|
*/ |
190
|
|
|
public static function getTypeChoices(): array |
191
|
|
|
{ |
192
|
|
|
return [ |
193
|
|
|
self::TYPE_CONNEXION => self::TYPE_CONNEXION, |
194
|
|
|
self::TYPE_DON => self::TYPE_DON, |
195
|
|
|
self::TYPE_FORUM => self::TYPE_FORUM, |
196
|
|
|
self::TYPE_INSCRIPTION => self::TYPE_INSCRIPTION, |
197
|
|
|
self::TYPE_MASTER => self::TYPE_MASTER, |
198
|
|
|
self::TYPE_PLATFORM => self::TYPE_PLATFORM, |
199
|
|
|
self::TYPE_SPECIAL_WEBMASTER => self::TYPE_SPECIAL_WEBMASTER, |
200
|
|
|
self::TYPE_TWITCH => self::TYPE_TWITCH, |
201
|
|
|
self::TYPE_VGR_CHART => self::TYPE_VGR_CHART, |
202
|
|
|
self::TYPE_VGR_PROOF => self::TYPE_VGR_PROOF, |
203
|
|
|
self::TYPE_VGR_SPECIAL_COUNTRY => self::TYPE_VGR_SPECIAL_COUNTRY, |
204
|
|
|
self::TYPE_VGR_SPECIAL_CUP => self::TYPE_VGR_SPECIAL_CUP, |
205
|
|
|
self::TYPE_VGR_SPECIAL_LEGEND => self::TYPE_VGR_SPECIAL_LEGEND, |
206
|
|
|
self::TYPE_VGR_SPECIAL_MEDALS => self::TYPE_VGR_SPECIAL_MEDALS, |
207
|
|
|
self::TYPE_VGR_SPECIAL_POINTS => self::TYPE_VGR_SPECIAL_POINTS, |
208
|
|
|
]; |
209
|
|
|
} |
210
|
|
|
|
211
|
|
|
public function majValue(): void |
212
|
|
|
{ |
213
|
|
|
if (self::TYPE_MASTER !== $this->type) { |
214
|
|
|
return; |
215
|
|
|
} |
216
|
|
|
if (0 === $this->nbPlayer) { |
217
|
|
|
$this->value = 0; |
218
|
|
|
} else { |
219
|
|
|
$this->value = floor( |
220
|
|
|
100 * (6250 * (-1 / (100 + $this->getGame() |
221
|
|
|
->getNbPlayer() - $this->nbPlayer) + 0.0102) / (pow($this->nbPlayer, 1 / 3))) |
222
|
|
|
); |
223
|
|
|
} |
224
|
|
|
} |
225
|
|
|
} |
226
|
|
|
|
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