-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathunits.php
664 lines (587 loc) · 28.1 KB
/
units.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
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
<?php
declare(strict_types = 1);
defined('INSIDE') OR exit('No direct script access allowed');
/**
* This class contains all information about every unit, including
* prices, dependencies and language-bindings.
*/
class D_Units {
/** @var array Mapping of Unit-ID to Unit-String-ID */
private static $units;
/** @var array Mapping of Unit-ID to the name in the currently loaded language */
private static $names;
/** @var array Mapping of Unit-ID to the description, according to the current language-file */
private static $descriptions;
/** @var array Mapping of Unit-ID to the price for the unit */
private static $pricelist;
/** @var array Mapping of Unit-ID to the requirements for the unit */
private static $requeriments;
private static $initialized = false;
static function destruct() {
self::$units = null;
self::$names = null;
self::$descriptions = null;
self::$pricelist = null;
self::$requeriments = null;
self::$initialized = false;
}
/**
*
*/
static function init() {
// check, if already initialized
if (self::$initialized) {
return;
}
self::$initialized = true;
require Config::$pathConfig['language'] . Config::$gameConfig['language'] . '/units.php';
self::$units = [
1 => 'metal_mine',
2 => 'crystal_mine',
3 => 'deuterium_synthesizer',
4 => 'solar_plant',
5 => 'fusion_reactor',
6 => 'robotic_factory',
7 => 'nanite_factory',
8 => 'shipyard',
9 => 'metal_storage',
10 => 'crystal_storage',
11 => 'deuterium_storage',
12 => 'research_lab',
13 => 'terraformer',
14 => 'alliance_depot',
15 => 'missile_silo',
101 => 'espionage_tech',
102 => 'computer_tech',
103 => 'weapon_tech',
104 => 'armour_tech',
105 => 'shielding_tech',
106 => 'energy_tech',
107 => 'hyperspace_tech',
108 => 'combustion_drive_tech',
109 => 'impulse_drive_tech',
110 => 'hyperspace_drive_tech',
111 => 'laser_tech',
112 => 'ion_tech',
113 => 'plasma_tech',
114 => 'intergalactic_research_tech',
115 => 'graviton_tech',
201 => 'small_cargo_ship',
202 => 'large_cargo_ship',
203 => 'light_fighter',
204 => 'heavy_fighter',
205 => 'cruiser',
206 => 'battleship',
207 => 'colony_ship',
208 => 'recycler',
209 => 'espionage_probe',
210 => 'bomber',
211 => 'solar_satellite',
212 => 'destroyer',
213 => 'battlecruiser',
214 => 'deathstar',
301 => 'rocket_launcher',
302 => 'light_laser',
303 => 'heavy_laser',
304 => 'gauss_cannon',
305 => 'ion_cannon',
306 => 'plasma_turret',
307 => 'small_shield_dome',
308 => 'large_shield_dome',
309 => 'anti_ballistic_missile',
310 => 'interplanetary_missile'
];
self::$names = [
1 => $lang["metal_mine"],
2 => $lang["crystal_mine"],
3 => $lang["deuterium_synthesizer"],
4 => $lang["solar_plant"],
5 => $lang["fusion_reactor"],
6 => $lang["robotic_factory"],
7 => $lang["nanite_factory"],
8 => $lang["shipyard"],
9 => $lang["metal_storage"],
10 => $lang["crystal_storage"],
11 => $lang["deuterium_storage"],
12 => $lang["research_lab"],
13 => $lang["terraformer"],
14 => $lang["alliance_depot"],
15 => $lang["missile_silo"],
101 => $lang["espionage_tech"],
102 => $lang["computer_tech"],
103 => $lang["weapon_tech"],
104 => $lang["armour_tech"],
105 => $lang["shielding_tech"],
106 => $lang["energy_tech"],
107 => $lang["hyperspace_tech"],
108 => $lang["combustion_drive_tech"],
109 => $lang["impulse_drive_tech"],
110 => $lang["hyperspace_drive_tech"],
111 => $lang["laser_tech"],
112 => $lang["ion_tech"],
113 => $lang["plasma_tech"],
114 => $lang["intergalactic_research_tech"],
115 => $lang["graviton_tech"],
201 => $lang["small_cargo_ship"],
202 => $lang["large_cargo_ship"],
203 => $lang["light_fighter"],
204 => $lang["heavy_fighter"],
205 => $lang["cruiser"],
206 => $lang["battleship"],
207 => $lang["colony_ship"],
208 => $lang["recycler"],
209 => $lang["espionage_probe"],
210 => $lang["bomber"],
211 => $lang["solar_satellite"],
212 => $lang["destroyer"],
213 => $lang["battlecruiser"],
214 => $lang["deathstar"],
301 => $lang["rocket_launcher"],
302 => $lang["light_laser"],
303 => $lang["heavy_laser"],
304 => $lang["gauss_cannon"],
305 => $lang["ion_cannon"],
306 => $lang["plasma_turret"],
307 => $lang["small_shield_dome"],
308 => $lang["large_shield_dome"],
309 => $lang["anti_ballistic_missile"],
310 => $lang["interplanetary_missile"]
];
self::$descriptions = [
1 => $lang["metal_mine_descr"],
2 => $lang["crystal_mine_descr"],
3 => $lang["deuterium_synthesizer_descr"],
4 => $lang["solar_plant_descr"],
5 => $lang["fusion_reactor_descr"],
6 => $lang["robotic_factory_descr"],
7 => $lang["nanite_factory_descr"],
8 => $lang["shipyard_descr"],
9 => $lang["metal_storage_descr"],
10 => $lang["crystal_storage_descr"],
11 => $lang["deuterium_storage_descr"],
12 => $lang["research_lab_descr"],
13 => $lang["terraformer_descr"],
14 => $lang["alliance_depot_descr"],
15 => $lang["missile_silo_descr"],
101 => $lang["espionage_tech_descr"],
102 => $lang["computer_tech_descr"],
103 => $lang["weapon_tech_descr"],
104 => $lang["armour_tech_descr"],
105 => $lang["shielding_tech_descr"],
106 => $lang["energy_tech_descr"],
107 => $lang["hyperspace_tech_descr"],
108 => $lang["combustion_drive_tech_descr"],
109 => $lang["impulse_drive_tech_descr"],
110 => $lang["hyperspace_drive_tech_descr"],
111 => $lang["laser_tech_descr"],
112 => $lang["ion_tech_descr"],
113 => $lang["plasma_tech_descr"],
114 => $lang["intergalactic_research_tech_descr"],
115 => $lang["graviton_tech_descr"],
201 => $lang["small_cargo_ship_descr"],
202 => $lang["large_cargo_ship_descr"],
203 => $lang["light_fighter_descr"],
204 => $lang["heavy_fighter_descr"],
205 => $lang["cruiser_descr"],
206 => $lang["battleship_descr"],
207 => $lang["colony_ship_descr"],
208 => $lang["recycler_descr"],
209 => $lang["espionage_probe_descr"],
210 => $lang["bomber_descr"],
211 => $lang["solar_satellite_descr"],
212 => $lang["destroyer_descr"],
213 => $lang["battlecruiser_descr"],
214 => $lang["deathstar_descr"],
301 => $lang["rocket_launcher_desc"],
302 => $lang["light_laser_desc"],
303 => $lang["heavy_laser_desc"],
304 => $lang["gauss_cannon_desc"],
305 => $lang["ion_cannon_desc"],
306 => $lang["plasma_turret_desc"],
307 => $lang["small_shield_dome_desc"],
308 => $lang["large_shield_dome_desc"],
309 => $lang["anti_ballistic_missile_desc"],
310 => $lang["interplanetary_missile_desc"]
];
self::$pricelist = [
// Buildings
1 => ['metal' => 60, 'crystal' => 15, 'deuterium' => 0, 'energy' => 0, 'factor' => 1.5],
2 => ['metal' => 48, 'crystal' => 24, 'deuterium' => 0, 'energy' => 0, 'factor' => 1.6],
3 => ['metal' => 225, 'crystal' => 75, 'deuterium' => 0, 'energy' => 0, 'factor' => 1.5],
4 => ['metal' => 75, 'crystal' => 30, 'deuterium' => 0, 'energy' => 0, 'factor' => 1.5],
5 => ['metal' => 900, 'crystal' => 360, 'deuterium' => 180, 'energy' => 0, 'factor' => 1.8],
6 => ['metal' => 400, 'crystal' => 120, 'deuterium' => 200, 'energy' => 0, 'factor' => 2],
7 => ['metal' => 1000000, 'crystal' => 500000, 'deuterium' => 100000, 'energy' => 0, 'factor' => 2],
8 => ['metal' => 400, 'crystal' => 200, 'deuterium' => 100, 'energy' => 0, 'factor' => 2],
9 => ['metal' => 1000, 'crystal' => 0, 'deuterium' => 0, 'energy' => 0, 'factor' => 2],
10 => ['metal' => 1000, 'crystal' => 500, 'deuterium' => 0, 'energy' => 0, 'factor' => 2],
11 => ['metal' => 1000, 'crystal' => 1000, 'deuterium' => 0, 'energy' => 0, 'factor' => 2],
12 => ['metal' => 200, 'crystal' => 400, 'deuterium' => 200, 'energy' => 0, 'factor' => 2],
13 => ['metal' => 0, 'crystal' => 50000, 'deuterium' => 100000, 'energy' => 1000, 'factor' => 2],
14 => ['metal' => 20000, 'crystal' => 40000, 'deuterium' => 0, 'energy' => 0, 'factor' => 2],
15 => ['metal' => 20000, 'crystal' => 20000, 'deuterium' => 1000, 'energy' => 0, 'factor' => 2],
// Techs
101 => ['metal' => 200, 'crystal' => 1000, 'deuterium' => 200, 'energy' => 0, 'factor' => 2],
102 => ['metal' => 0, 'crystal' => 400, 'deuterium' => 600, 'energy' => 0, 'factor' => 2],
103 => ['metal' => 800, 'crystal' => 200, 'deuterium' => 0, 'energy' => 0, 'factor' => 2],
104 => ['metal' => 200, 'crystal' => 600, 'deuterium' => 0, 'energy' => 0, 'factor' => 2],
105 => ['metal' => 1000, 'crystal' => 0, 'deuterium' => 0, 'energy' => 0, 'factor' => 2],
106 => ['metal' => 0, 'crystal' => 800, 'deuterium' => 400, 'energy' => 0, 'factor' => 2],
107 => ['metal' => 0, 'crystal' => 4000, 'deuterium' => 2000, 'energy' => 0, 'factor' => 2],
108 => ['metal' => 400, 'crystal' => 0, 'deuterium' => 600, 'energy' => 0, 'factor' => 2],
109 => ['metal' => 2000, 'crystal' => 4000, 'deuterium' => 600, 'energy' => 0, 'factor' => 2],
110 => ['metal' => 10000, 'crystal' => 20000, 'deuterium' => 6000, 'energy' => 0, 'factor' => 2],
111 => ['metal' => 200, 'crystal' => 100, 'deuterium' => 0, 'energy' => 0, 'factor' => 2],
112 => ['metal' => 1000, 'crystal' => 300, 'deuterium' => 100, 'energy' => 0, 'factor' => 2],
113 => ['metal' => 2000, 'crystal' => 4000, 'deuterium' => 1000, 'energy' => 0, 'factor' => 2],
114 => ['metal' => 240000, 'crystal' => 400000, 'deuterium' => 160000, 'energy' => 0, 'factor' => 2],
115 => ['metal' => 0, 'crystal' => 0, 'deuterium' => 0, 'energy' => 300000, 'factor' => 3],
// Fleet
201 => ['metal' => 2000,
'crystal' => 2000,
'deuterium' => 0,
'energy' => 0,
'factor' => 1,
'consumption' => 20,
'speed' => 28000,
'capacity' => 5000
],
202 => ['metal' => 6000,
'crystal' => 6000,
'deuterium' => 0,
'energy' => 0,
'factor' => 1,
'consumption' => 50,
'speed' => 17250,
'capacity' => 25000
],
203 => ['metal' => 3000,
'crystal' => 1000,
'deuterium' => 0,
'energy' => 0,
'factor' => 1,
'consumption' => 20,
'speed' => 28750,
'capacity' => 50
],
204 => ['metal' => 6000,
'crystal' => 4000,
'deuterium' => 0,
'energy' => 0,
'factor' => 1,
'consumption' => 75,
'speed' => 28000,
'capacity' => 100
],
205 => ['metal' => 20000,
'crystal' => 7000,
'deuterium' => 2000,
'energy' => 0,
'factor' => 1,
'consumption' => 300,
'speed' => 42000,
'capacity' => 800
],
206 => ['metal' => 45000,
'crystal' => 15000,
'deuterium' => 0,
'energy' => 0,
'factor' => 1,
'consumption' => 500,
'speed' => 31000,
'capacity' => 1500
],
207 => ['metal' => 10000, 'crystal' => 20000, 'deuterium' => 10000, 'energy' => 0, 'factor' => 1],
208 => ['metal' => 10000,
'crystal' => 6000,
'deuterium' => 2000,
'energy' => 0,
'factor' => 1,
'consumption' => 300,
'speed' => 4600,
'capacity' => 20000
],
209 => ['metal' => 0,
'crystal' => 1000,
'deuterium' => 0,
'energy' => 0,
'factor' => 1,
'consumption' => 1,
'speed' => 230000000,
'capacity' => 5
],
210 => ['metal' => 50000,
'crystal' => 25000,
'deuterium' => 15000,
'energy' => 0,
'factor' => 1,
'consumption' => 1000,
'speed' => 11200,
'capacity' => 500
],
211 => ['metal' => 0, 'crystal' => 2000, 'deuterium' => 500, 'energy' => 0, 'factor' => 1],
212 => ['metal' => 60000,
'crystal' => 50000,
'deuterium' => 15000,
'energy' => 0,
'factor' => 1,
'consumption' => 1000,
'speed' => 15500,
'capacity' => 2000
],
213 => ['metal' => 30000, 'crystal' => 40000, 'deuterium' => 15000, 'energy' => 0, 'factor' => 1],
214 => ['metal' => 5000000, 'crystal' => 4000000, 'deuterium' => 1000000, 'energy' => 0, 'factor' => 1],
// Defense
301 => ['metal' => 2000, 'crystal' => 0, 'deuterium' => 0, 'energy' => 0, 'factor' => 1],
302 => ['metal' => 1500, 'crystal' => 500, 'deuterium' => 0, 'energy' => 0, 'factor' => 1],
303 => ['metal' => 6000, 'crystal' => 2000, 'deuterium' => 0, 'energy' => 0, 'factor' => 1],
304 => ['metal' => 20000, 'crystal' => 15000, 'deuterium' => 2000, 'energy' => 0, 'factor' => 1],
305 => ['metal' => 2000, 'crystal' => 6000, 'deuterium' => 0, 'energy' => 0, 'factor' => 1],
306 => ['metal' => 50000, 'crystal' => 50000, 'deuterium' => 30000, 'energy' => 0, 'factor' => 1],
307 => ['metal' => 10000, 'crystal' => 10000, 'deuterium' => 0, 'energy' => 0, 'factor' => 1],
308 => ['metal' => 50000, 'crystal' => 50000, 'deuterium' => 0, 'energy' => 0, 'factor' => 1],
309 => ['metal' => 8000, 'crystal' => 2000, 'deuterium' => 0, 'energy' => 0, 'factor' => 1],
310 => ['metal' => 12500, 'crystal' => 2500, 'deuterium' => 10000, 'energy' => 0, 'factor' => 1]
];
self::$requeriments = [
// buildings
5 => [3 => 5, 106 => 3],
7 => [6 => 10, 102 => 10],
8 => [6 => 2],
13 => [7 => 1, 106 => 12],
// techs
101 => [12 => 3],
102 => [12 => 1],
103 => [12 => 4],
104 => [12 => 2],
105 => [12 => 6, 106 => 3],
106 => [12 => 1],
107 => [12 => 7, 106 => 5, 105 => 5],
108 => [12 => 1, 106 => 1],
109 => [12 => 2, 106 => 1],
110 => [12 => 7, 107 => 3],
111 => [12 => 1, 106 => 2],
112 => [12 => 4, 106 => 4, 111 => 5],
113 => [12 => 4, 106 => 8, 111 => 10, 112 => 5],
114 => [12 => 10, 102 => 8, 107 => 8],
115 => [12 => 12],
// fleet
201 => [8 => 2, 108 => 2],
202 => [8 => 4, 108 => 6],
203 => [8 => 1, 108 => 1],
204 => [8 => 3, 104 => 2, 109 => 2],
205 => [8 => 5, 109 => 4, 112 => 2],
206 => [8 => 7, 110 => 4],
207 => [8 => 4, 109 => 3],
208 => [8 => 4, 108 => 6, 105 => 2],
209 => [8 => 3, 108 => 3, 101 => 2],
210 => [8 => 8, 109 => 6, 113 => 5],
211 => [8 => 1],
212 => [8 => 9, 107 => 5, 110 => 6],
213 => [8 => 8, 111 => 12, 107 => 5, 110 => 5],
214 => [8 => 12, 115 => 1, 107 => 6, 110 => 7]
];
}
/**
* Returns the unitID given the unit-string-ID
* @param string $unitName the unit-string-ID
* @return int the unitID
*/
static function getUnitID(string $unitName) : int {
return array_keys(self::$units, $unitName)[0];
}
/**
* Returns the name of the unit-string-ID given the unitID
* @param int $id the unitID
* @return string the unit-string-ID
*/
static function getUnitName(int $id) : string {
if (isset(self::$units[$id])) {
return self::$units[$id];
}
return "";
}
/**
* Returns an array, containing all buildings with the unitID as the key and the unit-string-ID as the value
* @return array all buildings with the unitID as the key and the unit-string-ID as the value
*/
static function getBuildings() : array {
return array_slice(self::$units, 0, 15, true);
}
/**
* Returns an array, containing all technologies with the unitID as the key and the unit-string-ID as the value
* @return array all technologies with the unitID as the key and the unit-string-ID as the value
*/
static function getTechnologies() : array {
return array_slice(self::$units, 15, 15, true);
}
/**
* Returns an array, containing all fleets with the unitID as the key and the unit-string-ID as the value
* @return array all fleets with the unitID as the key and the unit-string-ID as the value
*/
static function getFleet() : array {
return array_slice(self::$units, 30, 14, true);
}
/**
* Returns an array, containing all defenses with the unitID as the key and the unit-string-ID as the value
* @return array all defenses with the unitID as the key and the unit-string-ID as the value
*/
static function getDefense() : array {
return array_slice(self::$units, 44, 10, true);
}
/**
* Returns the name of the unit, according to the current language-file
* @param int $id the unitID
* @return string the name of the unit, according to the current language-file
*/
static function getName(int $id) : string {
if (isset(self::$names[$id])) {
return self::$names[$id];
}
return "";
}
/**
* Returns the description of the unit, according to the current language-file
* @param int $id the unitID
* @return string the description of the unit, according to the current language-file
*/
static function getDescription(int $id) : string {
if (isset(self::$descriptions[$id])) {
return self::$descriptions[$id];
}
return "";
}
/**
* Returns the pricelist fot the unit
* @param int $id the unitID
* @return array the pricelist for the unit
*/
static function getPriceList(int $id) : array {
if (isset(self::$pricelist[$id])) {
return self::$pricelist[$id];
} else {
return [];
}
}
/**
* Returns the requirements for the unit, which are represented as key-value-pairs with the key being the id of
* the required unit and the value being the required level of this unit
* @param int $id the unitID
* @return array the requirements for the unit
*/
static function getRequirements(int $id) : array {
if (isset(self::$requeriments[$id])) {
return self::$requeriments[$id];
} else {
return [];
}
}
/**
* Calculates and returns the build-time for the next level (or one unit for fleet/defense) of the Unit
* @param U_Unit $unit the unit-object of the given unit
* @param int $robotLvl the level of the robotic factory
* @param int $shipYardLvl the level of the shipyard factory
* @param int $naniteLvl the level of the nanite factory
* @return float the needed time to build in seconds
*/
static function getBuildTime(U_Unit $unit, int $robotLvl, int $shipYardLvl, int $naniteLvl) : float {
if($robotLvl < 0 || $shipYardLvl < 0 || $naniteLvl < 0) {
return -1.0;
}
$metal = $unit->getCostMetal();
$crystal = $unit->getCostCrystal();
$factor = $unit->getFactor();
// building
if ($unit->getUnitId() < 100) {
//(39410 + 9852)/(2500 * (1+10) * 2^3)
return ($metal + $crystal) / (2500 * (1 + $robotLvl) * (2 ** $naniteLvl));
}
// TODO: research-lab-level and research-network level
// tech
if ($unit->getUnitId() > 100 && $unit->getUnitId() < 200) {
return ($metal * $factor + $crystal * $factor) / (2500 * (1 + $robotLvl) * pow(2, $naniteLvl));
}
// fleet and defense
if ($unit->getUnitId() > 200 && $unit->getUnitId() < 400) {
return ($metal + $crystal) / (2500 * (1 + $shipYardLvl) * pow(2, $naniteLvl));
}
return -1.0;
}
/**
* Returns the storage-capacity for a resource, given the storage level
* @param int $storage_level the storage level
* @return float the storage capacity
*/
static function getStorageCapacity(int $storage_level) : float {
if ($storage_level >= 0) {
// Source: http://ogame.wikia.com/wiki/Metal_Storage
return 100000 + 50000 * (ceil(pow(1.5, $storage_level)) - 1);
}
return -1.0;
}
/**
* Returns the metal-production per hour
* @param int $level the level of the metal-mine
* @return float the metal-production per hour
*/
static function getMetalProductionPerHour(int $level, int $plasmaLevel) : float {
if ($level >= 0) {
return floor(30 * $level * pow(1.1, $level)) * ((100 + 1 * $plasmaLevel)/100);
}
return -1.0;
}
/**
* Returns the crystal-production per hour
* @param int $level the level of the metal-mine
* @return float the metal-production per hour
*/
static function getCrystalProductionPerHour(int $level, int $plasmaLevel) : float {
if ($level >= 0) {
return floor(20 * $level * pow(1.1, $level)) * ((100 + 0.66 * $plasmaLevel)/100);
}
return -1.0;
}
/**
* Returns the deuterium-production per hour
* @param int $level the level of the metal-mine
* @return float the metal-production per hour
*/
static function getDeuteriumProductionPerHour(int $level, float $maxTemp) : float {
if ($level >= 0) {
return floor(10 * $level * pow(1.1, $level) * (1.28 - 0.002 * $maxTemp));
}
return -1.0;
}
/**
* Returns the energy-production for each energy-producing unit
* @param int $solarLevel the level of the Solar Plant
* @param int $fusionLevel the level of the Fusion Reactor
* @param int $energytech the level of the Energy Technology
* @param int $numSolarSats the amount of the Solar Satellites
* @param int $planetMaxTemp the maximum temperature of the current planet
* @return array the energy-production of each energy-producing unit
*/
static function getEnergyProduction(int $solarLevel, int $fusionLevel, int $energytech, int $numSolarSats,
int $planetMaxTemp) : array {
if ($solarLevel >= 0 && $fusionLevel >= 0 && $energytech >= 0 && $numSolarSats >= 0) {
return [
self::$units[4] => 20 * $solarLevel * pow(1.1, $solarLevel),
self::$units[5] => 30 * $fusionLevel * pow((1.05 + $energytech + 0.01), $fusionLevel),
self::$units[211] => (($planetMaxTemp / 4) + 20) * $numSolarSats
];
}
return [];
}
/**
* Returns the energy consumption of a given unit
* @param int $level the level of the unit
* @return float the energy consumption
*/
static function getEnergyConsumption(int $level) : float {
//TODO: check if a energy-consuming unit or not
if ($level >= 0) {
return 10 * $level * pow(1.1, $level);
}
return -1.0;
}
}