|
1
|
|
|
<?php namespace Xaoc303\BattleCalc; |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Class ArmyAttack |
|
5
|
|
|
* @package Xaoc303\BattleCalc |
|
6
|
|
|
*/ |
|
7
|
|
|
class ArmyAttack |
|
8
|
|
|
{ |
|
9
|
|
|
/** |
|
10
|
|
|
* @var array |
|
11
|
|
|
*/ |
|
12
|
|
|
private $unitsAtt; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* @var array |
|
16
|
|
|
*/ |
|
17
|
|
|
private $unitsDef; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* run |
|
21
|
|
|
* |
|
22
|
|
|
* @param Army $armyAtt |
|
23
|
|
|
* @param Army $armyDef |
|
24
|
|
|
* @param int $Inic |
|
25
|
|
|
*/ |
|
26
|
|
|
public static function run(Army &$armyAtt, Army &$armyDef, $Inic) |
|
27
|
|
|
{ |
|
28
|
|
|
$class = new ArmyAttack(); |
|
29
|
|
|
|
|
30
|
|
|
$class->unitsAtt = $armyAtt->getUnits(); |
|
31
|
|
|
$class->unitsDef = $armyDef->getUnits(); |
|
32
|
|
|
|
|
33
|
|
|
$class->attack($Inic); |
|
34
|
|
|
|
|
35
|
|
|
$armyAtt->setUnits($class->unitsAtt); |
|
36
|
|
|
$armyDef->setUnits($class->unitsDef); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* attack |
|
41
|
|
|
* |
|
42
|
|
|
* @param int $Inic |
|
43
|
|
|
*/ |
|
44
|
|
|
private function attack($Inic) |
|
45
|
|
|
{ |
|
46
|
|
|
$count = count($this->unitsAtt); |
|
47
|
|
|
for ($i = 0; $i < $count; $i++) { |
|
48
|
|
|
if ($this->unitsAtt[$i]['All']['Iniciative'] >= $Inic && $this->unitsAtt[$i]['All']['ManCount'] > 0) { |
|
49
|
|
|
$Cool = 24.0 / $this->unitsAtt[$i]['Base']['AttackCool']; // Атак в секунду |
|
50
|
|
|
$Cool = round($Cool, 2); // Округление до сотых |
|
51
|
|
|
$Cool += $this->unitsAtt[$i]['All']['AttackCoolDouble']; // + предыдущий остаток |
|
52
|
|
|
$this->unitsAtt[$i]['All']['AttackCoolInt'] = (int) $Cool; // int атак в секунду |
|
53
|
|
|
$this->unitsAtt[$i]['All']['AttackCoolDouble'] = $Cool - $this->unitsAtt[$i]['All']['AttackCoolInt']; // double остаток атак в секунду |
|
54
|
|
|
if ($this->unitsAtt[$i]['All']['AttackCoolInt'] > 0) { |
|
55
|
|
|
$this->attackAirOn($i); |
|
56
|
|
|
$this->attackTerOn($i); |
|
57
|
|
|
$this->attackMagicOn($i); |
|
58
|
|
|
} |
|
59
|
|
|
} |
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* attackAirOn |
|
65
|
|
|
* |
|
66
|
|
|
* @param int $i |
|
67
|
|
|
*/ |
|
68
|
|
|
private function attackAirOn(&$i) |
|
69
|
|
|
{ |
|
70
|
|
|
$this->unitsAtt[$i]['All']['AttackAir'] = ($this->unitsAtt[$i]['Base']['AttackAir'] * $this->unitsAtt[$i]['All']['ManCount']) * $this->unitsAtt[$i]['All']['AttackCoolInt']; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* attackTerOn |
|
75
|
|
|
* |
|
76
|
|
|
* @param int $i |
|
77
|
|
|
*/ |
|
78
|
|
|
private function attackTerOn(&$i) |
|
79
|
|
|
{ |
|
80
|
|
|
$this->unitsAtt[$i]['All']['AttackTer'] = ($this->unitsAtt[$i]['Base']['AttackTer'] * $this->unitsAtt[$i]['All']['ManCount']) * $this->unitsAtt[$i]['All']['AttackCoolInt']; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* attackMagicOn |
|
85
|
|
|
* |
|
86
|
|
|
* @param int $i |
|
87
|
|
|
*/ |
|
88
|
|
|
private function attackMagicOn(&$i) |
|
89
|
|
|
{ |
|
90
|
|
|
if ($this->unitsAtt[$i]['All']['MagicRound'] > 0) { |
|
91
|
|
|
for ($k = 0; $k < 3; $k++) { |
|
92
|
|
|
$this->unitsAtt[$i]['All']['Magic'][$k] = $this->unitsAtt[$i]['Base']['Magic'][$k]; |
|
93
|
|
|
$this->attackMagic($i, $k); |
|
94
|
|
|
} |
|
95
|
|
|
} |
|
96
|
|
|
$this->unitsAtt[$i]['All']['MagicRound']--; |
|
97
|
|
|
$this->unitsAtt[$i]['All']['MagicRound'] = $this->unitMagicRound($this->unitsAtt[$i]['Base']['ID'], $this->unitsAtt[$i]['All']['MagicRound']); |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* unitMagicRound |
|
102
|
|
|
* |
|
103
|
|
|
* @param integer $id |
|
104
|
|
|
* @param integer $round |
|
105
|
|
|
* @return int |
|
106
|
|
|
*/ |
|
107
|
|
|
private function unitMagicRound($id, $round) |
|
108
|
|
|
{ |
|
109
|
|
|
switch ($id) { |
|
110
|
|
|
case 108: |
|
111
|
|
|
case 111: |
|
112
|
|
|
case 201: |
|
113
|
|
|
case 202: |
|
114
|
|
|
case 203: |
|
115
|
|
|
case 204: |
|
116
|
|
|
case 205: |
|
117
|
|
|
return $round == -1 ? 1 : $round; |
|
118
|
|
|
case 311: |
|
119
|
|
|
return $round == -3 ? 1 : $round; |
|
120
|
|
|
case 104: |
|
121
|
|
|
case 107: |
|
122
|
|
|
case 114: |
|
123
|
|
|
case 211: |
|
124
|
|
|
case 214: |
|
125
|
|
|
case 308: |
|
126
|
|
|
return $round == -4 ? 1 : $round; |
|
127
|
|
|
default: |
|
128
|
|
|
return 0; |
|
129
|
|
|
} |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
/** |
|
133
|
|
|
* attackMagic |
|
134
|
|
|
* |
|
135
|
|
|
* @param integer $i |
|
136
|
|
|
* @param string $k |
|
137
|
|
|
*/ |
|
138
|
|
|
private function attackMagic($i, $k) |
|
139
|
|
|
{ |
|
140
|
|
|
if ($this->unitsAtt[$i]['All']['Magic'][$k] == null) { |
|
141
|
|
|
return; |
|
142
|
|
|
} |
|
143
|
|
|
|
|
144
|
|
|
if ($this->unitsAtt[$i]['All']['Magic'][$k] != 'Steam') { |
|
145
|
|
|
$this->unitsAtt[$i]['All']['AttackAir'] = 0; |
|
146
|
|
|
$this->unitsAtt[$i]['All']['AttackTer'] = 0; |
|
147
|
|
|
} |
|
148
|
|
|
|
|
149
|
|
|
$methodName = 'attackMagic'.$this->unitsAtt[$i]['All']['Magic'][$k]; |
|
150
|
|
|
switch ($this->unitsAtt[$i]['All']['Magic'][$k]) { |
|
151
|
|
|
// ------------------------------- |
|
152
|
|
|
case 'Storm': |
|
153
|
|
|
case 'FogP': |
|
154
|
|
|
$this->$methodName($i); |
|
155
|
|
|
break; |
|
156
|
|
|
case 'MindControl': |
|
157
|
|
|
break; |
|
158
|
|
|
case 'LockP': |
|
159
|
|
|
$this->$methodName($i); |
|
160
|
|
|
break; |
|
161
|
|
|
case 'Jump': |
|
162
|
|
|
break; |
|
163
|
|
|
case 'Phantom': |
|
164
|
|
|
case 'Scarab': |
|
165
|
|
|
$this->$methodName($i); |
|
166
|
|
|
break; |
|
167
|
|
|
|
|
168
|
|
|
// ------------------------------- |
|
169
|
|
|
case 'Remont': |
|
170
|
|
|
case 'Medicine': |
|
171
|
|
|
case 'Blind': |
|
172
|
|
|
case 'Steam': |
|
173
|
|
|
case 'Yamato': |
|
174
|
|
|
case 'Nuclear': |
|
175
|
|
|
$this->$methodName($i); |
|
176
|
|
|
break; |
|
177
|
|
|
case 'LockT': |
|
178
|
|
|
break; |
|
179
|
|
|
case 'Matrix': |
|
180
|
|
|
break; |
|
181
|
|
|
case 'EMI': |
|
182
|
|
|
case 'Radiation': |
|
183
|
|
|
case 'Mines': |
|
184
|
|
|
$this->$methodName($i); |
|
185
|
|
|
break; |
|
186
|
|
|
|
|
187
|
|
|
// ------------------------------- |
|
188
|
|
|
case 'FogZ': |
|
189
|
|
|
break; |
|
190
|
|
|
case 'Marker': |
|
191
|
|
|
break; |
|
192
|
|
|
case 'Plague': |
|
193
|
|
|
$this->$methodName($i); |
|
194
|
|
|
break; |
|
195
|
|
|
case 'Guest': |
|
196
|
|
|
break; |
|
197
|
|
|
case 'Web': |
|
198
|
|
|
break; |
|
199
|
|
|
} |
|
200
|
|
|
} |
|
201
|
|
|
|
|
202
|
|
|
/** |
|
203
|
|
|
* attackMagicStorm |
|
204
|
|
|
* |
|
205
|
|
|
* @param int $i |
|
206
|
|
|
*/ |
|
207
|
|
|
private function attackMagicStorm($i) |
|
208
|
|
|
{ |
|
209
|
|
|
$this->unitsAtt[$i]['All']['AttackMagicAll'] = 250 * $this->unitsAtt[$i]['All']['ManCount']; |
|
210
|
|
|
} |
|
211
|
|
|
|
|
212
|
|
|
/** |
|
213
|
|
|
* attackMagicLockP |
|
214
|
|
|
* |
|
215
|
|
|
* @param int $i |
|
216
|
|
|
*/ |
|
217
|
|
|
private function attackMagicLockP($i) |
|
218
|
|
|
{ |
|
219
|
|
|
$ManCount = $this->unitsAtt[$i]['All']['MagicManCount'] * $this->unitsAtt[$i]['All']['ManCount']; |
|
220
|
|
|
while ($ManCount > 0) { |
|
221
|
|
|
$ManCountExists = false; |
|
222
|
|
|
$count = count($this->unitsDef); |
|
223
|
|
|
for ($i1 = 0; $i1 < $count; $i1++) { |
|
224
|
|
|
if ($this->unitsDef[$i1]['All']['ManCount'] > 0 && $this->unitsDef[$i1]['All']['ManLock'] != $this->unitsDef[$i1]['All']['ManCount']) { |
|
225
|
|
|
$this->unitsDef[$i1]['All']['ManLock']++; |
|
226
|
|
|
$ManCount--; |
|
227
|
|
|
$ManCountExists = true; |
|
228
|
|
|
if ($ManCount == 0) { |
|
229
|
|
|
$i1 = $count; |
|
230
|
|
|
} |
|
231
|
|
|
} |
|
232
|
|
|
} |
|
233
|
|
|
if (!$ManCountExists) { |
|
234
|
|
|
$ManCount = 0; |
|
235
|
|
|
} |
|
236
|
|
|
} |
|
237
|
|
|
} |
|
238
|
|
|
|
|
239
|
|
|
/** |
|
240
|
|
|
* attackMagicPhantom |
|
241
|
|
|
* |
|
242
|
|
|
* @param int $i |
|
243
|
|
|
*/ |
|
244
|
|
|
private function attackMagicPhantom($i) |
|
245
|
|
|
{ |
|
246
|
|
|
$this->unitsAtt[$i]['All']['ManCount']++; |
|
247
|
|
|
$this->unitsAtt[$i]['All']['ManCountVisible']++; |
|
248
|
|
|
$this->unitsAtt[$i]['All']['ManPhantom']++; |
|
249
|
|
|
$this->unitsAtt[$i]['All']['HP'] += $this->unitsAtt[$i]['Base']['HP']; |
|
250
|
|
|
$this->unitsAtt[$i]['All']['Shield'] += $this->unitsAtt[$i]['Base']['Shield']; |
|
251
|
|
|
} |
|
252
|
|
|
|
|
253
|
|
|
/** |
|
254
|
|
|
* attackMagicScarab |
|
255
|
|
|
* |
|
256
|
|
|
* @param int $i |
|
257
|
|
|
*/ |
|
258
|
|
|
private function attackMagicScarab($i) |
|
259
|
|
|
{ |
|
260
|
|
|
$this->unitsAtt[$i]['All']['AttackTer'] = 100 * $this->unitsAtt[$i]['All']['ManCount']; |
|
261
|
|
|
} |
|
262
|
|
|
|
|
263
|
|
|
/** |
|
264
|
|
|
* attackMagicRemont |
|
265
|
|
|
* |
|
266
|
|
|
* @param int $i |
|
267
|
|
|
*/ |
|
268
|
|
|
private function attackMagicRemont($i) |
|
269
|
|
|
{ |
|
270
|
|
|
$this->unitsAtt[$i]['All']['HealingTech'] = 50 * $this->unitsAtt[$i]['All']['ManCount']; |
|
271
|
|
|
} |
|
272
|
|
|
|
|
273
|
|
|
/** |
|
274
|
|
|
* attackMagicMedicine |
|
275
|
|
|
* |
|
276
|
|
|
* @param int $i |
|
277
|
|
|
*/ |
|
278
|
|
|
private function attackMagicMedicine($i) |
|
279
|
|
|
{ |
|
280
|
|
|
$this->unitsAtt[$i]['All']['HealingLive'] = 80 * $this->unitsAtt[$i]['All']['ManCount']; |
|
281
|
|
|
} |
|
282
|
|
|
|
|
283
|
|
|
/** |
|
284
|
|
|
* attackMagicBlind |
|
285
|
|
|
* |
|
286
|
|
|
* @param int $i |
|
287
|
|
|
*/ |
|
288
|
|
|
private function attackMagicBlind($i) |
|
289
|
|
|
{ |
|
290
|
|
|
$ManCount = 3 * $this->unitsAtt[$i]['All']['ManCount']; |
|
291
|
|
|
while ($ManCount > 0) { |
|
292
|
|
|
$ManCountExists = false; |
|
293
|
|
|
$count = count($this->unitsDef); |
|
294
|
|
|
for ($i1 = 0; $i1 < $count; $i1++) { |
|
295
|
|
|
if (in_array($this->unitsDef[$i1]['Base']['ID'], [105, 109, 204, 213, 305])) { |
|
296
|
|
|
if ($this->unitsDef[$i1]['All']['ManCount'] > 0 && $this->unitsDef[$i1]['All']['ManCountVisible'] != $this->unitsDef[$i1]['All']['ManCount']) { |
|
297
|
|
|
$this->unitsDef[$i1]['All']['ManCountVisible']++; |
|
298
|
|
|
$ManCount--; |
|
299
|
|
|
$ManCountExists = true; |
|
300
|
|
|
if ($ManCount == 0) { |
|
301
|
|
|
$i1 = $count; |
|
302
|
|
|
} |
|
303
|
|
|
} |
|
304
|
|
|
} |
|
305
|
|
|
} |
|
306
|
|
|
if (!$ManCountExists) { |
|
307
|
|
|
$ManCount = 0; |
|
308
|
|
|
} |
|
309
|
|
|
} |
|
310
|
|
|
} |
|
311
|
|
|
|
|
312
|
|
|
/** |
|
313
|
|
|
* attackMagicSteam |
|
314
|
|
|
* |
|
315
|
|
|
* @param int $i |
|
316
|
|
|
*/ |
|
317
|
|
|
private function attackMagicSteam($i) |
|
318
|
|
|
{ |
|
319
|
|
|
if ($this->unitsAtt[$i]['All']['HP'] / $this->unitsAtt[$i]['All']['ManCount'] > 16) { |
|
320
|
|
|
$this->unitsAtt[$i]['All']['AttackAir'] = $this->unitsAtt[$i]['All']['AttackAir'] * 2; |
|
321
|
|
|
$this->unitsAtt[$i]['All']['AttackTer'] = $this->unitsAtt[$i]['All']['AttackTer'] * 2; |
|
322
|
|
|
$this->unitsAtt[$i]['All']['HP'] = $this->unitsAtt[$i]['All']['HP'] - (8 * $this->unitsAtt[$i]['All']['ManCount']); |
|
323
|
|
|
} |
|
324
|
|
|
} |
|
325
|
|
|
|
|
326
|
|
|
/** |
|
327
|
|
|
* attackMagicYamato |
|
328
|
|
|
* |
|
329
|
|
|
* @param int $i |
|
330
|
|
|
*/ |
|
331
|
|
|
private function attackMagicYamato($i) |
|
332
|
|
|
{ |
|
333
|
|
|
$this->unitsAtt[$i]['All']['AttackMagicAll'] = 260 * $this->unitsAtt[$i]['All']['ManCount']; |
|
334
|
|
|
} |
|
335
|
|
|
|
|
336
|
|
|
/** |
|
337
|
|
|
* attackMagicNuclear |
|
338
|
|
|
* |
|
339
|
|
|
* @param int $i |
|
340
|
|
|
*/ |
|
341
|
|
|
private function attackMagicNuclear($i) |
|
342
|
|
|
{ |
|
343
|
|
|
$this->unitsAtt[$i]['All']['AttackMagicAll'] = 300 * $this->unitsAtt[$i]['All']['ManCount']; |
|
344
|
|
|
} |
|
345
|
|
|
|
|
346
|
|
|
/** |
|
347
|
|
|
* attackMagicEMI |
|
348
|
|
|
* |
|
349
|
|
|
* @param int $i |
|
350
|
|
|
*/ |
|
351
|
|
|
private function attackMagicEMI($i) |
|
352
|
|
|
{ |
|
353
|
|
|
$this->unitsAtt[$i]['All']['AttackMagicShield'] = 250 * $this->unitsAtt[$i]['All']['ManCount']; |
|
354
|
|
|
} |
|
355
|
|
|
|
|
356
|
|
|
/** |
|
357
|
|
|
* attackMagicRadiation |
|
358
|
|
|
* |
|
359
|
|
|
* @param int $i |
|
360
|
|
|
*/ |
|
361
|
|
|
private function attackMagicRadiation($i) |
|
362
|
|
|
{ |
|
363
|
|
|
$this->unitsAtt[$i]['All']['AttackMagicHP'] = 100 * $this->unitsAtt[$i]['All']['ManCount']; |
|
364
|
|
|
} |
|
365
|
|
|
|
|
366
|
|
|
/** |
|
367
|
|
|
* attackMagicMines |
|
368
|
|
|
* |
|
369
|
|
|
* @param int $i |
|
370
|
|
|
*/ |
|
371
|
|
|
private function attackMagicMines($i) |
|
372
|
|
|
{ |
|
373
|
|
|
$this->unitsAtt[$i]['All']['AttackTer'] = 125 * $this->unitsAtt[$i]['All']['ManCount']; |
|
374
|
|
|
} |
|
375
|
|
|
|
|
376
|
|
|
/** |
|
377
|
|
|
* attackMagicPlague |
|
378
|
|
|
* |
|
379
|
|
|
* @param int $i |
|
380
|
|
|
*/ |
|
381
|
|
|
private function attackMagicPlague($i) |
|
382
|
|
|
{ |
|
383
|
|
|
$this->unitsAtt[$i]['All']['AttackMagicHP'] = 145 * $this->unitsAtt[$i]['All']['ManCount']; |
|
384
|
|
|
} |
|
385
|
|
|
} |
|
386
|
|
|
|