Completed
Push — work-fleets ( 070fe2...d6c2ef )
by SuperNova.WS
05:43
created
includes/includes/flt_page4.inc 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -1,19 +1,19 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if(SN_IN_FLEET !== true) {
3
+if (SN_IN_FLEET !== true) {
4 4
   $debug->error("Attempt to call FLEET page mode {$mode} directly - not from fleet.php", 'Forbidden', 403);
5 5
 }
6 6
 
7 7
 $fleetid = sys_get_param_id('fleetid');
8 8
 
9
-if(!is_numeric($fleetid) || empty($fleetid)) {
9
+if (!is_numeric($fleetid) || empty($fleetid)) {
10 10
   header("Location: fleet.php");
11 11
   exit();
12 12
 }
13 13
 
14 14
 $objFleet = new Fleet();
15 15
 $objFleet->dbLoad($fleetid);
16
-if(!$objFleet->dbId) {
16
+if (!$objFleet->dbId) {
17 17
   message($lang['fl_fleet_not_exists'], $lang['fl_error']);
18 18
 }
19 19
 
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
21 21
   message($lang['fl_isback'], $lang['fl_error']);
22 22
 }
23 23
 
24
-if($objFleet->playerOwnerId != $user['id']) {
25
-  $debug->warning($lang['fl_aks_hack_wrong_fleet'],'Wrong Fleet Owner',301);
24
+if ($objFleet->playerOwnerId != $user['id']) {
25
+  $debug->warning($lang['fl_aks_hack_wrong_fleet'], 'Wrong Fleet Owner', 301);
26 26
   message($lang['fl_aks_hack_wrong_fleet'], $lang['fl_error']);
27 27
 }
28 28
 
@@ -32,19 +32,19 @@  discard block
 block discarded – undo
32 32
 
33 33
 !$aks && !$userToAdd_unsafe ? $userToAdd_unsafe = $user['username'] : false;
34 34
 
35
-if($userToAdd_unsafe) {
35
+if ($userToAdd_unsafe) {
36 36
   $userToAdd = db_escape($userToAdd_unsafe);
37 37
   $userToAddID = db_user_by_username($userToAdd_unsafe, false, 'id', true, true);
38 38
   $userToAddID = $userToAddID['id'];
39 39
 
40
-  if($objFleet->target_owner_id == $userToAddID) {
40
+  if ($objFleet->target_owner_id == $userToAddID) {
41 41
     message($lang['flt_aks_player_same'], $lang['fl_error']);
42 42
   }
43 43
 
44
-  if($userToAddID) {
45
-    if(!$aks) {
44
+  if ($userToAddID) {
45
+    if (!$aks) {
46 46
       // No AСS exists - making one
47
-      if(!$objFleet->group_id) {
47
+      if (!$objFleet->group_id) {
48 48
         db_acs_insert($lang, $fleetid, $user, $objFleet);
49 49
 
50 50
         $aks = db_acs_get_by_fleet($fleetid);
@@ -58,26 +58,26 @@  discard block
 block discarded – undo
58 58
 
59 59
     $isUserExists = false;
60 60
     $invited_ar = explode(",", $aks['eingeladen']);
61
-    foreach($invited_ar as $inv) {
61
+    foreach ($invited_ar as $inv) {
62 62
       if ($userToAddID == $inv) {
63 63
         $isUserExists = true;
64 64
       }
65 65
     }
66 66
 
67
-    if(count($invited_ar) >= 5) {
67
+    if (count($invited_ar) >= 5) {
68 68
       message($lang['flt_aks_error_too_much_players'], $lang['fl_error']);
69 69
     }
70 70
 
71
-    if($isUserExists) {
71
+    if ($isUserExists) {
72 72
       $userToAdd_unsafe != $user['username'] ? $add_user_message_mr = sprintf($lang['fl_aks_player_invited_already'], $userToAdd) : false;
73 73
     } else {
74 74
       $add_user_message_mr = sprintf($lang['fl_aks_player_invited'], $userToAdd);
75 75
       db_acs_update($userToAddID, $fleetid)
76
-        or die(sprintf($lang['fl_aks_adding_error'],db_error()));
76
+        or die(sprintf($lang['fl_aks_adding_error'], db_error()));
77 77
       $aks['eingeladen'] .= ',' . $userToAddID;
78 78
     }
79
-    msg_send_simple_message ( $userToAddID, $user['id'], SN_TIME_NOW, MSG_TYPE_COMBAT, $user['username'],
80
-      $lang['fl_aks_invite_message_header'], sprintf( $lang['fl_aks_invite_message'], $user['username']));
79
+    msg_send_simple_message($userToAddID, $user['id'], SN_TIME_NOW, MSG_TYPE_COMBAT, $user['username'],
80
+      $lang['fl_aks_invite_message_header'], sprintf($lang['fl_aks_invite_message'], $user['username']));
81 81
   } else {
82 82
     $add_user_message_mr = sprintf($lang['fl_aks_player_error'], $userToAdd);
83 83
   }
@@ -91,8 +91,8 @@  discard block
 block discarded – undo
91 91
   'MISSION_NAME' => $lang['type_mission'][MT_AKS],
92 92
 ));
93 93
 
94
-if($aks['eingeladen'] && is_array($members = classSupernova::db_get_record_list(LOC_USER, "`id` in ({$aks['eingeladen']})")) && !empty($members)) {
95
-  foreach($members as $row) {
94
+if ($aks['eingeladen'] && is_array($members = classSupernova::db_get_record_list(LOC_USER, "`id` in ({$aks['eingeladen']})")) && !empty($members)) {
95
+  foreach ($members as $row) {
96 96
     $template->assign_block_vars('invited', array(
97 97
       'NAME' => $row['username'],
98 98
     ));
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 $fleet_data = tplParseFleetObject($objFleet, $i, $user);
118 118
 
119 119
 $template->assign_block_vars('fleets', $fleet_data['fleet']);
120
-foreach($fleet_data['ships'] as $ship_data) {
120
+foreach ($fleet_data['ships'] as $ship_data) {
121 121
   $template->assign_block_vars('fleets.ships', $ship_data);
122 122
 }
123 123
 
Please login to merge, or discard this patch.
includes/includes/flt_mission_relocate.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 
17 17
   $destination_planet = &$mission_data->dst_planet;
18 18
 
19
-  if(empty($destination_planet['id_owner']) || $objFleet->playerOwnerId != $destination_planet['id_owner']) {
19
+  if (empty($destination_planet['id_owner']) || $objFleet->playerOwnerId != $destination_planet['id_owner']) {
20 20
     $objFleet->mark_fleet_as_returned_and_save();
21 21
 
22 22
     return CACHE_FLEET;
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
       $fleet_resources[RES_DEUTERIUM], $lang['Deuterium']
32 32
     ) . '<br />' . $lang['sys_relocate_mess_user'];
33 33
   $fleet_real_array = $objFleet->get_unit_list();
34
-  foreach($fleet_real_array as $ship_id => $ship_count) {
34
+  foreach ($fleet_real_array as $ship_id => $ship_count) {
35 35
     $Message .= $lang['tech'][$ship_id] . ' - ' . $ship_count . '<br />';
36 36
   }
37 37
   msg_send_simple_message(
Please login to merge, or discard this patch.
includes/includes/flt_mission_transport.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
   $source_planet = &$mission_data->src_planet;
17 17
   $destination_planet = &$mission_data->dst_planet;
18 18
 
19
-  if(!isset($destination_planet['id']) || !$destination_planet['id_owner']) {
19
+  if (!isset($destination_planet['id']) || !$destination_planet['id_owner']) {
20 20
     $objFleet->mark_fleet_as_returned_and_save();
21 21
 
22 22
     return CACHE_FLEET;
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
     $fleet_resources[RES_DEUTERIUM], $lang['Deuterium']);
32 32
   msg_send_simple_message($objFleet->target_owner_id, '', $objFleet->time_arrive_to_target, MSG_TYPE_TRANSPORT, $lang['sys_mess_tower'], $lang['sys_mess_transport'], $Message);
33 33
 
34
-  if($objFleet->target_owner_id <> $objFleet->playerOwnerId) {
34
+  if ($objFleet->target_owner_id <> $objFleet->playerOwnerId) {
35 35
     msg_send_simple_message($objFleet->playerOwnerId, '', $objFleet->time_arrive_to_target, MSG_TYPE_TRANSPORT, $lang['sys_mess_tower'], $lang['sys_mess_transport'], $Message);
36 36
   }
37 37
 
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
31 31
 /**
32 32
  * Fleet mission "Relocate"
33 33
  *
34
- * @param $mission_data Mission
34
+ * @param Mission $mission_data Mission
35 35
  *
36 36
  * @return int
37 37
  *
Please login to merge, or discard this patch.
includes/includes/flt_mission_recycle.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 
21 21
   $destination_planet = &$mission_data->dst_planet;
22 22
 
23
-  if(empty($destination_planet['id'])) {
23
+  if (empty($destination_planet['id'])) {
24 24
     $objFleet->mark_fleet_as_returned();
25 25
     $objFleet->flush_changes_to_db();
26 26
 
@@ -31,10 +31,10 @@  discard block
 block discarded – undo
31 31
   $OtherFleetCapacity = 0;
32 32
 
33 33
   $fleet_array = $objFleet->get_unit_list();
34
-  foreach($fleet_array as $unit_id => $unit_count) {
35
-    if(in_array($unit_id, sn_get_groups('fleet'))) {
34
+  foreach ($fleet_array as $unit_id => $unit_count) {
35
+    if (in_array($unit_id, sn_get_groups('fleet'))) {
36 36
       $capacity = get_unit_param($unit_id, P_CAPACITY) * $unit_count;
37
-      if(in_array($unit_id, sn_get_groups('flt_recyclers'))) {
37
+      if (in_array($unit_id, sn_get_groups('flt_recyclers'))) {
38 38
         $RecyclerCapacity += $capacity;
39 39
       } else {
40 40
         $OtherFleetCapacity += $capacity;
@@ -43,33 +43,33 @@  discard block
 block discarded – undo
43 43
   }
44 44
 
45 45
   $fleet_resources_amount = $objFleet->get_resources_amount();
46
-  if($fleet_resources_amount > $OtherFleetCapacity) {
46
+  if ($fleet_resources_amount > $OtherFleetCapacity) {
47 47
     // Если во флоте есть другие корабли И количество ресурсов больше, чем их ёмкость трюмов - значит часть этих ресурсов лежит в трюмах переработчиков
48 48
     // Уменьшаем ёмкость переработчиков на указанную величину
49 49
     $RecyclerCapacity -= ($fleet_resources_amount - $OtherFleetCapacity);
50 50
   }
51 51
 
52 52
   $resources_recycled = array();
53
-  if(($destination_planet["debris_metal"] + $destination_planet["debris_crystal"]) <= $RecyclerCapacity) {
53
+  if (($destination_planet["debris_metal"] + $destination_planet["debris_crystal"]) <= $RecyclerCapacity) {
54 54
     $resources_recycled[RES_METAL] = $destination_planet["debris_metal"];
55 55
     $resources_recycled[RES_CRYSTAL] = $destination_planet["debris_crystal"];
56 56
   } else {
57
-    if(($destination_planet["debris_metal"] > $RecyclerCapacity / 2) &&
57
+    if (($destination_planet["debris_metal"] > $RecyclerCapacity / 2) &&
58 58
       ($destination_planet["debris_crystal"] > $RecyclerCapacity / 2)
59 59
     ) {
60 60
       $resources_recycled[RES_METAL] = $RecyclerCapacity / 2;
61 61
       $resources_recycled[RES_CRYSTAL] = $RecyclerCapacity / 2;
62 62
     } else {
63
-      if($destination_planet["debris_metal"] > $destination_planet["debris_crystal"]) {
63
+      if ($destination_planet["debris_metal"] > $destination_planet["debris_crystal"]) {
64 64
         $resources_recycled[RES_CRYSTAL] = $destination_planet["debris_crystal"];
65
-        if($destination_planet["debris_metal"] > ($RecyclerCapacity - $resources_recycled[RES_CRYSTAL])) {
65
+        if ($destination_planet["debris_metal"] > ($RecyclerCapacity - $resources_recycled[RES_CRYSTAL])) {
66 66
           $resources_recycled[RES_METAL] = $RecyclerCapacity - $resources_recycled[RES_CRYSTAL];
67 67
         } else {
68 68
           $resources_recycled[RES_METAL] = $destination_planet["debris_metal"];
69 69
         }
70 70
       } else {
71 71
         $resources_recycled[RES_METAL] = $destination_planet["debris_metal"];
72
-        if($destination_planet["debris_crystal"] > ($RecyclerCapacity - $resources_recycled[RES_METAL])) {
72
+        if ($destination_planet["debris_crystal"] > ($RecyclerCapacity - $resources_recycled[RES_METAL])) {
73 73
           $resources_recycled[RES_CRYSTAL] = $RecyclerCapacity - $resources_recycled[RES_METAL];
74 74
         } else {
75 75
           $resources_recycled[RES_CRYSTAL] = $destination_planet["debris_crystal"];
Please login to merge, or discard this patch.
includes/includes/sys_stat.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -39,23 +39,23 @@  discard block
 block discarded – undo
39 39
 
40 40
   $sta_update_msg = db_escape($sta_update_msg);
41 41
 
42
-  if($next_step) {
42
+  if ($next_step) {
43 43
     $sta_update_step++;
44 44
   }
45 45
   $sta_update_msg = "Update in progress. Step {$sta_update_step}/14: {$sta_update_msg}.";
46 46
 
47 47
   $config->db_saveItem('var_stat_update_msg', $sta_update_msg);
48
-  if($next_step) {
48
+  if ($next_step) {
49 49
     $debug->warning($sta_update_msg, 'Stat update', LOG_INFO_STAT_PROCESS);
50 50
   }
51 51
 }
52 52
 
53 53
 function sys_stat_calculate_flush(&$data, $force = false) {
54
-  if(count($data) < 25 && !$force) {
54
+  if (count($data) < 25 && !$force) {
55 55
     return;
56 56
   }
57 57
 
58
-  if(!empty($data)) {
58
+  if (!empty($data)) {
59 59
     doquery('REPLACE INTO {{statpoints}}
60 60
       (`id_owner`, `id_ally`, `stat_type`, `stat_code`, `tech_points`, `tech_count`, `build_points`, `build_count`,
61 61
        `defs_points`, `defs_count`, `fleet_points`, `fleet_count`, `res_points`, `res_count`, `total_points`,
@@ -95,11 +95,11 @@  discard block
 block discarded – undo
95 95
   $user_list = db_user_list('', true, 'id, dark_matter, metal, crystal, deuterium, user_as_ally, ally_id');
96 96
   $row_num = count($user_list);
97 97
   // while($player = db_fetch($query))
98
-  foreach($user_list as $player) {
99
-    if($i++ % 100 == 0) {
98
+  foreach ($user_list as $player) {
99
+    if ($i++ % 100 == 0) {
100 100
       sta_set_time_limit("calculating players stats (player {$i}/{$row_num})", false);
101 101
     }
102
-    if(array_key_exists($user_id = $player['id'], $user_skip_list)) {
102
+    if (array_key_exists($user_id = $player['id'], $user_skip_list)) {
103 103
       continue;
104 104
     }
105 105
 
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
     // $points[$user_id][UNIT_RESOURCES] += $resources;
110 110
 
111 111
     // А здесь мы фильтруем пользователей по $user_skip_list - далее не нужно этого делать, потому что
112
-    if(!isset($user_skip_list[$user_id])) {
112
+    if (!isset($user_skip_list[$user_id])) {
113 113
       $user_allies[$user_id] = $player['ally_id'];
114 114
     }
115 115
   }
@@ -123,11 +123,11 @@  discard block
 block discarded – undo
123 123
   $i = 0;
124 124
   $query = db_planet_list_resources_by_owner();
125 125
   $row_num = db_num_rows($query);
126
-  while($planet = db_fetch($query)) {
127
-    if($i++ % 100 == 0) {
126
+  while ($planet = db_fetch($query)) {
127
+    if ($i++ % 100 == 0) {
128 128
       sta_set_time_limit("calculating planets stats (planet {$i}/{$row_num})", false);
129 129
     }
130
-    if(array_key_exists($user_id = $planet['id_owner'], $user_skip_list)) {
130
+    if (array_key_exists($user_id = $planet['id_owner'], $user_skip_list)) {
131 131
       continue;
132 132
     }
133 133
 
@@ -142,8 +142,8 @@  discard block
 block discarded – undo
142 142
   $i = 0;
143 143
   $query = FleetList::dbQueryAllId();
144 144
   $row_num = db_num_rows($query);
145
-  while($fleet_row = db_fetch($query)) {
146
-    if($i++ % 100 == 0) {
145
+  while ($fleet_row = db_fetch($query)) {
146
+    if ($i++ % 100 == 0) {
147 147
       sta_set_time_limit("calculating flying fleets stats (fleet {$i}/{$row_num})", false);
148 148
     }
149 149
     $objFleet = new Fleet();
@@ -151,15 +151,15 @@  discard block
 block discarded – undo
151 151
     // К тому же при включённом кэшировании это быстро забъёт кэш холодными данными
152 152
     // $objFleet->_reset();
153 153
     $objFleet->dbRowParse($fleet_row);
154
-    if(array_key_exists($user_id = $objFleet->playerOwnerId, $user_skip_list)) {
154
+    if (array_key_exists($user_id = $objFleet->playerOwnerId, $user_skip_list)) {
155 155
       continue;
156 156
     }
157 157
 
158 158
     $fleet = $objFleet->get_unit_list();
159
-    foreach($fleet as $unit_id => $unit_amount) {
159
+    foreach ($fleet as $unit_id => $unit_amount) {
160 160
       $counts[$user_id][UNIT_SHIPS] += $unit_amount;
161 161
 
162
-      if(!isset($unit_cost_cache[$unit_id][0])) {
162
+      if (!isset($unit_cost_cache[$unit_id][0])) {
163 163
         $unit_cost_cache[$unit_id][0] = get_unit_param($unit_id, P_COST);
164 164
       }
165 165
       $unit_cost_data = &$unit_cost_cache[$unit_id][0];
@@ -179,11 +179,11 @@  discard block
 block discarded – undo
179 179
   $i = 0;
180 180
   $query = db_unit_list_stat_calculate();
181 181
   $row_num = db_num_rows($query);
182
-  while($unit = db_fetch($query)) {
183
-    if($i++ % 100 == 0) {
182
+  while ($unit = db_fetch($query)) {
183
+    if ($i++ % 100 == 0) {
184 184
       sta_set_time_limit("calculating unit stats (unit {$i}/{$row_num})", false);
185 185
     }
186
-    if(array_key_exists($user_id = $unit['unit_player_id'], $user_skip_list)) {
186
+    if (array_key_exists($user_id = $unit['unit_player_id'], $user_skip_list)) {
187 187
       continue;
188 188
     }
189 189
 
@@ -197,11 +197,11 @@  discard block
 block discarded – undo
197 197
   $i = 0;
198 198
   $query = db_que_list_stat();
199 199
   $row_num = db_num_rows($query);
200
-  while($que_item = db_fetch($query)) {
201
-    if($i++ % 100 == 0) {
200
+  while ($que_item = db_fetch($query)) {
201
+    if ($i++ % 100 == 0) {
202 202
       sta_set_time_limit("calculating ques stats (que item {$i}/{$row_num})", false);
203 203
     }
204
-    if(array_key_exists($user_id = $que_item['que_player_id'], $user_skip_list)) {
204
+    if (array_key_exists($user_id = $que_item['que_player_id'], $user_skip_list)) {
205 205
       continue;
206 206
     }
207 207
     $que_unit_amount = $que_item['que_unit_amount'];
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 
220 220
   sta_set_time_limit('posting new user stats to DB');
221 221
   $data = array();
222
-  foreach($user_allies as $user_id => $ally_id) {
222
+  foreach ($user_allies as $user_id => $ally_id) {
223 223
     // $counts[UNIT_RESOURCES] дублирует $points[UNIT_RESOURCES], поэтому $points не заполняем, а берем $counts и делим на 1000
224 224
     $points[$user_id][UNIT_RESOURCES] = $counts[$user_id][UNIT_RESOURCES] / 1000;
225 225
     $points[$user_id] = array_map('floor', $points[$user_id]);
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 
276 276
   // Updating player's ranks
277 277
   sta_set_time_limit("updating ranks for players");
278
-  foreach($rankNames as $rankName) {
278
+  foreach ($rankNames as $rankName) {
279 279
     sta_set_time_limit("updating player rank '{$rankName}'", false);
280 280
     doquery($qryResetRowNum);
281 281
     doquery(sprintf($qryFormat, $rankName, 1));
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 
284 284
   sta_set_time_limit("updating ranks for Alliances");
285 285
   // --- Updating Allie's ranks
286
-  foreach($rankNames as $rankName) {
286
+  foreach ($rankNames as $rankName) {
287 287
     sta_set_time_limit("updating Alliances rank '{$rankName}'", false);
288 288
     doquery($qryResetRowNum);
289 289
     doquery(sprintf($qryFormat, $rankName, 2));
Please login to merge, or discard this patch.
includes/includes/flt_page3.inc 1 patch
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 // @version 1.0
4 4
 // @copyright 2008 by Chlorel for XNova
5 5
 
6
-if(SN_IN_FLEET !== true) {
6
+if (SN_IN_FLEET !== true) {
7 7
   $debug->error("Attempt to call FLEET page mode {$mode} directly - not from fleet.php", 'Forbidden', 403);
8 8
 }
9 9
 
@@ -20,25 +20,25 @@  discard block
 block discarded – undo
20 20
 
21 21
   // Test de coherance de la destination (voir si elle se trouve dans les limites de l'univers connu
22 22
   $errorlist = '';
23
-  if(!$galaxy || $galaxy > $config->game_maxGalaxy || $galaxy < 1) {
23
+  if (!$galaxy || $galaxy > $config->game_maxGalaxy || $galaxy < 1) {
24 24
     $errorlist .= $lang['fl_limit_galaxy'];
25 25
   }
26
-  if(!$system || $system > $config->game_maxSystem || $system < 1) {
26
+  if (!$system || $system > $config->game_maxSystem || $system < 1) {
27 27
     $errorlist .= $lang['fl_limit_system'];
28 28
   }
29
-  if(!$planet || $planet < 1 || ($planet > $config->game_maxPlanet && $target_mission != MT_EXPLORE)) {
29
+  if (!$planet || $planet < 1 || ($planet > $config->game_maxPlanet && $target_mission != MT_EXPLORE)) {
30 30
     $errorlist .= $lang['fl_limit_planet'];
31 31
   }
32
-  if($planetrow['galaxy'] == $galaxy && $planetrow['system'] == $system && $planetrow['planet'] == $planet && $planetrow['planet_type'] == $planet_type) {
32
+  if ($planetrow['galaxy'] == $galaxy && $planetrow['system'] == $system && $planetrow['planet'] == $planet && $planetrow['planet_type'] == $planet_type) {
33 33
     $errorlist .= $lang['fl_ownpl_err'];
34 34
   }
35
-  if(!$planet_type) {
35
+  if (!$planet_type) {
36 36
     $errorlist .= $lang['fl_no_planettype'];
37 37
   }
38
-  if($planet_type != PT_PLANET && $planet_type != PT_DEBRIS && $planet_type != PT_MOON) {
38
+  if ($planet_type != PT_PLANET && $planet_type != PT_DEBRIS && $planet_type != PT_MOON) {
39 39
     $errorlist .= $lang['fl_fleet_err_pl'];
40 40
   }
41
-  if(empty($missiontype[$target_mission])) {
41
+  if (empty($missiontype[$target_mission])) {
42 42
     $errorlist .= $lang['fl_bad_mission'];
43 43
   }
44 44
 
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
   $TransDeuterium = max(0, sys_get_param_float('resource2'));
48 48
   $StorageNeeded = $TransMetal + $TransCrystal + $TransDeuterium;
49 49
 
50
-  if(!$StorageNeeded && $target_mission == MT_TRANSPORT) {
50
+  if (!$StorageNeeded && $target_mission == MT_TRANSPORT) {
51 51
     $errorlist .= $lang['fl_noenoughtgoods'];
52 52
   }
53 53
 
@@ -56,41 +56,41 @@  discard block
 block discarded – undo
56 56
   $user = db_user_by_id($user['id'], true);
57 57
   $planetrow = db_planet_by_id($planetrow['id'], true);
58 58
 
59
-  if($target_mission == MT_EXPLORE) {
60
-    if($MaxExpeditions == 0) {
59
+  if ($target_mission == MT_EXPLORE) {
60
+    if ($MaxExpeditions == 0) {
61 61
       $errorlist .= $lang['fl_expe_notech'];
62
-    } elseif($FlyingExpeditions >= $MaxExpeditions) {
62
+    } elseif ($FlyingExpeditions >= $MaxExpeditions) {
63 63
       $errorlist .= $lang['fl_expe_max'];
64 64
     }
65 65
   } else {
66
-    if($TargetPlanet['id_owner']) {
67
-      if($target_mission == MT_COLONIZE) {
66
+    if ($TargetPlanet['id_owner']) {
67
+      if ($target_mission == MT_COLONIZE) {
68 68
         $errorlist .= $lang['fl_colonized'];
69 69
       }
70 70
 
71
-      if($TargetPlanet['id_owner'] == $planetrow['id_owner']) {
72
-        if($target_mission == MT_ATTACK) {
71
+      if ($TargetPlanet['id_owner'] == $planetrow['id_owner']) {
72
+        if ($target_mission == MT_ATTACK) {
73 73
           $errorlist .= $lang['fl_no_self_attack'];
74 74
         }
75 75
 
76
-        if($target_mission == MT_SPY) {
76
+        if ($target_mission == MT_SPY) {
77 77
           $errorlist .= $lang['fl_no_self_spy'];
78 78
         }
79 79
       } else {
80
-        if($target_mission == MT_RELOCATE) {
80
+        if ($target_mission == MT_RELOCATE) {
81 81
           $errorlist .= $lang['fl_only_stay_at_home'];
82 82
         }
83 83
       }
84 84
     } else {
85
-      if($target_mission < MT_COLONIZE) {
85
+      if ($target_mission < MT_COLONIZE) {
86 86
         $errorlist .= $lang['fl_unknow_target'];
87 87
       } else {
88
-        if($target_mission == MT_DESTROY) {
88
+        if ($target_mission == MT_DESTROY) {
89 89
           $errorlist .= $lang['fl_nomoon'];
90 90
         }
91 91
 
92
-        if($target_mission == MT_RECYCLE) {
93
-          if($TargetPlanet['debris_metal'] + $TargetPlanet['debris_crystal'] == 0) {
92
+        if ($target_mission == MT_RECYCLE) {
93
+          if ($TargetPlanet['debris_metal'] + $TargetPlanet['debris_crystal'] == 0) {
94 94
             $errorlist .= $lang['fl_nodebris'];
95 95
           }
96 96
         }
@@ -99,13 +99,13 @@  discard block
 block discarded – undo
99 99
   }
100 100
 
101 101
 
102
-  if($sn_module['unit_captain']->manifest['active'] && $captain_id = sys_get_param_id('captain_id')) {
102
+  if ($sn_module['unit_captain']->manifest['active'] && $captain_id = sys_get_param_id('captain_id')) {
103 103
     $captain = $sn_module['unit_captain']->unit_captain_get($planetrow['id']);
104 104
 //      mrc_get_level($user, $planetrow, UNIT_CAPTAIN, true);
105
-    if(!$captain) {
105
+    if (!$captain) {
106 106
       $errorlist .= $lang['module_unit_captain_error_no_captain'];
107
-    } elseif($captain['unit_location_type'] == LOC_PLANET) {
108
-      if($target_mission == MT_RELOCATE && ($arriving_captain = mrc_get_level($user, $TargetPlanet, UNIT_CAPTAIN, true))) {
107
+    } elseif ($captain['unit_location_type'] == LOC_PLANET) {
108
+      if ($target_mission == MT_RELOCATE && ($arriving_captain = mrc_get_level($user, $TargetPlanet, UNIT_CAPTAIN, true))) {
109 109
         $errorlist .= $lang['module_unit_captain_error_captain_already_bound'];
110 110
       }
111 111
     } else {
@@ -113,14 +113,14 @@  discard block
 block discarded – undo
113 113
     }
114 114
   }
115 115
 
116
-  if($errorlist) {
116
+  if ($errorlist) {
117 117
     sn_db_transaction_rollback();
118 118
     message("<span class='error'><ul>{$errorlist}</ul></span>", $lang['fl_error'], 'fleet' . DOT_PHP_EX, false);
119 119
   }
120 120
 
121 121
   // On verifie s'il y a assez de vaisseaux sur la planete !
122
-  foreach($fleetarray as $Ship => $Count) {
123
-    if($Count > mrc_get_level($user, $planetrow, $Ship)) {
122
+  foreach ($fleetarray as $Ship => $Count) {
123
+    if ($Count > mrc_get_level($user, $planetrow, $Ship)) {
124 124
       message("<span class='error'><b>{$lang['fl_fleet_err']}</b></span>", $lang['fl_error'], 'fleet' . DOT_PHP_EX, 2);
125 125
     }
126 126
   }
@@ -131,10 +131,10 @@  discard block
 block discarded – undo
131 131
   //But is it acs??
132 132
   //Well all acs fleets must have a fleet code.
133 133
   //The co-ords must be the same as where the acs fleet is going.
134
-  if($fleet_group && sys_get_param_str('acs_target_mr') == "g{$galaxy}s{$system}p{$planet}t{$planet_type}") {
134
+  if ($fleet_group && sys_get_param_str('acs_target_mr') == "g{$galaxy}s{$system}p{$planet}t{$planet_type}") {
135 135
     //ACS attack must exist (if acs fleet has arrived this will also return false (2 checks in 1!!!)
136 136
     $aks = db_acs_get_by_group_id($fleet_group);
137
-    if(!$aks) {
137
+    if (!$aks) {
138 138
       $fleet_group = 0;
139 139
     } else {
140 140
       //Also it must be mission type 2
@@ -145,31 +145,31 @@  discard block
 block discarded – undo
145 145
       $planet = $aks['planet'];
146 146
       $planet_type = $aks['planet_type'];
147 147
     }
148
-  } elseif($target_mission == MT_AKS) {
148
+  } elseif ($target_mission == MT_AKS) {
149 149
     //Check that a failed acs attack isn't being sent, if it is, make it an attack fleet.
150 150
     $target_mission = MT_ATTACK;
151 151
   }
152 152
 
153
-  if($target_mission == MT_COLONIZE || $target_mission == MT_EXPLORE) {
153
+  if ($target_mission == MT_COLONIZE || $target_mission == MT_EXPLORE) {
154 154
     $TargetPlanet = array('galaxy' => $galaxy, 'system' => $system, 'planet' => $planet, 'id_owner' => 0);
155 155
   }
156 156
   $options = array('fleet_speed_percent' => $speed_percent, 'fleet_group' => $fleet_group, 'resources' => $StorageNeeded);
157 157
   $cant_attack = flt_can_attack($planetrow, $TargetPlanet, $fleetarray, $target_mission, $options);
158 158
 
159
-  if($cant_attack !== ATTACK_ALLOWED) {
159
+  if ($cant_attack !== ATTACK_ALLOWED) {
160 160
     message("<span class='error'><b>{$lang['fl_attack_error'][$cant_attack]}</b></span>", $lang['fl_error'], 'fleet' . DOT_PHP_EX, 99);
161 161
   }
162 162
 
163 163
   $speed_possible = array(10, 9, 8, 7, 6, 5, 4, 3, 2, 1);
164
-  if(!in_array($speed_percent, $speed_possible)) {
164
+  if (!in_array($speed_percent, $speed_possible)) {
165 165
     message("<span class='error'><b>" . $lang['fl_cheat_speed'] . "</b></span>", $lang['fl_error'], 'fleet' . DOT_PHP_EX, 2);
166 166
   }
167 167
 
168 168
   $mission_time_in_seconds = 0;
169 169
   $arrival_time = SN_TIME_NOW + $time_to_travel;
170
-  if($target_mission == MT_AKS && $aks) {
170
+  if ($target_mission == MT_AKS && $aks) {
171 171
 //    if($fleet_start_time > $aks['ankunft']) {
172
-    if($arrival_time > $aks['ankunft']) {
172
+    if ($arrival_time > $aks['ankunft']) {
173 173
       message($lang['fl_aks_too_slow'] . 'Fleet arrival: ' . date(FMT_DATE_TIME, $arrival_time) . " AKS arrival: " . date(FMT_DATE_TIME, $aks['ankunft']), $lang['fl_error']);
174 174
     }
175 175
     $group_sync_delta_time = $aks['ankunft'] - $arrival_time;
@@ -178,11 +178,11 @@  discard block
 block discarded – undo
178 178
     // Set return time to ACS return time + fleet's time to travel
179 179
     $return_time = $aks['ankunft'] + $time_to_travel;
180 180
   } else {
181
-    if($target_mission == MT_EXPLORE || $target_mission == MT_HOLD) {
181
+    if ($target_mission == MT_EXPLORE || $target_mission == MT_HOLD) {
182 182
       $max_duration = $target_mission == MT_EXPLORE ? get_player_max_expedition_duration($user) : ($target_mission == MT_HOLD ? 12 : 0);
183
-      if($max_duration) {
183
+      if ($max_duration) {
184 184
         $mission_time_in_hours = sys_get_param_id('missiontime');
185
-        if($mission_time_in_hours > $max_duration || $mission_time_in_hours < 1) {
185
+        if ($mission_time_in_hours > $max_duration || $mission_time_in_hours < 1) {
186 186
           $debug->warning('Supplying wrong mission time', 'Hack attempt', 302, array('base_dump' => true));
187 187
           die();
188 188
         }
@@ -196,19 +196,19 @@  discard block
 block discarded – undo
196 196
   $FleetStorage = 0;
197 197
 
198 198
   $db_changeset = array();
199
-  foreach($fleetarray as $Ship => $Count) {
199
+  foreach ($fleetarray as $Ship => $Count) {
200 200
     $FleetStorage += get_unit_param($Ship, P_CAPACITY) * $Count;
201 201
     $db_changeset['unit'][] = sn_db_unit_changeset_prepare($Ship, -$Count, $user, $planetrow['id']);
202 202
   }
203 203
   $FleetStorage -= $consumption;
204 204
 
205
-  if($StorageNeeded > $FleetStorage) {
205
+  if ($StorageNeeded > $FleetStorage) {
206 206
     message("<span class='error'><b>" . $lang['fl_nostoragespa'] . pretty_number($StorageNeeded - $FleetStorage) . "</b></span>", $lang['fl_error'], 'fleet' . DOT_PHP_EX, 2);
207 207
   }
208
-  if($planetrow['deuterium'] < $TransDeuterium + $consumption) {
208
+  if ($planetrow['deuterium'] < $TransDeuterium + $consumption) {
209 209
     message("<font color=\"red\"><b>" . $lang['fl_no_deuterium'] . pretty_number($TransDeuterium + $consumption - $planetrow['deuterium']) . "</b></font>", $lang['fl_error'], 'fleet' . DOT_PHP_EX, 2);
210 210
   }
211
-  if(($planetrow['metal'] < $TransMetal) || ($planetrow['crystal'] < $TransCrystal)) {
211
+  if (($planetrow['metal'] < $TransMetal) || ($planetrow['crystal'] < $TransCrystal)) {
212 212
     message("<font color=\"red\"><b>" . $lang['fl_no_resources'] . "</b></font>", $lang['fl_error'], 'fleet' . DOT_PHP_EX, 2);
213 213
   }
214 214
 
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 
239 239
   $template = gettemplate('fleet3', true);
240 240
 
241
-  if(is_array($captain)) {
241
+  if (is_array($captain)) {
242 242
     db_unit_set_by_id($captain['unit_id'], "`unit_location_type` = " . LOC_FLEET . ", `unit_location_id` = {$objFleet->dbId}");
243 243
   }
244 244
 
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
     'START_LEFT'         => floor($return_time + 1 - SN_TIME_NOW),
252 252
   );
253 253
 
254
-  if(!empty($TargetPlanet)) {
254
+  if (!empty($TargetPlanet)) {
255 255
     $template_route += array(
256 256
       'END_TYPE_TEXT_SH' => $lang['sys_planet_type_sh'][$TargetPlanet['planet_type']],
257 257
       'END_COORDS'       => uni_render_coordinates($TargetPlanet),
@@ -264,8 +264,8 @@  discard block
 block discarded – undo
264 264
   $template->assign_block_vars('fleets', $template_route);
265 265
 
266 266
   $sn_groups_fleet = sn_get_groups('fleet');
267
-  foreach($fleetarray as $ship_id => $ship_count) {
268
-    if(in_array($ship_id, $sn_groups_fleet) && $ship_count) {
267
+  foreach ($fleetarray as $ship_id => $ship_count) {
268
+    if (in_array($ship_id, $sn_groups_fleet) && $ship_count) {
269 269
 //      $ship_base_data = get_ship_data($ship_id, $user);
270 270
       $template->assign_block_vars('fleets.ships', array(
271 271
         'ID'          => $ship_id,
Please login to merge, or discard this patch.
includes/classes/UBE/UBEUnit.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
     parent::setUnitId($unitId);
51 51
 
52 52
     // Reset combat stats??
53
-    if($this->_unitId) {
53
+    if ($this->_unitId) {
54 54
       $this->amplify = $this->info[P_AMPLIFY];
55 55
       $this->capacity = $this->info[P_CAPACITY];
56 56
       $this->price[RES_METAL] = $this->info[P_COST][RES_METAL];
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
     $this->bonus_attack = $this->info[P_ATTACK];
73 73
     $this->bonus_shield = $this->info[P_SHIELD];
74 74
     $this->bonus_armor = $this->info[P_ARMOR];
75
-    if(is_object($this->unit_bonus)) {
75
+    if (is_object($this->unit_bonus)) {
76 76
       $this->bonus_attack = floor($this->bonus_attack * $this->unit_bonus->calcBonus(P_ATTACK));
77 77
       $this->bonus_shield = floor($this->bonus_shield * $this->unit_bonus->calcBonus(P_SHIELD));
78 78
       $this->bonus_armor = floor($this->bonus_armor * $this->unit_bonus->calcBonus(P_ARMOR));
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
     $this->randomized_attack = $this->bonus_attack;
81 81
     $this->randomized_shield = $this->bonus_shield;
82 82
     $this->randomized_armor = $this->bonus_armor;
83
-    if(!$is_simulator) {
83
+    if (!$is_simulator) {
84 84
       // TODO - randomize attack if is not simulator
85 85
       $this->randomized_attack = floor($this->bonus_attack * ($is_simulator ? 1 : mt_rand(UBE_RANDOMIZE_FROM, UBE_RANDOMIZE_TO) / 100));
86 86
       $this->randomized_shield = floor($this->bonus_shield * ($is_simulator ? 1 : mt_rand(UBE_RANDOMIZE_FROM, UBE_RANDOMIZE_TO) / 100));
@@ -159,22 +159,22 @@  discard block
 block discarded – undo
159 159
    * @version 2016-02-25 23:42:45 41a4.68
160 160
    */
161 161
   public function restore_unit($is_simulator) {
162
-    if($this->_type != UNIT_DEFENCE || $this->units_lost <= 0) {
162
+    if ($this->_type != UNIT_DEFENCE || $this->units_lost <= 0) {
163 163
       return;
164 164
     }
165 165
 
166
-    if($is_simulator) {
166
+    if ($is_simulator) {
167 167
       $units_giveback = round($this->units_lost * UBE_DEFENCE_RESTORATION_CHANCE_AVG / 100); // for simulation just return 75% of loss
168 168
     } else {
169 169
       // Checking - should we trigger mass-restore
170
-      if($this->units_lost >= UBE_DEFENCE_RESTORATION_MASS_COUNT) {
170
+      if ($this->units_lost >= UBE_DEFENCE_RESTORATION_MASS_COUNT) {
171 171
         // For large amount - mass-restoring defence
172 172
         $units_giveback = round($this->units_lost * mt_rand(UBE_DEFENCE_RESTORATION_CHANCE_MIN, UBE_DEFENCE_RESTORATION_CHANCE_MAX) / 100);
173 173
       } else {
174 174
         // For small amount - restoring defence per single unit
175 175
         $units_giveback = 0;
176
-        for($i = 1; $i <= $this->units_lost; $i++) {
177
-          if(mt_rand(1, 100) <= UBE_DEFENCE_RESTORATION_CHANCE_AVG) {
176
+        for ($i = 1; $i <= $this->units_lost; $i++) {
177
+          if (mt_rand(1, 100) <= UBE_DEFENCE_RESTORATION_CHANCE_AVG) {
178 178
             $units_giveback++;
179 179
           }
180 180
         }
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
    */
194 194
   public function receive_damage($is_simulator) {
195 195
     // TODO - Добавить взрывы от полуповрежденных юнитов - т.е. заранее вычислить из убитых юнитов еще количество убитых умножить на вероятность от структуры
196
-    if($this->_count <= 0) {
196
+    if ($this->_count <= 0) {
197 197
       return;
198 198
     }
199 199
 
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
     $this->adjustCount(-$units_lost);
217 217
 
218 218
     // Проверяем - не взорвался ли текущий юнит
219
-    while($this->_count > 0 && $this->attack_income > 0) {
219
+    while ($this->_count > 0 && $this->attack_income > 0) {
220 220
       $this->attack_damaged_unit($is_simulator);
221 221
     }
222 222
 
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
     $armor_left = $this->pool_armor % $this->randomized_armor;
242 242
     // Проверка - не атакуем ли мы целый корабль
243 243
     // Такое может быть, если на прошлой итерации поврежденный корабль был взорван и еще осталась входящяя атака
244
-    if($shield_left == 0 && $armor_left == 0) {
244
+    if ($shield_left == 0 && $armor_left == 0) {
245 245
       $shield_left = $this->randomized_shield;
246 246
       $armor_left = $this->randomized_armor;
247 247
     }
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
     // Вычитаем этот дамадж из щитов пула
256 256
     $this->pool_shield -= $damage_to_shield;
257 257
     // Если весь дамадж был поглощён щитами - выходим
258
-    if($this->attack_income <= 0) {
258
+    if ($this->attack_income <= 0) {
259 259
       return;
260 260
     }
261 261
 
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
     $armor_left -= $damage_to_armor;
273 273
 
274 274
     // Проверяем - осталась ли броня на текущем корабле и вааще
275
-    if($this->pool_armor <= 0 || $armor_left <= 0) {
275
+    if ($this->pool_armor <= 0 || $armor_left <= 0) {
276 276
       // Не осталось - корабль уничтожен
277 277
       $this->adjustCount(-1);
278 278
 
@@ -283,10 +283,10 @@  discard block
 block discarded – undo
283 283
     $armor_left_percent = $armor_left / $this->randomized_armor * 100;
284 284
     // Проверяем % здоровья
285 285
     // TODO - сделать динамический процент для каждого вида юнитов
286
-    if($armor_left_percent <= UBE_CRITICAL_DAMAGE_THRESHOLD) {
286
+    if ($armor_left_percent <= UBE_CRITICAL_DAMAGE_THRESHOLD) {
287 287
       // Дамадж пошёл по структуре. Чем более поврежден юнит - тем больше шансов у него взорваться
288 288
       $random = $is_simulator ? UBE_CRITICAL_DAMAGE_THRESHOLD / 2 : mt_rand(0, 100);
289
-      if($random >= $armor_left_percent) {
289
+      if ($random >= $armor_left_percent) {
290 290
         $this->adjustCount(-1);
291 291
         $this->unit_count_boom++;
292 292
 
Please login to merge, or discard this patch.
includes/classes/UBE/UBEPlayerList.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
       UBE_PLAYER_IS_DEFENDER => array(),
56 56
     );
57 57
 
58
-    foreach($this->_container as $player_id => $UBEPlayer) {
58
+    foreach ($this->_container as $player_id => $UBEPlayer) {
59 59
       $result[$UBEPlayer->getSide() ? UBE_PLAYER_IS_ATTACKER : UBE_PLAYER_IS_DEFENDER][$player_id] = $UBEPlayer->getDbRow();
60 60
     }
61 61
 
@@ -70,8 +70,8 @@  discard block
 block discarded – undo
70 70
    */
71 71
   public function get_first_player_on_side($side) {
72 72
     $result = null;
73
-    foreach($this->_container as $player_id => $UBEPlayer) {
74
-      if($UBEPlayer->getSide() == $side) {
73
+    foreach ($this->_container as $player_id => $UBEPlayer) {
74
+      if ($UBEPlayer->getSide() == $side) {
75 75
         $result = $UBEPlayer;
76 76
         break;
77 77
       }
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
    */
89 89
   public function get_player_sides() {
90 90
     $result = array();
91
-    foreach($this->_container as $player_id => $UBEPlayer) {
91
+    foreach ($this->_container as $player_id => $UBEPlayer) {
92 92
       $result[$player_id] = $UBEPlayer->getSide() ? UBE_PLAYER_IS_ATTACKER : UBE_PLAYER_IS_DEFENDER;
93 93
     }
94 94
 
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
   }
97 97
 
98 98
   public function ubeLoadPlayersAndSetSideFromFleetIdList(array $added_fleets, UBEFleetList $fleetList, $side = UBE_PLAYER_IS_DEFENDER) {
99
-    foreach($added_fleets as $fleet_id) {
99
+    foreach ($added_fleets as $fleet_id) {
100 100
       $this->db_load_player_by_id($fleetList[$fleet_id]->owner_id, $side);
101 101
     }
102 102
   }
Please login to merge, or discard this patch.
includes/classes/UBE/UBEMoonCalculator.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 
71 71
     $debris_for_moon = $debris->debris_total();
72 72
 
73
-    if(!$debris_for_moon) {
73
+    if (!$debris_for_moon) {
74 74
       return;
75 75
     }
76 76
 
@@ -78,12 +78,12 @@  discard block
 block discarded – undo
78 78
     $moon_chance = min($debris_for_moon / UBE_MOON_DEBRIS_PER_PERCENT, UBE_MOON_PERCENT_MAX); // TODO Configure
79 79
     $moon_chance = $moon_chance >= UBE_MOON_PERCENT_MIN ? $moon_chance : 0;
80 80
     $this->create_chance = $moon_chance;
81
-    if($moon_chance) {
82
-      if($is_simulator || mt_rand(1, 100) <= $moon_chance) {
81
+    if ($moon_chance) {
82
+      if ($is_simulator || mt_rand(1, 100) <= $moon_chance) {
83 83
         $this->status = UBE_MOON_CREATE_SUCCESS;
84 84
         $this->moon_diameter = round($is_simulator ? $moon_chance * 150 + 1999 : mt_rand($moon_chance * 100 + 1000, $moon_chance * 200 + 2999));
85 85
 
86
-        if($debris_for_moon <= UBE_MOON_DEBRIS_MAX_SPENT) {
86
+        if ($debris_for_moon <= UBE_MOON_DEBRIS_MAX_SPENT) {
87 87
           $debris->_reset();
88 88
         } else {
89 89
           $moon_debris_left_percent = ($debris_for_moon - UBE_MOON_DEBRIS_MAX_SPENT) / $debris_for_moon;
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
    */
103 103
   protected function moon_destroy_try($reapers) {
104 104
     // TODO: $is_simulator
105
-    if($reapers <= 0) {
105
+    if ($reapers <= 0) {
106 106
       return;
107 107
     }
108 108
 
@@ -120,8 +120,8 @@  discard block
 block discarded – undo
120 120
    * @version 2016-02-25 23:42:45 41a4.68
121 121
    */
122 122
   public function calculate_moon(UBE $ube) {
123
-    if(UBE_MOON_EXISTS == $this->status) {
124
-      if($ube->mission_type_id == MT_DESTROY && $ube->combat_result == UBE_COMBAT_RESULT_WIN) {
123
+    if (UBE_MOON_EXISTS == $this->status) {
124
+      if ($ube->mission_type_id == MT_DESTROY && $ube->combat_result == UBE_COMBAT_RESULT_WIN) {
125 125
         $reapers = $ube->fleet_list->ube_calculate_attack_reapers();
126 126
         $this->moon_destroy_try($reapers);
127 127
       }
@@ -131,12 +131,12 @@  discard block
 block discarded – undo
131 131
   }
132 132
 
133 133
   public function report_generate_sql() {
134
-    return "`ube_report_moon` = " . (int)$this->status . ",
135
-      `ube_report_moon_chance` = " . (int)$this->create_chance . ",
136
-      `ube_report_moon_size` = " . (float)$this->moon_diameter . ",
137
-      `ube_report_moon_reapers` = " . (int)$this->reapers_status . ",
138
-      `ube_report_moon_destroy_chance` = " . (int)$this->destroy_chance . ",
139
-      `ube_report_moon_reapers_die_chance` = " . (int)$this->reaper_die_chance;
134
+    return "`ube_report_moon` = " . (int) $this->status . ",
135
+      `ube_report_moon_chance` = " . (int) $this->create_chance . ",
136
+      `ube_report_moon_size` = " . (float) $this->moon_diameter . ",
137
+      `ube_report_moon_reapers` = " . (int) $this->reapers_status . ",
138
+      `ube_report_moon_destroy_chance` = " . (int) $this->destroy_chance . ",
139
+      `ube_report_moon_reapers_die_chance` = " . (int) $this->reaper_die_chance;
140 140
   }
141 141
 
142 142
   public function report_render_moon() {
@@ -166,11 +166,11 @@  discard block
 block discarded – undo
166 166
    * @param $planet_id
167 167
    */
168 168
   public function db_apply_result($planet_info, $destination_user_id) {
169
-    if($this->status == UBE_MOON_CREATE_SUCCESS) {
169
+    if ($this->status == UBE_MOON_CREATE_SUCCESS) {
170 170
       $moon_row = uni_create_moon($planet_info[PLANET_GALAXY], $planet_info[PLANET_SYSTEM], $planet_info[PLANET_PLANET], $destination_user_id, $this->moon_diameter, '', false);
171 171
       $this->moon_name = $moon_row['name'];
172 172
       unset($moon_row);
173
-    } elseif($this->status == UBE_MOON_DESTROY_SUCCESS) {
173
+    } elseif ($this->status == UBE_MOON_DESTROY_SUCCESS) {
174 174
       db_planet_delete_by_id($planet_info[PLANET_ID]);
175 175
     }
176 176
   }
@@ -179,14 +179,14 @@  discard block
 block discarded – undo
179 179
     global $lang;
180 180
 
181 181
     $text_defender = '';
182
-    if($this->status == UBE_MOON_CREATE_SUCCESS) {
182
+    if ($this->status == UBE_MOON_CREATE_SUCCESS) {
183 183
       $text_defender .= "{$lang['ube_report_moon_created']} {$this->moon_diameter} {$lang['sys_kilometers_short']}<br /><br />";
184
-    } elseif($this->status == UBE_MOON_CREATE_FAILED) {
184
+    } elseif ($this->status == UBE_MOON_CREATE_FAILED) {
185 185
       $text_defender .= "{$lang['ube_report_moon_chance']} {$this->create_chance}%<br /><br />";
186 186
     }
187 187
 
188
-    if($ube->mission_type_id == MT_DESTROY) {
189
-      if($this->reapers_status == UBE_MOON_REAPERS_NONE) {
188
+    if ($ube->mission_type_id == MT_DESTROY) {
189
+      if ($this->reapers_status == UBE_MOON_REAPERS_NONE) {
190 190
         $text_defender .= $lang['ube_report_moon_reapers_none'];
191 191
       } else {
192 192
         $text_defender .= "{$lang['ube_report_moon_reapers_wave']}. {$lang['ube_report_moon_reapers_chance']} {$this->destroy_chance}%. ";
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
    * @version 2016-02-25 23:42:45 41a4.68
216 216
    */
217 217
   public function ubeInitLoadStatis($destination_planet) {
218
-    if($destination_planet['planet_type'] == PT_MOON || is_array($moon = db_planet_by_parent($destination_planet['id'], true, '`id`'))) {
218
+    if ($destination_planet['planet_type'] == PT_MOON || is_array($moon = db_planet_by_parent($destination_planet['id'], true, '`id`'))) {
219 219
       $this->status = UBE_MOON_EXISTS;
220 220
       $this->moon_diameter = !empty($moon['planet_type']) && $moon['planet_type'] == PT_MOON ? $moon['diameter'] : $destination_planet['diameter'];
221 221
       $this->reapers_status = UBE_MOON_REAPERS_NONE;
Please login to merge, or discard this patch.