1 | <?php |
||
13 | class Map extends AvatarModel implements NamedModel |
||
14 | { |
||
15 | /** |
||
16 | * The name of the map |
||
17 | * @var string |
||
18 | */ |
||
19 | protected $name; |
||
20 | |||
21 | /** |
||
22 | * A description of the map |
||
23 | * @var string |
||
24 | */ |
||
25 | protected $description; |
||
26 | |||
27 | /** |
||
28 | * The world size of the map |
||
29 | * @var int|null |
||
30 | */ |
||
31 | protected $world_size; |
||
32 | |||
33 | /** |
||
34 | * Whether or not the map is randomly generated each match |
||
35 | * @var bool |
||
36 | */ |
||
37 | protected $randomly_generated; |
||
38 | |||
39 | /** |
||
40 | * The number of a shots this map has |
||
41 | * @var int |
||
42 | */ |
||
43 | protected $shot_count; |
||
44 | |||
45 | /** |
||
46 | * Whether or not this map has ricochet |
||
47 | * @var bool |
||
48 | */ |
||
49 | protected $ricochet; |
||
50 | |||
51 | /** |
||
52 | * Whether or not this map has jumping |
||
53 | * @var bool |
||
54 | */ |
||
55 | protected $jumping; |
||
56 | |||
57 | /** |
||
58 | * The game mode this map supports |
||
59 | * |
||
60 | * @see Map::GAME_MODE_CTF |
||
61 | * @see Map::GAME_MODE_AHOD |
||
62 | * |
||
63 | * @var int |
||
64 | */ |
||
65 | protected $game_mode; |
||
66 | |||
67 | /** |
||
68 | * Whether or not this map is currently not in rotation on the official game servers |
||
69 | * |
||
70 | * @var bool |
||
71 | */ |
||
72 | protected $is_inactive; |
||
73 | |||
74 | const DELETED_COLUMN = 'is_deleted'; |
||
75 | const TABLE = "maps"; |
||
76 | |||
77 | /** |
||
78 | * The location where avatars will be stored |
||
79 | */ |
||
80 | const AVATAR_LOCATION = "/web/assets/imgs/avatars/maps/"; |
||
81 | |||
82 | const CREATE_PERMISSION = Permission::ADD_MAP; |
||
83 | const EDIT_PERMISSION = Permission::EDIT_MAP; |
||
84 | const SOFT_DELETE_PERMISSION = Permission::SOFT_DELETE_MAP; |
||
85 | const HARD_DELETE_PERMISSION = Permission::HARD_DELETE_MAP; |
||
86 | |||
87 | const GAME_MODE_CTF = 1; |
||
88 | const GAME_MODE_AHOD = 2; |
||
89 | |||
90 | /** |
||
91 | * {@inheritdoc} |
||
92 | */ |
||
93 | protected function assignResult($map) |
||
94 | { |
||
95 | $this->name = $map['name']; |
||
96 | $this->description = $map['description']; |
||
97 | $this->world_size = $map['world_size']; |
||
98 | $this->randomly_generated = $map['randomly_generated']; |
||
99 | $this->alias = $map['alias']; |
||
100 | $this->avatar = $map['avatar']; |
||
101 | $this->shot_count = $map['shot_count']; |
||
102 | $this->ricochet = $map['ricochet']; |
||
103 | $this->jumping = $map['jumping']; |
||
104 | $this->game_mode = $map['game_mode']; |
||
105 | $this->is_inactive = $map['is_inactive']; |
||
106 | $this->is_deleted = $map['is_deleted']; |
||
107 | } |
||
108 | |||
109 | /** |
||
110 | * Add a new map |
||
111 | * |
||
112 | * @param string $name The name of the map |
||
113 | * @param string|null $alias The custom API-friendly alias of the map |
||
114 | * @param string $description The description of the map |
||
115 | * @param string|null $avatar An image of the map |
||
116 | * |
||
117 | * @since 0.11.0 The `$status` argument has been removed |
||
118 | * |
||
119 | * @return static |
||
120 | */ |
||
121 | public static function addMap($name, $alias = null, $description = '', $avatar = null) |
||
122 | { |
||
123 | return self::create(array( |
||
124 | 'name' => $name, |
||
125 | 'alias' => $alias, |
||
126 | 'description' => $description, |
||
127 | 'avatar' => $avatar, |
||
128 | )); |
||
129 | } |
||
130 | |||
131 | /** |
||
132 | * Get the name of the map |
||
133 | * |
||
134 | * @return string |
||
135 | */ |
||
136 | public function getName() |
||
140 | |||
141 | /** |
||
142 | * Get the description of the map |
||
143 | * |
||
144 | * @return string |
||
145 | */ |
||
146 | public function getDescription() |
||
150 | |||
151 | /** |
||
152 | * Get the world size of the map |
||
153 | * |
||
154 | * @return int|null |
||
155 | */ |
||
156 | public function getWorldSize() |
||
160 | |||
161 | /** |
||
162 | * Get the number of shots this map has |
||
163 | * |
||
164 | * @return int |
||
165 | */ |
||
166 | public function getShotCount() |
||
170 | |||
171 | /** |
||
172 | * Get the game mode supported by this map |
||
173 | * |
||
174 | * @see Map::GAME_MODE_CTF |
||
175 | * @see Map::GAME_MODE_AHOD |
||
176 | * |
||
177 | * @return int |
||
178 | */ |
||
179 | public function getGameMode() |
||
183 | |||
184 | /** |
||
185 | * Get whether or not the map is randomly generated each match |
||
186 | * |
||
187 | * @return bool |
||
188 | */ |
||
189 | public function isRandomlyGenerated() |
||
193 | |||
194 | /** |
||
195 | * Get whether or not ricochet is enabled |
||
196 | * |
||
197 | * @return bool |
||
198 | */ |
||
199 | public function isRicochetEnabled() |
||
203 | |||
204 | /** |
||
205 | * Get whether or not jumping is enabled |
||
206 | * |
||
207 | * @return bool |
||
208 | */ |
||
209 | public function isJumpingEnabled() |
||
213 | |||
214 | /** |
||
215 | * Get whether or not this map is inactive. |
||
216 | * |
||
217 | * An inactive map is one that is not currently in rotation on official match servers. |
||
218 | * |
||
219 | * @return bool |
||
220 | */ |
||
221 | public function isInactive() |
||
225 | |||
226 | /** |
||
227 | * Set the name of the map |
||
228 | * |
||
229 | * @param string $name The new name |
||
230 | * @return self |
||
231 | */ |
||
232 | public function setName($name) |
||
236 | |||
237 | /** |
||
238 | * Set the description of the map |
||
239 | * |
||
240 | * @param string $description The new description |
||
241 | * @return self |
||
242 | */ |
||
243 | public function setDescription($description) |
||
247 | |||
248 | /** |
||
249 | * Set the world size of this map |
||
250 | * |
||
251 | * @param int $world_size |
||
252 | * |
||
253 | * @return Map |
||
254 | */ |
||
255 | public function setWorldSize($world_size) |
||
259 | |||
260 | /** |
||
261 | * Set the number of shots this map has |
||
262 | * |
||
263 | * @param int $shot_count |
||
264 | * |
||
265 | * @return self |
||
266 | */ |
||
267 | public function setShotCount($shot_count) |
||
271 | |||
272 | /** |
||
273 | * Set whether or not this map is randomly generated |
||
274 | * |
||
275 | * @param bool $randomly_generated |
||
276 | * |
||
277 | * @return Map |
||
278 | */ |
||
279 | public function setRandomlyGenerated($randomly_generated) |
||
283 | |||
284 | /** |
||
285 | * Set whether or not this map supports ricochet |
||
286 | * |
||
287 | * @param bool $ricochet |
||
288 | * |
||
289 | * @return self |
||
290 | */ |
||
291 | public function setRicochetEnabled($ricochet) |
||
295 | |||
296 | /** |
||
297 | * Set whether or not this map supports jumping |
||
298 | * |
||
299 | * @param bool $jumping |
||
300 | * |
||
301 | * @return self |
||
302 | */ |
||
303 | public function setJumpingEnabled($jumping) |
||
307 | |||
308 | /** |
||
309 | * Set the game mode for this map |
||
310 | * |
||
311 | * @param int $game_mode |
||
312 | * |
||
313 | * @see Map::GAME_MODE_CTF |
||
314 | * @see Map::GAME_MODE_AHOD |
||
315 | * |
||
316 | * @return Map |
||
317 | */ |
||
318 | public function setGameMode($game_mode) |
||
322 | |||
323 | /** |
||
324 | * Set whether or not this map is in active rotation on official match servers. |
||
325 | * |
||
326 | * @param bool $inactive |
||
327 | * |
||
328 | * @return static |
||
329 | */ |
||
330 | public function setInactive($inactive) |
||
334 | |||
335 | /** |
||
336 | * Get the number of matches played on this map |
||
337 | * |
||
338 | * @return int |
||
339 | */ |
||
340 | public function countMatches() |
||
347 | |||
348 | /** |
||
349 | * Get a query builder for news |
||
350 | * |
||
351 | * @throws Exception |
||
352 | * |
||
353 | * @return QueryBuilderFlex |
||
354 | */ |
||
355 | public static function getQueryBuilder() |
||
361 | |||
362 | /** |
||
363 | * {@inheritdoc} |
||
364 | */ |
||
365 | public static function getActiveModels(QueryBuilderFlex &$qb) |
||
374 | } |
||
375 |
This check looks for accesses to local static members using the fully qualified name instead of
self::
.While this is perfectly valid, the fully qualified name of
Certificate::TRIPLEDES_CBC
could just as well be replaced byself::TRIPLEDES_CBC
. Referencing local members withself::
assured the access will still work when the class is renamed, makes it perfectly clear that the member is in fact local and will usually be shorter.