Completed
Push — work-fleets ( 5b06a4...37e31f )
by SuperNova.WS
04:49
created
includes/classes/UBE/UBEDebris.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
    */
31 31
   public function debris_add_resource($resource_id, $resource_amount) {
32 32
     // В обломках может быть только металл или кристалл
33
-    if($resource_id != RES_METAL && $resource_id != RES_CRYSTAL) {
33
+    if ($resource_id != RES_METAL && $resource_id != RES_CRYSTAL) {
34 34
       return;
35 35
     }
36 36
     $this->debris[$resource_id] += $resource_amount;
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
    * @param bool  $is_simulator
42 42
    */
43 43
   public function add_wrecks(array $wreckage, $is_simulator) {
44
-    foreach($wreckage as $resource_id => $resource_amount) {
44
+    foreach ($wreckage as $resource_id => $resource_amount) {
45 45
       $this->debris_add_resource($resource_id, floor($resource_amount *
46 46
         ($is_simulator
47 47
           ? UBE_SHIP_WRECKS_TO_DEBRIS_AVG
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
    * @param bool  $is_simulator
58 58
    */
59 59
   public function add_cargo_drop(array $dropped_resources, $is_simulator) {
60
-    foreach($dropped_resources as $resource_id => $resource_amount) {
60
+    foreach ($dropped_resources as $resource_id => $resource_amount) {
61 61
       $this->debris_add_resource($resource_id, floor($resource_amount *
62 62
         ($is_simulator
63 63
           ? UBE_CARGO_DROPPED_TO_DEBRIS_AVG
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
    * @param $moon_debris_left_part
97 97
    */
98 98
   public function debris_adjust_proportional($moon_debris_left_part) {
99
-    foreach($this->debris as $resource_id => &$resource_amount) {
99
+    foreach ($this->debris as $resource_id => &$resource_amount) {
100 100
       $resource_amount = floor($resource_amount * $moon_debris_left_part);
101 101
     }
102 102
   }
@@ -121,9 +121,9 @@  discard block
 block discarded – undo
121 121
    */
122 122
   public function report_generate_sql(classConfig $config) {
123 123
     return "
124
-      `ube_report_debris_metal` = " . (float)$this->debris_get_resource(RES_METAL) . ",
125
-      `ube_report_debris_crystal` = " . (float)$this->debris_get_resource(RES_CRYSTAL) . ",
126
-      `ube_report_debris_total_in_metal` = " . (float)$this->debris_in_metal($config) . ", ";
124
+      `ube_report_debris_metal` = " . (float) $this->debris_get_resource(RES_METAL) . ",
125
+      `ube_report_debris_crystal` = " . (float) $this->debris_get_resource(RES_CRYSTAL) . ",
126
+      `ube_report_debris_total_in_metal` = " . (float) $this->debris_in_metal($config) . ", ";
127 127
   }
128 128
 
129 129
   /**
Please login to merge, or discard this patch.
includes/classes/UBE/UBEDebug.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
    * @version 41a6.0
12 12
    */
13 13
   public static function unit_dump_header() {
14
-    if(!defined('DEBUG_UBE')) {
14
+    if (!defined('DEBUG_UBE')) {
15 15
       return;
16 16
     }
17 17
 
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
    * @version 41a6.0
49 49
    */
50 50
   public static function unit_dump(UBEUnit $unit, $desc = '', UBEUnit $before = null) {
51
-    if(!defined('DEBUG_UBE')) {
51
+    if (!defined('DEBUG_UBE')) {
52 52
       return;
53 53
     }
54 54
 
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
    * @version 41a6.0
87 87
    */
88 88
   public static function unit_dump_footer() {
89
-    if(!defined('DEBUG_UBE')) {
89
+    if (!defined('DEBUG_UBE')) {
90 90
       return;
91 91
     }
92 92
 
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
    * @return UBEUnit
102 102
    */
103 103
   public static function unit_dump_defender(UBEUnit $attacking_unit_pool, UBEUnit $defending_unit_pool, $defending_fleet_id) {
104
-    if(!defined('DEBUG_UBE')) {
104
+    if (!defined('DEBUG_UBE')) {
105 105
       return null;
106 106
     }
107 107
 
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
    * @version 41a6.0
128 128
    */
129 129
   public static function unit_dump_delta(UBEUnit $unit, $field, UBEUnit $before = null) {
130
-    if(!defined('DEBUG_UBE')) {
130
+    if (!defined('DEBUG_UBE')) {
131 131
       return;
132 132
     }
133 133
 
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
     print(pretty_number($unit->$field));
137 137
     print("</td>");
138 138
     print("<td>");
139
-    if(!empty($before)) {
139
+    if (!empty($before)) {
140 140
       print('' . pretty_number($unit->$field - $before->$field) . '');
141 141
     }
142 142
     print("</td>");
Please login to merge, or discard this patch.
includes/classes/UBE/ArrayAccessV2.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 
43 43
 
44 44
   public function __clone() {
45
-    if(static::$_clonable == ArrayAccessV2::CLONE_NONE) {
45
+    if (static::$_clonable == ArrayAccessV2::CLONE_NONE) {
46 46
       return;
47 47
     }
48 48
 
@@ -50,10 +50,10 @@  discard block
 block discarded – undo
50 50
   }
51 51
 
52 52
   protected static function _deep_clone(&$array) {
53
-    foreach($array as &$value) {
54
-      if(is_object($value)) {
53
+    foreach ($array as &$value) {
54
+      if (is_object($value)) {
55 55
         $value = clone $value;
56
-      } elseif(is_array($value) && static::$_clonable == ArrayAccessV2::CLONE_DEEP) {
56
+      } elseif (is_array($value) && static::$_clonable == ArrayAccessV2::CLONE_DEEP) {
57 57
         static::_deep_clone($value);
58 58
       }
59 59
     }
@@ -67,8 +67,8 @@  discard block
 block discarded – undo
67 67
    */
68 68
   public function __call($method_name, array $arguments) {
69 69
     $object_first = reset($this->_container);
70
-    if($object_first !== false && method_exists($object_first, $method_name)) {
71
-      foreach($this->_container as $unit_id => $object) {
70
+    if ($object_first !== false && method_exists($object_first, $method_name)) {
71
+      foreach ($this->_container as $unit_id => $object) {
72 72
         call_user_func_array(array($object, $method_name), $arguments);
73 73
       }
74 74
     }
@@ -83,8 +83,8 @@  discard block
 block discarded – undo
83 83
    */
84 84
   public function getSumProperty($property_name) {
85 85
     $result = 0.0;
86
-    foreach($this->_container as $object) {
87
-      if(is_object($object) && property_exists($object, $property_name)) {
86
+    foreach ($this->_container as $object) {
87
+      if (is_object($object) && property_exists($object, $property_name)) {
88 88
         $result += $object->$property_name;
89 89
       }
90 90
     }
@@ -100,8 +100,8 @@  discard block
 block discarded – undo
100 100
    * @return mixed
101 101
    */
102 102
   public function aggregateByMethod($method_name, &$result) {
103
-    foreach($this->_container as $object) {
104
-      if(is_object($object) && method_exists($object, $method_name)) {
103
+    foreach ($this->_container as $object) {
104
+      if (is_object($object) && method_exists($object, $method_name)) {
105 105
         call_user_func(array($object, $method_name), $result);
106 106
       }
107 107
     }
Please login to merge, or discard this patch.
includes/classes/Bonus.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -28,12 +28,12 @@  discard block
 block discarded – undo
28 28
    * @param $unit_level
29 29
    */
30 30
   public function add_unit_by_snid($unit_id, $unit_level) {
31
-    if(!$unit_level) {
31
+    if (!$unit_level) {
32 32
       return;
33 33
     }
34 34
 
35
-    foreach(static::$_bonus_group as $param_name => $unit_list) {
36
-      if(!empty($unit_list[$unit_id])) {
35
+    foreach (static::$_bonus_group as $param_name => $unit_list) {
36
+      if (!empty($unit_list[$unit_id])) {
37 37
         // Простейший вариант - мультипликатор по базе
38 38
         // Общий мультипликатор добавляется в конец
39 39
         $this->grants[$param_name][$unit_id] = $unit_level;
@@ -82,16 +82,16 @@  discard block
 block discarded – undo
82 82
 //    $this->grants[$param_name][$unit_id] = $unit_level * get_unit_param($unit_id, P_BONUS_VALUE) / 100;;
83 83
     $value_add = floatval($base_value);
84 84
     $cumulative = 1.0; // Для случая BONUS_PERCENT
85
-    if(!empty($this->grants[$param]) && is_array($this->grants[$param])) {
86
-      foreach($this->grants[$param] as $unit_id => $unit_level) {
85
+    if (!empty($this->grants[$param]) && is_array($this->grants[$param])) {
86
+      foreach ($this->grants[$param] as $unit_id => $unit_level) {
87 87
         $unit_bonus = 0;
88
-        if($unit_id < 0) {
88
+        if ($unit_id < 0) {
89 89
           // Meta-unit - leave as is
90 90
         } else {
91 91
           // TODO - Подумать, что будет при смешивании разных бонусов и как этого избежать
92 92
           $bonus_value = get_unit_param($unit_id, P_BONUS_VALUE);
93 93
           $bonus_type = get_unit_param($unit_id, P_BONUS_TYPE);
94
-          switch($bonus_type) {
94
+          switch ($bonus_type) {
95 95
             case BONUS_PERCENT:
96 96
               $unit_bonus = $unit_level * $bonus_value / 100;
97 97
               $cumulative += $unit_bonus;
Please login to merge, or discard this patch.
includes/classes/FleetList.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -37,14 +37,14 @@  discard block
 block discarded – undo
37 37
       (!empty($where_safe) ? " WHERE {$where_safe}" : '') .
38 38
       " FOR UPDATE;"
39 39
     );
40
-    while($row = db_fetch($query)) {
40
+    while ($row = db_fetch($query)) {
41 41
       /**
42 42
        * @var Fleet $fleet
43 43
        */
44 44
       $fleet = $this->_createElement();
45 45
       $fleet->dbRowParse($row);
46 46
 
47
-      if(isset($this[$fleet->dbId])) {
47
+      if (isset($this[$fleet->dbId])) {
48 48
         // Нужно ли ????
49 49
         classSupernova::$debug->error('Fleet list already set');
50 50
       }
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
    * @return static
171 171
    */
172 172
   public static function dbGetFleetListAndMissileByCoordinates($coordinates, $for_phalanx = false) {
173
-    if(empty($coordinates) || !is_array($coordinates)) {
173
+    if (empty($coordinates) || !is_array($coordinates)) {
174 174
       return array();
175 175
     }
176 176
 
@@ -199,8 +199,8 @@  discard block
 block discarded – undo
199 199
      * @var Fleet[] $array_of_Fleet
200 200
      */
201 201
     $array_of_Fleet = array();
202
-    if(!empty($fleet_db_list) && $fleet_db_list->count()) {
203
-      foreach($fleet_db_list->_container as $fleet_id => $objFleet) {
202
+    if (!empty($fleet_db_list) && $fleet_db_list->count()) {
203
+      foreach ($fleet_db_list->_container as $fleet_id => $objFleet) {
204 204
         $array_of_Fleet[$fleet_id] = $objFleet;
205 205
       }
206 206
       $planet_fleets = flt_get_fleets_to_planet_by_array_of_Fleet($array_of_Fleet);
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
       "SELECT * FROM `{{iraks}}`" .
250 250
       (!empty($where) ? " WHERE {$where}" : '') .
251 251
       " FOR UPDATE;");
252
-    while($missile_db_row = db_fetch($query)) {
252
+    while ($missile_db_row = db_fetch($query)) {
253 253
       /**
254 254
        * @var Fleet $objFleet
255 255
        */
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
    */
272 272
   public static function dbGetFleetListAndMissileINCOMING($owner_id) {
273 273
     $owner_id_safe = idval($owner_id);
274
-    if(empty($owner_id_safe)) {
274
+    if (empty($owner_id_safe)) {
275 275
       return array();
276 276
     }
277 277
 
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
    */
306 306
   public static function fleet_count_flying($player_id, $mission_id = 0) {
307 307
     $player_id_safe = idval($player_id);
308
-    if(!empty($player_id_safe)) {
308
+    if (!empty($player_id_safe)) {
309 309
       $mission_id_safe = intval($mission_id);
310 310
       $result = static::db_fleet_count(
311 311
         "`fleet_owner` = {$player_id_safe}" .
Please login to merge, or discard this patch.
includes/classes/UnitResourceLoot.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
   public static function _init($group_name = '') {
27 27
     parent::_init($group_name);
28 28
 
29
-    foreach(static::$_group_unit_id_list as $resource_id) {
29
+    foreach (static::$_group_unit_id_list as $resource_id) {
30 30
       static::$_group_pnames[$resource_id] = pname_resource_name($resource_id);
31 31
     }
32 32
 
@@ -48,8 +48,8 @@  discard block
 block discarded – undo
48 48
 
49 49
     !is_array($resource_array) ? $resource_array = array() : false;
50 50
 
51
-    foreach($resource_array as $resource_id => $resource_actual_delta) {
52
-      if(!$resource_actual_delta) {
51
+    foreach ($resource_array as $resource_id => $resource_actual_delta) {
52
+      if (!$resource_actual_delta) {
53 53
         // No delta - no changes
54 54
         continue;
55 55
       }
Please login to merge, or discard this patch.
includes/classes/Player.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -229,8 +229,8 @@
 block discarded – undo
229 229
   public function calcColonyMaxCount($astrotech = -1) {
230 230
     global $config;
231 231
 
232
-    if($astrotech == -1) {
233
-      if(!isset($this->db_row[UNIT_PLAYER_COLONIES_MAX])) {
232
+    if ($astrotech == -1) {
233
+      if (!isset($this->db_row[UNIT_PLAYER_COLONIES_MAX])) {
234 234
 
235 235
         $expeditions = get_player_max_expeditons($this->db_row);
236 236
         $astrotech = mrc_get_level($this->db_row, false, TECH_ASTROTECH);
Please login to merge, or discard this patch.
includes/classes/PlayerList.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
    * @version 41a6.16
24 24
    */
25 25
   protected function db_load_player_by_id($player_id) {
26
-    if(isset($this[$player_id])) {
26
+    if (isset($this[$player_id])) {
27 27
       return;
28 28
     }
29 29
 
Please login to merge, or discard this patch.
includes/classes/db_mysql_v5.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -30,11 +30,11 @@  discard block
 block discarded – undo
30 30
 
31 31
     static $need_keys = array('server', 'user', 'pass', 'name', 'prefix');
32 32
 
33
-    if($this->connected) {
33
+    if ($this->connected) {
34 34
       return true;
35 35
     }
36 36
 
37
-    if(empty($settings) || !is_array($settings) || array_intersect($need_keys, array_keys($settings)) != $need_keys) {
37
+    if (empty($settings) || !is_array($settings) || array_intersect($need_keys, array_keys($settings)) != $need_keys) {
38 38
       $debug->error_fatal('There is missconfiguration in your config.php. Check it again');
39 39
     }
40 40
 
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
     return mysqli_real_escape_string($this->link, $unescaped_string);
91 91
   }
92 92
   function mysql_close_link() {
93
-    if(is_object($this->link)) {
93
+    if (is_object($this->link)) {
94 94
       $this->link->close();
95 95
       $this->connected = false;
96 96
       unset($this->link);
Please login to merge, or discard this patch.