1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* resources.php |
5
|
|
|
* |
6
|
|
|
* Planet resource interface page |
7
|
|
|
* |
8
|
|
|
* 2.2 - copyright (ñ) 2010 by Gorlum for http://supernova.ws |
9
|
|
|
* [~] - more optimization to utilize PTE |
10
|
|
|
* [~] - code formatting according to PCG |
11
|
|
|
* [~] - content of BuildRessourcePage.php moved to resource.php |
12
|
|
|
* 2.1 - copyright 2010 by Gorlum for http://supernova.ws |
13
|
|
|
* [~] - Security checked for SQL-injection |
14
|
|
|
* 2.0 - copyright 2010 by Gorlum for http://supernova.ws |
15
|
|
|
* [+] - almost fully rewrote and optimized |
16
|
|
|
* 1.0 [BuildRessourcePage.php] copyright 2008 by ShadoV for XNova |
17
|
|
|
* [+] - Mise en module initiale (creation) |
18
|
|
|
* 1.1 - copyright 2010 by Gorlum for http://supernova.ws |
19
|
|
|
* [%] - Security checks & tests by Gorlum for http://supernova.ws |
20
|
|
|
* 1.0 copyright (ñ) 2008 by Chlorel for XNova |
21
|
|
|
* [!] - Passage en fonction pour utilisation XNova |
22
|
|
|
* |
23
|
|
|
**/ |
24
|
|
|
|
25
|
|
|
include('common.' . substr(strrchr(__FILE__, '.'), 1)); |
26
|
|
|
|
27
|
|
|
use \Meta\Economic\ResourceCalculations; |
|
|
|
|
28
|
|
|
use Planet\DBStaticPlanet; |
29
|
|
|
use Planet\Planet; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @param $resource_id |
33
|
|
|
* @param ResourceCalculations $capsObj |
34
|
|
|
*/ |
35
|
|
|
function int_calc_storage_bar($resource_id, $capsObj) |
36
|
|
|
{ |
37
|
|
|
global $lang, $template, $planetrow, $user; |
38
|
|
|
|
39
|
|
|
$totalProduction = $capsObj->getProduction($resource_id); |
40
|
|
|
$storage_fill = $capsObj->getStorage($resource_id) ? floor(mrc_get_level($user, $planetrow, $resource_id) / $capsObj->getStorage($resource_id) * 100) : 0; |
41
|
|
|
|
42
|
|
|
$template->assign_block_vars('resources', [ |
43
|
|
|
'NAME' => $lang["sys_" . pname_resource_name($resource_id)], |
44
|
|
|
|
45
|
|
|
'HOURLY' => $totalProduction, |
46
|
|
|
'DAILY' => $totalProduction * 24, |
47
|
|
|
'WEEKLY' => $totalProduction * 24 * 7, |
48
|
|
|
'MONTHLY' => $totalProduction * 24 * 30, |
49
|
|
|
|
50
|
|
|
'STORAGE' => intval($storage_fill), |
51
|
|
|
'BAR' => min($storage_fill, 100), |
52
|
|
|
]); |
53
|
|
|
}; |
54
|
|
|
|
55
|
|
|
$ValidList['percent'] = array ( 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 ); |
56
|
|
|
$template = SnTemplate::gettemplate('resources', true); |
|
|
|
|
57
|
|
|
|
58
|
|
|
/** @noinspection PhpUnhandledExceptionInspection */ |
59
|
|
|
$planet = SN::$gc->repoV2->getPlanet($planetrow['id']); |
60
|
|
|
if(!empty($transmutation_result = $planet->sn_sys_planet_core_transmute($user))) { |
61
|
|
|
$template->assign_block_vars('result', $transmutation_result); |
62
|
|
|
$planet->dbLoadRecord($planetrow['id']); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
$sn_group_factories = sn_get_groups('factories'); |
66
|
|
|
/** |
67
|
|
|
* @param debug $debug |
68
|
|
|
* @param array $sn_group_factories |
69
|
|
|
* @param array $planetrow |
70
|
|
|
* @param Planet $planet |
71
|
|
|
* |
72
|
|
|
* @return mixed |
73
|
|
|
*/ |
74
|
|
|
function updateProductionSpeeds($debug, $sn_group_factories, $planetrow, $planet) { |
75
|
|
|
$production = $_POST['production']; |
76
|
|
|
if (!is_array($production)) { |
77
|
|
|
return $planetrow; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
$SubQry = []; |
81
|
|
|
foreach ($production as $prod_id => $percent) { |
82
|
|
|
if ($percent > 100 || $percent < 0) { |
83
|
|
|
$debug->warning('Supplying wrong production percent (less then 0 or greater then 100)', 'Hack attempt', 302, array('base_dump' => true)); |
84
|
|
|
die(); |
|
|
|
|
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
$prod_id = intval($prod_id); |
88
|
|
|
if (in_array($prod_id, $sn_group_factories) && get_unit_param($prod_id, P_MINING_IS_MANAGED)) { |
89
|
|
|
$field_name = pname_factory_production_field_name($prod_id); |
90
|
|
|
$percent = floor($percent / 10); |
91
|
|
|
$planetrow[$field_name] = $percent; |
92
|
|
|
//$SubQry .= "`{$field_name}` = '{$percent}',"; |
93
|
|
|
$SubQry[] = "`{$field_name}` = '{$percent}'"; |
94
|
|
|
} else { |
95
|
|
|
$debug->warning('Supplying wrong ID in production array - attempt to change some field - ID' . $prod_id, 'Resource Page', 301); |
96
|
|
|
continue; |
97
|
|
|
} |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
!empty($SubQry) ? DBStaticPlanet::db_planet_set_by_id($planetrow['id'], implode(',', $SubQry)) : false; |
101
|
|
|
if (!empty($SubQry)) { |
102
|
|
|
$planet->dbLoadRecord($planetrow['id']); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
return $planetrow; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
$planetrow = updateProductionSpeeds($debug, $sn_group_factories, $planetrow, $planet); |
109
|
|
|
|
110
|
|
|
// ------------------------------------------------------------------------------------------------------- |
111
|
|
|
// $BuildTemp = $planetrow[ 'temp_max' ]; |
112
|
|
|
// $BuildEnergyTech = $user['energy_tech']; |
113
|
|
|
for ($Option = 10; $Option >= 0; $Option--) |
114
|
|
|
{ |
115
|
|
|
$template->assign_block_vars('option', array( |
116
|
|
|
'VALUE' => $Option * 10, |
117
|
|
|
)); |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
$capsObj = new ResourceCalculations(); |
121
|
|
|
$capsObj->eco_get_planet_caps($user, $planetrow, 3600); |
122
|
|
|
|
123
|
|
|
$template->assign_block_vars('production', array( |
124
|
|
|
'TYPE' => $lang['res_basic_income'], |
125
|
|
|
|
126
|
|
|
'METAL_TYPE' => $capsObj->productionCurrentMatrix[RES_METAL][0], |
127
|
|
|
'CRYSTAL_TYPE' => $capsObj->productionCurrentMatrix[RES_CRYSTAL][0], |
128
|
|
|
'DEUTERIUM_TYPE' => $capsObj->productionCurrentMatrix[RES_DEUTERIUM][0], |
129
|
|
|
'ENERGY_TYPE' => $capsObj->productionCurrentMatrix[RES_ENERGY][0], |
130
|
|
|
)); |
131
|
|
|
|
132
|
|
|
foreach($sn_group_factories as $unit_id) |
133
|
|
|
{ |
134
|
|
|
if(mrc_get_level($user, $planetrow, $unit_id) > 0 && get_unit_param($unit_id)) |
135
|
|
|
{ |
136
|
|
|
$level_plain = mrc_get_level($user, $planetrow, $unit_id, false, true); |
137
|
|
|
$template->assign_block_vars('production', array( |
138
|
|
|
'ID' => $unit_id, |
139
|
|
|
'PERCENT' => $planetrow[pname_factory_production_field_name($unit_id)] * 10, |
140
|
|
|
'TYPE' => $lang['tech'][$unit_id], |
141
|
|
|
'LEVEL' => $level_plain, |
142
|
|
|
'LEVEL_BONUS' => mrc_get_level($user, $planetrow, $unit_id) - $level_plain, |
143
|
|
|
'LEVEL_TYPE' => ($unit_id > 200) ? $lang['quantity'] : $lang['level'], |
144
|
|
|
|
145
|
|
|
'METAL_TYPE' => $capsObj->productionCurrentMatrix[RES_METAL][$unit_id], |
146
|
|
|
'CRYSTAL_TYPE' => $capsObj->productionCurrentMatrix[RES_CRYSTAL][$unit_id], |
147
|
|
|
'DEUTERIUM_TYPE' => $capsObj->productionCurrentMatrix[RES_DEUTERIUM][$unit_id], |
148
|
|
|
'ENERGY_TYPE' => $capsObj->productionCurrentMatrix[RES_ENERGY][$unit_id], |
149
|
|
|
|
150
|
|
|
'METAL_FULL' => $capsObj->productionFullMatrix[RES_METAL][$unit_id], |
151
|
|
|
'CRYSTAL_FULL' => $capsObj->productionFullMatrix[RES_CRYSTAL][$unit_id], |
152
|
|
|
'DEUTERIUM_FULL' => $capsObj->productionFullMatrix[RES_DEUTERIUM][$unit_id], |
153
|
|
|
'ENERGY_FULL' => $capsObj->productionFullMatrix[RES_ENERGY][$unit_id], |
154
|
|
|
|
155
|
|
|
'P_MINING_IS_MANAGED' => get_unit_param($unit_id, P_MINING_IS_MANAGED), |
156
|
|
|
)); |
157
|
|
|
} |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
|
161
|
|
|
$user_dark_matter = mrc_get_level($user, false, RES_DARK_MATTER); |
162
|
|
|
$template->assign_recursive($planet->tpl_planet_density_info($user_dark_matter)); |
163
|
|
|
|
164
|
|
|
$template->assign_block_vars('production', array( |
165
|
|
|
'TYPE' => $lang['res_total'], |
166
|
|
|
|
167
|
|
|
'METAL_TYPE' => $capsObj->getProduction(RES_METAL), |
168
|
|
|
'CRYSTAL_TYPE' => $capsObj->getProduction(RES_CRYSTAL), |
169
|
|
|
'DEUTERIUM_TYPE' => $capsObj->getProduction(RES_DEUTERIUM), |
170
|
|
|
'ENERGY_TYPE' => $capsObj->getProduction(RES_ENERGY), |
171
|
|
|
|
172
|
|
|
'METAL_FULL' => $capsObj->getProductionFull(RES_METAL), |
173
|
|
|
'CRYSTAL_FULL' => $capsObj->getProductionFull(RES_CRYSTAL), |
174
|
|
|
'DEUTERIUM_FULL' => $capsObj->getProductionFull(RES_DEUTERIUM), |
175
|
|
|
'ENERGY_FULL' => $capsObj->getProductionFull(RES_ENERGY), |
176
|
|
|
)); |
177
|
|
|
|
178
|
|
|
int_calc_storage_bar(RES_METAL, $capsObj); |
179
|
|
|
int_calc_storage_bar(RES_CRYSTAL, $capsObj); |
180
|
|
|
int_calc_storage_bar(RES_DEUTERIUM, $capsObj); |
181
|
|
|
|
182
|
|
|
$template->assign_vars(array( |
183
|
|
|
'PLANET_NAME' => $planetrow['name'], |
184
|
|
|
'PLANET_TYPE' => $planetrow['planet_type'], |
185
|
|
|
|
186
|
|
|
'PRODUCTION_LEVEL' => floor($capsObj->efficiency * 100), |
187
|
|
|
|
188
|
|
|
'PAGE_HINT' => $lang['res_hint'], |
189
|
|
|
)); |
190
|
|
|
|
191
|
|
|
SnTemplate::display($template, $lang['res_planet_production']); |
192
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths