-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdefense.php
368 lines (306 loc) · 10.2 KB
/
defense.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
<?php
declare(strict_types = 1);
defined('INSIDE') OR exit('No direct script access allowed');
/**
* This class maps the 'defense'-table to an php object.
*/
class D_Defense {
/** @var int Amount of Rocket Launcher */
private $rocket_launcher;
/** @var int Amount of Light Laser */
private $light_laser;
/** @var int Amount of Heavy laser */
private $heavy_laser;
/** @var int Amount of Ion Cannon */
private $ion_cannon;
/** @var int Amount of Gauss Cannon */
private $gauss_cannon;
/** @var int Amount of Plasma Turret */
private $plasma_turret;
/** @var int Amount of Small Shield Dome */
private $small_shield_dome;
/** @var int Amount of Large Shield Dome */
private $large_shield_dome;
/** @var int Amount of Anti Ballistic Missile */
private $anti_ballistic_missile;
/** @var int Amount of Interplanetary Missile */
private $interplanetary_missile;
/**
* D_Defense constructor.
* The parameters are the different amounts of the defense
* @param int $drocket_launcher
* @param int $dlight_laser
* @param int $dheavy_laser
* @param int $dion_cannon
* @param int $dgauss_cannon
* @param int $dplasma_turret
* @param int $dsmall_shield_dome
* @param int $dlarge_shield_dome
* @param int $danti_ballistic_missile
* @param int $dinterplanetary_missile
*/
public function __construct(
int $drocket_launcher, int $dlight_laser, int $dheavy_laser, int $dgauss_cannon, int $dion_cannon,
int $dplasma_turret, int $dsmall_shield_dome,
int $dlarge_shield_dome, int $danti_ballistic_missile, int $dinterplanetary_missile
) {
$this->rocket_launcher = $drocket_launcher;
$this->light_laser = $dlight_laser;
$this->heavy_laser = $dheavy_laser;
$this->ion_cannon = $dion_cannon;
$this->gauss_cannon = $dgauss_cannon;
$this->plasma_turret = $dplasma_turret;
$this->small_shield_dome = $dsmall_shield_dome;
$this->large_shield_dome = $dlarge_shield_dome;
$this->anti_ballistic_missile = $danti_ballistic_missile;
$this->interplanetary_missile = $dinterplanetary_missile;
}
/**
* Prints the object to the page
* @codeCoverageIgnore
*/
public function print() : void {
echo '<pre>';
print_r($this);
echo '</pre>';
}
/**
* Returns the current amount
* @return int the current amount
*/
public function getRocketLauncher() : int {
return $this->rocket_launcher;
}
/**
* Sets the current amount
* @param int $rocket_launcher the new amount
*/
public function setRocketLauncher(int $amount) : void {
if ($amount >= 0) {
$this->rocket_launcher = $amount;
}
}
/**
* Returns the current amount
* @return int the current amount
*/
public function getLightLaser() : int {
return $this->light_laser;
}
/**
* Sets the current amount
* @param int $light_laser the new amount
*/
public function setLightLaser(int $amount) : void {
if ($amount >= 0) {
$this->light_laser = $amount;
}
}
/**
* Returns the current amount amount
* @return int the current amount
*/
public function getHeavyLaser() : int {
return $this->heavy_laser;
}
/**
* Sets the current amount
* @param int $heavy_laser the new amount
*/
public function setHeavyLaser(int $amount) : void {
if ($amount >= 0) {
$this->heavy_laser = $amount;
}
}
/**
* Returns the current amount amount
* @return int the current amount
*/
public function getIonCannon() : int {
return $this->ion_cannon;
}
/**
* Sets the current amount
* @param int $ion_cannon the new amount
*/
public function setIonCannon(int $amount) : void {
if ($amount >= 0) {
$this->ion_cannon = $amount;
}
}
/**
* Returns the current amount
* @return int the current amount
*/
public function getGaussCannon() : int {
return $this->gauss_cannon;
}
/**
* Sets the current amount
* @param int $gauss_cannon the new amount
*/
public function setGaussCannon(int $amount) : void {
if ($amount >= 0) {
$this->gauss_cannon = $amount;
}
}
/**
* Returns the current amount
* @return int the current amount
*/
public function getPlasmaTurret() : int {
return $this->plasma_turret;
}
/**
* Sets the current amount
* @param int $plasma_turret the new amount
*/
public function setPlasmaTurret(int $amount) : void {
if ($amount >= 0) {
$this->plasma_turret = $amount;
}
}
/**
* Returns the current amount
* @return int the current amount
*/
public function getSmallShieldDome() : int {
return $this->small_shield_dome;
}
/**
* Sets the current amount
* @param int $small_shield_dome the new amount
*/
public function setSmallShieldDome(int $amount) : void {
if ($amount >= 0 && $amount <= 1) {
$this->small_shield_dome = $amount;
}
}
/**
* Returns the current amount
* @return int the current amount
*/
public function getLargeShieldDome() : int {
return $this->large_shield_dome;
}
/**
* Sets the current amount
* @param int $large_shield_dome the new amount
*/
public function setLargeShieldDome(int $amount) : void {
if ($amount >= 0 && $amount <= 1) {
$this->large_shield_dome = $amount;
}
}
/**
* Returns the current amount
* @return int the current amount
*/
public function getAntiBallisticMissile() : int {
return $this->anti_ballistic_missile;
}
/**
* Sets the current amount
* @param int $anti_ballistic_missile the new amount
*/
public function setAntiBallisticMissile(int $amount) : void {
if ($amount >= 0) {
$this->anti_ballistic_missile = $amount;
}
}
/**
* Returns the current amount
* @return int the current amount
*/
public function getInterplanetaryMissile() : int {
return $this->interplanetary_missile;
}
/**
* Sets the current amount
* @param int $interplanetary_missile the new amount
*/
public function setInterplanetaryMissile(int $amount) : void {
if ($amount >= 0) {
$this->interplanetary_missile = $amount;
}
}
/**
* Return the level of the defense, given its id
* @param int $id the defense id
* @return int the level of the defense
*/
public function getDefenseByID(int $id) : int {
switch ($id) {
case 301:
return $this->getRocketLauncher();
break;
case 302:
return $this->getLightLaser();
break;
case 303:
return $this->getHeavyLaser();
break;
case 304:
return $this->getGaussCannon();
break;
case 305:
return $this->getIonCannon();
break;
case 306:
return $this->getPlasmaTurret();
break;
case 307:
return $this->getSmallShieldDome();
break;
case 308:
return $this->getLargeShieldDome();
break;
case 309:
return $this->getAntiBallisticMissile();
break;
case 310:
return $this->getInterplanetaryMissile();
break;
}
return -1;
}
/**
* Sets the level of the defense, given its id and new level
* @param int $id the id of the defense
* @param int $level the new level of the defense
*/
public function setDefenseByID(int $id, int $level) {
switch ($id) {
case 301:
$this->setRocketLauncher($level);
break;
case 302:
$this->setLightLaser($level);
break;
case 303:
$this->setHeavyLaser($level);
break;
case 304:
$this->setGaussCannon($level);
break;
case 305:
$this->setIonCannon($level);
break;
case 306:
$this->setPlasmaTurret($level);
break;
case 307:
$this->setSmallShieldDome($level);
break;
case 308:
$this->setLargeShieldDome($level);
break;
case 309:
$this->setAntiBallisticMissile($level);
break;
case 310:
$this->setInterplanetaryMissile($level);
break;
}
}
}