Completed
Push — work-fleets ( 8591a1...0fb536 )
by SuperNova.WS
07:12
created
classes/UBE/UBEMoonCalculator.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 
73 73
     $debris_for_moon = $debris->debris_total();
74 74
 
75
-    if(!$debris_for_moon) {
75
+    if (!$debris_for_moon) {
76 76
       return;
77 77
     }
78 78
 
@@ -80,12 +80,12 @@  discard block
 block discarded – undo
80 80
     $moon_chance = min($debris_for_moon / UBE_MOON_DEBRIS_PER_PERCENT, UBE_MOON_PERCENT_MAX); // TODO Configure
81 81
     $moon_chance = $moon_chance >= UBE_MOON_PERCENT_MIN ? $moon_chance : 0;
82 82
     $this->create_chance = $moon_chance;
83
-    if($moon_chance) {
84
-      if($is_simulator || mt_rand(1, 100) <= $moon_chance) {
83
+    if ($moon_chance) {
84
+      if ($is_simulator || mt_rand(1, 100) <= $moon_chance) {
85 85
         $this->status = UBE_MOON_CREATE_SUCCESS;
86 86
         $this->moon_diameter = round($is_simulator ? $moon_chance * 150 + 1999 : mt_rand($moon_chance * 100 + 1000, $moon_chance * 200 + 2999));
87 87
 
88
-        if($debris_for_moon <= UBE_MOON_DEBRIS_MAX_SPENT) {
88
+        if ($debris_for_moon <= UBE_MOON_DEBRIS_MAX_SPENT) {
89 89
           $debris->_reset();
90 90
         } else {
91 91
           $moon_debris_left_percent = ($debris_for_moon - UBE_MOON_DEBRIS_MAX_SPENT) / $debris_for_moon;
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
    */
105 105
   protected function moon_destroy_try($reapers) {
106 106
     // TODO: $is_simulator
107
-    if($reapers <= 0) {
107
+    if ($reapers <= 0) {
108 108
       return;
109 109
     }
110 110
 
@@ -122,8 +122,8 @@  discard block
 block discarded – undo
122 122
    * @version 2016-02-25 23:42:45 41a4.68
123 123
    */
124 124
   public function calculate_moon(UBE $ube) {
125
-    if(UBE_MOON_EXISTS == $this->status) {
126
-      if($ube->mission_type_id == MT_DESTROY && $ube->combat_result == UBE_COMBAT_RESULT_WIN) {
125
+    if (UBE_MOON_EXISTS == $this->status) {
126
+      if ($ube->mission_type_id == MT_DESTROY && $ube->combat_result == UBE_COMBAT_RESULT_WIN) {
127 127
         $reapers = $ube->fleet_list->ube_calculate_attack_reapers();
128 128
         $this->moon_destroy_try($reapers);
129 129
       }
@@ -137,12 +137,12 @@  discard block
 block discarded – undo
137 137
    */
138 138
   public function report_generate_array() {
139 139
     return array(
140
-      'ube_report_moon'                    => (int)$this->status,
141
-      'ube_report_moon_chance'             => (int)$this->create_chance,
142
-      'ube_report_moon_size'               => (float)$this->moon_diameter,
143
-      'ube_report_moon_reapers'            => (int)$this->reapers_status,
144
-      'ube_report_moon_destroy_chance'     => (int)$this->destroy_chance,
145
-      'ube_report_moon_reapers_die_chance' => (int)$this->reaper_die_chance,
140
+      'ube_report_moon'                    => (int) $this->status,
141
+      'ube_report_moon_chance'             => (int) $this->create_chance,
142
+      'ube_report_moon_size'               => (float) $this->moon_diameter,
143
+      'ube_report_moon_reapers'            => (int) $this->reapers_status,
144
+      'ube_report_moon_destroy_chance'     => (int) $this->destroy_chance,
145
+      'ube_report_moon_reapers_die_chance' => (int) $this->reaper_die_chance,
146 146
     );
147 147
   }
148 148
 
@@ -173,11 +173,11 @@  discard block
 block discarded – undo
173 173
    * @param $planet_id
174 174
    */
175 175
   public function db_apply_result($planet_info, $destination_user_id) {
176
-    if($this->status == UBE_MOON_CREATE_SUCCESS) {
176
+    if ($this->status == UBE_MOON_CREATE_SUCCESS) {
177 177
       $moon_row = uni_create_moon($planet_info[PLANET_GALAXY], $planet_info[PLANET_SYSTEM], $planet_info[PLANET_PLANET], $destination_user_id, $this->moon_diameter, '', false);
178 178
       $this->moon_name = $moon_row['name'];
179 179
       unset($moon_row);
180
-    } elseif($this->status == UBE_MOON_DESTROY_SUCCESS) {
180
+    } elseif ($this->status == UBE_MOON_DESTROY_SUCCESS) {
181 181
       DBStaticPlanet::db_planet_delete_by_id($planet_info[PLANET_ID]);
182 182
     }
183 183
   }
@@ -186,14 +186,14 @@  discard block
 block discarded – undo
186 186
     $classLocale = classLocale::$lang;
187 187
 
188 188
     $text_defender = '';
189
-    if($this->status == UBE_MOON_CREATE_SUCCESS) {
189
+    if ($this->status == UBE_MOON_CREATE_SUCCESS) {
190 190
       $text_defender .= "{$classLocale['ube_report_moon_created']} {$this->moon_diameter} {$classLocale['sys_kilometers_short']}<br /><br />";
191
-    } elseif($this->status == UBE_MOON_CREATE_FAILED) {
191
+    } elseif ($this->status == UBE_MOON_CREATE_FAILED) {
192 192
       $text_defender .= "{$classLocale['ube_report_moon_chance']} {$this->create_chance}%<br /><br />";
193 193
     }
194 194
 
195
-    if($ube->mission_type_id == MT_DESTROY) {
196
-      if($this->reapers_status == UBE_MOON_REAPERS_NONE) {
195
+    if ($ube->mission_type_id == MT_DESTROY) {
196
+      if ($this->reapers_status == UBE_MOON_REAPERS_NONE) {
197 197
         $text_defender .= classLocale::$lang['ube_report_moon_reapers_none'];
198 198
       } else {
199 199
         $text_defender .= "{$classLocale['ube_report_moon_reapers_wave']}. {$classLocale['ube_report_moon_reapers_chance']} {$this->destroy_chance}%. ";
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
    * @version 2016-02-25 23:42:45 41a4.68
223 223
    */
224 224
   public function ubeInitLoadStatis($destination_planet) {
225
-    if($destination_planet['planet_type'] == PT_MOON || is_array($moon = DBStaticPlanet::db_planet_by_parent($destination_planet['id'], true, '`id`'))) {
225
+    if ($destination_planet['planet_type'] == PT_MOON || is_array($moon = DBStaticPlanet::db_planet_by_parent($destination_planet['id'], true, '`id`'))) {
226 226
       $this->status = UBE_MOON_EXISTS;
227 227
       $this->moon_diameter = !empty($moon['planet_type']) && $moon['planet_type'] == PT_MOON ? $moon['diameter'] : $destination_planet['diameter'];
228 228
       $this->reapers_status = UBE_MOON_REAPERS_NONE;
Please login to merge, or discard this patch.
classes/DBRow.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
    * @param db_mysql|null $db
87 87
    */
88 88
   public static function setDb($db = null) {
89
-    if(empty($db) || !($db instanceof db_mysql)) {
89
+    if (empty($db) || !($db instanceof db_mysql)) {
90 90
       $db = null;
91 91
     }
92 92
     static::$db = !empty($db) || !class_exists('classSupernova', false) ? $db : classSupernova::$db;
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
       }
453 453
     }
454 454
 
455
-    if(empty($set)) {
455
+    if (empty($set)) {
456 456
       $theResult = true;
457 457
     } else {
458 458
       $theResult = classSupernova::$db->doUpdateRowAdjust(
Please login to merge, or discard this patch.
classes/Pimple/ServiceProviderInterface.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -32,8 +32,7 @@
 block discarded – undo
32 32
  * @author  Fabien Potencier
33 33
  * @author  Dominik Zogg
34 34
  */
35
-interface ServiceProviderInterface
36
-{
35
+interface ServiceProviderInterface {
37 36
     /**
38 37
      * Registers services on the given container.
39 38
      *
Please login to merge, or discard this patch.
includes/init/init_functions.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 // ------------------------------------------------------------------------------------------------------------------------------
4 4
 function sn_sys_load_php_files($dir_name, $load_extension = '.php', $modules = false) {
5
-  if(!file_exists($dir_name) || !is_dir($dir_name)) {
5
+  if (!file_exists($dir_name) || !is_dir($dir_name)) {
6 6
     return;
7 7
   }
8 8
 
@@ -39,10 +39,10 @@  discard block
 block discarded – undo
39 39
  */
40 40
 function init_update() {
41 41
   $update_file = SN_ROOT_PHYSICAL . "includes/update" . DOT_PHP_EX;
42
-  if(!file_exists($update_file)) {
42
+  if (!file_exists($update_file)) {
43 43
     return;
44 44
   }
45
-  if(
45
+  if (
46 46
     filemtime($update_file) <= classSupernova::$config->db_loadItem('var_db_update')
47 47
     &&
48 48
     classSupernova::$config->db_loadItem('db_version') >= DB_VERSION
@@ -50,9 +50,9 @@  discard block
 block discarded – undo
50 50
     return;
51 51
   }
52 52
 
53
-  if(defined('IN_ADMIN')) {
53
+  if (defined('IN_ADMIN')) {
54 54
     sn_db_transaction_start(); // Для защиты от двойного запуска апдейта - начинаем транзакцию. Так запись в базе будет блокирована
55
-    if(SN_TIME_NOW >= classSupernova::$config->db_loadItem('var_db_update_end')) {
55
+    if (SN_TIME_NOW >= classSupernova::$config->db_loadItem('var_db_update_end')) {
56 56
       classSupernova::$config->db_saveItem('var_db_update_end', SN_TIME_NOW + (classSupernova::$config->upd_lock_time ? classSupernova::$config->upd_lock_time : 300));
57 57
       sn_db_transaction_commit();
58 58
 
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
       $current_time = time();
63 63
       classSupernova::$config->db_saveItem('var_db_update', $current_time);
64 64
       classSupernova::$config->db_saveItem('var_db_update_end', $current_time);
65
-    } elseif(filemtime($update_file) > classSupernova::$config->var_db_update) {
65
+    } elseif (filemtime($update_file) > classSupernova::$config->var_db_update) {
66 66
       sn_db_transaction_rollback();
67 67
       $timeout = classSupernova::$config->var_db_update_end - SN_TIME_NOW;
68 68
       die(
Please login to merge, or discard this patch.
classes/sn_module.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
     require SN_ROOT_PHYSICAL . 'config.php';
76 76
 
77 77
     $module_config_array = get_class($this) . '_config';
78
-    if(!empty($$module_config_array) && is_array($$module_config_array)) {
78
+    if (!empty($$module_config_array) && is_array($$module_config_array)) {
79 79
       $this->config = $$module_config_array;
80 80
 
81 81
       return true;
@@ -93,15 +93,15 @@  discard block
 block discarded – undo
93 93
 
94 94
     // TODO: Load configuration from DB. Manifest setting
95 95
     // Trying to load configuration from file
96
-    if(!$config_exists = $this->loadModuleRootConfig()) {
96
+    if (!$config_exists = $this->loadModuleRootConfig()) {
97 97
       // Конфигурация может лежать в config_path в манифеста или в корне модуля
98
-      if(isset($this->manifest['config_path']) && file_exists($config_filename = $this->manifest['config_path'] . '/config.php')) {
98
+      if (isset($this->manifest['config_path']) && file_exists($config_filename = $this->manifest['config_path'] . '/config.php')) {
99 99
         $config_exists = true;
100
-      } elseif(file_exists($config_filename = dirname($filename) . '/config.php')) {
100
+      } elseif (file_exists($config_filename = dirname($filename) . '/config.php')) {
101 101
         $config_exists = true;
102 102
       }
103 103
 
104
-      if($config_exists) {
104
+      if ($config_exists) {
105 105
         include($config_filename);
106 106
         $module_config_array = $class_module_name . '_config';
107 107
         $this->config = $$module_config_array;
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 
119 119
     // Checking module status - is it installed and active
120 120
     $this->check_status();
121
-    if(!$this->manifest['active']) {
121
+    if (!$this->manifest['active']) {
122 122
       return;
123 123
     }
124 124
 
@@ -138,11 +138,11 @@  discard block
 block discarded – undo
138 138
 
139 139
   protected function setSystemConstants() {
140 140
     // Setting constants - if any
141
-    if(empty($this->manifest['constants']) || !is_array($this->manifest['constants'])) {
141
+    if (empty($this->manifest['constants']) || !is_array($this->manifest['constants'])) {
142 142
       return;
143 143
     }
144 144
 
145
-    foreach($this->manifest['constants'] as $constant_name => $constant_value) {
145
+    foreach ($this->manifest['constants'] as $constant_name => $constant_value) {
146 146
       !defined($constant_name) ? define($constant_name, $constant_value) : false;
147 147
     }
148 148
   }
@@ -154,48 +154,48 @@  discard block
 block discarded – undo
154 154
     // New values from module variables will overwrite previous values (for root variables) and array elements with corresponding indexes (for arrays)
155 155
     // Constants as array indexes are honored - it's make valid such declarations as 'sn_data[ques][QUE_STRUCTURES]'
156 156
     $this->manifest['vars'] = $this->__assign_vars();
157
-    if(empty($this->manifest['vars']) || !is_array($this->manifest['vars'])) {
157
+    if (empty($this->manifest['vars']) || !is_array($this->manifest['vars'])) {
158 158
       return;
159 159
     }
160 160
 
161 161
     $vars_assigned = array();
162
-    foreach($this->manifest['vars'] as $var_name => $var_value) {
162
+    foreach ($this->manifest['vars'] as $var_name => $var_value) {
163 163
       $sub_vars = explode('[', str_replace(']', '', $var_name));
164 164
       $var_name = $sub_vars[0];
165 165
 
166
-      if(!isset($vars_assigned[$var_name])) {
166
+      if (!isset($vars_assigned[$var_name])) {
167 167
         $vars_assigned[$var_name] = true;
168 168
         global $$var_name;
169 169
       }
170 170
 
171 171
       $pointer = &$$var_name;
172
-      if(($n = count($sub_vars)) > 1) {
173
-        for($i = 1; $i < $n; $i++) {
174
-          if(defined($sub_vars[$i])) {
172
+      if (($n = count($sub_vars)) > 1) {
173
+        for ($i = 1; $i < $n; $i++) {
174
+          if (defined($sub_vars[$i])) {
175 175
             $sub_vars[$i] = constant($sub_vars[$i]);
176 176
           }
177 177
 
178
-          if(!isset($pointer[$sub_vars[$i]]) && $i != $n) {
178
+          if (!isset($pointer[$sub_vars[$i]]) && $i != $n) {
179 179
             $pointer[$sub_vars[$i]] = array();
180 180
           }
181 181
           $pointer = &$pointer[$sub_vars[$i]];
182 182
         }
183 183
       }
184 184
 
185
-      if(!isset($pointer) || !is_array($pointer)) {
185
+      if (!isset($pointer) || !is_array($pointer)) {
186 186
         $pointer = $var_value;
187
-      } elseif(is_array($$var_name)) {
187
+      } elseif (is_array($$var_name)) {
188 188
         $pointer = array_merge_recursive_numeric($pointer, $var_value);
189 189
       }
190 190
     }
191 191
   }
192 192
 
193 193
   protected function mergeMenu(&$sn_menu_extra, &$menu_patch) {
194
-    if(!is_array($menu_patch)) {
194
+    if (!is_array($menu_patch)) {
195 195
       return;
196 196
     }
197 197
 
198
-    foreach($menu_patch as $menu_item_name => $menu_item_data) {
198
+    foreach ($menu_patch as $menu_item_name => $menu_item_data) {
199 199
       $sn_menu_extra[$menu_item_name] = $menu_item_data;
200 200
     }
201 201
   }
@@ -204,34 +204,34 @@  discard block
 block discarded – undo
204 204
     // Overriding function if any
205 205
     sn_sys_handler_add(classSupernova::$functions, $this->manifest['functions'], $this);
206 206
 
207
-    foreach(classSupernova::$sn_mvc as $handler_type => &$handler_data) {
207
+    foreach (classSupernova::$sn_mvc as $handler_type => &$handler_data) {
208 208
       sn_sys_handler_add($handler_data, $this->manifest['mvc'][$handler_type], $this, $handler_type);
209 209
     }
210 210
   }
211 211
 
212 212
   protected function mergeNavbarButton() {
213
-    if(empty($this->manifest['navbar_prefix_button']) || !is_array($this->manifest['navbar_prefix_button'])) {
213
+    if (empty($this->manifest['navbar_prefix_button']) || !is_array($this->manifest['navbar_prefix_button'])) {
214 214
       return;
215 215
     }
216 216
 
217
-    foreach($this->manifest['navbar_prefix_button'] as $button_image => $button_url_relative) {
217
+    foreach ($this->manifest['navbar_prefix_button'] as $button_image => $button_url_relative) {
218 218
       classSupernova::$sn_mvc['navbar_prefix_button'][$button_image] = $button_url_relative;
219 219
     }
220 220
   }
221 221
 
222 222
   protected function mergeI18N() {
223 223
     $arrayName = 'i18n';
224
-    if(empty($this->manifest[$arrayName]) || !is_array($this->manifest[$arrayName])) {
224
+    if (empty($this->manifest[$arrayName]) || !is_array($this->manifest[$arrayName])) {
225 225
       return;
226 226
     }
227 227
 
228
-    foreach($this->manifest[$arrayName] as $pageName => &$contentList) {
229
-      foreach($contentList as &$i18n_file_data) {
230
-        if(is_array($i18n_file_data) && !$i18n_file_data['path']) {
228
+    foreach ($this->manifest[$arrayName] as $pageName => &$contentList) {
229
+      foreach ($contentList as &$i18n_file_data) {
230
+        if (is_array($i18n_file_data) && !$i18n_file_data['path']) {
231 231
           $i18n_file_data['path'] = $this->manifest['root_relative'];
232 232
         }
233 233
       }
234
-      if(!isset(classSupernova::$sn_mvc[$arrayName][$pageName])) {
234
+      if (!isset(classSupernova::$sn_mvc[$arrayName][$pageName])) {
235 235
         classSupernova::$sn_mvc[$arrayName][$pageName] = array();
236 236
       }
237 237
       classSupernova::$sn_mvc[$arrayName][$pageName] += $contentList;
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
           $load_order[$loaded_module_name] = $level;
311 311
         }
312 312
       }
313
-    } while($prev_order != $load_order);
313
+    } while ($prev_order != $load_order);
314 314
 
315 315
     asort($load_order);
316 316
 
Please login to merge, or discard this patch.