Completed
Push — work-fleets ( 451000...e7900f )
by SuperNova.WS
06:16
created
fleet.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -7,9 +7,9 @@  discard block
 block discarded – undo
7 7
 
8 8
 // TODO - Переместить это куда-нибудь
9 9
 $fleet_page = sys_get_param_int('fleet_page', sys_get_param_int('mode'));
10
-if($fleet_ship_sort = sys_get_param_id('sort_elements') && $fleet_page == 0) {
10
+if ($fleet_ship_sort = sys_get_param_id('sort_elements') && $fleet_page == 0) {
11 11
   define('IN_AJAX', true);
12
-  if(!empty(classLocale::$lang['player_option_fleet_ship_sort'][$fleet_ship_sort])) {
12
+  if (!empty(classLocale::$lang['player_option_fleet_ship_sort'][$fleet_ship_sort])) {
13 13
     // player_save_option($user, PLAYER_OPTION_FLEET_SHIP_SORT, $fleet_ship_sort);
14 14
     // player_save_option($user, PLAYER_OPTION_FLEET_SHIP_SORT_INVERSE, sys_get_param_id('fleet_ship_sort_inverse', 0));
15 15
     classSupernova::$user_options[PLAYER_OPTION_FLEET_SHIP_SORT] = $fleet_ship_sort;
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 //}
73 73
 
74 74
 
75
-switch($fleet_page) {
75
+switch ($fleet_page) {
76 76
   case 3:
77 77
 
78 78
   case 2:
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 
91 91
 $objFleet5->fleetPage0Prepare();
92 92
 
93
-switch($fleet_page) {
93
+switch ($fleet_page) {
94 94
   case 1:
95 95
     $objFleet5->fleetPage1($planet_type);
96 96
   break;
Please login to merge, or discard this patch.
includes/classes/Fleet.php 1 patch
Spacing   +86 added lines, -87 removed lines patch added patch discarded remove patch
@@ -307,9 +307,9 @@  discard block
 block discarded – undo
307 307
   public function tplRenderAvailableShips($playerRow, $planetRow) {
308 308
     $record_index = 0;
309 309
     $ship_list = array();
310
-    foreach(sn_get_groups('fleet') as $n => $unit_id) {
310
+    foreach (sn_get_groups('fleet') as $n => $unit_id) {
311 311
       $unit_level = mrc_get_level($playerRow, $planetRow, $unit_id, false, true);
312
-      if($unit_level <= 0) {
312
+      if ($unit_level <= 0) {
313 313
         continue;
314 314
       }
315 315
       $ship_data = get_ship_data($unit_id, $playerRow);
@@ -337,8 +337,8 @@  discard block
 block discarded – undo
337 337
   public function tplSortShipList(&$ship_list) {
338 338
     $fleet_ship_sort = classSupernova::$user_options[PLAYER_OPTION_FLEET_SHIP_SORT];
339 339
     $fleet_ship_sort_inverse = classSupernova::$user_options[PLAYER_OPTION_FLEET_SHIP_SORT_INVERSE];
340
-    if($fleet_ship_sort || $fleet_ship_sort_inverse != PLAYER_OPTION_SORT_ORDER_PLAIN) {
341
-      switch($fleet_ship_sort) {
340
+    if ($fleet_ship_sort || $fleet_ship_sort_inverse != PLAYER_OPTION_SORT_ORDER_PLAIN) {
341
+      switch ($fleet_ship_sort) {
342 342
         case PLAYER_OPTION_SORT_NAME:
343 343
           $fleet_ship_sort_field = 'NAME';
344 344
         break;
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
         break;
357 357
       }
358 358
       $fleet_ship_sort_inverse_a = $fleet_ship_sort_inverse ? -1 : 1;
359
-      usort($ship_list, function ($a, $b) use ($fleet_ship_sort_field, $fleet_ship_sort_inverse_a) {
359
+      usort($ship_list, function($a, $b) use ($fleet_ship_sort_field, $fleet_ship_sort_inverse_a) {
360 360
         return $a[$fleet_ship_sort_field] < $b[$fleet_ship_sort_field] ? -1 * $fleet_ship_sort_inverse_a : (
361 361
         $a[$fleet_ship_sort_field] > $b[$fleet_ship_sort_field] ? 1 * $fleet_ship_sort_inverse_a : 0
362 362
         );
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
   public function dbInsert() {
379 379
     // WARNING! MISSION TIMES MUST BE SET WITH set_times() method!
380 380
     // TODO - more checks!
381
-    if(empty($this->_time_launch)) {
381
+    if (empty($this->_time_launch)) {
382 382
       die('Fleet time not set!');
383 383
     }
384 384
 
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
     // Записываем изменения в БД
588 588
     $this->dbSave();
589 589
 
590
-    if($this->_group_id) {
590
+    if ($this->_group_id) {
591 591
       // TODO: Make here to delete only one AKS - by adding aks_fleet_count to AKS table
592 592
       db_fleet_aks_purge();
593 593
     }
@@ -654,18 +654,18 @@  discard block
 block discarded – undo
654 654
    */
655 655
   // TODO - separate shipList and unitList
656 656
   public function unitsSetFromArray($unit_array) {
657
-    if(empty($unit_array) || !is_array($unit_array)) {
657
+    if (empty($unit_array) || !is_array($unit_array)) {
658 658
       return;
659 659
     }
660
-    foreach($unit_array as $unit_id => $unit_count) {
660
+    foreach ($unit_array as $unit_id => $unit_count) {
661 661
       $unit_count = floatval($unit_count);
662
-      if(!$unit_count) {
662
+      if (!$unit_count) {
663 663
         continue;
664 664
       }
665 665
 
666
-      if($this->isShip($unit_id)) {
666
+      if ($this->isShip($unit_id)) {
667 667
         $this->unitList->unitSetCount($unit_id, $unit_count);
668
-      } elseif($this->isResource($unit_id)) {
668
+      } elseif ($this->isResource($unit_id)) {
669 669
         $this->resource_list[$unit_id] = $unit_count;
670 670
       } else {
671 671
         throw new Exception('Trying to pass to fleet non-resource and non-ship ' . var_export($unit_array, true), ERR_ERROR);
@@ -694,7 +694,7 @@  discard block
 block discarded – undo
694 694
   public function parse_missile_db_row($missile_db_row) {
695 695
 //    $this->_reset();
696 696
 
697
-    if(empty($missile_db_row) || !is_array($missile_db_row)) {
697
+    if (empty($missile_db_row) || !is_array($missile_db_row)) {
698 698
       return;
699 699
     }
700 700
 
@@ -857,7 +857,7 @@  discard block
 block discarded – undo
857 857
   public function shipsGetCapacityRecyclers(array $recycler_info) {
858 858
     $recyclers_incoming_capacity = 0;
859 859
     $fleet_data = $this->shipsGetArray();
860
-    foreach($recycler_info as $recycler_id => $recycler_data) {
860
+    foreach ($recycler_info as $recycler_id => $recycler_data) {
861 861
       $recyclers_incoming_capacity += $fleet_data[$recycler_id] * $recycler_data['capacity'];
862 862
     }
863 863
 
@@ -877,7 +877,7 @@  discard block
 block discarded – undo
877 877
     sn_db_transaction_check(true);
878 878
 
879 879
     // Если флот уже обработан - не существует или возращается - тогда ничего не делаем
880
-    if($this->isEmpty()) {
880
+    if ($this->isEmpty()) {
881 881
       return $result;
882 882
     }
883 883
 
@@ -899,18 +899,18 @@  discard block
 block discarded – undo
899 899
     // TODO - Проверка, что планета всё еще существует на указанных координатах, а не телепортировалась, не удалена хозяином, не уничтожена врагом
900 900
     // Флот, который возвращается на захваченную планету, пропадает
901 901
     // Ship landing is possible only to fleet owner's planet
902
-    if($this->getPlayerOwnerId() == $planet_arrival['id_owner']) {
902
+    if ($this->getPlayerOwnerId() == $planet_arrival['id_owner']) {
903 903
       $db_changeset = array();
904 904
 
905 905
       $fleet_array = $this->shipsGetArray();
906
-      foreach($fleet_array as $ship_id => $ship_count) {
907
-        if($ship_count) {
906
+      foreach ($fleet_array as $ship_id => $ship_count) {
907
+        if ($ship_count) {
908 908
           $db_changeset['unit'][] = sn_db_unit_changeset_prepare($ship_id, $ship_count, $user, $planet_arrival['id']);
909 909
         }
910 910
       }
911 911
 
912 912
       // Adjusting ship amount on planet
913
-      if(!empty($db_changeset)) {
913
+      if (!empty($db_changeset)) {
914 914
         db_changeset_apply($db_changeset);
915 915
       }
916 916
 
@@ -958,7 +958,7 @@  discard block
 block discarded – undo
958 958
    * @param array $resource_list
959 959
    */
960 960
   public function resourcesSet($resource_list) {
961
-    if(!empty($this->propertiesAdjusted['resource_list'])) {
961
+    if (!empty($this->propertiesAdjusted['resource_list'])) {
962 962
       throw new PropertyAccessException('Property "resource_list" already was adjusted so no SET is possible until dbSave in ' . get_called_class() . '::unitSetResourceList', ERR_ERROR);
963 963
     }
964 964
     $this->resourcesAdjust($resource_list, true);
@@ -972,13 +972,13 @@  discard block
 block discarded – undo
972 972
   public function resourcesAdjust($resource_delta_list, $replace_value = false) {
973 973
     !is_array($resource_delta_list) ? $resource_delta_list = array() : false;
974 974
 
975
-    foreach($resource_delta_list as $resource_id => $unit_delta) {
976
-      if(!UnitResourceLoot::is_in_group($resource_id) || !($unit_delta = floor($unit_delta))) {
975
+    foreach ($resource_delta_list as $resource_id => $unit_delta) {
976
+      if (!UnitResourceLoot::is_in_group($resource_id) || !($unit_delta = floor($unit_delta))) {
977 977
         // Not a resource or no resources - continuing
978 978
         continue;
979 979
       }
980 980
 
981
-      if($replace_value) {
981
+      if ($replace_value) {
982 982
         $this->resource_list[$resource_id] = $unit_delta;
983 983
       } else {
984 984
         $this->resource_list[$resource_id] += $unit_delta;
@@ -988,7 +988,7 @@  discard block
 block discarded – undo
988 988
       }
989 989
 
990 990
       // Check for negative unit value
991
-      if($this->resource_list[$resource_id] < 0) {
991
+      if ($this->resource_list[$resource_id] < 0) {
992 992
         // TODO
993 993
         throw new Exception('Resource ' . $resource_id . ' will become negative in ' . get_called_class() . '::unitAdjustResourceList', ERR_ERROR);
994 994
       }
@@ -1040,7 +1040,7 @@  discard block
 block discarded – undo
1040 1040
     sn_db_transaction_check(true);
1041 1041
 
1042 1042
     // Если флот уже обработан - не существует или возращается - тогда ничего не делаем
1043
-    if(!$this->resourcesGetTotal()) {
1043
+    if (!$this->resourcesGetTotal()) {
1044 1044
       return $result;
1045 1045
     }
1046 1046
 
@@ -1060,7 +1060,7 @@  discard block
 block discarded – undo
1060 1060
     // TODO - Проверка, что планета всё еще существует на указанных координатах, а не телепортировалась, не удалена хозяином, не уничтожена врагом
1061 1061
 
1062 1062
     // Restoring resources to planet
1063
-    if($this->resourcesGetTotal()) {
1063
+    if ($this->resourcesGetTotal()) {
1064 1064
       $fleet_resources = $this->resourcesGetList();
1065 1065
       db_planet_set_by_id($planet_arrival['id'],
1066 1066
         "`metal` = `metal` + '{$fleet_resources[RES_METAL]}', `crystal` = `crystal` + '{$fleet_resources[RES_CRYSTAL]}', `deuterium` = `deuterium` + '{$fleet_resources[RES_DEUTERIUM]}'");
@@ -1112,11 +1112,11 @@  discard block
 block discarded – undo
1112 1112
 
1113 1113
   protected function populateTargetPlanet() {
1114 1114
     $targetPlanetCoords = $this->targetVector;
1115
-    if($this->mission_type != MT_NONE) {
1115
+    if ($this->mission_type != MT_NONE) {
1116 1116
       $this->restrictTargetTypeByMission();
1117 1117
 
1118 1118
       // If current planet type is not allowed on mission - switch planet type
1119
-      if(empty($this->allowed_planet_types[$this->targetVector->type])) {
1119
+      if (empty($this->allowed_planet_types[$this->targetVector->type])) {
1120 1120
         $targetPlanetCoords->type = reset($this->allowed_planet_types);
1121 1121
       }
1122 1122
     }
@@ -1125,14 +1125,14 @@  discard block
 block discarded – undo
1125 1125
   }
1126 1126
 
1127 1127
   protected function restrictTargetTypeByMission() {
1128
-    if($this->_mission_type == MT_MISSILE) {
1128
+    if ($this->_mission_type == MT_MISSILE) {
1129 1129
       $this->allowed_planet_types = array(PT_PLANET => PT_PLANET);
1130
-    } elseif($this->_mission_type == MT_COLONIZE || $this->_mission_type == MT_EXPLORE) {
1130
+    } elseif ($this->_mission_type == MT_COLONIZE || $this->_mission_type == MT_EXPLORE) {
1131 1131
       // TODO - PT_NONE
1132 1132
       $this->allowed_planet_types = array(PT_PLANET => PT_PLANET);
1133
-    } elseif($this->_mission_type == MT_RECYCLE) {
1133
+    } elseif ($this->_mission_type == MT_RECYCLE) {
1134 1134
       $this->allowed_planet_types = array(PT_DEBRIS => PT_DEBRIS);
1135
-    } elseif($this->_mission_type == MT_DESTROY) {
1135
+    } elseif ($this->_mission_type == MT_DESTROY) {
1136 1136
       $this->allowed_planet_types = array(PT_MOON => PT_MOON);
1137 1137
     } else {
1138 1138
       $this->allowed_planet_types = array(PT_PLANET => PT_PLANET, PT_MOON => PT_MOON);
@@ -1169,7 +1169,7 @@  discard block
 block discarded – undo
1169 1169
 
1170 1170
     lng_include('overview');
1171 1171
 
1172
-    if(empty($this->dbSourcePlanetRow)) {
1172
+    if (empty($this->dbSourcePlanetRow)) {
1173 1173
       message(classLocale::$lang['fl_noplanetrow'], classLocale::$lang['fl_error']);
1174 1174
     }
1175 1175
 
@@ -1178,11 +1178,11 @@  discard block
 block discarded – undo
1178 1178
     $ship_list = $this->tplRenderAvailableShips($this->dbOwnerRow, $this->dbSourcePlanetRow);
1179 1179
     $this->tplSortShipList($ship_list);
1180 1180
 
1181
-    foreach($ship_list as $ship_data) {
1181
+    foreach ($ship_list as $ship_data) {
1182 1182
       $template->assign_block_vars('ships', $ship_data);
1183 1183
     }
1184 1184
 
1185
-    foreach(classLocale::$lang['player_option_fleet_ship_sort'] as $sort_id => $sort_text) {
1185
+    foreach (classLocale::$lang['player_option_fleet_ship_sort'] as $sort_id => $sort_text) {
1186 1186
       $template->assign_block_vars('ship_sort_list', array(
1187 1187
         'VALUE' => $sort_id,
1188 1188
         'TEXT'  => $sort_text,
@@ -1238,7 +1238,7 @@  discard block
 block discarded – undo
1238 1238
     $template = gettemplate('fleet1', true);
1239 1239
 
1240 1240
 
1241
-    foreach($this->allowed_planet_types as $possible_planet_type_id) {
1241
+    foreach ($this->allowed_planet_types as $possible_planet_type_id) {
1242 1242
       $template->assign_block_vars('possible_planet_type_id', array(
1243 1243
         'ID'         => $possible_planet_type_id,
1244 1244
         'NAME'       => classLocale::$lang['sys_planet_type'][$possible_planet_type_id],
@@ -1251,7 +1251,7 @@  discard block
 block discarded – undo
1251 1251
       'START_COORDS'       => uni_render_coordinates($this->dbSourcePlanetRow),
1252 1252
       'START_NAME'         => $this->dbSourcePlanetRow['name'],
1253 1253
     );
1254
-    if(!empty($this->dbTargetRow)) {
1254
+    if (!empty($this->dbTargetRow)) {
1255 1255
       $template_route += array(
1256 1256
         'END_TYPE_TEXT_SH' => classLocale::$lang['sys_planet_type_sh'][$this->dbTargetRow['planet_type']],
1257 1257
         'END_COORDS'       => uni_render_coordinates($this->dbTargetRow),
@@ -1264,13 +1264,13 @@  discard block
 block discarded – undo
1264 1264
     $fleet = array();
1265 1265
     $this->unitList->unitsRender($page, $fleet, $template);
1266 1266
 
1267
-    if(empty($fleet['fleetarray'])) {
1267
+    if (empty($fleet['fleetarray'])) {
1268 1268
       message(classLocale::$lang['fl_err_no_ships'], classLocale::$lang['fl_error'], 'fleet' . DOT_PHP_EX, 5);
1269 1269
     }
1270 1270
 
1271 1271
     // Building list of shortcuts
1272 1272
     $query = db_note_list_select_by_owner_and_planet($this->dbOwnerRow);
1273
-    while($shortcut = db_fetch($query)) {
1273
+    while ($shortcut = db_fetch($query)) {
1274 1274
       $template->assign_block_vars('shortcut', array(
1275 1275
         'NAME'           => $shortcut['title'],
1276 1276
         'GALAXY'         => $shortcut['galaxy'],
@@ -1285,9 +1285,9 @@  discard block
 block discarded – undo
1285 1285
 
1286 1286
     // Building list of own planets & moons
1287 1287
     $colonies = db_planet_list_sorted($this->dbOwnerRow);
1288
-    if(count($colonies) > 1) {
1289
-      foreach($colonies as $row) {
1290
-        if($row['id'] == $this->dbSourcePlanetRow['id']) {
1288
+    if (count($colonies) > 1) {
1289
+      foreach ($colonies as $row) {
1290
+        if ($row['id'] == $this->dbSourcePlanetRow['id']) {
1291 1291
           continue;
1292 1292
         }
1293 1293
 
@@ -1303,10 +1303,10 @@  discard block
 block discarded – undo
1303 1303
     }
1304 1304
 
1305 1305
     $aks_madnessred = db_acs_get_list();
1306
-    while($row = db_fetch($aks_madnessred)) {
1306
+    while ($row = db_fetch($aks_madnessred)) {
1307 1307
       $members = explode(',', $row['eingeladen']);
1308
-      foreach($members as $a => $b) {
1309
-        if($b == $this->dbOwnerRow['id']) {
1308
+      foreach ($members as $a => $b) {
1309
+        if ($b == $this->dbOwnerRow['id']) {
1310 1310
           $template->assign_block_vars('acss', array(
1311 1311
             'ID'         => $row['id'],
1312 1312
             'NAME'       => $row['name'],
@@ -1344,7 +1344,7 @@  discard block
 block discarded – undo
1344 1344
 
1345 1345
 
1346 1346
     // Is it exploration - fleet sent beyond of system?
1347
-    if($this->targetVector->planet > classSupernova::$config->game_maxPlanet) {
1347
+    if ($this->targetVector->planet > classSupernova::$config->game_maxPlanet) {
1348 1348
       $this->allowed_missions = array(MT_EXPLORE => MT_EXPLORE,);
1349 1349
 
1350 1350
       // TODO - check for only spies in fleet
@@ -1354,18 +1354,18 @@  discard block
 block discarded – undo
1354 1354
     unset($this->allowed_missions[MT_EXPLORE]);
1355 1355
     // No exploration beyond this point
1356 1356
 
1357
-    if(!uni_vector_valid($this->targetVector)) {
1357
+    if (!uni_vector_valid($this->targetVector)) {
1358 1358
       throw new Exception('LANG_INVALID_COORDINATES');
1359 1359
     }
1360 1360
 
1361 1361
     // Is it colonization - fleet sent to empty place?
1362
-    if(empty($this->dbTargetRow)) {
1362
+    if (empty($this->dbTargetRow)) {
1363 1363
       // Only planet can be destination for colonization
1364
-      if(!$this->targetVector->type == PT_PLANET) {
1364
+      if (!$this->targetVector->type == PT_PLANET) {
1365 1365
         throw new Exception('LANG_INVALID_COLONIZATION_TYPE_ONLY_PLANET_CAN_BE_COLONIZED');
1366 1366
       }
1367 1367
       // Colonization fleet should have at least one colonizer
1368
-      if(!$this->unitList->unitsCountById(SHIP_COLONIZER) <= 0) {
1368
+      if (!$this->unitList->unitsCountById(SHIP_COLONIZER) <= 0) {
1369 1369
         throw new Exception('LANG_INVALID_COLONIZATION_TYPE_ONLY_PLANET_CAN_BE_COLONIZED', ATTACK_NO_COLONIZER);
1370 1370
       }
1371 1371
 
@@ -1385,15 +1385,15 @@  discard block
 block discarded – undo
1385 1385
 
1386 1386
     $TargetPlanet = db_planet_by_gspt($galaxy, $system, $planet, $check_type);
1387 1387
 
1388
-    if($TargetPlanet['id_owner']) {
1388
+    if ($TargetPlanet['id_owner']) {
1389 1389
       $UsedPlanet = true;
1390
-      if($TargetPlanet['id_owner'] == $user['id']) {
1390
+      if ($TargetPlanet['id_owner'] == $user['id']) {
1391 1391
         $YourPlanet = true;
1392 1392
       }
1393 1393
     }
1394 1394
 
1395
-    if(!$UsedPlanet) {
1396
-      if($fleetarray[SHIP_COLONIZER]) {
1395
+    if (!$UsedPlanet) {
1396
+      if ($fleetarray[SHIP_COLONIZER]) {
1397 1397
         $missiontype[MT_COLONIZE] = classLocale::$lang['type_mission'][MT_COLONIZE];
1398 1398
         $target_mission = MT_COLONIZE;
1399 1399
         $planet_type = PT_PLANET;
@@ -1402,24 +1402,24 @@  discard block
 block discarded – undo
1402 1402
       }
1403 1403
     } else {
1404 1404
       $recyclers = 0;
1405
-      foreach(sn_get_groups('flt_recyclers') as $recycler_id) {
1405
+      foreach (sn_get_groups('flt_recyclers') as $recycler_id) {
1406 1406
         $recyclers += $fleetarray[$recycler_id];
1407 1407
       }
1408
-      if($recyclers > 0 && $planet_type == PT_DEBRIS) {
1408
+      if ($recyclers > 0 && $planet_type == PT_DEBRIS) {
1409 1409
         $target_mission = MT_RECYCLE;
1410 1410
         $missiontype[MT_RECYCLE] = classLocale::$lang['type_mission'][MT_RECYCLE];
1411
-      } elseif($planet_type == PT_PLANET || $planet_type == PT_MOON) {
1412
-        if($YourPlanet) {
1411
+      } elseif ($planet_type == PT_PLANET || $planet_type == PT_MOON) {
1412
+        if ($YourPlanet) {
1413 1413
           $missiontype[MT_RELOCATE] = classLocale::$lang['type_mission'][MT_RELOCATE];
1414 1414
           $missiontype[MT_TRANSPORT] = classLocale::$lang['type_mission'][MT_TRANSPORT];
1415 1415
         } else {
1416 1416
           // Not Your Planet
1417
-          if($fleetarray[SHIP_SPY]) {
1417
+          if ($fleetarray[SHIP_SPY]) {
1418 1418
             // Only spy missions if any spy
1419 1419
             $missiontype[MT_SPY] = classLocale::$lang['type_mission'][MT_SPY];
1420 1420
           } else {
1421 1421
             // If no spies...
1422
-            if($fleet_group_mr) {
1422
+            if ($fleet_group_mr) {
1423 1423
               $missiontype[MT_AKS] = classLocale::$lang['type_mission'][MT_AKS];
1424 1424
             } else {
1425 1425
               $missiontype[MT_ATTACK] = classLocale::$lang['type_mission'][MT_ATTACK];
@@ -1427,7 +1427,7 @@  discard block
 block discarded – undo
1427 1427
 
1428 1428
               $missiontype[MT_HOLD] = classLocale::$lang['type_mission'][MT_HOLD];
1429 1429
 
1430
-              if($planet_type == PT_MOON && $fleetarray[SHIP_HUGE_DEATH_STAR]) {
1430
+              if ($planet_type == PT_MOON && $fleetarray[SHIP_HUGE_DEATH_STAR]) {
1431 1431
                 $missiontype[MT_DESTROY] = classLocale::$lang['type_mission'][MT_DESTROY];
1432 1432
               }
1433 1433
             }
@@ -1466,23 +1466,23 @@  discard block
 block discarded – undo
1466 1466
     $UsedPlanet = false;
1467 1467
     $YourPlanet = false;
1468 1468
     $missiontype = array();
1469
-    if($planet > classSupernova::$config->game_maxPlanet) {
1469
+    if ($planet > classSupernova::$config->game_maxPlanet) {
1470 1470
       $target_mission = MT_EXPLORE;
1471 1471
       $missiontype[MT_EXPLORE] = classLocale::$lang['type_mission'][MT_EXPLORE];
1472
-    } elseif($galaxy && $system && $planet) {
1472
+    } elseif ($galaxy && $system && $planet) {
1473 1473
       $check_type = $planet_type == PT_MOON ? PT_MOON : PT_PLANET;
1474 1474
 
1475 1475
       $TargetPlanet = db_planet_by_gspt($galaxy, $system, $planet, $check_type);
1476 1476
 
1477
-      if($TargetPlanet['id_owner']) {
1477
+      if ($TargetPlanet['id_owner']) {
1478 1478
         $UsedPlanet = true;
1479
-        if($TargetPlanet['id_owner'] == $user['id']) {
1479
+        if ($TargetPlanet['id_owner'] == $user['id']) {
1480 1480
           $YourPlanet = true;
1481 1481
         }
1482 1482
       }
1483 1483
 
1484
-      if(!$UsedPlanet) {
1485
-        if($fleetarray[SHIP_COLONIZER]) {
1484
+      if (!$UsedPlanet) {
1485
+        if ($fleetarray[SHIP_COLONIZER]) {
1486 1486
           $missiontype[MT_COLONIZE] = classLocale::$lang['type_mission'][MT_COLONIZE];
1487 1487
           $target_mission = MT_COLONIZE;
1488 1488
           $planet_type = PT_PLANET;
@@ -1491,24 +1491,24 @@  discard block
 block discarded – undo
1491 1491
         }
1492 1492
       } else {
1493 1493
         $recyclers = 0;
1494
-        foreach(sn_get_groups('flt_recyclers') as $recycler_id) {
1494
+        foreach (sn_get_groups('flt_recyclers') as $recycler_id) {
1495 1495
           $recyclers += $fleetarray[$recycler_id];
1496 1496
         }
1497
-        if($recyclers > 0 && $planet_type == PT_DEBRIS) {
1497
+        if ($recyclers > 0 && $planet_type == PT_DEBRIS) {
1498 1498
           $target_mission = MT_RECYCLE;
1499 1499
           $missiontype[MT_RECYCLE] = classLocale::$lang['type_mission'][MT_RECYCLE];
1500
-        } elseif($planet_type == PT_PLANET || $planet_type == PT_MOON) {
1501
-          if($YourPlanet) {
1500
+        } elseif ($planet_type == PT_PLANET || $planet_type == PT_MOON) {
1501
+          if ($YourPlanet) {
1502 1502
             $missiontype[MT_RELOCATE] = classLocale::$lang['type_mission'][MT_RELOCATE];
1503 1503
             $missiontype[MT_TRANSPORT] = classLocale::$lang['type_mission'][MT_TRANSPORT];
1504 1504
           } else {
1505 1505
             // Not Your Planet
1506
-            if($fleetarray[SHIP_SPY]) {
1506
+            if ($fleetarray[SHIP_SPY]) {
1507 1507
               // Only spy missions if any spy
1508 1508
               $missiontype[MT_SPY] = classLocale::$lang['type_mission'][MT_SPY];
1509 1509
             } else {
1510 1510
               // If no spies...
1511
-              if($fleet_group_mr) {
1511
+              if ($fleet_group_mr) {
1512 1512
                 $missiontype[MT_AKS] = classLocale::$lang['type_mission'][MT_AKS];
1513 1513
               } else {
1514 1514
                 $missiontype[MT_ATTACK] = classLocale::$lang['type_mission'][MT_ATTACK];
@@ -1516,7 +1516,7 @@  discard block
 block discarded – undo
1516 1516
 
1517 1517
                 $missiontype[MT_HOLD] = classLocale::$lang['type_mission'][MT_HOLD];
1518 1518
 
1519
-                if($planet_type == PT_MOON && $fleetarray[SHIP_HUGE_DEATH_STAR]) {
1519
+                if ($planet_type == PT_MOON && $fleetarray[SHIP_HUGE_DEATH_STAR]) {
1520 1520
                   $missiontype[MT_DESTROY] = classLocale::$lang['type_mission'][MT_DESTROY];
1521 1521
                 }
1522 1522
               }
@@ -1534,7 +1534,7 @@  discard block
 block discarded – undo
1534 1534
 
1535 1535
     try {
1536 1536
       $this->restrictMission();
1537
-      if(!$target_mission && is_array($missiontype)) {
1537
+      if (!$target_mission && is_array($missiontype)) {
1538 1538
         $target_mission = MT_ATTACK;
1539 1539
       }
1540 1540
 
@@ -1549,13 +1549,13 @@  discard block
 block discarded – undo
1549 1549
       $consumption = $travel_data['consumption'];
1550 1550
 
1551 1551
       return array($ship_amount, $planet_type, $duration);
1552
-    } catch(Exception $e) {
1552
+    } catch (Exception $e) {
1553 1553
       die($e->getMessage());
1554 1554
     }
1555 1555
 
1556 1556
     $template = gettemplate('fleet2', true);
1557 1557
 
1558
-    foreach($missiontype as $key => $value) {
1558
+    foreach ($missiontype as $key => $value) {
1559 1559
       $template->assign_block_vars('missions', array(
1560 1560
         'ID'      => $key,
1561 1561
         'NAME'    => $value,
@@ -1571,7 +1571,7 @@  discard block
 block discarded – undo
1571 1571
       'START_NAME'         => $planetrow['name'],
1572 1572
     );
1573 1573
 
1574
-    if(!empty($TargetPlanet)) {
1574
+    if (!empty($TargetPlanet)) {
1575 1575
       $template_route += array(
1576 1576
         'END_TYPE_TEXT_SH' => classLocale::$lang['sys_planet_type_sh'][$TargetPlanet['planet_type']],
1577 1577
         'END_COORDS'       => uni_render_coordinates($TargetPlanet),
@@ -1582,8 +1582,8 @@  discard block
 block discarded – undo
1582 1582
     $template->assign_block_vars('fleets', $template_route);
1583 1583
 
1584 1584
     $sn_groups_fleet = sn_get_groups('fleet');
1585
-    foreach($fleetarray as $ship_id => $ship_count) {
1586
-      if(in_array($ship_id, $sn_groups_fleet) && $ship_count) {
1585
+    foreach ($fleetarray as $ship_id => $ship_count) {
1586
+      if (in_array($ship_id, $sn_groups_fleet) && $ship_count) {
1587 1587
 //      $ship_base_data = get_ship_data($ship_id, $user);
1588 1588
         $template->assign_block_vars('fleets.ships', array(
1589 1589
           'ID'          => $ship_id,
@@ -1597,15 +1597,14 @@  discard block
 block discarded – undo
1597 1597
     }
1598 1598
 
1599 1599
     $fleet_capacity = 0;
1600
-    foreach($fleetarray as $Ship => $Count) {
1600
+    foreach ($fleetarray as $Ship => $Count) {
1601 1601
       $fleet_capacity += get_unit_param($Ship, P_CAPACITY) * $Count;
1602 1602
     }
1603 1603
 
1604
-    $max_duration = $target_mission == MT_EXPLORE ? get_player_max_expedition_duration($user) :
1605
-      (isset($missiontype[MT_HOLD]) ? 12 : 0);
1606
-    if($max_duration) {
1604
+    $max_duration = $target_mission == MT_EXPLORE ? get_player_max_expedition_duration($user) : (isset($missiontype[MT_HOLD]) ? 12 : 0);
1605
+    if ($max_duration) {
1607 1606
       $config_game_speed_expedition = ($target_mission == MT_EXPLORE && classSupernova::$config->game_speed_expedition ? classSupernova::$config->game_speed_expedition : 1);
1608
-      for($i = 1; $i <= $max_duration; $i++) {
1607
+      for ($i = 1; $i <= $max_duration; $i++) {
1609 1608
         $template->assign_block_vars('duration', array(
1610 1609
           'ID'   => $i,
1611 1610
           'TIME' => pretty_time(ceil($i * 3600 / $config_game_speed_expedition)),
@@ -1614,7 +1613,7 @@  discard block
 block discarded – undo
1614 1613
     }
1615 1614
 
1616 1615
     $sn_group_resources = sn_get_groups('resources');
1617
-    for($i = 0; $i < 3; $i++) {
1616
+    for ($i = 0; $i < 3; $i++) {
1618 1617
       $amount = $planetrow[$sn_group_resources[$i]] - ($i == 2 ? $consumption : 0);
1619 1618
       $template->assign_block_vars('resources', array(
1620 1619
         'ID'        => $i,
@@ -1624,7 +1623,7 @@  discard block
 block discarded – undo
1624 1623
       ));
1625 1624
     }
1626 1625
 
1627
-    if(sn_module::$sn_module['unit_captain']->manifest['active'] && ($captain = sn_module::$sn_module['unit_captain']->unit_captain_get($planetrow['id'])) && $captain['unit_location_type'] == LOC_PLANET) {
1626
+    if (sn_module::$sn_module['unit_captain']->manifest['active'] && ($captain = sn_module::$sn_module['unit_captain']->unit_captain_get($planetrow['id'])) && $captain['unit_location_type'] == LOC_PLANET) {
1628 1627
       $template->assign_vars(array(
1629 1628
         'CAPTAIN_ID'     => $captain['unit_id'],
1630 1629
         'CAPTAIN_LEVEL'  => $captain['captain_level'],
Please login to merge, or discard this patch.
includes/classes/UnitList.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
    * @param Unit  $value
89 89
    */
90 90
   public function offsetSet($offset, $value) {
91
-    if(isset($this->mapUnitIdToDb[$value->unitId])) {
91
+    if (isset($this->mapUnitIdToDb[$value->unitId])) {
92 92
       classSupernova::$debug->error('UnitList::offsetSet: Unit with UnitId ' . $value->unitId . ' already exists');
93 93
     }
94 94
     $this->mapUnitIdToDb[$value->unitId] = $value;
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
   }
97 97
 
98 98
   public function offsetUnset($offset) {
99
-    if(!empty($this[$offset]->unitId)) {
99
+    if (!empty($this[$offset]->unitId)) {
100 100
 //      $unit_id = $this[$offset]->unitId;
101 101
 //      $this->mapUnitIdToDb[$unit_id] = null;
102 102
 //      unset($this->mapUnitIdToDb[$unit_id]);
@@ -117,20 +117,20 @@  discard block
 block discarded – undo
117 117
   public function dbLoad($dbId, $lockSkip = false) {
118 118
 //    $this->_reset();
119 119
 
120
-    if($dbId <= 0) {
120
+    if ($dbId <= 0) {
121 121
       return;
122 122
     }
123 123
 
124
-    if(!is_object($this->locatedAt)) {
124
+    if (!is_object($this->locatedAt)) {
125 125
       classSupernova::$debug->error('UnitList::dbLoad have no locatedAt field set');
126 126
     }
127 127
 
128 128
     $unit_array = classSupernova::db_get_unit_list_by_location(0, $this->getLocationType(), $this->getLocationDbId());
129
-    if(!is_array($unit_array)) {
129
+    if (!is_array($unit_array)) {
130 130
       return;
131 131
     }
132 132
 
133
-    foreach($unit_array as $unit_db_row) {
133
+    foreach ($unit_array as $unit_db_row) {
134 134
       $unit = $this->_createElement();
135 135
       $unit->dbRowParse($unit_db_row);
136 136
 
@@ -145,25 +145,25 @@  discard block
 block discarded – undo
145 145
   }
146 146
 
147 147
   public function dbSave() {
148
-    if(!is_object($this->locatedAt)) {
148
+    if (!is_object($this->locatedAt)) {
149 149
       classSupernova::$debug->error('UnitList::dbSave have no locatedAt field set');
150 150
     }
151 151
 
152
-    foreach($this->mapUnitIdToDb as $unit) {
152
+    foreach ($this->mapUnitIdToDb as $unit) {
153 153
       $unit_db_id = $unit->dbId;
154 154
       $unit->dbSave();
155 155
 
156
-      if($unit->isEmpty()) {
156
+      if ($unit->isEmpty()) {
157 157
         // Removing unit object
158 158
         // TODO - change when there will be common bus for all objects
159 159
         // ...or should I? If COUNT is empty - it means that object does not exists in DB. So it should be deleted from PHP memory and cache too
160 160
         unset($this[$unit_db_id]);
161 161
       } else {
162
-        if($unit->dbId <= 0) {
162
+        if ($unit->dbId <= 0) {
163 163
           classSupernova::$debug->error('Error writing unit to DB');
164 164
         }
165 165
         // If unit is new then putting unit object to container
166
-        if(empty($this->_container[$unit->dbId])) {
166
+        if (empty($this->_container[$unit->dbId])) {
167 167
           $this->_container[$unit->dbId] = $unit;
168 168
         }
169 169
       }
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
   }
202 202
 
203 203
   public function unitGetCount($unit_id) {
204
-    if(empty($this->mapUnitIdToDb[$unit_id])) {
204
+    if (empty($this->mapUnitIdToDb[$unit_id])) {
205 205
       throw new Exception('Unit [' . $unit_id . '] is not exists in UnitList');
206 206
     }
207 207
     return $this->mapUnitIdToDb[$unit_id]->count;
@@ -216,14 +216,14 @@  discard block
 block discarded – undo
216 216
    * @param bool $replace_value
217 217
    */
218 218
   public function unitAdjustCount($unit_id, $unit_count = 0, $replace_value = false) {
219
-    if(empty($this->mapUnitIdToDb[$unit_id])) {
219
+    if (empty($this->mapUnitIdToDb[$unit_id])) {
220 220
       // If unit not exists - creating one and setting all attributes
221 221
       $this->mapUnitIdToDb[$unit_id] = $this->_createElement();
222 222
       $this->mapUnitIdToDb[$unit_id]->setUnitId($unit_id);
223 223
       $this->mapUnitIdToDb[$unit_id]->setLocatedAt($this);
224 224
     }
225 225
 
226
-    if($replace_value) {
226
+    if ($replace_value) {
227 227
       $this->mapUnitIdToDb[$unit_id]->count = $unit_count;
228 228
     } else {
229 229
       $this->mapUnitIdToDb[$unit_id]->adjustCount($unit_count);
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
    */
238 238
   public function unitsGetArray() {
239 239
     $result = array();
240
-    foreach($this->mapUnitIdToDb as $unit) {
240
+    foreach ($this->mapUnitIdToDb as $unit) {
241 241
       $result[$unit->unitId] = $unit->count;
242 242
     }
243 243
 
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
   }
246 246
 
247 247
   public function unitsCountApplyLossMultiplier($ships_lost_multiplier) {
248
-    foreach($this->mapUnitIdToDb as $unit_id => $unit) {
248
+    foreach ($this->mapUnitIdToDb as $unit_id => $unit) {
249 249
       $unit->count = floor($unit->count * $ships_lost_multiplier);
250 250
     }
251 251
   }
@@ -271,8 +271,8 @@  discard block
 block discarded – undo
271 271
 
272 272
   public function unitsPropertySumById($unit_id = 0, $propertyName = 'count') {
273 273
     $result = 0;
274
-    foreach($this->mapUnitIdToDb as $unit) {
275
-      if(!$unit_id || $unit->unitId == $unit_id) {
274
+    foreach ($this->mapUnitIdToDb as $unit) {
275
+      if (!$unit_id || $unit->unitId == $unit_id) {
276 276
         $result += $unit->$propertyName;
277 277
       }
278 278
     }
@@ -292,18 +292,18 @@  discard block
 block discarded – undo
292 292
      * @var Fleet $objFleet
293 293
      */
294 294
     $objFleet = $this->getLocatedAt();
295
-    if(empty($objFleet)) {
295
+    if (empty($objFleet)) {
296 296
       throw new Exception('No fleet owner on UnitList::unitsRender() in ' . __FILE__ . '@' . __LINE__);
297 297
     }
298 298
 
299
-    foreach($this->mapUnitIdToDb as $unit) {
299
+    foreach ($this->mapUnitIdToDb as $unit) {
300 300
       $ship_id = $unit->unitId;
301 301
       $ship_count = $unit->count;
302
-      if(!UnitShip::is_in_group($ship_id) || $ship_count <= 0) {
302
+      if (!UnitShip::is_in_group($ship_id) || $ship_count <= 0) {
303 303
         continue;
304 304
       }
305 305
 
306
-      if($ship_count > mrc_get_level($objFleet->dbOwnerRow, $objFleet->dbSourcePlanetRow, $ship_id, false, true)) {
306
+      if ($ship_count > mrc_get_level($objFleet->dbOwnerRow, $objFleet->dbSourcePlanetRow, $ship_id, false, true)) {
307 307
         $page .= classLocale::$lang['fl_noenought'];
308 308
       } else {
309 309
         $fleet['fleetarray'][$ship_id] = $ship_count;
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
 
397 397
     print('</tr>');
398 398
 
399
-    foreach($this->mapUnitIdToDb as $unit) {
399
+    foreach ($this->mapUnitIdToDb as $unit) {
400 400
       print('<tr>');
401 401
 
402 402
       print('<td>');
@@ -447,14 +447,14 @@  discard block
 block discarded – undo
447 447
 
448 448
 
449 449
   public function unitZeroDbId() {
450
-    foreach($this->mapUnitIdToDb as $unit) {
450
+    foreach ($this->mapUnitIdToDb as $unit) {
451 451
       $unit->zeroDbId();
452 452
     }
453 453
   }
454 454
 
455 455
 
456 456
   public function unitZeroCount() {
457
-    foreach($this->mapUnitIdToDb as $unit) {
457
+    foreach ($this->mapUnitIdToDb as $unit) {
458 458
       $unit->count = 0;
459 459
     }
460 460
   }
Please login to merge, or discard this patch.
includes/classes/Vector.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,9 +16,9 @@
 block discarded – undo
16 16
    * @param int              $type
17 17
    */
18 18
   public function __construct($galaxy = 0, $system = 0, $planet = 0, $type = PT_NONE) {
19
-    if(is_string($galaxy) && $galaxy == VECTOR_READ_VECTOR && is_object($system) && $system instanceof Vector) {
19
+    if (is_string($galaxy) && $galaxy == VECTOR_READ_VECTOR && is_object($system) && $system instanceof Vector) {
20 20
       $this->readFromVector($system);
21
-    } elseif(is_string($galaxy) && $galaxy == VECTOR_READ_PARAMS && is_array($system)) {
21
+    } elseif (is_string($galaxy) && $galaxy == VECTOR_READ_PARAMS && is_array($system)) {
22 22
       $this->readFromParamFleets($system);
23 23
     } else {
24 24
       $this->galaxy = $galaxy;
Please login to merge, or discard this patch.
includes/classes/Player.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -228,8 +228,8 @@  discard block
 block discarded – undo
228 228
    * @return int|mixed
229 229
    */
230 230
   public function calcColonyMaxCount($astrotech = -1) {
231
-    if($astrotech == -1) {
232
-      if(!isset($this->_dbRow[UNIT_PLAYER_COLONIES_MAX])) {
231
+    if ($astrotech == -1) {
232
+      if (!isset($this->_dbRow[UNIT_PLAYER_COLONIES_MAX])) {
233 233
 
234 234
         $expeditions = get_player_max_expeditons($this->_dbRow);
235 235
         $astrotech = mrc_get_level($this->_dbRow, null, TECH_ASTROTECH);
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 
303 303
 
304 304
   public function expeditionsMax() {
305
-    if($this->expeditionsMax === null) {
305
+    if ($this->expeditionsMax === null) {
306 306
       $this->expeditionsMax = get_player_max_expeditons($this->_dbRow);
307 307
     }
308 308
 
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
   }
311 311
 
312 312
   public function expeditionsFlying() {
313
-    if($this->expeditionsFlying === null) {
313
+    if ($this->expeditionsFlying === null) {
314 314
       $this->expeditionsFlying = FleetList::fleet_count_flying($this->_dbId, MT_EXPLORE);
315 315
     }
316 316
 
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 
320 320
 
321 321
   public function fleetsMax() {
322
-    if($this->fleetMax === null) {
322
+    if ($this->fleetMax === null) {
323 323
       $this->fleetMax = GetMaxFleets($this->_dbRow);
324 324
     }
325 325
 
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
   }
328 328
 
329 329
   public function fleetsFlying() {
330
-    if($this->fleetFlying === null) {
330
+    if ($this->fleetFlying === null) {
331 331
       $this->fleetFlying = FleetList::fleet_count_flying($this->_dbId);
332 332
     }
333 333
 
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 
337 337
 
338 338
   public function coloniesMax() {
339
-    if($this->coloniesMax === null) {
339
+    if ($this->coloniesMax === null) {
340 340
       $this->coloniesMax = get_player_max_colonies($this->_dbRow);
341 341
     }
342 342
 
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
   }
345 345
 
346 346
   public function coloniesCurrent() {
347
-    if($this->coloniesCurrent === null) {
347
+    if ($this->coloniesCurrent === null) {
348 348
       $this->coloniesCurrent = get_player_current_colonies($this->_dbRow);
349 349
     }
350 350
 
Please login to merge, or discard this patch.