1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Created by Gorlum 24.03.2018 21:54 |
4
|
|
|
*/ |
5
|
|
|
|
6
|
|
|
namespace Meta\Economic; |
7
|
|
|
|
8
|
|
|
|
9
|
|
|
use SN; |
10
|
|
|
|
11
|
|
|
class BuildDataStatic { |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* @param float $prevDivisor - because this is Hooker prev result variable should be declared |
15
|
|
|
* @param array $user |
16
|
|
|
* @param array $planet |
17
|
|
|
* @param int $unit_id |
18
|
|
|
* @param array $unit_data |
19
|
|
|
* |
20
|
|
|
* @return float |
21
|
|
|
*/ |
22
|
|
|
public static function getStructuresTimeDivisor($prevDivisor, $user, $planet, $unit_id, $unit_data) { |
23
|
|
|
$result = 1; |
24
|
|
|
if (in_array($unit_id, sn_get_groups('structures'))) { |
25
|
|
|
$result = pow(2, mrc_get_level($user, $planet, STRUC_FACTORY_NANO)) * (mrc_get_level($user, $planet, STRUC_FACTORY_ROBOT) + 1); |
|
|
|
|
26
|
|
|
} elseif (in_array($unit_id, sn_get_groups('defense'))) { |
27
|
|
|
$result = pow(2, mrc_get_level($user, $planet, STRUC_FACTORY_NANO)) * (mrc_get_level($user, $planet, STRUC_FACTORY_HANGAR) + 1); |
28
|
|
|
} elseif (in_array($unit_id, sn_get_groups('fleet'))) { |
29
|
|
|
$result = pow(2, mrc_get_level($user, $planet, STRUC_FACTORY_NANO)) * (mrc_get_level($user, $planet, STRUC_FACTORY_HANGAR) + 1); |
30
|
|
|
} elseif (in_array($unit_id, sn_get_groups('tech'))) { |
31
|
|
|
$result = eco_get_lab_max_effective_level($user, intval($unit_data[P_REQUIRE][STRUC_LABORATORY])); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
return $result; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @param int $unit_id |
39
|
|
|
* |
40
|
|
|
* @return float |
41
|
|
|
*/ |
42
|
|
|
public static function getMercenaryTimeDivisor($user, $planet, $unit_id) { |
43
|
|
|
if (in_array($unit_id, sn_get_groups('structures'))) { |
44
|
|
|
$mercenary = MRC_ENGINEER; |
45
|
|
|
} elseif (in_array($unit_id, sn_get_groups('tech'))) { |
46
|
|
|
$mercenary = MRC_ACADEMIC; |
47
|
|
|
} elseif (in_array($unit_id, sn_get_groups('defense'))) { |
48
|
|
|
$mercenary = MRC_FORTIFIER; |
49
|
|
|
} elseif (in_array($unit_id, sn_get_groups('fleet'))) { |
50
|
|
|
$mercenary = MRC_ENGINEER; |
51
|
|
|
} else { |
52
|
|
|
$mercenary = 0; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
return $mercenary ? mrc_modify_value($user, $planet, $mercenary, 1) : 1; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @param array $user |
60
|
|
|
* @param array $planet |
61
|
|
|
* @param int $unit_id |
62
|
|
|
* |
63
|
|
|
* @return float|int |
64
|
|
|
*/ |
65
|
|
|
public static function getCapitalTimeDivisor($user, $planet, $unit_id) { |
66
|
|
|
static $capitalUnitGroups; |
67
|
|
|
if(empty($capitalUnitGroups)) { |
68
|
|
|
$capitalUnitGroups = sn_get_groups(sn_get_groups(GROUP_CAPITAL_BUILDING_BONUS_GROUPS)); |
|
|
|
|
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
if ( |
72
|
|
|
// If planet is capital |
73
|
|
|
$user['id_planet'] == $planet['id'] |
74
|
|
|
&& |
75
|
|
|
SN::$gc->config->planet_capital_building_rate > 0 |
76
|
|
|
&& |
77
|
|
|
in_array($unit_id, $capitalUnitGroups) |
78
|
|
|
) { |
79
|
|
|
$capitalTimeDivisor = SN::$gc->config->planet_capital_building_rate; |
80
|
|
|
} else { |
81
|
|
|
$capitalTimeDivisor = 1; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
return $capitalTimeDivisor; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
} |
88
|
|
|
|