@@ -30,11 +30,11 @@ discard block |
||
30 | 30 | |
31 | 31 | static $need_keys = array('server', 'user', 'pass', 'name', 'prefix'); |
32 | 32 | |
33 | - if($this->connected) { |
|
33 | + if ($this->connected) { |
|
34 | 34 | return true; |
35 | 35 | } |
36 | 36 | |
37 | - if(empty($settings) || !is_array($settings) || array_intersect($need_keys, array_keys($settings)) != $need_keys) { |
|
37 | + if (empty($settings) || !is_array($settings) || array_intersect($need_keys, array_keys($settings)) != $need_keys) { |
|
38 | 38 | $debug->error_fatal('There is missconfiguration in your config.php. Check it again'); |
39 | 39 | } |
40 | 40 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | return mysqli_real_escape_string($this->link, $unescaped_string); |
91 | 91 | } |
92 | 92 | function mysql_close_link() { |
93 | - if(is_object($this->link)) { |
|
93 | + if (is_object($this->link)) { |
|
94 | 94 | $this->link->close(); |
95 | 95 | $this->connected = false; |
96 | 96 | unset($this->link); |
@@ -154,15 +154,15 @@ discard block |
||
154 | 154 | * @param string $group_name |
155 | 155 | */ |
156 | 156 | public static function _init($group_name = '') { |
157 | - if(static::$_is_static_init) { |
|
157 | + if (static::$_is_static_init) { |
|
158 | 158 | return; |
159 | 159 | } |
160 | 160 | |
161 | - if($group_name) { |
|
161 | + if ($group_name) { |
|
162 | 162 | static::$_sn_group_name = $group_name; |
163 | 163 | } |
164 | 164 | |
165 | - if(static::$_sn_group_name) { |
|
165 | + if (static::$_sn_group_name) { |
|
166 | 166 | static::$_group_unit_id_list = sn_get_groups(static::$_sn_group_name); |
167 | 167 | empty(static::$_group_unit_id_list) ? static::$_group_unit_id_list = array() : false; |
168 | 168 | } |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | // TODO - Reset combat stats?? |
188 | 188 | $this->_unitId = $unitId; |
189 | 189 | |
190 | - if($this->_unitId) { |
|
190 | + if ($this->_unitId) { |
|
191 | 191 | $this->info = get_unit_param($this->_unitId); |
192 | 192 | $this->_type = $this->info[P_UNIT_TYPE]; |
193 | 193 | } else { |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | |
199 | 199 | protected function setCount($value) { |
200 | 200 | // TODO - Reset combat stats?? |
201 | - if($value < 0) { |
|
201 | + if ($value < 0) { |
|
202 | 202 | classSupernova::$debug->error('Can not set Unit::$count to negative value'); |
203 | 203 | } |
204 | 204 | $this->_count = $value; |
@@ -411,7 +411,7 @@ |
||
411 | 411 | /** |
412 | 412 | * @param array $field_set |
413 | 413 | * |
414 | - * @return int|string |
|
414 | + * @return integer |
|
415 | 415 | */ |
416 | 416 | protected function db_field_set_create(array $field_set) { |
417 | 417 | !sn_db_field_set_is_safe($field_set) ? $field_set = sn_db_field_set_make_safe($field_set) : false; |
@@ -138,14 +138,14 @@ discard block |
||
138 | 138 | |
139 | 139 | // If method is not getter or setter OR property name not exists in $_properties - raising exception |
140 | 140 | // Descendants can catch this Exception to make own __call magic |
141 | - if(($left3 != 'get' && $left3 != 'set') || empty(static::$_properties[$propertyName])) { |
|
141 | + if (($left3 != 'get' && $left3 != 'set') || empty(static::$_properties[$propertyName])) { |
|
142 | 142 | throw new ExceptionPropertyNotExists('Property ' . $propertyName . ' not exists when calling getter/setter ' . get_called_class() . '::' . $name, ERR_ERROR); |
143 | 143 | } |
144 | 144 | |
145 | 145 | // TODO check for read-only |
146 | 146 | |
147 | - if($left3 == 'set') { |
|
148 | - if(!empty($this->propertiesAdjusted[$propertyName])) { |
|
147 | + if ($left3 == 'set') { |
|
148 | + if (!empty($this->propertiesAdjusted[$propertyName])) { |
|
149 | 149 | throw new PropertyAccessException('Property ' . $propertyName . ' already was adjusted so no SET is possible until dbSave in ' . get_called_class() . '::' . $name, ERR_ERROR); |
150 | 150 | } |
151 | 151 | $this->propertiesChanged[$propertyName] = 1; |
@@ -154,13 +154,13 @@ discard block |
||
154 | 154 | // Now deciding - will we call a protected setter or will we work with protected property |
155 | 155 | |
156 | 156 | // If method exists - just calling it |
157 | - if(method_exists($this, $name)) { |
|
157 | + if (method_exists($this, $name)) { |
|
158 | 158 | return call_user_func_array(array($this, $name), $arguments); |
159 | 159 | } |
160 | 160 | // No getter/setter exists - works directly with protected property |
161 | 161 | |
162 | 162 | // Is it getter? |
163 | - if($left3 === 'get') { |
|
163 | + if ($left3 === 'get') { |
|
164 | 164 | return $this->{'_' . $propertyName}; |
165 | 165 | } |
166 | 166 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | */ |
183 | 183 | public function dbLoad($dbId, $lockSkip = false) { |
184 | 184 | $dbId = idval($dbId); |
185 | - if($dbId <= 0) { |
|
185 | + if ($dbId <= 0) { |
|
186 | 186 | classSupernova::$debug->error(get_called_class() . '::dbLoad $dbId not positive = ' . $dbId); |
187 | 187 | |
188 | 188 | return; |
@@ -191,12 +191,12 @@ discard block |
||
191 | 191 | $this->_dbId = $dbId; |
192 | 192 | $this->lockSkip = $lockSkip; |
193 | 193 | // TODO - Use classSupernova::$db_records_locked |
194 | - if(false && !$lockSkip && sn_db_transaction_check(false)) { |
|
194 | + if (false && !$lockSkip && sn_db_transaction_check(false)) { |
|
195 | 195 | $this->dbGetLockById($this->_dbId); |
196 | 196 | } |
197 | 197 | |
198 | 198 | $db_row = doquery("SELECT * FROM `{{" . static::$_table . "}}` WHERE `" . static::$_dbIdFieldName . "` = " . $this->_dbId . " LIMIT 1 FOR UPDATE;", true); |
199 | - if(empty($db_row)) { |
|
199 | + if (empty($db_row)) { |
|
200 | 200 | return; |
201 | 201 | } |
202 | 202 | |
@@ -224,26 +224,26 @@ discard block |
||
224 | 224 | */ |
225 | 225 | // TODO - perform operations only if properties was changed |
226 | 226 | public function dbSave() { |
227 | - if($this->isNew()) { |
|
227 | + if ($this->isNew()) { |
|
228 | 228 | // No DB_ID - new unit |
229 | - if($this->isEmpty()) { |
|
229 | + if ($this->isEmpty()) { |
|
230 | 230 | classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - object is empty on ' . get_called_class() . '::dbSave'); |
231 | 231 | } |
232 | 232 | $this->dbInsert(); |
233 | 233 | } else { |
234 | 234 | // DB_ID is present |
235 | - if($this->isEmpty()) { |
|
235 | + if ($this->isEmpty()) { |
|
236 | 236 | $this->dbDelete(); |
237 | 237 | } else { |
238 | - if(!sn_db_transaction_check(false)) { |
|
238 | + if (!sn_db_transaction_check(false)) { |
|
239 | 239 | classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - transaction should always be started on ' . get_called_class() . '::dbUpdate'); |
240 | 240 | } |
241 | 241 | $this->dbUpdate(); |
242 | 242 | } |
243 | 243 | } |
244 | 244 | |
245 | - if(!empty($this->triggerDbOperationOn)) { |
|
246 | - foreach($this->triggerDbOperationOn as $item) { |
|
245 | + if (!empty($this->triggerDbOperationOn)) { |
|
246 | + foreach ($this->triggerDbOperationOn as $item) { |
|
247 | 247 | $item->dbSave(); |
248 | 248 | } |
249 | 249 | } |
@@ -263,12 +263,12 @@ discard block |
||
263 | 263 | */ |
264 | 264 | // TODO - protected |
265 | 265 | public function dbInsert() { |
266 | - if(!$this->isNew()) { |
|
266 | + if (!$this->isNew()) { |
|
267 | 267 | classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - record db_id is not empty on ' . get_called_class() . '::dbInsert'); |
268 | 268 | } |
269 | 269 | $this->_dbId = $this->db_field_set_create($this->dbMakeFieldSet()); |
270 | 270 | |
271 | - if(empty($this->_dbId)) { |
|
271 | + if (empty($this->_dbId)) { |
|
272 | 272 | classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - error saving record ' . get_called_class() . '::dbInsert'); |
273 | 273 | } |
274 | 274 | |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | // TODO - protected |
282 | 282 | public function dbUpdate() { |
283 | 283 | // TODO - Update |
284 | - if($this->isNew()) { |
|
284 | + if ($this->isNew()) { |
|
285 | 285 | classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - unit db_id is empty on dbUpdate'); |
286 | 286 | } |
287 | 287 | $this->db_field_update($this->dbMakeFieldSet(true)); |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | */ |
293 | 293 | // TODO - protected |
294 | 294 | public function dbDelete() { |
295 | - if($this->isNew()) { |
|
295 | + if ($this->isNew()) { |
|
296 | 296 | classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - unit db_id is empty on dbDelete'); |
297 | 297 | } |
298 | 298 | doquery("DELETE FROM {{" . static::$_table . "}} WHERE `" . static::$_dbIdFieldName . "` = " . $this->_dbId); |
@@ -334,18 +334,18 @@ discard block |
||
334 | 334 | * @param array $db_row |
335 | 335 | */ |
336 | 336 | public function dbRowParse(array $db_row) { |
337 | - foreach(static::$_properties as $property_name => &$property_data) { |
|
337 | + foreach (static::$_properties as $property_name => &$property_data) { |
|
338 | 338 | // Advanced values extraction procedure. Should be used when at least one of following rules is matched: |
339 | 339 | // - one field should translate to several properties; |
340 | 340 | // - one property should be filled according to several fields; |
341 | 341 | // - property filling requires some lookup in object values; |
342 | - if(!empty($property_data[P_METHOD_EXTRACT]) && is_callable(array($this, $property_data[P_METHOD_EXTRACT]))) { |
|
342 | + if (!empty($property_data[P_METHOD_EXTRACT]) && is_callable(array($this, $property_data[P_METHOD_EXTRACT]))) { |
|
343 | 343 | call_user_func_array(array($this, $property_data[P_METHOD_EXTRACT]), array(&$db_row)); |
344 | 344 | continue; |
345 | 345 | } |
346 | 346 | |
347 | 347 | // If property is read-only - doing nothing |
348 | - if(!empty($property_data[P_READ_ONLY])) { |
|
348 | + if (!empty($property_data[P_READ_ONLY])) { |
|
349 | 349 | continue; |
350 | 350 | } |
351 | 351 | |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | !empty($property_data[P_FUNC_INPUT]) && is_callable($property_data[P_FUNC_INPUT]) ? $value = call_user_func($property_data[P_FUNC_INPUT], $value) : false; |
357 | 357 | |
358 | 358 | // If there is setter for this field - using it. Setters is always a methods of $THIS |
359 | - if(!empty($property_data[P_METHOD_SET]) && is_callable(array($this, $property_data[P_METHOD_SET]))) { |
|
359 | + if (!empty($property_data[P_METHOD_SET]) && is_callable(array($this, $property_data[P_METHOD_SET]))) { |
|
360 | 360 | call_user_func(array($this, $property_data[P_METHOD_SET]), $value); |
361 | 361 | } else { |
362 | 362 | $this->{$property_name} = $value; |
@@ -372,21 +372,21 @@ discard block |
||
372 | 372 | protected function dbMakeFieldSet($isUpdate = false) { |
373 | 373 | $array = array(); |
374 | 374 | |
375 | - foreach(static::$_properties as $property_name => &$property_data) { |
|
375 | + foreach (static::$_properties as $property_name => &$property_data) { |
|
376 | 376 | // TODO - on isUpdate add only changed/adjusted properties |
377 | 377 | |
378 | - if(!empty($property_data[P_METHOD_INJECT]) && is_callable(array($this, $property_data[P_METHOD_INJECT]))) { |
|
378 | + if (!empty($property_data[P_METHOD_INJECT]) && is_callable(array($this, $property_data[P_METHOD_INJECT]))) { |
|
379 | 379 | call_user_func_array(array($this, $property_data[P_METHOD_INJECT]), array(&$array)); |
380 | 380 | continue; |
381 | 381 | } |
382 | 382 | |
383 | 383 | // Skipping properties which have no corresponding field in DB |
384 | - if(empty($property_data[P_DB_FIELD])) { |
|
384 | + if (empty($property_data[P_DB_FIELD])) { |
|
385 | 385 | continue; |
386 | 386 | } |
387 | 387 | |
388 | 388 | // Checking - is property was adjusted or changed |
389 | - if($isUpdate && array_key_exists($property_name, $this->propertiesAdjusted)) { |
|
389 | + if ($isUpdate && array_key_exists($property_name, $this->propertiesAdjusted)) { |
|
390 | 390 | // For adjusted property - take value from propertiesAdjusted array |
391 | 391 | // TODO - differ how treated conversion to string for changed and adjusted properties |
392 | 392 | $value = $this->propertiesAdjusted[$property_name]; |
@@ -416,17 +416,17 @@ discard block |
||
416 | 416 | */ |
417 | 417 | protected function isFieldChanged($fieldName) { |
418 | 418 | $isFieldChanged = false; |
419 | - foreach($this->propertiesChanged as $propertyName => $cork) { |
|
419 | + foreach ($this->propertiesChanged as $propertyName => $cork) { |
|
420 | 420 | $propertyScheme = static::$_properties[$propertyName]; |
421 | - if(!empty($propertyScheme[P_DB_FIELDS_LINKED])) { |
|
422 | - foreach($propertyScheme[P_DB_FIELDS_LINKED] as $linkedFieldName) { |
|
423 | - if($linkedFieldName == $fieldName) { |
|
421 | + if (!empty($propertyScheme[P_DB_FIELDS_LINKED])) { |
|
422 | + foreach ($propertyScheme[P_DB_FIELDS_LINKED] as $linkedFieldName) { |
|
423 | + if ($linkedFieldName == $fieldName) { |
|
424 | 424 | $isFieldChanged = $propertyName; |
425 | 425 | break 2; |
426 | 426 | } |
427 | 427 | } |
428 | 428 | } |
429 | - if(!empty($propertyScheme[P_DB_FIELD]) && $propertyScheme[P_DB_FIELD] == $fieldName) { |
|
429 | + if (!empty($propertyScheme[P_DB_FIELD]) && $propertyScheme[P_DB_FIELD] == $fieldName) { |
|
430 | 430 | $isFieldChanged = $propertyName; |
431 | 431 | break; |
432 | 432 | } |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | $fields = implode(',', array_keys($field_set)); |
449 | 449 | |
450 | 450 | $result = 0; |
451 | - if(classSupernova::db_query("INSERT INTO `{{" . static::$_table . "}}` ({$fields}) VALUES ({$values});")) { |
|
451 | + if (classSupernova::db_query("INSERT INTO `{{" . static::$_table . "}}` ({$fields}) VALUES ({$values});")) { |
|
452 | 452 | $result = db_insert_id(); |
453 | 453 | } |
454 | 454 | |
@@ -466,13 +466,13 @@ discard block |
||
466 | 466 | sn_db_field_set_safe_flag_clear($field_set); |
467 | 467 | |
468 | 468 | $set = array(); |
469 | - foreach($field_set as $fieldName => $value) { |
|
470 | - if(!($changedProperty = $this->isFieldChanged($fieldName))) { |
|
469 | + foreach ($field_set as $fieldName => $value) { |
|
470 | + if (!($changedProperty = $this->isFieldChanged($fieldName))) { |
|
471 | 471 | continue; |
472 | 472 | } |
473 | 473 | |
474 | 474 | // TODO - separate sets from adjusts |
475 | - if(array_key_exists($changedProperty, $this->propertiesAdjusted)) { |
|
475 | + if (array_key_exists($changedProperty, $this->propertiesAdjusted)) { |
|
476 | 476 | $value = "`{$fieldName}` + ($value)"; // braces for negative values |
477 | 477 | } |
478 | 478 |
@@ -20,14 +20,14 @@ discard block |
||
20 | 20 | $TargetAddress = sprintf($lang['sys_adress_planet'], $fleet_end_coordinates['galaxy'], $fleet_end_coordinates['system'], $fleet_end_coordinates['planet']); |
21 | 21 | |
22 | 22 | $TheMessage = $lang['sys_colo_no_colonizer']; |
23 | - if($objFleet->shipsGetTotalById(SHIP_COLONIZER) >= 1) { |
|
23 | + if ($objFleet->shipsGetTotalById(SHIP_COLONIZER) >= 1) { |
|
24 | 24 | $TheMessage = $lang['sys_colo_notfree']; |
25 | - if(empty($mission_data->dst_planet)) { |
|
25 | + if (empty($mission_data->dst_planet)) { |
|
26 | 26 | $iPlanetCount = get_player_current_colonies($src_user_row); |
27 | 27 | |
28 | 28 | // Can we colonize more planets? |
29 | 29 | $TheMessage = $lang['sys_colo_maxcolo']; |
30 | - if($iPlanetCount < get_player_max_colonies($src_user_row)) { |
|
30 | + if ($iPlanetCount < get_player_max_colonies($src_user_row)) { |
|
31 | 31 | // Yes, we can colonize |
32 | 32 | $TheMessage = $lang['sys_colo_badpos']; |
33 | 33 | |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | $fleet_end_coordinates['galaxy'], $fleet_end_coordinates['system'], $fleet_end_coordinates['planet'], |
36 | 36 | $objFleet->playerOwnerId, "{$lang['sys_colo_defaultname']} {$iPlanetCount}", false, |
37 | 37 | array('user_row' => $src_user_row)); |
38 | - if($NewOwnerPlanet) { |
|
38 | + if ($NewOwnerPlanet) { |
|
39 | 39 | $TheMessage = $lang['sys_colo_arrival'] . $TargetAddress . $lang['sys_colo_allisok']; |
40 | 40 | msg_send_simple_message($objFleet->playerOwnerId, '', $objFleet->time_arrive_to_target, MSG_TYPE_SPY, $lang['sys_colo_mess_from'], $lang['sys_colo_mess_report'], $TheMessage); |
41 | 41 |
@@ -162,20 +162,20 @@ discard block |
||
162 | 162 | $this->owner_id, |
163 | 163 | $this->db_id, |
164 | 164 | |
165 | - (float)$this->UBE_PLANET[PLANET_ID], |
|
165 | + (float) $this->UBE_PLANET[PLANET_ID], |
|
166 | 166 | "'" . db_escape($this->UBE_PLANET[PLANET_NAME]) . "'", |
167 | - (int)$this->UBE_PLANET[PLANET_GALAXY], |
|
168 | - (int)$this->UBE_PLANET[PLANET_SYSTEM], |
|
169 | - (int)$this->UBE_PLANET[PLANET_PLANET], |
|
170 | - (int)$this->UBE_PLANET[PLANET_TYPE], |
|
171 | - |
|
172 | - (float)$this->resource_list[RES_METAL], |
|
173 | - (float)$this->resource_list[RES_CRYSTAL], |
|
174 | - (float)$this->resource_list[RES_DEUTERIUM], |
|
175 | - |
|
176 | - (float)$this->fleet_bonus->calcBonus(P_ATTACK), |
|
177 | - (float)$this->fleet_bonus->calcBonus(P_SHIELD), |
|
178 | - (float)$this->fleet_bonus->calcBonus(P_ARMOR), |
|
167 | + (int) $this->UBE_PLANET[PLANET_GALAXY], |
|
168 | + (int) $this->UBE_PLANET[PLANET_SYSTEM], |
|
169 | + (int) $this->UBE_PLANET[PLANET_PLANET], |
|
170 | + (int) $this->UBE_PLANET[PLANET_TYPE], |
|
171 | + |
|
172 | + (float) $this->resource_list[RES_METAL], |
|
173 | + (float) $this->resource_list[RES_CRYSTAL], |
|
174 | + (float) $this->resource_list[RES_DEUTERIUM], |
|
175 | + |
|
176 | + (float) $this->fleet_bonus->calcBonus(P_ATTACK), |
|
177 | + (float) $this->fleet_bonus->calcBonus(P_SHIELD), |
|
178 | + (float) $this->fleet_bonus->calcBonus(P_ARMOR), |
|
179 | 179 | ); |
180 | 180 | } |
181 | 181 | |
@@ -190,13 +190,13 @@ discard block |
||
190 | 190 | $this->group_id = $objFleet->group_id; |
191 | 191 | |
192 | 192 | $fleet_unit_list = $objFleet->shipsGetArray(); |
193 | - foreach($fleet_unit_list as $unit_id => $unit_count) { |
|
194 | - if(!$unit_count) { |
|
193 | + foreach ($fleet_unit_list as $unit_id => $unit_count) { |
|
194 | + if (!$unit_count) { |
|
195 | 195 | continue; |
196 | 196 | } |
197 | 197 | |
198 | 198 | $unit_type = get_unit_param($unit_id, P_UNIT_TYPE); |
199 | - if($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE) { |
|
199 | + if ($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE) { |
|
200 | 200 | $this->unit_list->unitAdjustCount($unit_id, $unit_count); |
201 | 201 | } |
202 | 202 | } |
@@ -232,13 +232,13 @@ discard block |
||
232 | 232 | // } |
233 | 233 | // } |
234 | 234 | |
235 | - foreach($sn_group_combat as $unit_id) { |
|
236 | - if($unit_count = mrc_get_level($player_db_row, $planet_row, $unit_id)) { |
|
235 | + foreach ($sn_group_combat as $unit_id) { |
|
236 | + if ($unit_count = mrc_get_level($player_db_row, $planet_row, $unit_id)) { |
|
237 | 237 | $this->unit_list->unitAdjustCount($unit_id, $unit_count); |
238 | 238 | } |
239 | 239 | } |
240 | 240 | |
241 | - foreach(sn_get_groups('resources_loot') as $resource_id) { |
|
241 | + foreach (sn_get_groups('resources_loot') as $resource_id) { |
|
242 | 242 | $this->resource_list[$resource_id] = floor(mrc_get_level($player_db_row, $planet_row, $resource_id)); |
243 | 243 | } |
244 | 244 | |
@@ -297,27 +297,27 @@ discard block |
||
297 | 297 | $ube_report_id, |
298 | 298 | $this->db_id, |
299 | 299 | |
300 | - (float)$this->resources_lost_on_units[RES_METAL], |
|
301 | - (float)$this->resources_lost_on_units[RES_CRYSTAL], |
|
302 | - (float)$this->resources_lost_on_units[RES_DEUTERIUM], |
|
303 | - (float)$this->cargo_dropped[RES_METAL], |
|
304 | - (float)$this->cargo_dropped[RES_CRYSTAL], |
|
305 | - (float)$this->cargo_dropped[RES_DEUTERIUM], |
|
306 | - (float)$this->resources_looted[RES_METAL], |
|
307 | - (float)$this->resources_looted[RES_CRYSTAL], |
|
308 | - (float)$this->resources_looted[RES_DEUTERIUM], |
|
309 | - (float)$this->resources_lost_in_metal[RES_METAL], |
|
300 | + (float) $this->resources_lost_on_units[RES_METAL], |
|
301 | + (float) $this->resources_lost_on_units[RES_CRYSTAL], |
|
302 | + (float) $this->resources_lost_on_units[RES_DEUTERIUM], |
|
303 | + (float) $this->cargo_dropped[RES_METAL], |
|
304 | + (float) $this->cargo_dropped[RES_CRYSTAL], |
|
305 | + (float) $this->cargo_dropped[RES_DEUTERIUM], |
|
306 | + (float) $this->resources_looted[RES_METAL], |
|
307 | + (float) $this->resources_looted[RES_CRYSTAL], |
|
308 | + (float) $this->resources_looted[RES_DEUTERIUM], |
|
309 | + (float) $this->resources_lost_in_metal[RES_METAL], |
|
310 | 310 | ); |
311 | 311 | } |
312 | 312 | |
313 | 313 | public function report_render_outcome_side_fleet() { |
314 | 314 | $UBE_DEFENCE_RESTORE = array(); |
315 | 315 | $UBE_UNITS_LOST = array(); |
316 | - foreach($this->unit_list->_container as $UBEUnit) { |
|
317 | - if($UBEUnit->units_restored) { |
|
316 | + foreach ($this->unit_list->_container as $UBEUnit) { |
|
317 | + if ($UBEUnit->units_restored) { |
|
318 | 318 | $UBE_DEFENCE_RESTORE[$UBEUnit->unitId] = $UBEUnit->units_restored; |
319 | 319 | } |
320 | - if($UBEUnit->units_lost) { |
|
320 | + if ($UBEUnit->units_lost) { |
|
321 | 321 | $UBE_UNITS_LOST[$UBEUnit->unitId] = $UBEUnit->units_lost; |
322 | 322 | } |
323 | 323 | } |
@@ -344,16 +344,16 @@ discard block |
||
344 | 344 | global $lang; |
345 | 345 | |
346 | 346 | $result = array(); |
347 | - if(!empty($array)) { |
|
348 | - foreach($array as $unit_id => $unit_count) { |
|
349 | - if($unit_count) { |
|
347 | + if (!empty($array)) { |
|
348 | + foreach ($array as $unit_id => $unit_count) { |
|
349 | + if ($unit_count) { |
|
350 | 350 | $result[] = array( |
351 | 351 | 'NAME' => $lang['tech'][$unit_id], |
352 | 352 | 'LOSS' => pretty_number($unit_count), |
353 | 353 | ); |
354 | 354 | } |
355 | 355 | } |
356 | - if($lang_header_index && count($result)) { |
|
356 | + if ($lang_header_index && count($result)) { |
|
357 | 357 | array_unshift($result, array('NAME' => $lang[$lang_header_index])); |
358 | 358 | } |
359 | 359 | } |
@@ -366,16 +366,16 @@ discard block |
||
366 | 366 | $fleet_id = $this->db_id; |
367 | 367 | |
368 | 368 | $unit_sort_order = 0; |
369 | - foreach($this->unit_list->_container as $UBEUnit) { |
|
370 | - if($UBEUnit->units_lost || $UBEUnit->units_restored) { |
|
369 | + foreach ($this->unit_list->_container as $UBEUnit) { |
|
370 | + if ($UBEUnit->units_lost || $UBEUnit->units_restored) { |
|
371 | 371 | $unit_sort_order++; |
372 | 372 | $sql_perform_report_unit[] = array( |
373 | 373 | $ube_report_id, |
374 | 374 | $fleet_id, |
375 | 375 | |
376 | 376 | $UBEUnit->unitId, |
377 | - (float)$UBEUnit->units_restored, |
|
378 | - (float)$UBEUnit->units_lost, |
|
377 | + (float) $UBEUnit->units_restored, |
|
378 | + (float) $UBEUnit->units_lost, |
|
379 | 379 | |
380 | 380 | $unit_sort_order, |
381 | 381 | ); |
@@ -391,9 +391,9 @@ discard block |
||
391 | 391 | function ube_combat_result_calculate_resources() { |
392 | 392 | $resource_delta_fleet = array(); |
393 | 393 | // Если во флоте остались юниты или это планета - генерируем изменение ресурсов |
394 | - foreach(sn_get_groups('resources_loot') as $resource_id) { |
|
395 | - $resource_change = (float)$this->resources_looted[$resource_id] + (float)$this->cargo_dropped[$resource_id]; |
|
396 | - if($resource_change) { |
|
394 | + foreach (sn_get_groups('resources_loot') as $resource_id) { |
|
395 | + $resource_change = (float) $this->resources_looted[$resource_id] + (float) $this->cargo_dropped[$resource_id]; |
|
396 | + if ($resource_change) { |
|
397 | 397 | $resource_delta_fleet[$resource_id] = -($resource_change); |
398 | 398 | } |
399 | 399 | } |
@@ -426,12 +426,12 @@ discard block |
||
426 | 426 | ); |
427 | 427 | |
428 | 428 | $this->fleet_capacity = 0; |
429 | - foreach($this->unit_list->_container as $UBEUnit) { |
|
429 | + foreach ($this->unit_list->_container as $UBEUnit) { |
|
430 | 430 | $this->fleet_capacity += $UBEUnit->capacity * $UBEUnit->getCount(); |
431 | 431 | |
432 | - if($UBEUnit->units_lost) { |
|
433 | - foreach($UBEUnit->price as $resource_id => $unit_resource_price) { |
|
434 | - if(!$unit_resource_price) { |
|
432 | + if ($UBEUnit->units_lost) { |
|
433 | + foreach ($UBEUnit->price as $resource_id => $unit_resource_price) { |
|
434 | + if (!$unit_resource_price) { |
|
435 | 435 | continue; |
436 | 436 | } |
437 | 437 | |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | $this->resources_lost_on_units[$resource_id] += $resources_lost; |
440 | 440 | // Если это корабль - прибавляем потери к обломкам на орбите |
441 | 441 | // TODO - опция выбрасывания обороны в обломки |
442 | - if($UBEUnit->getType() == UNIT_SHIPS) { |
|
442 | + if ($UBEUnit->getType() == UNIT_SHIPS) { |
|
443 | 443 | $this->resources_lost_on_ships[$resource_id] += $resources_lost; |
444 | 444 | } |
445 | 445 | } |
@@ -451,11 +451,11 @@ discard block |
||
451 | 451 | |
452 | 452 | // Если емкость трюмов меньше количество ресурсов - часть ресов выбрасываем нахуй |
453 | 453 | // На планете ($fleet_id = 0) ресурсы в космос не выбрасываются |
454 | - if($this->db_id != 0 && $this->fleet_capacity < $fleet_total_resources) { |
|
454 | + if ($this->db_id != 0 && $this->fleet_capacity < $fleet_total_resources) { |
|
455 | 455 | $drop_share = 1 - $this->fleet_capacity / $fleet_total_resources; // Какая часть ресурсов выброшена |
456 | - foreach($this->resource_list as $resource_id => &$resource_amount) { |
|
456 | + foreach ($this->resource_list as $resource_id => &$resource_amount) { |
|
457 | 457 | // Не просчитываем ресурсы, которых нет на борту кораблей флота |
458 | - if(!$resource_amount) { |
|
458 | + if (!$resource_amount) { |
|
459 | 459 | continue; |
460 | 460 | } |
461 | 461 | |
@@ -476,19 +476,19 @@ discard block |
||
476 | 476 | $objFleet2->setDbId($this->db_id); |
477 | 477 | |
478 | 478 | // Если это была миссия Уничтожения И звезда смерти взорвалась И мы работаем с аттакерами - значит все аттакеры умерли |
479 | - if($this->is_attacker == UBE_PLAYER_IS_ATTACKER && $reapers_status == UBE_MOON_REAPERS_DIED) { |
|
479 | + if ($this->is_attacker == UBE_PLAYER_IS_ATTACKER && $reapers_status == UBE_MOON_REAPERS_DIED) { |
|
480 | 480 | $objFleet2->dbDelete(); |
481 | - } elseif($ship_count_initial == 0) { // $ship_count_lost == $ship_count_initial || |
|
481 | + } elseif ($ship_count_initial == 0) { // $ship_count_lost == $ship_count_initial || |
|
482 | 482 | $objFleet2->dbDelete(); |
483 | 483 | } else { |
484 | - if($ship_count_lost) { |
|
484 | + if ($ship_count_lost) { |
|
485 | 485 | // Просматриваем результаты изменения флотов |
486 | - foreach($this->unit_list->_container as $UBEUnit) { |
|
486 | + foreach ($this->unit_list->_container as $UBEUnit) { |
|
487 | 487 | // Перебираем аутком на случай восстановления юнитов |
488 | 488 | // if(($units_left = $UBEUnit->getCount() - (float)$UBEUnit->units_lost) > 0) { |
489 | 489 | // $fleet_real_array[$UBEUnit->unitId] = $units_left; |
490 | 490 | // }; |
491 | - if(floatval($UBEUnit->units_lost) != 0) { |
|
491 | + if (floatval($UBEUnit->units_lost) != 0) { |
|
492 | 492 | $objFleet2->shipAdjustCount($UBEUnit->unitId, floatval($UBEUnit->units_lost)); |
493 | 493 | }; |
494 | 494 | } |
@@ -498,7 +498,7 @@ discard block |
||
498 | 498 | $objFleet2->resourcesAdjust($resource_delta_fleet); |
499 | 499 | |
500 | 500 | // Если защитник и не РМФ - отправляем флот назад |
501 | - if($this->is_attacker == UBE_PLAYER_IS_ATTACKER || ($this->is_attacker == UBE_PLAYER_IS_DEFENDER && !$is_small_fleet_recce)) { |
|
501 | + if ($this->is_attacker == UBE_PLAYER_IS_ATTACKER || ($this->is_attacker == UBE_PLAYER_IS_DEFENDER && !$is_small_fleet_recce)) { |
|
502 | 502 | $objFleet2->markReturned(); |
503 | 503 | } |
504 | 504 | $objFleet2->dbSave(); |
@@ -528,7 +528,7 @@ discard block |
||
528 | 528 | public function calculate_unit_partial_data(UBEASA $side_ASA) { |
529 | 529 | $this->fleet_share_of_side_armor = $this->total_stats[P_ARMOR] / $side_ASA->getArmor(); |
530 | 530 | |
531 | - foreach($this->unit_list->_container as $UBEUnit) { |
|
531 | + foreach ($this->unit_list->_container as $UBEUnit) { |
|
532 | 532 | $UBEUnit->share_of_side_armor = $UBEUnit->pool_armor / $side_ASA->getArmor(); |
533 | 533 | } |
534 | 534 | } |
@@ -540,9 +540,9 @@ discard block |
||
540 | 540 | * @version 2016-02-25 23:42:45 41a4.68 |
541 | 541 | */ |
542 | 542 | public function attack_fleets(UBEFleetList $fleet_list, $is_simulator) { |
543 | - foreach($fleet_list->_container as $defending_fleet) { |
|
543 | + foreach ($fleet_list->_container as $defending_fleet) { |
|
544 | 544 | // Не атакуются флоты на своей стороне |
545 | - if($this->is_attacker == $defending_fleet->is_attacker) { |
|
545 | + if ($this->is_attacker == $defending_fleet->is_attacker) { |
|
546 | 546 | continue; |
547 | 547 | } |
548 | 548 | $this->attack_fleet($defending_fleet, $is_simulator); |
@@ -558,12 +558,12 @@ discard block |
||
558 | 558 | public function attack_fleet(UBEFleet $defending_fleet, $is_simulator) { |
559 | 559 | UBEDebug::unit_dump_header(); |
560 | 560 | |
561 | - foreach($this->unit_list->_container as $attacking_unit_pool) { |
|
561 | + foreach ($this->unit_list->_container as $attacking_unit_pool) { |
|
562 | 562 | UBEDebug::unit_dump($attacking_unit_pool, 'attacker'); |
563 | 563 | |
564 | 564 | // if($attack_unit_count <= 0) continue; // TODO: Это пока нельзя включать - вот если будут "боевые порядки юнитов..." |
565 | - foreach($defending_fleet->unit_list->_container as $defending_unit_pool) { |
|
566 | - if($defending_unit_pool->isEmpty()) { |
|
565 | + foreach ($defending_fleet->unit_list->_container as $defending_unit_pool) { |
|
566 | + if ($defending_unit_pool->isEmpty()) { |
|
567 | 567 | continue; |
568 | 568 | } |
569 | 569 |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
153 | - * @param $ube_report_id |
|
153 | + * @param integer $ube_report_id |
|
154 | 154 | * |
155 | 155 | * @return array |
156 | 156 | * |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | |
289 | 289 | |
290 | 290 | /** |
291 | - * @param $ube_report_id |
|
291 | + * @param integer $ube_report_id |
|
292 | 292 | * |
293 | 293 | * @return array |
294 | 294 | */ |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | // Рендерит таблицу общего результата боя |
337 | 337 | /** |
338 | 338 | * @param $array |
339 | - * @param $lang_header_index |
|
339 | + * @param string $lang_header_index |
|
340 | 340 | * |
341 | 341 | * @return array |
342 | 342 | */ |
@@ -362,6 +362,9 @@ discard block |
||
362 | 362 | } |
363 | 363 | |
364 | 364 | |
365 | + /** |
|
366 | + * @param integer $ube_report_id |
|
367 | + */ |
|
365 | 368 | public function sql_generate_outcome_unit_array(&$sql_perform_report_unit, $ube_report_id) { |
366 | 369 | $fleet_id = $this->db_id; |
367 | 370 | |
@@ -468,6 +471,10 @@ discard block |
||
468 | 471 | $this->fleet_capacity -= $fleet_total_resources; |
469 | 472 | } |
470 | 473 | |
474 | + /** |
|
475 | + * @param integer $is_small_fleet_recce |
|
476 | + * @param integer $reapers_status |
|
477 | + */ |
|
471 | 478 | public function db_save_combat_result_fleet($is_small_fleet_recce, $reapers_status) { |
472 | 479 | $ship_count_initial = $this->unit_list->unitsCount(); |
473 | 480 | $ship_count_lost = $this->unit_list->unitCountLost(); |
@@ -535,7 +542,7 @@ discard block |
||
535 | 542 | |
536 | 543 | /** |
537 | 544 | * @param UBEFleetList $fleet_list |
538 | - * @param $is_simulator |
|
545 | + * @param boolean $is_simulator |
|
539 | 546 | * |
540 | 547 | * @version 2016-02-25 23:42:45 41a4.68 |
541 | 548 | */ |
@@ -10,7 +10,7 @@ |
||
10 | 10 | * |
11 | 11 | * @param Fleet $objFleet |
12 | 12 | * @param bool $start |
13 | - * @param null $result |
|
13 | + * @param integer $result |
|
14 | 14 | * |
15 | 15 | * @return mixed |
16 | 16 | */ |
@@ -19,15 +19,11 @@ discard block |
||
19 | 19 | // ------------------------------------------------------------------ |
20 | 20 | function flt_flyingFleetsSort($a, $b) { |
21 | 21 | // Сравниваем время флотов - кто раньше, тот и первый обрабатывается |
22 | - return $a['fleet_time'] > $b['fleet_time'] ? 1 : ($a['fleet_time'] < $b['fleet_time'] ? -1 : |
|
23 | - // Если время - одинаковое, сравниваем события флотов |
|
22 | + return $a['fleet_time'] > $b['fleet_time'] ? 1 : ($a['fleet_time'] < $b['fleet_time'] ? -1 : // Если время - одинаковое, сравниваем события флотов |
|
24 | 23 | // Если события - одинаковые, то флоты равны |
25 | - ($a['fleet_event'] == $b['fleet_event'] ? 0 : |
|
26 | - // Если события разные - первыми считаем прибывающие флоты |
|
27 | - ($a['fleet_event'] == EVENT_FLT_ARRIVE ? 1 : ($b['fleet_event'] == EVENT_FLT_ARRIVE ? -1 : |
|
28 | - // Если нет прибывающих флотов - дальше считаем флоты, которые закончили миссию |
|
29 | - ($a['fleet_event'] == EVENT_FLT_ACOMPLISH ? 1 : ($b['fleet_event'] == EVENT_FLT_ACOMPLISH ? -1 : |
|
30 | - // Если нет флотов, закончивших задание - остались возвращающиеся флоты, которые равны между собой |
|
24 | + ($a['fleet_event'] == $b['fleet_event'] ? 0 : // Если события разные - первыми считаем прибывающие флоты |
|
25 | + ($a['fleet_event'] == EVENT_FLT_ARRIVE ? 1 : ($b['fleet_event'] == EVENT_FLT_ARRIVE ? -1 : // Если нет прибывающих флотов - дальше считаем флоты, которые закончили миссию |
|
26 | + ($a['fleet_event'] == EVENT_FLT_ACOMPLISH ? 1 : ($b['fleet_event'] == EVENT_FLT_ACOMPLISH ? -1 : // Если нет флотов, закончивших задание - остались возвращающиеся флоты, которые равны между собой |
|
31 | 27 | // TODO: Добавить еще проверку по ID флота и/или времени запуска - что бы обсчитывать их в порядке запуска |
32 | 28 | ( |
33 | 29 | 0 // Вообще сюда доходить не должно - будет отсекаться на равенстве событий |
@@ -41,7 +37,7 @@ discard block |
||
41 | 37 | function log_file($msg) { |
42 | 38 | static $handler; |
43 | 39 | |
44 | - if(!$handler) { |
|
40 | + if (!$handler) { |
|
45 | 41 | $handler = fopen('event.log', 'a+'); |
46 | 42 | } |
47 | 43 | |
@@ -81,12 +77,12 @@ discard block |
||
81 | 77 | */ |
82 | 78 | global $debug; |
83 | 79 | |
84 | - if(classSupernova::$config->game_disable != GAME_DISABLE_NONE || $skip_fleet_update) { |
|
80 | + if (classSupernova::$config->game_disable != GAME_DISABLE_NONE || $skip_fleet_update) { |
|
85 | 81 | return; |
86 | 82 | } |
87 | 83 | |
88 | 84 | sn_db_transaction_start(); |
89 | - if(classSupernova::$config->db_loadItem('game_disable') != GAME_DISABLE_NONE || SN_TIME_NOW - strtotime(classSupernova::$config->db_loadItem('fleet_update_last')) <= classSupernova::$config->fleet_update_interval) { |
|
85 | + if (classSupernova::$config->db_loadItem('game_disable') != GAME_DISABLE_NONE || SN_TIME_NOW - strtotime(classSupernova::$config->db_loadItem('fleet_update_last')) <= classSupernova::$config->fleet_update_interval) { |
|
90 | 86 | sn_db_transaction_rollback(); |
91 | 87 | |
92 | 88 | return; |
@@ -94,14 +90,14 @@ discard block |
||
94 | 90 | |
95 | 91 | |
96 | 92 | // Watchdog timer |
97 | - if(classSupernova::$config->db_loadItem('fleet_update_lock')) { |
|
98 | - if(defined('DEBUG_FLYING_FLEETS')) { |
|
93 | + if (classSupernova::$config->db_loadItem('fleet_update_lock')) { |
|
94 | + if (defined('DEBUG_FLYING_FLEETS')) { |
|
99 | 95 | $random = 0; |
100 | 96 | } else { |
101 | 97 | $random = mt_rand(240, 300); |
102 | 98 | } |
103 | 99 | |
104 | - if(SN_TIME_NOW - strtotime(classSupernova::$config->fleet_update_lock) <= $random) { |
|
100 | + if (SN_TIME_NOW - strtotime(classSupernova::$config->fleet_update_lock) <= $random) { |
|
105 | 101 | sn_db_transaction_rollback(); |
106 | 102 | |
107 | 103 | return; |
@@ -125,11 +121,11 @@ discard block |
||
125 | 121 | $missions_used = array(); |
126 | 122 | |
127 | 123 | $objFleetList = FleetList::dbGetFleetListCurrentTick(); |
128 | - foreach($objFleetList->_container as $objFleet) { |
|
124 | + foreach ($objFleetList->_container as $objFleet) { |
|
129 | 125 | set_time_limit(15); |
130 | 126 | // TODO - Унифицировать код с темплейтным разбором эвентов на планете! |
131 | 127 | $missions_used[$objFleet->mission_type] = 1; |
132 | - if($objFleet->time_arrive_to_target <= SN_TIME_NOW && !$objFleet->isReturning()) { |
|
128 | + if ($objFleet->time_arrive_to_target <= SN_TIME_NOW && !$objFleet->isReturning()) { |
|
133 | 129 | $fleet_event_list[] = array( |
134 | 130 | 'object' => $objFleet, |
135 | 131 | 'fleet_time' => $objFleet->time_arrive_to_target, |
@@ -137,7 +133,7 @@ discard block |
||
137 | 133 | ); |
138 | 134 | } |
139 | 135 | |
140 | - if($objFleet->time_mission_job_complete > 0 && $objFleet->time_mission_job_complete <= SN_TIME_NOW && !$objFleet->isReturning()) { |
|
136 | + if ($objFleet->time_mission_job_complete > 0 && $objFleet->time_mission_job_complete <= SN_TIME_NOW && !$objFleet->isReturning()) { |
|
141 | 137 | $fleet_event_list[] = array( |
142 | 138 | 'object' => $objFleet, |
143 | 139 | 'fleet_time' => $objFleet->time_mission_job_complete, |
@@ -145,7 +141,7 @@ discard block |
||
145 | 141 | ); |
146 | 142 | } |
147 | 143 | |
148 | - if($objFleet->time_return_to_source <= SN_TIME_NOW) { |
|
144 | + if ($objFleet->time_return_to_source <= SN_TIME_NOW) { |
|
149 | 145 | $fleet_event_list[] = array( |
150 | 146 | 'object' => $objFleet, |
151 | 147 | 'fleet_time' => $objFleet->time_return_to_source, |
@@ -171,17 +167,17 @@ discard block |
||
171 | 167 | // MT_MISSILE => 'flt_mission_missile.php', |
172 | 168 | MT_EXPLORE => 'flt_mission_explore', |
173 | 169 | ); |
174 | - foreach($missions_used as $mission_id => $cork) { |
|
170 | + foreach ($missions_used as $mission_id => $cork) { |
|
175 | 171 | require_once(SN_ROOT_PHYSICAL . "includes/includes/{$mission_files[$mission_id]}" . DOT_PHP_EX); |
176 | 172 | } |
177 | 173 | |
178 | 174 | //log_file('Обработка миссий'); |
179 | 175 | $sn_groups_mission = sn_get_groups('missions'); |
180 | - foreach($fleet_event_list as $fleet_event) { |
|
176 | + foreach ($fleet_event_list as $fleet_event) { |
|
181 | 177 | // TODO: Указатель тут потом сделать |
182 | 178 | // TODO: СЕЙЧАС НАДО ПРОВЕРЯТЬ ПО БАЗЕ - А ЖИВОЙ ЛИ ФЛОТ?! |
183 | 179 | $fleet_row = $fleet_event['fleet_row']; |
184 | - if(empty($fleet_event['object'])) { |
|
180 | + if (empty($fleet_event['object'])) { |
|
185 | 181 | // Fleet was destroyed in course of previous actions |
186 | 182 | continue; |
187 | 183 | } |
@@ -205,20 +201,20 @@ discard block |
||
205 | 201 | |
206 | 202 | $objFleet->dbLoad($objFleet->dbId); |
207 | 203 | |
208 | - if(!$objFleet->dbId) { |
|
204 | + if (!$objFleet->dbId) { |
|
209 | 205 | // Fleet was destroyed in course of previous actions |
210 | 206 | sn_db_transaction_commit(); |
211 | 207 | continue; |
212 | 208 | } |
213 | 209 | |
214 | - if($fleet_event['fleet_event'] == EVENT_FLT_RETURN) { |
|
210 | + if ($fleet_event['fleet_event'] == EVENT_FLT_RETURN) { |
|
215 | 211 | // Fleet returns to planet |
216 | 212 | $objFleet->shipsLand(true); |
217 | 213 | sn_db_transaction_commit(); |
218 | 214 | continue; |
219 | 215 | } |
220 | 216 | |
221 | - if($fleet_event['fleet_event'] == EVENT_FLT_ARRIVE && $objFleet->isReturning()) { |
|
217 | + if ($fleet_event['fleet_event'] == EVENT_FLT_ARRIVE && $objFleet->isReturning()) { |
|
222 | 218 | // При событии EVENT_FLT_ARRIVE флот всегда должен иметь fleet_mess == 0 |
223 | 219 | // В противном случае это означает, что флот уже был обработан ранее - например, при САБе |
224 | 220 | sn_db_transaction_commit(); |
@@ -238,13 +234,13 @@ discard block |
||
238 | 234 | $objMission->dst_planet = $mission_data['dst_planet'] ? db_planet_by_vector($objFleet->target_coordinates_typed(), '', true, '`id`, `id_owner`, `name`') : null; |
239 | 235 | $objMission->fleet_event = $fleet_event['fleet_event']; |
240 | 236 | |
241 | - if($objMission->dst_planet && $objMission->dst_planet['id_owner']) { |
|
237 | + if ($objMission->dst_planet && $objMission->dst_planet['id_owner']) { |
|
242 | 238 | $update_result = sys_o_get_updated($objMission->dst_planet['id_owner'], $objMission->dst_planet['id'], $objFleet->time_arrive_to_target); |
243 | 239 | $objMission->dst_user = !empty($objMission->dst_user) ? $update_result['user'] : null; |
244 | 240 | $objMission->dst_planet = $update_result['planet']; |
245 | 241 | } |
246 | 242 | |
247 | - switch($objFleet->mission_type) { |
|
243 | + switch ($objFleet->mission_type) { |
|
248 | 244 | // Для боевых атак нужно обновлять по САБу и по холду - таки надо возвращать данные из обработчика миссий! |
249 | 245 | case MT_AKS: |
250 | 246 | case MT_ATTACK: |
@@ -1,32 +1,32 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * index.php - overview.php |
|
4 | - * |
|
5 | - * 2.4 - copyright (c) 2010 by Gorlum for http://supernova.ws |
|
6 | - * [-] Removed News frame |
|
7 | - * [-] Time & Usersonline moved to Top-Frame |
|
8 | - * 2.3 - copyright (c) 2010 by Gorlum for http://supernova.ws |
|
9 | - * [*] Complying with PCG |
|
10 | - * 2.2 - copyright (c) 2010 by Gorlum for http://supernova.ws |
|
11 | - * [+] Redo flying fleet list |
|
12 | - * 2.1 - copyright (c) 2010 by Gorlum for http://supernova.ws |
|
13 | - * [+] Planets on planet list now have indication of planet fill |
|
14 | - * [+] Planets on planet list now have indication when there is enemy fleet flying to planet |
|
15 | - * 2.0 - copyright (c) 2010 by Gorlum for http://supernova.ws |
|
16 | - * [+] Now there is full planet list on right side of screen a-la oGame |
|
17 | - * [+] Planet list now include icons for buildings/tech/fleet on progress |
|
18 | - * 1.5 - copyright (c) 2010 by Gorlum for http://supernova.ws |
|
19 | - * [*] Subplanet timers now use sn_timer.js library |
|
20 | - * 1.4 - copyright (c) 2010 by Gorlum for http://supernova.ws |
|
21 | - * [*] All mainplanet timers now use new sn_timer.js library |
|
22 | - * 1.3 - copyright (c) 2010 by Gorlum for http://supernova.ws |
|
23 | - * [*] Adjusted layouts of player infos |
|
24 | - * 1.2 - copyright (c) 2010 by Gorlum for http://supernova.ws |
|
25 | - * [*] Adjusted layouts of planet infos |
|
26 | - * 1.1 - Security checks by Gorlum for http://supernova.ws |
|
27 | - * @version 1 |
|
28 | - * @copyright 2008 By Chlorel for XNova |
|
29 | - */ |
|
3 | + * index.php - overview.php |
|
4 | + * |
|
5 | + * 2.4 - copyright (c) 2010 by Gorlum for http://supernova.ws |
|
6 | + * [-] Removed News frame |
|
7 | + * [-] Time & Usersonline moved to Top-Frame |
|
8 | + * 2.3 - copyright (c) 2010 by Gorlum for http://supernova.ws |
|
9 | + * [*] Complying with PCG |
|
10 | + * 2.2 - copyright (c) 2010 by Gorlum for http://supernova.ws |
|
11 | + * [+] Redo flying fleet list |
|
12 | + * 2.1 - copyright (c) 2010 by Gorlum for http://supernova.ws |
|
13 | + * [+] Planets on planet list now have indication of planet fill |
|
14 | + * [+] Planets on planet list now have indication when there is enemy fleet flying to planet |
|
15 | + * 2.0 - copyright (c) 2010 by Gorlum for http://supernova.ws |
|
16 | + * [+] Now there is full planet list on right side of screen a-la oGame |
|
17 | + * [+] Planet list now include icons for buildings/tech/fleet on progress |
|
18 | + * 1.5 - copyright (c) 2010 by Gorlum for http://supernova.ws |
|
19 | + * [*] Subplanet timers now use sn_timer.js library |
|
20 | + * 1.4 - copyright (c) 2010 by Gorlum for http://supernova.ws |
|
21 | + * [*] All mainplanet timers now use new sn_timer.js library |
|
22 | + * 1.3 - copyright (c) 2010 by Gorlum for http://supernova.ws |
|
23 | + * [*] Adjusted layouts of player infos |
|
24 | + * 1.2 - copyright (c) 2010 by Gorlum for http://supernova.ws |
|
25 | + * [*] Adjusted layouts of planet infos |
|
26 | + * 1.1 - Security checks by Gorlum for http://supernova.ws |
|
27 | + * @version 1 |
|
28 | + * @copyright 2008 By Chlorel for XNova |
|
29 | + */ |
|
30 | 30 | |
31 | 31 | //define('SN_RENDER_NAVBAR_PLANET', false); |
32 | 32 |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | |
79 | 79 | $result = array(); |
80 | 80 | |
81 | -switch($mode = sys_get_param_str('mode')) { |
|
81 | +switch ($mode = sys_get_param_str('mode')) { |
|
82 | 82 | case 'manage': |
83 | 83 | sn_sys_sector_buy('overview.php?mode=manage'); |
84 | 84 | |
@@ -88,11 +88,11 @@ discard block |
||
88 | 88 | $template = gettemplate('planet_manage', true); |
89 | 89 | $planet_id = sys_get_param_id('planet_id'); |
90 | 90 | |
91 | - if(sys_get_param_str('rename') && $new_name = sys_get_param_str('new_name')) { |
|
91 | + if (sys_get_param_str('rename') && $new_name = sys_get_param_str('new_name')) { |
|
92 | 92 | $planetrow['name'] = $new_name; |
93 | 93 | // $new_name = db_escape($new_name); |
94 | 94 | db_planet_set_by_id($planetrow['id'], "`name` = '{$new_name}'"); |
95 | - } elseif(sys_get_param_str('action') == 'make_capital') { |
|
95 | + } elseif (sys_get_param_str('action') == 'make_capital') { |
|
96 | 96 | try { |
97 | 97 | sn_db_transaction_start(); |
98 | 98 | $user = db_user_by_id($user['id'], true, '*'); |
@@ -101,15 +101,15 @@ discard block |
||
101 | 101 | // $user = $global_data['user']; |
102 | 102 | // $planetrow = $global_data['planet']; |
103 | 103 | |
104 | - if($planetrow['planet_type'] != PT_PLANET) { |
|
104 | + if ($planetrow['planet_type'] != PT_PLANET) { |
|
105 | 105 | throw new exception(classLocale::$lang['ov_capital_err_not_a_planet'], ERR_ERROR); |
106 | 106 | } |
107 | 107 | |
108 | - if($planetrow['id'] == $user['id_planet']) { |
|
108 | + if ($planetrow['id'] == $user['id_planet']) { |
|
109 | 109 | throw new exception(classLocale::$lang['ov_capital_err_capital_already'], ERR_ERROR); |
110 | 110 | } |
111 | 111 | |
112 | - if($user_dark_matter < classSupernova::$config->planet_capital_cost) { |
|
112 | + if ($user_dark_matter < classSupernova::$config->planet_capital_cost) { |
|
113 | 113 | throw new exception(classLocale::$lang['ov_capital_err_no_dark_matter'], ERR_ERROR); |
114 | 114 | } |
115 | 115 | |
@@ -126,16 +126,16 @@ discard block |
||
126 | 126 | ); |
127 | 127 | sn_db_transaction_commit(); |
128 | 128 | sys_redirect('overview.php?mode=manage'); |
129 | - } catch(exception $e) { |
|
129 | + } catch (exception $e) { |
|
130 | 130 | sn_db_transaction_rollback(); |
131 | 131 | $result[] = array( |
132 | 132 | 'STATUS' => $e->getCode(), |
133 | 133 | 'MESSAGE' => $e->getMessage(), |
134 | 134 | ); |
135 | 135 | } |
136 | - } elseif(sys_get_param_str('action') == 'planet_teleport') { |
|
136 | + } elseif (sys_get_param_str('action') == 'planet_teleport') { |
|
137 | 137 | try { |
138 | - if(!uni_coordinates_valid($new_coordinates = array( |
|
138 | + if (!uni_coordinates_valid($new_coordinates = array( |
|
139 | 139 | 'galaxy' => sys_get_param_int('new_galaxy'), |
140 | 140 | 'system' => sys_get_param_int('new_system'), |
141 | 141 | 'planet' => sys_get_param_int('new_planet'))) |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | // $planetrow = $global_data['planet']; |
153 | 153 | |
154 | 154 | $can_teleport = uni_planet_teleport_check($user, $planetrow, $new_coordinates); |
155 | - if($can_teleport['result'] != ERR_NONE) { |
|
155 | + if ($can_teleport['result'] != ERR_NONE) { |
|
156 | 156 | throw new exception($can_teleport['message'], $can_teleport['result']); |
157 | 157 | } |
158 | 158 | |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | db_planet_set_by_gspt($planetrow['galaxy'], $planetrow['system'], $planetrow['planet'], PT_ALL, |
164 | 164 | "galaxy = {$new_coordinates['galaxy']}, system = {$new_coordinates['system']}, planet = {$new_coordinates['planet']}, planet_teleport_next = {$planet_teleport_next}"); |
165 | 165 | |
166 | - if($planetrow['id'] == $user['id_planet']) { |
|
166 | + if ($planetrow['id'] == $user['id_planet']) { |
|
167 | 167 | db_user_set_by_id($user['id'], "galaxy = {$new_coordinates['galaxy']}, system = {$new_coordinates['system']}, planet = {$new_coordinates['planet']}"); |
168 | 168 | } |
169 | 169 | |
@@ -176,17 +176,17 @@ discard block |
||
176 | 176 | 'MESSAGE' => classLocale::$lang['ov_teleport_err_none'], |
177 | 177 | ); |
178 | 178 | sys_redirect('overview.php?mode=manage'); |
179 | - } catch(exception $e) { |
|
179 | + } catch (exception $e) { |
|
180 | 180 | sn_db_transaction_rollback(); |
181 | 181 | $result[] = array( |
182 | 182 | 'STATUS' => $e->getCode(), |
183 | 183 | 'MESSAGE' => $e->getMessage(), |
184 | 184 | ); |
185 | 185 | } |
186 | - } elseif(sys_get_param_str('action') == 'planet_abandon') { |
|
186 | + } elseif (sys_get_param_str('action') == 'planet_abandon') { |
|
187 | 187 | // if(sec_password_check($user['id'], sys_get_param('abandon_confirm'))) { |
188 | - if(classSupernova::$auth->password_check(sys_get_param('abandon_confirm'))) { |
|
189 | - if($user['id_planet'] != $user['current_planet'] && $user['current_planet'] == $planet_id) { |
|
188 | + if (classSupernova::$auth->password_check(sys_get_param('abandon_confirm'))) { |
|
189 | + if ($user['id_planet'] != $user['current_planet'] && $user['current_planet'] == $planet_id) { |
|
190 | 190 | $destroyed = SN_TIME_NOW + 60 * 60 * 24; |
191 | 191 | db_planet_set_by_id($user['current_planet'], "`destruyed`='{$destroyed}', `id_owner`=0"); |
192 | 192 | db_planet_set_by_parent($user['current_planet'], "`destruyed`='{$destroyed}', `id_owner`=0"); |
@@ -196,9 +196,9 @@ discard block |
||
196 | 196 | message(classLocale::$lang['ov_delete_wrong_planet'], classLocale::$lang['colony_abandon'], 'overview.php?mode=manage'); |
197 | 197 | } |
198 | 198 | } else { |
199 | - message(classLocale::$lang['ov_delete_wrong_pass'] , classLocale::$lang['colony_abandon'], 'overview.php?mode=manage'); |
|
199 | + message(classLocale::$lang['ov_delete_wrong_pass'], classLocale::$lang['colony_abandon'], 'overview.php?mode=manage'); |
|
200 | 200 | } |
201 | - } elseif( |
|
201 | + } elseif ( |
|
202 | 202 | ($hire = sys_get_param_int('hire')) && in_array($hire, sn_get_groups('governors')) |
203 | 203 | && ( |
204 | 204 | !get_unit_param($hire, P_MAX_STACK) || |
@@ -213,8 +213,8 @@ discard block |
||
213 | 213 | $user = db_user_by_id($user['id'], true); |
214 | 214 | $planetrow = db_planet_by_id($planetrow['id'], true); |
215 | 215 | $build_data = eco_get_build_data($user, $planetrow, $hire, $planetrow['PLANET_GOVERNOR_ID'] == $hire ? $planetrow['PLANET_GOVERNOR_LEVEL'] : 0); |
216 | - if($build_data['CAN'][BUILD_CREATE]) { |
|
217 | - if($planetrow['PLANET_GOVERNOR_ID'] == $hire) { |
|
216 | + if ($build_data['CAN'][BUILD_CREATE]) { |
|
217 | + if ($planetrow['PLANET_GOVERNOR_ID'] == $hire) { |
|
218 | 218 | $planetrow['PLANET_GOVERNOR_LEVEL']++; |
219 | 219 | $query = '`PLANET_GOVERNOR_LEVEL` + 1'; |
220 | 220 | } else { |
@@ -240,8 +240,8 @@ discard block |
||
240 | 240 | |
241 | 241 | lng_include('mrc_mercenary'); |
242 | 242 | int_planet_pretemplate($planetrow, $template); |
243 | - foreach(sn_get_groups('governors') as $governor_id) { |
|
244 | - if($planetrow['planet_type'] == PT_MOON && $governor_id == MRC_TECHNOLOGIST) { |
|
243 | + foreach (sn_get_groups('governors') as $governor_id) { |
|
244 | + if ($planetrow['planet_type'] == PT_MOON && $governor_id == MRC_TECHNOLOGIST) { |
|
245 | 245 | continue; |
246 | 246 | } |
247 | 247 | |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | 'PAGE_HINT' => classLocale::$lang['ov_manage_page_hint'], |
294 | 294 | )); |
295 | 295 | |
296 | - foreach($result as &$a_result) { |
|
296 | + foreach ($result as &$a_result) { |
|
297 | 297 | $template->assign_block_vars('result', $a_result); |
298 | 298 | } |
299 | 299 | |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | default: |
304 | 304 | sn_sys_sector_buy(); |
305 | 305 | |
306 | - if(sys_get_param_str('rename') && $new_name = sys_get_param_str('new_name')) { |
|
306 | + if (sys_get_param_str('rename') && $new_name = sys_get_param_str('new_name')) { |
|
307 | 307 | $planetrow['name'] = $new_name; |
308 | 308 | $new_name_safe = db_escape($new_name); |
309 | 309 | db_planet_set_by_id($planetrow['id'], "`name` = '{$new_name_safe}'"); |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | |
334 | 334 | $planet_count = 0; |
335 | 335 | $planets_query = db_planet_list_sorted($user, false, '*'); |
336 | - foreach($planets_query as $an_id => $UserPlanet) { |
|
336 | + foreach ($planets_query as $an_id => $UserPlanet) { |
|
337 | 337 | sn_db_transaction_start(); |
338 | 338 | $UserPlanet = sys_o_get_updated($user, $UserPlanet['id'], SN_TIME_NOW, false, true); |
339 | 339 | sn_db_transaction_commit(); |
@@ -344,16 +344,16 @@ discard block |
||
344 | 344 | |
345 | 345 | $planet_fleet_id = 0; |
346 | 346 | $fleet_list = $template_planet['fleet_list']; |
347 | - if($fleet_list['own']['count']) { |
|
347 | + if ($fleet_list['own']['count']) { |
|
348 | 348 | $planet_fleet_id = "p{$UserPlanet['id']}"; |
349 | 349 | $fleets_to_planet[$UserPlanet['id']] = tpl_parse_fleet_sn($fleet_list['own']['total'], $planet_fleet_id); |
350 | 350 | // $fleet_id++;tpl_parse_fleet_sn |
351 | 351 | } |
352 | - if($UserPlanet['planet_type'] == PT_MOON) { |
|
352 | + if ($UserPlanet['planet_type'] == PT_MOON) { |
|
353 | 353 | continue; |
354 | 354 | } |
355 | 355 | $moon = db_planet_by_parent($UserPlanet['id']); |
356 | - if($moon) { |
|
356 | + if ($moon) { |
|
357 | 357 | $moon_fill = min(100, floor($moon['field_current'] / eco_planet_fields_max($moon) * 100)); |
358 | 358 | } else { |
359 | 359 | $moon_fill = 0; |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | tpl_assign_fleet($template, $fleets); |
394 | 394 | |
395 | 395 | $lune = $planetrow['planet_type'] == PT_PLANET ? db_planet_by_parent($planetrow['id']) : db_planet_by_id($planetrow['parent_planet']); |
396 | - if($lune) { |
|
396 | + if ($lune) { |
|
397 | 397 | $template->assign_vars(array( |
398 | 398 | 'MOON_ID' => $lune['id'], |
399 | 399 | 'MOON_IMG' => $lune['image'], |
@@ -405,15 +405,15 @@ discard block |
||
405 | 405 | $planet_fill = $planet_fill > 100 ? 100 : $planet_fill; |
406 | 406 | |
407 | 407 | $planet_recyclers_orbiting = 0; |
408 | - foreach(sn_get_groups('flt_recyclers') as $recycler_id) { |
|
408 | + foreach (sn_get_groups('flt_recyclers') as $recycler_id) { |
|
409 | 409 | $planet_recyclers_orbiting += mrc_get_level($user, $planetrow, $recycler_id); |
410 | 410 | } |
411 | 411 | |
412 | 412 | int_planet_pretemplate($planetrow, $template); |
413 | 413 | |
414 | 414 | $sn_group_ques = sn_get_groups('ques'); |
415 | - if(!defined('GAME_STRUCTURES_DISABLED') || !GAME_STRUCTURES_DISABLED) { |
|
416 | - foreach(array(QUE_STRUCTURES => $sn_group_ques[QUE_STRUCTURES]) as $que_id => $que_type_data) { |
|
415 | + if (!defined('GAME_STRUCTURES_DISABLED') || !GAME_STRUCTURES_DISABLED) { |
|
416 | + foreach (array(QUE_STRUCTURES => $sn_group_ques[QUE_STRUCTURES]) as $que_id => $que_type_data) { |
|
417 | 417 | $this_que = $que['ques'][$que_id][$user['id']][$planetrow['id']]; |
418 | 418 | $template->assign_block_vars('ques', array( |
419 | 419 | 'ID' => $que_id, |
@@ -421,8 +421,8 @@ discard block |
||
421 | 421 | 'LENGTH' => empty($this_que) ? 0 : count($this_que), |
422 | 422 | )); |
423 | 423 | |
424 | - if(!empty($this_que)) { |
|
425 | - foreach($this_que as $que_item) { |
|
424 | + if (!empty($this_que)) { |
|
425 | + foreach ($this_que as $que_item) { |
|
426 | 426 | $template->assign_block_vars('que', que_tpl_parse_element($que_item)); |
427 | 427 | } |
428 | 428 | } |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | 'LENGTH' => $que_hangar_length, |
437 | 437 | )); |
438 | 438 | |
439 | - if(!defined('GAME_DEFENSE_DISABLED') || !GAME_DEFENSE_DISABLED) { |
|
439 | + if (!defined('GAME_DEFENSE_DISABLED') || !GAME_DEFENSE_DISABLED) { |
|
440 | 440 | $que_hangar_length = tpl_assign_hangar($template, $planetrow, SUBQUE_DEFENSE); |
441 | 441 | $template->assign_block_vars('ques', array( |
442 | 442 | 'ID' => SUBQUE_DEFENSE, |
@@ -448,12 +448,12 @@ discard block |
||
448 | 448 | $overview_planet_rows = $user['opt_int_overview_planet_rows']; |
449 | 449 | $overview_planet_columns = $user['opt_int_overview_planet_columns']; |
450 | 450 | |
451 | - if($overview_planet_rows <= 0 && $overview_planet_columns <= 0) { |
|
451 | + if ($overview_planet_rows <= 0 && $overview_planet_columns <= 0) { |
|
452 | 452 | $overview_planet_rows = $user_option_list[OPT_INTERFACE]['opt_int_overview_planet_rows']; |
453 | 453 | $overview_planet_columns = $user_option_list[OPT_INTERFACE]['opt_int_overview_planet_columns']; |
454 | 454 | } |
455 | 455 | |
456 | - if($overview_planet_rows > 0 && $overview_planet_columns <= 0) { |
|
456 | + if ($overview_planet_rows > 0 && $overview_planet_columns <= 0) { |
|
457 | 457 | $overview_planet_columns = ceil($planet_count / $overview_planet_rows); |
458 | 458 | } |
459 | 459 | |
@@ -510,7 +510,7 @@ discard block |
||
510 | 510 | )); |
511 | 511 | tpl_set_resource_info($template, $planetrow, $fleets_to_planet, 2); |
512 | 512 | |
513 | - foreach($result as &$a_result) { |
|
513 | + foreach ($result as &$a_result) { |
|
514 | 514 | $template->assign_block_vars('result', $a_result); |
515 | 515 | } |
516 | 516 |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | 'shield' => 10, |
36 | 36 | 'armor' => 400, |
37 | 37 | 'attack' => 5, |
38 | - 'amplify' => array(SHIP_SPY => 100, SHIP_SATTELITE_SOLAR => 250, ), |
|
38 | + 'amplify' => array(SHIP_SPY => 100, SHIP_SATTELITE_SOLAR => 250,), |
|
39 | 39 | ), |
40 | 40 | SHIP_CARGO_BIG => array( |
41 | 41 | 'name' => 'big_ship_cargo', |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | 'shield' => 25, |
56 | 56 | 'armor' => 1200, |
57 | 57 | 'attack' => 5, |
58 | - 'amplify' => array(SHIP_SPY => 100, SHIP_SATTELITE_SOLAR => 250, ), |
|
58 | + 'amplify' => array(SHIP_SPY => 100, SHIP_SATTELITE_SOLAR => 250,), |
|
59 | 59 | 'engine' => array( |
60 | 60 | array( |
61 | 61 | 'tech' => TECH_ENGINE_CHEMICAL, |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | 'shield' => 50, |
84 | 84 | 'armor' => 3000, |
85 | 85 | 'attack' => 10, |
86 | - 'amplify' => array(SHIP_SPY => 100, SHIP_SATTELITE_SOLAR => 250, ), |
|
86 | + 'amplify' => array(SHIP_SPY => 100, SHIP_SATTELITE_SOLAR => 250,), |
|
87 | 87 | 'engine' => array( |
88 | 88 | array( |
89 | 89 | 'tech' => TECH_ENGINE_ION, |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | 'shield' => 200, |
112 | 112 | 'armor' => 70000, |
113 | 113 | 'attack' => 50, |
114 | - 'amplify' => array(SHIP_SPY => 100, SHIP_SATTELITE_SOLAR => 250, ), |
|
114 | + 'amplify' => array(SHIP_SPY => 100, SHIP_SATTELITE_SOLAR => 250,), |
|
115 | 115 | 'engine' => array( |
116 | 116 | array( |
117 | 117 | 'tech' => TECH_ENGINE_HYPER, |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | 'shield' => 100, |
141 | 141 | 'armor' => 3000, |
142 | 142 | 'attack' => 50, |
143 | - 'amplify' => array(SHIP_SPY => 10.001, SHIP_SATTELITE_SOLAR => 21, ), |
|
143 | + 'amplify' => array(SHIP_SPY => 10.001, SHIP_SATTELITE_SOLAR => 21,), |
|
144 | 144 | 'engine' => array( |
145 | 145 | array( |
146 | 146 | 'tech' => TECH_ENGINE_ION, |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | 'shield' => 10, |
169 | 169 | 'armor' => 1600, |
170 | 170 | 'attack' => 1, |
171 | - 'amplify' => array(SHIP_SPY => 500.05, SHIP_SATTELITE_SOLAR => 1050, ), |
|
171 | + 'amplify' => array(SHIP_SPY => 500.05, SHIP_SATTELITE_SOLAR => 1050,), |
|
172 | 172 | 'engine' => array( |
173 | 173 | array( |
174 | 174 | 'tech' => TECH_ENGINE_CHEMICAL, |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | 'shield' => 0.01, |
197 | 197 | 'armor' => 100, |
198 | 198 | 'attack' => 0.01, |
199 | - 'amplify' => array( SHIP_SPY => 1,), |
|
199 | + 'amplify' => array(SHIP_SPY => 1,), |
|
200 | 200 | 'engine' => array( |
201 | 201 | array( |
202 | 202 | 'tech' => TECH_ENGINE_CHEMICAL, |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | 'factor' => 1, |
221 | 221 | ), |
222 | 222 | P_UNIT_PRODUCTION => array( |
223 | - RES_ENERGY => function($level, $production_factor, $user, $planet_row) {return ($planet_row["temp_max"] / 4 + 20) * $level * (0.1 * $production_factor);}, |
|
223 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) {return ($planet_row["temp_max"] / 4 + 20) * $level * (0.1 * $production_factor); }, |
|
224 | 224 | ), |
225 | 225 | P_MINING_IS_MANAGED => true, |
226 | 226 | |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | 'shield' => 10, |
230 | 230 | 'armor' => 200, |
231 | 231 | 'attack' => 1, |
232 | - 'amplify' => array(SHIP_SPY => 1, ), |
|
232 | + 'amplify' => array(SHIP_SPY => 1,), |
|
233 | 233 | 'engine' => array( |
234 | 234 | array( |
235 | 235 | 'tech' => TECH_ENGINE_CHEMICAL, |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | 'shield' => 10, |
262 | 262 | 'armor' => 400, |
263 | 263 | 'attack' => 50, |
264 | - 'amplify' => array(SHIP_CARGO_SMALL => 16.4, SHIP_SPY => 10.001, SHIP_SATTELITE_SOLAR => 21, ), |
|
264 | + 'amplify' => array(SHIP_CARGO_SMALL => 16.4, SHIP_SPY => 10.001, SHIP_SATTELITE_SOLAR => 21,), |
|
265 | 265 | 'engine' => array( |
266 | 266 | array( |
267 | 267 | 'tech' => TECH_ENGINE_CHEMICAL, |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | 'shield' => 25, |
291 | 291 | 'armor' => 1000, |
292 | 292 | 'attack' => 150, |
293 | - 'amplify' => array(SHIP_CARGO_SMALL => 8.2, SHIP_SPY => 3.33367, SHIP_SATTELITE_SOLAR => 7, ), |
|
293 | + 'amplify' => array(SHIP_CARGO_SMALL => 8.2, SHIP_SPY => 3.33367, SHIP_SATTELITE_SOLAR => 7,), |
|
294 | 294 | 'engine' => array( |
295 | 295 | array( |
296 | 296 | 'tech' => TECH_ENGINE_ION, |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | 'shield' => 50, |
350 | 350 | 'armor' => 2700, |
351 | 351 | 'attack' => 400, |
352 | - 'amplify' => array(SHIP_SMALL_FIGHTER_LIGHT => 6.15, SHIP_SPY => 1.25013, SHIP_SATTELITE_SOLAR => 2.625, UNIT_DEF_TURRET_MISSILE => 5.5, ), |
|
352 | + 'amplify' => array(SHIP_SMALL_FIGHTER_LIGHT => 6.15, SHIP_SPY => 1.25013, SHIP_SATTELITE_SOLAR => 2.625, UNIT_DEF_TURRET_MISSILE => 5.5,), |
|
353 | 353 | 'engine' => array( |
354 | 354 | array( |
355 | 355 | 'tech' => TECH_ENGINE_ION, |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | 'shield' => 200, |
409 | 409 | 'armor' => 6000, |
410 | 410 | 'attack' => 1000, |
411 | - 'amplify' => array(SHIP_SPY => 0.50005, SHIP_SATTELITE_SOLAR => 1.05, UNIT_DEF_TURRET_MISSILE => 1.76, ), |
|
411 | + 'amplify' => array(SHIP_SPY => 0.50005, SHIP_SATTELITE_SOLAR => 1.05, UNIT_DEF_TURRET_MISSILE => 1.76,), |
|
412 | 412 | 'engine' => array( |
413 | 413 | array( |
414 | 414 | 'tech' => TECH_ENGINE_HYPER, |
@@ -504,7 +504,7 @@ discard block |
||
504 | 504 | 'shield' => 500, |
505 | 505 | 'armor' => 11000, |
506 | 506 | 'attack' => 2000, |
507 | - 'amplify' => array(SHIP_SPY => 0.25003, SHIP_SATTELITE_SOLAR => 0.525, SHIP_LARGE_BATTLESHIP => 7.4, UNIT_DEF_TURRET_LASER_SMALL => 1.125, ), |
|
507 | + 'amplify' => array(SHIP_SPY => 0.25003, SHIP_SATTELITE_SOLAR => 0.525, SHIP_LARGE_BATTLESHIP => 7.4, UNIT_DEF_TURRET_LASER_SMALL => 1.125,), |
|
508 | 508 | 'engine' => array( |
509 | 509 | array( |
510 | 510 | 'tech' => TECH_ENGINE_HYPER, |
@@ -608,7 +608,7 @@ discard block |
||
608 | 608 | 'shield' => 20, |
609 | 609 | 'armor' => 200, |
610 | 610 | 'attack' => 80, |
611 | - 'amplify' => array(SHIP_SPY => 7, ), |
|
611 | + 'amplify' => array(SHIP_SPY => 7,), |
|
612 | 612 | ), |
613 | 613 | UNIT_DEF_TURRET_LASER_SMALL => array( |
614 | 614 | 'name' => 'small_laser', |
@@ -626,7 +626,7 @@ discard block |
||
626 | 626 | 'shield' => 25, |
627 | 627 | 'armor' => 200, |
628 | 628 | 'attack' => 100, |
629 | - 'amplify' => array(SHIP_SPY => 5, ), |
|
629 | + 'amplify' => array(SHIP_SPY => 5,), |
|
630 | 630 | ), |
631 | 631 | UNIT_DEF_TURRET_LASER_BIG => array( |
632 | 632 | 'name' => 'big_laser', |
@@ -644,7 +644,7 @@ discard block |
||
644 | 644 | 'shield' => 100, |
645 | 645 | 'armor' => 800, |
646 | 646 | 'attack' => 250, |
647 | - 'amplify' => array(SHIP_SPY => 2, ), |
|
647 | + 'amplify' => array(SHIP_SPY => 2,), |
|
648 | 648 | ), |
649 | 649 | UNIT_DEF_TURRET_GAUSS => array( |
650 | 650 | 'name' => 'gauss_canyon', |
@@ -662,7 +662,7 @@ discard block |
||
662 | 662 | 'armor' => 3500, |
663 | 663 | 'shield' => 200, |
664 | 664 | 'attack' => 1100, |
665 | - 'amplify' => array(SHIP_SPY => 0.5, ), |
|
665 | + 'amplify' => array(SHIP_SPY => 0.5,), |
|
666 | 666 | ), |
667 | 667 | UNIT_DEF_TURRET_ION => array( |
668 | 668 | 'name' => 'ionic_canyon', |
@@ -680,7 +680,7 @@ discard block |
||
680 | 680 | 'shield' => 500, |
681 | 681 | 'armor' => 800, |
682 | 682 | 'attack' => 150, |
683 | - 'amplify' => array(SHIP_SPY => 3.3, ), |
|
683 | + 'amplify' => array(SHIP_SPY => 3.3,), |
|
684 | 684 | ), |
685 | 685 | UNIT_DEF_TURRET_PLASMA => array( |
686 | 686 | 'name' => 'buster_canyon', |
@@ -698,7 +698,7 @@ discard block |
||
698 | 698 | 'shield' => 300, |
699 | 699 | 'armor' => 10000, |
700 | 700 | 'attack' => 3000, |
701 | - 'amplify' => array(SHIP_SPY => 0.17, ), |
|
701 | + 'amplify' => array(SHIP_SPY => 0.17,), |
|
702 | 702 | ), |
703 | 703 | |
704 | 704 | UNIT_DEF_SHIELD_SMALL => array( |
@@ -718,7 +718,7 @@ discard block |
||
718 | 718 | 'shield' => 2000, |
719 | 719 | 'armor' => 2000, |
720 | 720 | 'attack' => 1, |
721 | - 'amplify' => array(SHIP_SPY => 500, ), |
|
721 | + 'amplify' => array(SHIP_SPY => 500,), |
|
722 | 722 | ), |
723 | 723 | UNIT_DEF_SHIELD_BIG => array( |
724 | 724 | 'name' => 'big_protection_shield', |
@@ -737,7 +737,7 @@ discard block |
||
737 | 737 | 'shield' => 2000, |
738 | 738 | 'armor' => 10000, |
739 | 739 | 'attack' => 1, |
740 | - 'amplify' => array(SHIP_SPY => 500, ), |
|
740 | + 'amplify' => array(SHIP_SPY => 500,), |
|
741 | 741 | ), |
742 | 742 | UNIT_DEF_SHIELD_PLANET => array( |
743 | 743 | 'name' => 'planet_protector', |
@@ -239,6 +239,9 @@ |
||
239 | 239 | } |
240 | 240 | } |
241 | 241 | |
242 | + /** |
|
243 | + * @param string $arrayName |
|
244 | + */ |
|
242 | 245 | protected function mergeArraySpecial($arrayName) { |
243 | 246 | global $sn_mvc; |
244 | 247 |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | require SN_ROOT_PHYSICAL . 'config.php'; |
77 | 77 | |
78 | 78 | $module_config_array = get_class($this) . '_config'; |
79 | - if(!empty($$module_config_array) && is_array($$module_config_array)) { |
|
79 | + if (!empty($$module_config_array) && is_array($$module_config_array)) { |
|
80 | 80 | $this->config = $$module_config_array; |
81 | 81 | |
82 | 82 | return true; |
@@ -94,15 +94,15 @@ discard block |
||
94 | 94 | |
95 | 95 | // TODO: Load configuration from DB. Manifest setting |
96 | 96 | // Trying to load configuration from file |
97 | - if(!$config_exists = $this->loadModuleRootConfig()) { |
|
97 | + if (!$config_exists = $this->loadModuleRootConfig()) { |
|
98 | 98 | // Конфигурация может лежать в config_path в манифеста или в корне модуля |
99 | - if(isset($this->manifest['config_path']) && file_exists($config_filename = $this->manifest['config_path'] . '/config.php')) { |
|
99 | + if (isset($this->manifest['config_path']) && file_exists($config_filename = $this->manifest['config_path'] . '/config.php')) { |
|
100 | 100 | $config_exists = true; |
101 | - } elseif(file_exists($config_filename = dirname($filename) . '/config.php')) { |
|
101 | + } elseif (file_exists($config_filename = dirname($filename) . '/config.php')) { |
|
102 | 102 | $config_exists = true; |
103 | 103 | } |
104 | 104 | |
105 | - if($config_exists) { |
|
105 | + if ($config_exists) { |
|
106 | 106 | include($config_filename); |
107 | 107 | $module_config_array = $class_module_name . '_config'; |
108 | 108 | $this->config = $$module_config_array; |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | |
120 | 120 | // Checking module status - is it installed and active |
121 | 121 | $this->check_status(); |
122 | - if(!$this->manifest['active']) { |
|
122 | + if (!$this->manifest['active']) { |
|
123 | 123 | return; |
124 | 124 | } |
125 | 125 | |
@@ -139,11 +139,11 @@ discard block |
||
139 | 139 | |
140 | 140 | protected function setSystemConstants() { |
141 | 141 | // Setting constants - if any |
142 | - if(empty($this->manifest['constants']) || !is_array($this->manifest['constants'])) { |
|
142 | + if (empty($this->manifest['constants']) || !is_array($this->manifest['constants'])) { |
|
143 | 143 | return; |
144 | 144 | } |
145 | 145 | |
146 | - foreach($this->manifest['constants'] as $constant_name => $constant_value) { |
|
146 | + foreach ($this->manifest['constants'] as $constant_name => $constant_value) { |
|
147 | 147 | defined($constant_name) || define($constant_name, $constant_value); |
148 | 148 | } |
149 | 149 | } |
@@ -155,48 +155,48 @@ discard block |
||
155 | 155 | // New values from module variables will overwrite previous values (for root variables) and array elements with corresponding indexes (for arrays) |
156 | 156 | // Constants as array indexes are honored - it's make valid such declarations as 'sn_data[ques][QUE_STRUCTURES]' |
157 | 157 | $this->manifest['vars'] = $this->__assign_vars(); |
158 | - if(empty($this->manifest['vars']) || !is_array($this->manifest['vars'])) { |
|
158 | + if (empty($this->manifest['vars']) || !is_array($this->manifest['vars'])) { |
|
159 | 159 | return; |
160 | 160 | } |
161 | 161 | |
162 | 162 | $vars_assigned = array(); |
163 | - foreach($this->manifest['vars'] as $var_name => $var_value) { |
|
163 | + foreach ($this->manifest['vars'] as $var_name => $var_value) { |
|
164 | 164 | $sub_vars = explode('[', str_replace(']', '', $var_name)); |
165 | 165 | $var_name = $sub_vars[0]; |
166 | 166 | |
167 | - if(!isset($vars_assigned[$var_name])) { |
|
167 | + if (!isset($vars_assigned[$var_name])) { |
|
168 | 168 | $vars_assigned[$var_name] = true; |
169 | 169 | global $$var_name; |
170 | 170 | } |
171 | 171 | |
172 | 172 | $pointer = &$$var_name; |
173 | - if(($n = count($sub_vars)) > 1) { |
|
174 | - for($i = 1; $i < $n; $i++) { |
|
175 | - if(defined($sub_vars[$i])) { |
|
173 | + if (($n = count($sub_vars)) > 1) { |
|
174 | + for ($i = 1; $i < $n; $i++) { |
|
175 | + if (defined($sub_vars[$i])) { |
|
176 | 176 | $sub_vars[$i] = constant($sub_vars[$i]); |
177 | 177 | } |
178 | 178 | |
179 | - if(!isset($pointer[$sub_vars[$i]]) && $i != $n) { |
|
179 | + if (!isset($pointer[$sub_vars[$i]]) && $i != $n) { |
|
180 | 180 | $pointer[$sub_vars[$i]] = array(); |
181 | 181 | } |
182 | 182 | $pointer = &$pointer[$sub_vars[$i]]; |
183 | 183 | } |
184 | 184 | } |
185 | 185 | |
186 | - if(!isset($pointer) || !is_array($pointer)) { |
|
186 | + if (!isset($pointer) || !is_array($pointer)) { |
|
187 | 187 | $pointer = $var_value; |
188 | - } elseif(is_array($$var_name)) { |
|
188 | + } elseif (is_array($$var_name)) { |
|
189 | 189 | $pointer = array_merge_recursive_numeric($pointer, $var_value); |
190 | 190 | } |
191 | 191 | } |
192 | 192 | } |
193 | 193 | |
194 | 194 | protected function mergeMenu(&$sn_menu_extra, &$menu_patch) { |
195 | - if(!is_array($menu_patch)) { |
|
195 | + if (!is_array($menu_patch)) { |
|
196 | 196 | return; |
197 | 197 | } |
198 | 198 | |
199 | - foreach($menu_patch as $menu_item_name => $menu_item_data) { |
|
199 | + foreach ($menu_patch as $menu_item_name => $menu_item_data) { |
|
200 | 200 | $sn_menu_extra[$menu_item_name] = $menu_item_data; |
201 | 201 | } |
202 | 202 | } |
@@ -205,34 +205,34 @@ discard block |
||
205 | 205 | // Overriding function if any |
206 | 206 | sn_sys_handler_add(classSupernova::$functions, $this->manifest['functions'], $this); |
207 | 207 | |
208 | - foreach(classSupernova::$sn_mvc as $handler_type => &$handler_data) { |
|
208 | + foreach (classSupernova::$sn_mvc as $handler_type => &$handler_data) { |
|
209 | 209 | sn_sys_handler_add($handler_data, $this->manifest['mvc'][$handler_type], $this, $handler_type); |
210 | 210 | } |
211 | 211 | } |
212 | 212 | |
213 | 213 | protected function mergeNavbarButton() { |
214 | - if(empty($this->manifest['navbar_prefix_button']) || !is_array($this->manifest['navbar_prefix_button'])) { |
|
214 | + if (empty($this->manifest['navbar_prefix_button']) || !is_array($this->manifest['navbar_prefix_button'])) { |
|
215 | 215 | return; |
216 | 216 | } |
217 | 217 | |
218 | - foreach($this->manifest['navbar_prefix_button'] as $button_image => $button_url_relative) { |
|
218 | + foreach ($this->manifest['navbar_prefix_button'] as $button_image => $button_url_relative) { |
|
219 | 219 | classSupernova::$sn_mvc['navbar_prefix_button'][$button_image] = $button_url_relative; |
220 | 220 | } |
221 | 221 | } |
222 | 222 | |
223 | 223 | protected function mergeI18N() { |
224 | 224 | $arrayName = 'i18n'; |
225 | - if(empty($this->manifest[$arrayName]) || !is_array($this->manifest[$arrayName])) { |
|
225 | + if (empty($this->manifest[$arrayName]) || !is_array($this->manifest[$arrayName])) { |
|
226 | 226 | return; |
227 | 227 | } |
228 | 228 | |
229 | - foreach($this->manifest[$arrayName] as $pageName => &$contentList) { |
|
230 | - foreach($contentList as &$i18n_file_data) { |
|
231 | - if(is_array($i18n_file_data) && !$i18n_file_data['path']) { |
|
229 | + foreach ($this->manifest[$arrayName] as $pageName => &$contentList) { |
|
230 | + foreach ($contentList as &$i18n_file_data) { |
|
231 | + if (is_array($i18n_file_data) && !$i18n_file_data['path']) { |
|
232 | 232 | $i18n_file_data['path'] = $this->manifest['root_relative']; |
233 | 233 | } |
234 | 234 | } |
235 | - if(!isset(classSupernova::$sn_mvc[$arrayName][$pageName])) { |
|
235 | + if (!isset(classSupernova::$sn_mvc[$arrayName][$pageName])) { |
|
236 | 236 | classSupernova::$sn_mvc[$arrayName][$pageName] = array(); |
237 | 237 | } |
238 | 238 | classSupernova::$sn_mvc[$arrayName][$pageName] += $contentList; |
@@ -240,13 +240,13 @@ discard block |
||
240 | 240 | } |
241 | 241 | |
242 | 242 | protected function mergeArraySpecial($arrayName) { |
243 | - if(empty($this->manifest[$arrayName]) || !is_array($this->manifest[$arrayName])) { |
|
243 | + if (empty($this->manifest[$arrayName]) || !is_array($this->manifest[$arrayName])) { |
|
244 | 244 | return; |
245 | 245 | } |
246 | 246 | |
247 | - foreach($this->manifest[$arrayName] as $pageName => &$contentList) { |
|
247 | + foreach ($this->manifest[$arrayName] as $pageName => &$contentList) { |
|
248 | 248 | !isset(classSupernova::$sn_mvc[$arrayName][$pageName]) ? classSupernova::$sn_mvc[$arrayName][$pageName] = array() : false; |
249 | - foreach($contentList as $contentName => &$content) { |
|
249 | + foreach ($contentList as $contentName => &$content) { |
|
250 | 250 | classSupernova::$sn_mvc[$arrayName][$pageName][$contentName] = $content; |
251 | 251 | } |
252 | 252 | } |