-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathfleet.php
496 lines (411 loc) · 13.2 KB
/
fleet.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
<?php
declare(strict_types = 1);
defined('INSIDE') OR exit('No direct script access allowed');
/**
* This class maps the 'fleet'-table to an php object.
*/
class D_Fleet {
/** @var int Amount of Small Cargo Ship */
private $small_cargo_ship;
/** @var int Amount of Large Cargo Ship */
private $large_cargo_ship;
/** @var int Amount of Light Fighter */
private $light_fighter;
/** @var int Amount of Heavy Fighter */
private $heavy_fighter;
/** @var int Amount of Cruiser */
private $cruiser;
/** @var int Amount of Battleship */
private $battleship;
/** @var int Amount of Colony Ship */
private $colony_ship;
/** @var int Amount of Recycler */
private $recycler;
/** @var int Amount of Espionage Probe */
private $espionage_probe;
/** @var int Amount of Bomber */
private $bomber;
/** @var int Amount of Solar Satellite */
private $solar_satellite;
/** @var int Amount of Destroyer */
private $destroyer;
/** @var int Amount of Battlecruiser */
private $battlecruiser;
/** @var int Amount of Deathstar */
private $deathstar;
/**
* D_Fleet constructor.
* The parameters are the different amounts of the fleet
* @param int $fsmall_cargo_ship
* @param int $flarge_cargo_ship
* @param int $flight_fighter
* @param int $fheavy_fighter
* @param int $fcruiser
* @param int $fbattleship
* @param int $fcolony_ship
* @param int $frecycler
* @param int $fespionage_probe
* @param int $fbomber
* @param int $fsolar_satellite
* @param int $fdestroyer
* @param int $fbattlecruiser
* @param int $fdeathstar
*/
public function __construct(
int $fsmall_cargo_ship, int $flarge_cargo_ship, int $flight_fighter, int $fheavy_fighter, int $fcruiser,
int $fbattleship, int $fcolony_ship,
int $frecycler, int $fespionage_probe, int $fbomber, int $fsolar_satellite, int $fdestroyer,
int $fbattlecruiser, int $fdeathstar
) {
$this->small_cargo_ship = $fsmall_cargo_ship;
$this->large_cargo_ship = $flarge_cargo_ship;
$this->light_fighter = $flight_fighter;
$this->heavy_fighter = $fheavy_fighter;
$this->cruiser = $fcruiser;
$this->battleship = $fbattleship;
$this->colony_ship = $fcolony_ship;
$this->recycler = $frecycler;
$this->espionage_probe = $fespionage_probe;
$this->bomber = $fbomber;
$this->solar_satellite = $fsolar_satellite;
$this->destroyer = $fdestroyer;
$this->battlecruiser = $fbattlecruiser;
$this->deathstar = $fdeathstar;
}
/**
* Prints the object to the page
* @codeCoverageIgnore
*/
public function print() : void {
echo '<pre>';
print_r($this);
echo '</pre>';
}
/**
* Return the level of the fleet, given its id
* @param int $id the fleet id
* @return int the level of the fleet
*/
public function getFleetByID(int $id) : int {
switch ($id) {
case 201:
return $this->getSmallCargoShip();
break;
case 202:
return $this->getLargeCargoShip();
break;
case 203:
return $this->getLightFighter();
break;
case 204:
return $this->getHeavyFighter();
break;
case 205:
return $this->getCruiser();
break;
case 206:
return $this->getBattleship();
break;
case 207:
return $this->getColonyShip();
break;
case 208:
return $this->getRecycler();
break;
case 209:
return $this->getEspionageProbe();
break;
case 210:
return $this->getBomber();
break;
case 211:
return $this->getSolarSatellite();
break;
case 212:
return $this->getDestroyer();
break;
case 213:
return $this->getBattlecruiser();
break;
case 214:
return $this->getDeathstar();
break;
}
return -1;
}
/**
* Returns the current amount amount
* @return int the current amont
*/
public function getSmallCargoShip() : int {
return intval($this->small_cargo_ship);
}
/**
* Sets the current amount
* @param int the current amount
*/
public function setSmallCargoShip(int $amount) : void {
if ($amount >= 0) {
$this->small_cargo_ship = $amount;
}
}
/**
* Returns the current amount amount
* @return int the current amont
*/
public function getLargeCargoShip() : int {
return intval($this->large_cargo_ship);
}
/**
* Sets the current amount
* @param int the current amount
*/
public function setLargeCargoShip(int $amount) : void {
if ($amount >= 0) {
$this->large_cargo_ship = $amount;
}
}
/**
* Returns the current amount amount
* @return int the current amont
*/
public function getLightFighter() : int {
return intval($this->light_fighter);
}
/**
* Sets the current amount
* @param int the current amount
*/
public function setLightFighter(int $amount) : void {
if ($amount >= 0) {
$this->light_fighter = $amount;
}
}
/**
* Returns the current amount amount
* @return int the current amont
*/
public function getHeavyFighter() : int {
return intval($this->heavy_fighter);
}
/**
* Sets the current amount
* @param int the current amount
*/
public function setHeavyFighter(int $amount) : void {
if ($amount >= 0) {
$this->heavy_fighter = $amount;
}
}
/**
* Returns the current amount amount
* @return int the current amont
*/
public function getCruiser() : int {
return intval($this->cruiser);
}
/**
* Sets the current amount
* @param int the current amount
*/
public function setCruiser(int $amount) : void {
if ($amount >= 0) {
$this->cruiser = $amount;
}
}
/**
* Returns the current amount amount
* @return int the current amont
*/
public function getBattleship() : int {
return intval($this->battleship);
}
/**
* Sets the current amount
* @param int the current amount
*/
public function setBattleship(int $amount) : void {
if ($amount >= 0) {
$this->battleship = $amount;
}
}
/**
* Returns the current amount amount
* @return int the current amont
*/
public function getColonyShip() : int {
return intval($this->colony_ship);
}
/**
* Sets the current amount
* @param int the current amount
*/
public function setColonyShip(int $amount) : void {
if ($amount >= 0) {
$this->colony_ship = $amount;
}
}
/**
* Returns the current amount amount
* @return int the current amont
*/
public function getRecycler() : int {
return intval($this->recycler);
}
/**
* Sets the current amount
* @param int the current amount
*/
public function setRecycler(int $amount) : void {
if ($amount >= 0) {
$this->recycler = $amount;
}
}
/**
* Returns the current amount amount
* @return int the current amont
*/
public function getEspionageProbe() : int {
return intval($this->espionage_probe);
}
/**
* Sets the current amount
* @param int the current amount
*/
public function setEspionageProbe(int $amount) : void {
if ($amount >= 0) {
$this->espionage_probe = $amount;
}
}
/**
* Returns the current amount amount
* @return int the current amont
*/
public function getBomber() : int {
return intval($this->bomber);
}
/**
* Sets the current amount
* @param int the current amount
*/
public function setBomber(int $amount) : void {
if ($amount >= 0) {
$this->bomber = $amount;
}
}
/**
* Returns the current amount amount
* @return int the current amont
*/
public function getSolarSatellite() : int {
return intval($this->solar_satellite);
}
/**
* Sets the current amount
* @param int the current amount
*/
public function setSolarSatellite(int $amount) : void {
if ($amount >= 0) {
$this->solar_satellite = $amount;
}
}
/**
* Returns the current amount amount
* @return int the current amont
*/
public function getDestroyer() : int {
return intval($this->destroyer);
}
/**
* Sets the current amount
* @param int the current amount
*/
public function setDestroyer(int $amount) : void {
if ($amount >= 0) {
$this->destroyer = $amount;
}
}
/**
* Returns the current amount amount
* @return int the current amount
*/
public function getBattlecruiser() : int {
return intval($this->battlecruiser);
}
/**
* Sets the current amount
* @param int the current amount
*/
public function setBattlecruiser(int $amount) : void {
if ($amount >= 0) {
$this->battlecruiser = $amount;
}
}
/**
* Returns the current amount amount
* @return int the current amont
*/
public function getDeathstar() : int {
return intval($this->deathstar);
}
/**
* Sets the current amount
* @param int the current amount
*/
public function setDeathstar(int $amount) : void {
if ($amount >= 0) {
$this->deathstar = $amount;
}
}
/**
* Sets the level of the fleet, given its id and new level
* @param int $id the id of the fleet
* @param int $level the new level of the fleet
*/
public function setFleetByID(int $id, int $level) {
switch ($id) {
case 201:
$this->setSmallCargoShip($level);
break;
case 202:
$this->setLargeCargoShip($level);
break;
case 203:
$this->setLightFighter($level);
break;
case 204:
$this->setHeavyFighter($level);
break;
case 205:
$this->setCruiser($level);
break;
case 206:
$this->setBattleship($level);
break;
case 207:
$this->setColonyShip($level);
break;
case 208:
$this->setRecycler($level);
break;
case 209:
$this->setEspionageProbe($level);
break;
case 210:
$this->setBomber($level);
break;
case 211:
$this->setSolarSatellite($level);
break;
case 212:
$this->setDestroyer($level);
break;
case 213:
$this->setBattlecruiser($level);
break;
case 214:
$this->setDeathstar($level);
break;
}
}
}