|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
// Compare function to sort fleet in time order |
|
4
|
|
|
function tpl_assign_fleet_compare($a, $b) |
|
5
|
|
|
{ |
|
6
|
|
|
if($a['fleet']['OV_THIS_PLANET'] == $b['fleet']['OV_THIS_PLANET']) |
|
7
|
|
|
{ |
|
8
|
|
|
if($a['fleet']['OV_LEFT'] == $b['fleet']['OV_LEFT']) |
|
9
|
|
|
{ |
|
10
|
|
|
return 0; |
|
11
|
|
|
} |
|
12
|
|
|
return ($a['fleet']['OV_LEFT'] < $b['fleet']['OV_LEFT']) ? -1 : 1; |
|
13
|
|
|
} |
|
14
|
|
|
else |
|
15
|
|
|
{ |
|
16
|
|
|
return $a['fleet']['OV_THIS_PLANET'] ? -1 : 1; |
|
17
|
|
|
} |
|
18
|
|
|
} |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* @param array $fleets |
|
22
|
|
|
* @param string $js_name |
|
23
|
|
|
* |
|
24
|
|
|
* @return array |
|
25
|
|
|
*/ |
|
26
|
|
|
function tpl_assign_fleet_generate($fleets, $js_name = 'fleets') { |
|
27
|
|
|
$result = []; |
|
28
|
|
|
if (empty($fleets)) { |
|
29
|
|
|
return $result; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
usort($fleets, 'tpl_assign_fleet_compare'); |
|
33
|
|
|
|
|
34
|
|
|
foreach ($fleets as $fleet_data) { |
|
35
|
|
|
$temp = $fleet_data['fleet']; |
|
36
|
|
|
|
|
37
|
|
|
if ($fleet_data['ships']) { |
|
38
|
|
|
$temp['.']['ships'] = $fleet_data['ships']; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
$result['.'][$js_name][] = $temp; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
return $result; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* For backward compatibility |
|
49
|
|
|
* |
|
50
|
|
|
* @param template $template |
|
51
|
|
|
* @param array $fleets |
|
52
|
|
|
* @param string $js_name |
|
53
|
|
|
* |
|
54
|
|
|
* @deprecated |
|
55
|
|
|
*/ |
|
56
|
|
|
function tpl_assign_fleet(&$template, $fleets, $js_name = 'fleets') { |
|
57
|
|
|
if (!$fleets) { |
|
|
|
|
|
|
58
|
|
|
return; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
$template->assign_recursive(tpl_assign_fleet_generate($fleets, $js_name)); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* function that parses internal fleet representation (as array(id => count)) |
|
66
|
|
|
* |
|
67
|
|
|
* @param $fleet |
|
68
|
|
|
* @param $fleet_id |
|
69
|
|
|
* |
|
70
|
|
|
* @return mixed |
|
71
|
|
|
*/ |
|
72
|
|
|
function tpl_parse_fleet_sn($fleet, $fleet_id) { |
|
73
|
|
|
global $lang, $user; |
|
|
|
|
|
|
74
|
|
|
|
|
75
|
|
|
$user_data = &$user; |
|
76
|
|
|
|
|
77
|
|
|
$return['fleet'] = array( |
|
78
|
|
|
'ID' => $fleet_id, |
|
79
|
|
|
|
|
80
|
|
|
'METAL' => $fleet[RES_METAL], |
|
81
|
|
|
'CRYSTAL' => $fleet[RES_CRYSTAL], |
|
82
|
|
|
'DEUTERIUM' => $fleet[RES_DEUTERIUM], |
|
83
|
|
|
); |
|
84
|
|
|
|
|
85
|
|
|
foreach ($fleet as $ship_id => $ship_amount) { |
|
86
|
|
|
if (in_array($ship_id, sn_get_groups('fleet'))) { |
|
87
|
|
|
$single_ship_data = get_ship_data($ship_id, $user_data); |
|
88
|
|
|
$return['ships'][$ship_id] = array( |
|
89
|
|
|
'ID' => $ship_id, |
|
90
|
|
|
'NAME' => $lang['tech'][$ship_id], |
|
91
|
|
|
'AMOUNT' => $ship_amount, |
|
92
|
|
|
'CONSUMPTION' => $single_ship_data['consumption'], |
|
93
|
|
|
'SPEED' => $single_ship_data['speed'], |
|
94
|
|
|
'CAPACITY' => $single_ship_data['capacity'], |
|
95
|
|
|
); |
|
96
|
|
|
} |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
return $return; |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* @param array $fleet |
|
104
|
|
|
* @param int $index |
|
105
|
|
|
* @param array|bool $user_data |
|
106
|
|
|
* |
|
107
|
|
|
* @return mixed |
|
108
|
|
|
*/ |
|
109
|
|
|
function tpl_parse_fleet_db($fleet, $index, $user_data = false){return sn_function_call('tpl_parse_fleet_db', array($fleet, $index, $user_data, &$result));} |
|
110
|
|
|
/** |
|
111
|
|
|
* @param array $fleet |
|
112
|
|
|
* @param int $index |
|
113
|
|
|
* @param array|bool $user_data |
|
114
|
|
|
* @param $result |
|
115
|
|
|
* |
|
116
|
|
|
* @return mixed |
|
117
|
|
|
*/ |
|
118
|
|
|
function sn_tpl_parse_fleet_db($fleet, $index, $user_data = false, &$result) { |
|
119
|
|
|
global $lang, $user; |
|
|
|
|
|
|
120
|
|
|
|
|
121
|
|
|
if(!$user_data) { |
|
122
|
|
|
$user_data = $user; |
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
|
|
if($fleet['fleet_mess'] == 0 && $fleet['fleet_mission'] == MT_AKS) { |
|
126
|
|
|
$aks = doquery("SELECT * FROM {{aks}} WHERE id={$fleet['fleet_group']} LIMIT 1;", true); |
|
127
|
|
|
} |
|
128
|
|
|
|
|
129
|
|
|
$spy_level = $user['id'] == $fleet['fleet_owner'] ? 100 : GetSpyLevel($user); |
|
130
|
|
|
|
|
131
|
|
|
$result['fleet'] = isset($result['fleet']) ? $result['fleet'] : array(); |
|
132
|
|
|
|
|
133
|
|
|
$result['fleet'] = array( |
|
134
|
|
|
'NUMBER' => $index, |
|
135
|
|
|
|
|
136
|
|
|
'ID' => $fleet['fleet_id'], |
|
137
|
|
|
'OWNER' => $fleet['fleet_owner'], |
|
138
|
|
|
'TARGET_OWNER' => $fleet['fleet_target_owner'], |
|
139
|
|
|
|
|
140
|
|
|
'MESSAGE' => $fleet['fleet_mess'], |
|
141
|
|
|
'MISSION' => $fleet['fleet_mission'], |
|
142
|
|
|
'MISSION_NAME' => $lang['type_mission'][$fleet['fleet_mission']], |
|
143
|
|
|
'ACS' => $aks['name'], |
|
144
|
|
|
'AMOUNT' => $spy_level >= 4 ? (HelperString::numberFloorAndFormat($fleet['fleet_amount']) . ($fleet['fleet_resource_metal'] + $fleet['fleet_resource_crystal'] + $fleet['fleet_resource_deuterium'] ? '+' : '')) : '?', |
|
145
|
|
|
|
|
146
|
|
|
'METAL' => $spy_level >= 8 ? $fleet['fleet_resource_metal'] : 0, |
|
147
|
|
|
'CRYSTAL' => $spy_level >= 8 ? $fleet['fleet_resource_crystal'] : 0, |
|
148
|
|
|
'DEUTERIUM' => $spy_level >= 8 ? $fleet['fleet_resource_deuterium'] : 0, |
|
149
|
|
|
|
|
150
|
|
|
'START_TYPE_TEXT_SH' => $lang['sys_planet_type_sh'][$fleet['fleet_start_type']], |
|
151
|
|
|
'START_COORDS' => "[{$fleet['fleet_start_galaxy']}:{$fleet['fleet_start_system']}:{$fleet['fleet_start_planet']}]", |
|
152
|
|
|
'START_TIME_TEXT' => date(FMT_DATE_TIME, $fleet['fleet_end_time'] + SN_CLIENT_TIME_DIFF), |
|
153
|
|
|
'START_LEFT' => floor($fleet['fleet_end_time'] + 1 - SN_TIME_NOW), |
|
154
|
|
|
'START_URL' => uni_render_coordinates_href($fleet, 'fleet_start_', 3), |
|
155
|
|
|
'START_NAME' => $fleet['fleet_start_name'], |
|
156
|
|
|
|
|
157
|
|
|
'END_TYPE_TEXT_SH' => $lang['sys_planet_type_sh'][$fleet['fleet_end_type']], |
|
158
|
|
|
'END_COORDS' => "[{$fleet['fleet_end_galaxy']}:{$fleet['fleet_end_system']}:{$fleet['fleet_end_planet']}]", |
|
159
|
|
|
'END_TIME_TEXT' => date(FMT_DATE_TIME, $fleet['fleet_start_time'] + SN_CLIENT_TIME_DIFF), |
|
160
|
|
|
'END_LEFT' => floor($fleet['fleet_start_time'] + 1 - SN_TIME_NOW), |
|
161
|
|
|
'END_URL' => uni_render_coordinates_href($fleet, 'fleet_end_', 3), |
|
162
|
|
|
'END_NAME' => $fleet['fleet_end_name'], |
|
163
|
|
|
|
|
164
|
|
|
'STAY_TIME' => date(FMT_DATE_TIME, $fleet['fleet_end_stay'] + SN_CLIENT_TIME_DIFF), |
|
165
|
|
|
'STAY_LEFT' => floor($fleet['fleet_end_stay'] + 1 - SN_TIME_NOW), |
|
166
|
|
|
|
|
167
|
|
|
'OV_LABEL' => $fleet['ov_label'], |
|
168
|
|
|
'EVENT_TIME_TEXT' => date(FMT_DATE_TIME, $fleet['event_time'] + SN_CLIENT_TIME_DIFF), |
|
169
|
|
|
'OV_LEFT' => floor($fleet['event_time'] + 1 - SN_TIME_NOW), |
|
170
|
|
|
'OV_THIS_PLANET' => $fleet['ov_this_planet'], |
|
171
|
|
|
); |
|
172
|
|
|
|
|
173
|
|
|
$ship_list = explode(';', $fleet['fleet_array']); |
|
174
|
|
|
|
|
175
|
|
|
$ship_id = 0; |
|
176
|
|
|
if($spy_level >= 6) { |
|
177
|
|
|
foreach($ship_list as $ship_record) { |
|
178
|
|
|
if($ship_record) { |
|
179
|
|
|
$ship_data = explode(',', $ship_record); |
|
180
|
|
|
if($spy_level >= 10) { |
|
181
|
|
|
$single_ship_data = get_ship_data($ship_data[0], $user_data); |
|
182
|
|
|
$result['ships'][$ship_data[0]] = array( |
|
183
|
|
|
'ID' => $ship_data[0], |
|
184
|
|
|
'NAME' => $lang['tech'][$ship_data[0]], |
|
185
|
|
|
'AMOUNT' => $ship_data[1], |
|
186
|
|
|
'AMOUNT_TEXT' => HelperString::numberFloorAndFormat($ship_data[1]), |
|
187
|
|
|
'CONSUMPTION' => $single_ship_data['consumption'], |
|
188
|
|
|
'SPEED' => $single_ship_data['speed'], |
|
189
|
|
|
'CAPACITY' => $single_ship_data['capacity'], |
|
190
|
|
|
); |
|
191
|
|
|
} else { |
|
192
|
|
|
$result['ships'][$ship_data[0]] = array( |
|
193
|
|
|
'ID' => $ship_id++, |
|
194
|
|
|
'NAME' => $lang['tech'][UNIT_SHIPS], |
|
195
|
|
|
'AMOUNT' => $ship_data[1], |
|
196
|
|
|
'AMOUNT_TEXT' => HelperString::numberFloorAndFormat($ship_data[1]), |
|
197
|
|
|
'CONSUMPTION' => 0, |
|
198
|
|
|
'CONSUMPTION_TEXT' => '0', |
|
199
|
|
|
'SPEED' => 0, |
|
200
|
|
|
'CAPACITY' => 0, |
|
201
|
|
|
); |
|
202
|
|
|
} |
|
203
|
|
|
} |
|
204
|
|
|
} |
|
205
|
|
|
} |
|
206
|
|
|
|
|
207
|
|
|
return $result; |
|
208
|
|
|
} |
|
209
|
|
|
|
|
210
|
|
|
function tpl_parse_planet_que($que, $planet, $que_id) |
|
211
|
|
|
{ |
|
212
|
|
|
$hangar_que = array(); |
|
213
|
|
|
$que_hangar = $que['ques'][$que_id][$planet['id_owner']][$planet['id']]; |
|
214
|
|
|
if(!empty($que_hangar)) |
|
215
|
|
|
{ |
|
216
|
|
|
foreach($que_hangar as $que_item) |
|
217
|
|
|
{ |
|
218
|
|
|
$hangar_que['que'][] = array('id' => $que_item['que_unit_id'], 'count' => $que_item['que_unit_amount']); |
|
219
|
|
|
$hangar_que[$que_item['que_unit_id']] += $que_item['que_unit_amount']; |
|
220
|
|
|
} |
|
221
|
|
|
} |
|
222
|
|
|
|
|
223
|
|
|
return $hangar_que; |
|
224
|
|
|
} |
|
225
|
|
|
|
|
226
|
|
|
/** |
|
227
|
|
|
* @param array $planet |
|
228
|
|
|
* @param array $fleet_list |
|
229
|
|
|
* |
|
230
|
|
|
* @return array |
|
231
|
|
|
*/ |
|
232
|
|
|
function tpl_parse_planet_result_fleet($planet, $fleet_list) { |
|
233
|
|
|
return [ |
|
234
|
|
|
'FLEET_OWN' => $fleet_list['own']['count'], |
|
235
|
|
|
'FLEET_ENEMY' => $fleet_list['enemy']['count'], |
|
236
|
|
|
'FLEET_NEUTRAL' => $fleet_list['neutral']['count'], |
|
237
|
|
|
'PLANET_FLEET_ID' => !empty($fleet_list['own']['count']) ? getUniqueFleetId($planet) : 0, |
|
238
|
|
|
]; |
|
239
|
|
|
} |
|
240
|
|
|
|
|
241
|
|
|
|
|
242
|
|
|
/** |
|
243
|
|
|
* @param int $parentPlanetId |
|
244
|
|
|
* |
|
245
|
|
|
* @return array |
|
246
|
|
|
*/ |
|
247
|
|
|
function tpl_parse_planet_moon($parentPlanetId) { |
|
248
|
|
|
$moon_fill = 0; |
|
249
|
|
|
$moon_fleets = []; |
|
250
|
|
|
|
|
251
|
|
|
$moon = DBStaticPlanet::db_planet_by_parent($parentPlanetId); |
|
252
|
|
|
if ($moon) { |
|
253
|
|
|
$moon_fill = min(100, floor($moon['field_current'] / eco_planet_fields_max($moon) * 100)); |
|
254
|
|
|
$moon_fleets = flt_get_fleets_to_planet($moon); |
|
255
|
|
|
} |
|
256
|
|
|
|
|
257
|
|
|
return [ |
|
258
|
|
|
'MOON_ID' => $moon['id'], |
|
259
|
|
|
'MOON_NAME' => $moon['name'], |
|
260
|
|
|
'MOON_IMG' => $moon['image'], |
|
261
|
|
|
'MOON_FILL' => min(100, $moon_fill), |
|
262
|
|
|
'MOON_ENEMY' => !empty($moon_fleets['enemy']['count']) ? $moon_fleets['enemy']['count'] : 0, |
|
263
|
|
|
|
|
264
|
|
|
'MOON_PLANET' => $moon['parent_planet'], |
|
265
|
|
|
]; |
|
266
|
|
|
} |
|
267
|
|
|
|
|
268
|
|
|
/** |
|
269
|
|
|
* @param array $planet |
|
270
|
|
|
* |
|
271
|
|
|
* @return array |
|
272
|
|
|
*/ |
|
273
|
|
|
function tpl_parse_planet($planet) |
|
274
|
|
|
{ |
|
275
|
|
|
global $lang; |
|
|
|
|
|
|
276
|
|
|
|
|
277
|
|
|
$que = que_get($planet['id_owner'], $planet['id'], false); |
|
278
|
|
|
$structure_que = tpl_parse_planet_que($que, $planet, QUE_STRUCTURES); // TODO Заменить на que_tpl_parse_element($que_element); |
|
279
|
|
|
$structure_que_first = is_array($structure_que['que']) ? reset($structure_que['que']) : array(); |
|
280
|
|
|
$hangar_que = tpl_parse_planet_que($que, $planet, SUBQUE_FLEET); // TODO Заменить на que_tpl_parse_element($que_element); |
|
281
|
|
|
$hangar_que_first = is_array($hangar_que['que']) ? reset($hangar_que['que']) : array(); |
|
282
|
|
|
$defense_que = tpl_parse_planet_que($que, $planet, SUBQUE_DEFENSE); // TODO Заменить на que_tpl_parse_element($que_element); |
|
283
|
|
|
$defense_que_first = is_array($defense_que['que']) ? reset($defense_que['que']) : array(); |
|
284
|
|
|
|
|
285
|
|
|
$result = [ |
|
286
|
|
|
'ID' => $planet['id'], |
|
287
|
|
|
'NAME' => $planet['name'], |
|
288
|
|
|
'IMAGE' => $planet['image'], |
|
289
|
|
|
|
|
290
|
|
|
'GALAXY' => $planet['galaxy'], |
|
291
|
|
|
'SYSTEM' => $planet['system'], |
|
292
|
|
|
'PLANET' => $planet['planet'], |
|
293
|
|
|
'TYPE' => $planet['planet_type'], |
|
294
|
|
|
'COORDINATES' => uni_render_coordinates($planet), |
|
295
|
|
|
|
|
296
|
|
|
'METAL_PERCENT' => $planet['metal_mine_porcent'] * 10, |
|
297
|
|
|
'CRYSTAL_PERCENT' => $planet['crystal_mine_porcent'] * 10, |
|
298
|
|
|
'DEUTERIUM_PERCENT' => $planet['deuterium_sintetizer_porcent'] * 10, |
|
299
|
|
|
|
|
300
|
|
|
'STRUCTURE' => isset($structure_que_first['id']) ? $lang['tech'][$structure_que_first['id']] : '', |
|
301
|
|
|
|
|
302
|
|
|
// 'HANGAR' => isset($hangar_que['que'][0]['id']) ? $lang['tech'][$hangar_que['que'][0]['id']] : '', |
|
|
|
|
|
|
303
|
|
|
'HANGAR' => isset($hangar_que_first['id']) ? $lang['tech'][$hangar_que_first['id']] : '', |
|
304
|
|
|
// 'hangar_que' => $hangar_que, |
|
|
|
|
|
|
305
|
|
|
|
|
306
|
|
|
// 'DEFENSE' => isset($defense_que['que'][0]['id']) ? $lang['tech'][$defense_que['que'][0]['id']] : '', |
|
|
|
|
|
|
307
|
|
|
'DEFENSE' => isset($defense_que_first['id']) ? $lang['tech'][$defense_que_first['id']] : '', |
|
308
|
|
|
// 'defense_que' => $defense_que, |
|
|
|
|
|
|
309
|
|
|
|
|
310
|
|
|
'FIELDS_CUR' => $planet['field_current'], |
|
311
|
|
|
'FIELDS_MAX' => eco_planet_fields_max($planet), |
|
312
|
|
|
'FILL' => min(100, floor($planet['field_current'] / eco_planet_fields_max($planet) * 100)), |
|
313
|
|
|
|
|
314
|
|
|
'PLANET_GOVERNOR_ID' => $planet['PLANET_GOVERNOR_ID'], |
|
315
|
|
|
'PLANET_GOVERNOR_NAME' => $lang['tech'][$planet['PLANET_GOVERNOR_ID']], |
|
316
|
|
|
'PLANET_GOVERNOR_LEVEL' => $planet['PLANET_GOVERNOR_LEVEL'], |
|
317
|
|
|
'PLANET_GOVERNOR_LEVEL_MAX' => get_unit_param($planet['PLANET_GOVERNOR_ID'], P_MAX_STACK), |
|
318
|
|
|
]; |
|
319
|
|
|
|
|
320
|
|
|
if(!empty($que['ques'][QUE_STRUCTURES][$planet['id_owner']][$planet['id']])) |
|
321
|
|
|
{ |
|
322
|
|
|
$result['building_que'] = []; |
|
323
|
|
|
$building_que = &$que['ques'][QUE_STRUCTURES][$planet['id_owner']][$planet['id']]; |
|
324
|
|
|
foreach($building_que as $que_element) |
|
325
|
|
|
{ |
|
326
|
|
|
$result['building_que'][] = que_tpl_parse_element($que_element); |
|
327
|
|
|
} |
|
328
|
|
|
} |
|
329
|
|
|
|
|
330
|
|
|
return $result; |
|
331
|
|
|
} |
|
332
|
|
|
|
|
333
|
|
|
function flt_get_fleets_to_planet($planet, $fleet_db_list = 0) |
|
334
|
|
|
{ |
|
335
|
|
|
if(!($planet && $planet['id']) && !$fleet_db_list) |
|
336
|
|
|
{ |
|
337
|
|
|
return $planet; |
|
338
|
|
|
} |
|
339
|
|
|
|
|
340
|
|
|
global $user; |
|
|
|
|
|
|
341
|
|
|
|
|
342
|
|
|
if($fleet_db_list === 0) |
|
343
|
|
|
{ |
|
344
|
|
|
$fleet_db_list = fleet_and_missiles_list_by_coordinates($planet); |
|
345
|
|
|
} |
|
346
|
|
|
|
|
347
|
|
|
foreach($fleet_db_list as $fleet) |
|
348
|
|
|
{ |
|
349
|
|
|
if($fleet['fleet_owner'] == $user['id']) |
|
350
|
|
|
{ |
|
351
|
|
|
if($fleet['fleet_mission'] == MT_MISSILE) |
|
352
|
|
|
{ |
|
353
|
|
|
continue; |
|
354
|
|
|
} |
|
355
|
|
|
$fleet_ownage = 'own'; |
|
356
|
|
|
} |
|
357
|
|
|
else |
|
358
|
|
|
{ |
|
359
|
|
|
switch($fleet['fleet_mission']) |
|
360
|
|
|
{ |
|
361
|
|
|
case MT_ATTACK: |
|
362
|
|
|
case MT_AKS: |
|
363
|
|
|
case MT_DESTROY: |
|
364
|
|
|
case MT_MISSILE: |
|
365
|
|
|
$fleet_ownage = 'enemy'; |
|
366
|
|
|
break; |
|
367
|
|
|
|
|
368
|
|
|
default: |
|
369
|
|
|
$fleet_ownage = 'neutral'; |
|
370
|
|
|
break; |
|
371
|
|
|
|
|
372
|
|
|
} |
|
373
|
|
|
} |
|
374
|
|
|
|
|
375
|
|
|
$fleet_list[$fleet_ownage]['fleets'][$fleet['fleet_id']] = $fleet; |
|
376
|
|
|
|
|
377
|
|
|
if($fleet['fleet_mess'] == 1 || ($fleet['fleet_mess'] == 0 && $fleet['fleet_mission'] == MT_RELOCATE) || ($fleet['fleet_target_owner'] != $user['id'])) |
|
378
|
|
|
{ |
|
379
|
|
|
// $fleet_sn = flt_expand($fleet); |
|
|
|
|
|
|
380
|
|
|
$fleet_sn = sys_unit_str2arr($fleet['fleet_array']); |
|
381
|
|
|
foreach($fleet_sn as $ship_id => $ship_amount) |
|
382
|
|
|
{ |
|
383
|
|
|
if(in_array($ship_id, sn_get_groups('fleet'))) |
|
384
|
|
|
{ |
|
385
|
|
|
$fleet_list[$fleet_ownage]['total'][$ship_id] += $ship_amount; |
|
386
|
|
|
} |
|
387
|
|
|
} |
|
388
|
|
|
} |
|
389
|
|
|
|
|
390
|
|
|
$fleet_list[$fleet_ownage]['count']++; |
|
391
|
|
|
$fleet_list[$fleet_ownage]['amount'] += $fleet['fleet_amount']; |
|
392
|
|
|
$fleet_list[$fleet_ownage]['total'][RES_METAL] += $fleet['fleet_resource_metal']; |
|
393
|
|
|
$fleet_list[$fleet_ownage]['total'][RES_CRYSTAL] += $fleet['fleet_resource_crystal']; |
|
394
|
|
|
$fleet_list[$fleet_ownage]['total'][RES_DEUTERIUM] += $fleet['fleet_resource_deuterium']; |
|
395
|
|
|
} |
|
396
|
|
|
|
|
397
|
|
|
return $fleet_list; |
|
398
|
|
|
} |
|
399
|
|
|
|
|
400
|
|
|
/** |
|
401
|
|
|
* @param template $template |
|
402
|
|
|
* @param array $planetrow |
|
403
|
|
|
* @param array $fleets_to_planet |
|
404
|
|
|
*/ |
|
405
|
|
|
function tpl_set_resource_info(&$template, $planetrow, $fleets_to_planet = array()) |
|
406
|
|
|
{ |
|
407
|
|
|
$template->assign_vars(array( |
|
408
|
|
|
'RESOURCE_ROUNDING' => 0, |
|
409
|
|
|
|
|
410
|
|
|
'PLANET_ENERGY' => $planetrow['energy_used'], |
|
411
|
|
|
'ENERGY_BALANCE_NUMBER' => $planetrow['energy_max'] - $planetrow['energy_used'], |
|
412
|
|
|
'ENERGY_BALANCE' => prettyNumberStyledDefault($planetrow['energy_max'] - $planetrow['energy_used']), |
|
413
|
|
|
'ENERGY_MAX_NUMBER' => $planetrow['energy_max'], |
|
414
|
|
|
'ENERGY_MAX_NUMBER_TEXT_NO_COLOR' => HelperString::numberFloorAndFormat($planetrow['energy_max']), |
|
415
|
|
|
'ENERGY_MAX_NUMBER_TEXT' => Tools::numberPercentSpan($planetrow['energy_max'], $planetrow['energy_used']), |
|
416
|
|
|
'ENERGY_MAX' => prettyNumberStyledCompare($planetrow['energy_max'], -$planetrow['energy_used']), |
|
417
|
|
|
'ENERGY_FILL' => round(($planetrow["energy_used"]/($planetrow["energy_max"]+1))*100,0), |
|
418
|
|
|
|
|
419
|
|
|
'PLANET_METAL' => floor($planetrow["metal"]), |
|
420
|
|
|
'PLANET_METAL_TEXT' => prettyNumberStyledCompare($planetrow["metal"], $planetrow["metal_max"]), |
|
421
|
|
|
'PLANET_METAL_MAX' => floor($planetrow["metal_max"]), |
|
422
|
|
|
'PLANET_METAL_MAX_TEXT' => Tools::numberPercentSpan($planetrow["metal_max"], $planetrow["metal"]), |
|
423
|
|
|
'PLANET_METAL_MAX_NO_COLOR' => HelperString::numberFloorAndFormat($planetrow["metal_max"]), |
|
424
|
|
|
'PLANET_METAL_FILL' => round(($planetrow["metal"]/($planetrow["metal_max"]+1))*100,0), |
|
425
|
|
|
'PLANET_METAL_PERHOUR' => round($planetrow["metal_perhour"], 5), |
|
426
|
|
|
'PLANET_METAL_FLEET_TEXT' => prettyNumberStyledDefault($fleets_to_planet[$planetrow['id']]['fleet']['METAL']), |
|
427
|
|
|
|
|
428
|
|
|
'PLANET_CRYSTAL' => floor($planetrow["crystal"]), |
|
429
|
|
|
'PLANET_CRYSTAL_TEXT' => prettyNumberStyledCompare($planetrow["crystal"], $planetrow["crystal_max"]), |
|
430
|
|
|
'PLANET_CRYSTAL_MAX' => floor($planetrow["crystal_max"]), |
|
431
|
|
|
'PLANET_CRYSTAL_MAX_TEXT' => Tools::numberPercentSpan($planetrow["crystal_max"], $planetrow["crystal"]), |
|
432
|
|
|
'PLANET_CRYSTAL_MAX_NO_COLOR' => HelperString::numberFloorAndFormat($planetrow["crystal_max"]), |
|
433
|
|
|
'PLANET_CRYSTAL_FILL' => round(($planetrow["crystal"]/($planetrow["crystal_max"]+1))*100,0), |
|
434
|
|
|
'PLANET_CRYSTAL_PERHOUR' => round($planetrow["crystal_perhour"], 5), |
|
435
|
|
|
'PLANET_CRYSTAL_FLEET_TEXT' => prettyNumberStyledDefault($fleets_to_planet[$planetrow['id']]['fleet']['CRYSTAL']), |
|
436
|
|
|
|
|
437
|
|
|
'PLANET_DEUTERIUM' => floor($planetrow["deuterium"]), |
|
438
|
|
|
'PLANET_DEUTERIUM_TEXT' => prettyNumberStyledCompare($planetrow["deuterium"], $planetrow["deuterium_max"]), |
|
439
|
|
|
'PLANET_DEUTERIUM_MAX' => floor($planetrow["deuterium_max"]), |
|
440
|
|
|
'PLANET_DEUTERIUM_MAX_TEXT' => Tools::numberPercentSpan($planetrow["deuterium_max"], $planetrow["deuterium"]), |
|
441
|
|
|
'PLANET_DEUTERIUM_MAX_NO_COLOR' => HelperString::numberFloorAndFormat($planetrow["deuterium_max"]), |
|
442
|
|
|
'PLANET_DEUTERIUM_FILL' => round(($planetrow["deuterium"]/($planetrow["deuterium_max"]+1))*100,0), |
|
443
|
|
|
'PLANET_DEUTERIUM_PERHOUR' => round($planetrow["deuterium_perhour"], 5), |
|
444
|
|
|
'PLANET_DEUTERIUM_FLEET_TEXT' => prettyNumberStyledDefault($fleets_to_planet[$planetrow['id']]['fleet']['DEUTERIUM']), |
|
445
|
|
|
)); |
|
446
|
|
|
} |
|
447
|
|
|
|
|
448
|
|
|
/** |
|
449
|
|
|
* @return int[][] |
|
450
|
|
|
*/ |
|
451
|
|
|
function templateFillPercent() { |
|
452
|
|
|
$result = []; |
|
453
|
|
|
for ($i = 100; $i >= 0; $i -= 10) { |
|
454
|
|
|
$result[] = ['PERCENT' => $i]; |
|
455
|
|
|
} |
|
456
|
|
|
|
|
457
|
|
|
return ['.' => ['percent' => $result]]; |
|
458
|
|
|
} |
|
459
|
|
|
|