Completed
Push — work-fleets ( 006942...3604bd )
by SuperNova.WS
06:54
created
classes/UBE/UBEFleet.php 2 patches
Doc Comments   +11 added lines, -4 removed lines patch added patch discarded remove patch
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
   }
151 151
 
152 152
   /**
153
-   * @param $ube_report_id
153
+   * @param integer $ube_report_id
154 154
    *
155 155
    * @return array
156 156
    *
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 
289 289
 
290 290
   /**
291
-   * @param $ube_report_id
291
+   * @param integer $ube_report_id
292 292
    *
293 293
    * @return array
294 294
    */
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
   // Рендерит таблицу общего результата боя
337 337
   /**
338 338
    * @param $array
339
-   * @param $lang_header_index
339
+   * @param string $lang_header_index
340 340
    *
341 341
    * @return array
342 342
    */
@@ -362,6 +362,9 @@  discard block
 block discarded – undo
362 362
   }
363 363
 
364 364
 
365
+  /**
366
+   * @param integer $ube_report_id
367
+   */
365 368
   public function sql_generate_outcome_unit_array(&$sql_perform_report_unit, $ube_report_id) {
366 369
     $fleet_id = $this->db_id;
367 370
 
@@ -468,6 +471,10 @@  discard block
 block discarded – undo
468 471
     $this->fleet_capacity -= $fleet_total_resources;
469 472
   }
470 473
 
474
+  /**
475
+   * @param integer $is_small_fleet_recce
476
+   * @param integer $reapers_status
477
+   */
471 478
   public function db_save_combat_result_fleet($is_small_fleet_recce, $reapers_status) {
472 479
     $ship_count_initial = $this->unit_list->unitsCount();
473 480
     $ship_count_lost = $this->unit_list->unitCountLost();
@@ -535,7 +542,7 @@  discard block
 block discarded – undo
535 542
 
536 543
   /**
537 544
    * @param UBEFleetList $fleet_list
538
-   * @param              $is_simulator
545
+   * @param              boolean $is_simulator
539 546
    *
540 547
    * @version 2016-02-25 23:42:45 41a4.68
541 548
    */
Please login to merge, or discard this patch.
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -162,20 +162,20 @@  discard block
 block discarded – undo
162 162
       $this->owner_id,
163 163
       $this->db_id,
164 164
 
165
-      (float)$this->UBE_PLANET[PLANET_ID],
166
-      "'" . db_escape($this->UBE_PLANET[PLANET_NAME]) . "'",
167
-      (int)$this->UBE_PLANET[PLANET_GALAXY],
168
-      (int)$this->UBE_PLANET[PLANET_SYSTEM],
169
-      (int)$this->UBE_PLANET[PLANET_PLANET],
170
-      (int)$this->UBE_PLANET[PLANET_TYPE],
171
-
172
-      (float)$this->resource_list[RES_METAL],
173
-      (float)$this->resource_list[RES_CRYSTAL],
174
-      (float)$this->resource_list[RES_DEUTERIUM],
175
-
176
-      (float)$this->fleet_bonus->calcBonus(P_ATTACK),
177
-      (float)$this->fleet_bonus->calcBonus(P_SHIELD),
178
-      (float)$this->fleet_bonus->calcBonus(P_ARMOR),
165
+      (float) $this->UBE_PLANET[PLANET_ID],
166
+      "'".db_escape($this->UBE_PLANET[PLANET_NAME])."'",
167
+      (int) $this->UBE_PLANET[PLANET_GALAXY],
168
+      (int) $this->UBE_PLANET[PLANET_SYSTEM],
169
+      (int) $this->UBE_PLANET[PLANET_PLANET],
170
+      (int) $this->UBE_PLANET[PLANET_TYPE],
171
+
172
+      (float) $this->resource_list[RES_METAL],
173
+      (float) $this->resource_list[RES_CRYSTAL],
174
+      (float) $this->resource_list[RES_DEUTERIUM],
175
+
176
+      (float) $this->fleet_bonus->calcBonus(P_ATTACK),
177
+      (float) $this->fleet_bonus->calcBonus(P_SHIELD),
178
+      (float) $this->fleet_bonus->calcBonus(P_ARMOR),
179 179
     );
180 180
   }
181 181
 
@@ -189,13 +189,13 @@  discard block
 block discarded – undo
189 189
     $this->owner_id = $objFleet->playerOwnerId;
190 190
     $this->group_id = $objFleet->group_id;
191 191
 
192
-    foreach($objFleet->shipsIterator() as $unit_id => $unit) {
193
-      if(!$unit->count) {
192
+    foreach ($objFleet->shipsIterator() as $unit_id => $unit) {
193
+      if (!$unit->count) {
194 194
         continue;
195 195
       }
196 196
 
197 197
       $unit_type = get_unit_param($unit_id, P_UNIT_TYPE);
198
-      if($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE) {
198
+      if ($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE) {
199 199
         $this->unit_list->unitAdjustCount($unit_id, $unit->count);
200 200
       }
201 201
     }
@@ -231,13 +231,13 @@  discard block
 block discarded – undo
231 231
 //      }
232 232
 //    }
233 233
 
234
-    foreach($sn_group_combat as $unit_id) {
235
-      if($unit_count = mrc_get_level($player_db_row, $planet_row, $unit_id)) {
234
+    foreach ($sn_group_combat as $unit_id) {
235
+      if ($unit_count = mrc_get_level($player_db_row, $planet_row, $unit_id)) {
236 236
         $this->unit_list->unitAdjustCount($unit_id, $unit_count);
237 237
       }
238 238
     }
239 239
 
240
-    foreach(sn_get_groups('resources_loot') as $resource_id) {
240
+    foreach (sn_get_groups('resources_loot') as $resource_id) {
241 241
       $this->resource_list[$resource_id] = floor(mrc_get_level($player_db_row, $planet_row, $resource_id));
242 242
     }
243 243
 
@@ -296,27 +296,27 @@  discard block
 block discarded – undo
296 296
       $ube_report_id,
297 297
       $this->db_id,
298 298
 
299
-      (float)$this->resources_lost_on_units[RES_METAL],
300
-      (float)$this->resources_lost_on_units[RES_CRYSTAL],
301
-      (float)$this->resources_lost_on_units[RES_DEUTERIUM],
302
-      (float)$this->cargo_dropped[RES_METAL],
303
-      (float)$this->cargo_dropped[RES_CRYSTAL],
304
-      (float)$this->cargo_dropped[RES_DEUTERIUM],
305
-      (float)$this->resources_looted[RES_METAL],
306
-      (float)$this->resources_looted[RES_CRYSTAL],
307
-      (float)$this->resources_looted[RES_DEUTERIUM],
308
-      (float)$this->resources_lost_in_metal[RES_METAL],
299
+      (float) $this->resources_lost_on_units[RES_METAL],
300
+      (float) $this->resources_lost_on_units[RES_CRYSTAL],
301
+      (float) $this->resources_lost_on_units[RES_DEUTERIUM],
302
+      (float) $this->cargo_dropped[RES_METAL],
303
+      (float) $this->cargo_dropped[RES_CRYSTAL],
304
+      (float) $this->cargo_dropped[RES_DEUTERIUM],
305
+      (float) $this->resources_looted[RES_METAL],
306
+      (float) $this->resources_looted[RES_CRYSTAL],
307
+      (float) $this->resources_looted[RES_DEUTERIUM],
308
+      (float) $this->resources_lost_in_metal[RES_METAL],
309 309
     );
310 310
   }
311 311
 
312 312
   public function report_render_outcome_side_fleet() {
313 313
     $UBE_DEFENCE_RESTORE = array();
314 314
     $UBE_UNITS_LOST = array();
315
-    foreach($this->unit_list->_container as $UBEUnit) {
316
-      if($UBEUnit->units_restored) {
315
+    foreach ($this->unit_list->_container as $UBEUnit) {
316
+      if ($UBEUnit->units_restored) {
317 317
         $UBE_DEFENCE_RESTORE[$UBEUnit->unitId] = $UBEUnit->units_restored;
318 318
       }
319
-      if($UBEUnit->units_lost) {
319
+      if ($UBEUnit->units_lost) {
320 320
         $UBE_UNITS_LOST[$UBEUnit->unitId] = $UBEUnit->units_lost;
321 321
       }
322 322
     }
@@ -341,16 +341,16 @@  discard block
 block discarded – undo
341 341
    */
342 342
   protected function report_render_outcome_side_fleet_line(&$array, $lang_header_index) {
343 343
     $result = array();
344
-    if(!empty($array)) {
345
-      foreach($array as $unit_id => $unit_count) {
346
-        if($unit_count) {
344
+    if (!empty($array)) {
345
+      foreach ($array as $unit_id => $unit_count) {
346
+        if ($unit_count) {
347 347
           $result[] = array(
348 348
             'NAME' => classLocale::$lang['tech'][$unit_id],
349 349
             'LOSS' => pretty_number($unit_count),
350 350
           );
351 351
         }
352 352
       }
353
-      if($lang_header_index && count($result)) {
353
+      if ($lang_header_index && count($result)) {
354 354
         array_unshift($result, array('NAME' => classLocale::$lang[$lang_header_index]));
355 355
       }
356 356
     }
@@ -363,16 +363,16 @@  discard block
 block discarded – undo
363 363
     $fleet_id = $this->db_id;
364 364
 
365 365
     $unit_sort_order = 0;
366
-    foreach($this->unit_list->_container as $UBEUnit) {
367
-      if($UBEUnit->units_lost || $UBEUnit->units_restored) {
366
+    foreach ($this->unit_list->_container as $UBEUnit) {
367
+      if ($UBEUnit->units_lost || $UBEUnit->units_restored) {
368 368
         $unit_sort_order++;
369 369
         $sql_perform_report_unit[] = array(
370 370
           $ube_report_id,
371 371
           $fleet_id,
372 372
 
373 373
           $UBEUnit->unitId,
374
-          (float)$UBEUnit->units_restored,
375
-          (float)$UBEUnit->units_lost,
374
+          (float) $UBEUnit->units_restored,
375
+          (float) $UBEUnit->units_lost,
376 376
 
377 377
           $unit_sort_order,
378 378
         );
@@ -388,9 +388,9 @@  discard block
 block discarded – undo
388 388
   function ube_combat_result_calculate_resources() {
389 389
     $resource_delta_fleet = array();
390 390
     // Если во флоте остались юниты или это планета - генерируем изменение ресурсов
391
-    foreach(sn_get_groups('resources_loot') as $resource_id) {
392
-      $resource_change = (float)$this->resources_looted[$resource_id] + (float)$this->cargo_dropped[$resource_id];
393
-      if($resource_change) {
391
+    foreach (sn_get_groups('resources_loot') as $resource_id) {
392
+      $resource_change = (float) $this->resources_looted[$resource_id] + (float) $this->cargo_dropped[$resource_id];
393
+      if ($resource_change) {
394 394
         $resource_delta_fleet[$resource_id] = -($resource_change);
395 395
       }
396 396
     }
@@ -423,12 +423,12 @@  discard block
 block discarded – undo
423 423
     );
424 424
 
425 425
     $this->fleet_capacity = 0;
426
-    foreach($this->unit_list->_container as $UBEUnit) {
426
+    foreach ($this->unit_list->_container as $UBEUnit) {
427 427
       $this->fleet_capacity += $UBEUnit->capacity * $UBEUnit->getCount();
428 428
 
429
-      if($UBEUnit->units_lost) {
430
-        foreach($UBEUnit->price as $resource_id => $unit_resource_price) {
431
-          if(!$unit_resource_price) {
429
+      if ($UBEUnit->units_lost) {
430
+        foreach ($UBEUnit->price as $resource_id => $unit_resource_price) {
431
+          if (!$unit_resource_price) {
432 432
             continue;
433 433
           }
434 434
 
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
           $this->resources_lost_on_units[$resource_id] += $resources_lost;
437 437
           // Если это корабль - прибавляем потери к обломкам на орбите
438 438
           // TODO - опция выбрасывания обороны в обломки
439
-          if($UBEUnit->getType() == UNIT_SHIPS) {
439
+          if ($UBEUnit->getType() == UNIT_SHIPS) {
440 440
             $this->resources_lost_on_ships[$resource_id] += $resources_lost;
441 441
           }
442 442
         }
@@ -448,11 +448,11 @@  discard block
 block discarded – undo
448 448
 
449 449
     // Если емкость трюмов меньше количество ресурсов - часть ресов выбрасываем нахуй
450 450
     // На планете ($fleet_id = 0) ресурсы в космос не выбрасываются
451
-    if($this->db_id != 0 && $this->fleet_capacity < $fleet_total_resources) {
451
+    if ($this->db_id != 0 && $this->fleet_capacity < $fleet_total_resources) {
452 452
       $drop_share = 1 - $this->fleet_capacity / $fleet_total_resources; // Какая часть ресурсов выброшена
453
-      foreach($this->resource_list as $resource_id => &$resource_amount) {
453
+      foreach ($this->resource_list as $resource_id => &$resource_amount) {
454 454
         // Не просчитываем ресурсы, которых нет на борту кораблей флота
455
-        if(!$resource_amount) {
455
+        if (!$resource_amount) {
456 456
           continue;
457 457
         }
458 458
 
@@ -473,19 +473,19 @@  discard block
 block discarded – undo
473 473
     $objFleet2->setDbId($this->db_id);
474 474
 
475 475
     // Если это была миссия Уничтожения И звезда смерти взорвалась И мы работаем с аттакерами - значит все аттакеры умерли
476
-    if($this->is_attacker == UBE_PLAYER_IS_ATTACKER && $reapers_status == UBE_MOON_REAPERS_DIED) {
476
+    if ($this->is_attacker == UBE_PLAYER_IS_ATTACKER && $reapers_status == UBE_MOON_REAPERS_DIED) {
477 477
       $objFleet2->dbDelete();
478
-    } elseif($ship_count_initial == 0) { // $ship_count_lost == $ship_count_initial ||
478
+    } elseif ($ship_count_initial == 0) { // $ship_count_lost == $ship_count_initial ||
479 479
       $objFleet2->dbDelete();
480 480
     } else {
481
-      if($ship_count_lost) {
481
+      if ($ship_count_lost) {
482 482
         // Просматриваем результаты изменения флотов
483
-        foreach($this->unit_list->_container as $UBEUnit) {
483
+        foreach ($this->unit_list->_container as $UBEUnit) {
484 484
           // Перебираем аутком на случай восстановления юнитов
485 485
 //          if(($units_left = $UBEUnit->getCount() - (float)$UBEUnit->units_lost) > 0) {
486 486
 //            $fleet_real_array[$UBEUnit->unitId] = $units_left;
487 487
 //          };
488
-          if(floatval($UBEUnit->units_lost) != 0) {
488
+          if (floatval($UBEUnit->units_lost) != 0) {
489 489
             $objFleet2->shipAdjustCount($UBEUnit->unitId, floatval($UBEUnit->units_lost));
490 490
           };
491 491
         }
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
       $objFleet2->resourcesAdjust($resource_delta_fleet);
496 496
 
497 497
       // Если защитник и не РМФ - отправляем флот назад
498
-      if($this->is_attacker == UBE_PLAYER_IS_ATTACKER || ($this->is_attacker == UBE_PLAYER_IS_DEFENDER && !$is_small_fleet_recce)) {
498
+      if ($this->is_attacker == UBE_PLAYER_IS_ATTACKER || ($this->is_attacker == UBE_PLAYER_IS_DEFENDER && !$is_small_fleet_recce)) {
499 499
         $objFleet2->markReturned();
500 500
       }
501 501
       $objFleet2->dbSave();
@@ -525,7 +525,7 @@  discard block
 block discarded – undo
525 525
   public function calculate_unit_partial_data(UBEASA $side_ASA) {
526 526
     $this->fleet_share_of_side_armor = $this->total_stats[P_ARMOR] / $side_ASA->getArmor();
527 527
 
528
-    foreach($this->unit_list->_container as $UBEUnit) {
528
+    foreach ($this->unit_list->_container as $UBEUnit) {
529 529
       $UBEUnit->share_of_side_armor = $UBEUnit->pool_armor / $side_ASA->getArmor();
530 530
     }
531 531
   }
@@ -537,9 +537,9 @@  discard block
 block discarded – undo
537 537
    * @version 2016-02-25 23:42:45 41a4.68
538 538
    */
539 539
   public function attack_fleets(UBEFleetList $fleet_list, $is_simulator) {
540
-    foreach($fleet_list->_container as $defending_fleet) {
540
+    foreach ($fleet_list->_container as $defending_fleet) {
541 541
       // Не атакуются флоты на своей стороне
542
-      if($this->is_attacker == $defending_fleet->is_attacker) {
542
+      if ($this->is_attacker == $defending_fleet->is_attacker) {
543 543
         continue;
544 544
       }
545 545
       $this->attack_fleet($defending_fleet, $is_simulator);
@@ -555,12 +555,12 @@  discard block
 block discarded – undo
555 555
   public function attack_fleet(UBEFleet $defending_fleet, $is_simulator) {
556 556
     UBEDebug::unit_dump_header();
557 557
 
558
-    foreach($this->unit_list->_container as $attacking_unit_pool) {
558
+    foreach ($this->unit_list->_container as $attacking_unit_pool) {
559 559
       UBEDebug::unit_dump($attacking_unit_pool, 'attacker');
560 560
 
561 561
       // if($attack_unit_count <= 0) continue; // TODO: Это пока нельзя включать - вот если будут "боевые порядки юнитов..."
562
-      foreach($defending_fleet->unit_list->_container as $defending_unit_pool) {
563
-        if($defending_unit_pool->isEmpty()) {
562
+      foreach ($defending_fleet->unit_list->_container as $defending_unit_pool) {
563
+        if ($defending_unit_pool->isEmpty()) {
564 564
           continue;
565 565
         }
566 566
 
Please login to merge, or discard this patch.
classes/UBE/UBEFleetList.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -278,6 +278,9 @@
 block discarded – undo
278 278
     return count($this->ube_side_present_at_round_start);
279 279
   }
280 280
 
281
+  /**
282
+   * @param integer $round
283
+   */
281 284
   public function ubeAnalyzeFleetOutcome($round) {
282 285
     $this->ube_actualize_sides();
283 286
 
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -82,13 +82,13 @@  discard block
 block discarded – undo
82 82
    */
83 83
   public function ube_db_load_fleets_outcome($report_row) {
84 84
     $query = doquery("SELECT * FROM {{ube_report_outcome_fleet}} WHERE `ube_report_id` = {$report_row['ube_report_id']}");
85
-    while($row = db_fetch($query)) {
85
+    while ($row = db_fetch($query)) {
86 86
       $fleet_id = $row['ube_report_outcome_fleet_fleet_id'];
87 87
       $this[$fleet_id]->load_outcome_from_report_row($row);
88 88
     }
89 89
 
90 90
     $query = doquery("SELECT * FROM {{ube_report_outcome_unit}} WHERE `ube_report_id` = {$report_row['ube_report_id']} ORDER BY `ube_report_outcome_unit_sort_order`");
91
-    while($row = db_fetch($query)) {
91
+    while ($row = db_fetch($query)) {
92 92
       $fleet_id = $row['ube_report_outcome_unit_fleet_id'];
93 93
       $this[$fleet_id]->load_unit_outcome_from_row($row);
94 94
     }
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
       UBE_PLAYER_IS_DEFENDER => array(),
109 109
     );
110 110
 
111
-    foreach($this->_container as $fleet_id => $UBEFleet) {
111
+    foreach ($this->_container as $fleet_id => $UBEFleet) {
112 112
       $result[$UBEFleet->is_attacker][] = array(
113 113
         'ID'          => $fleet_id,
114 114
         'NAME'        => $ube->players[$UBEFleet->owner_id]->name,
@@ -131,11 +131,11 @@  discard block
 block discarded – undo
131 131
    */
132 132
   public function ube_analyze_fleets($is_simulator, UBEDebris $debris, array $resource_exchange_rates) {
133 133
     // Генерируем результат боя
134
-    foreach($this->_container as $fleet_id => $UBEFleet) {
134
+    foreach ($this->_container as $fleet_id => $UBEFleet) {
135 135
       // Инициализируем массив результатов для флота
136 136
 //      $this->init_fleet_outcome_and_link_to_side($UBEFleet);
137 137
 
138
-      foreach($UBEFleet->unit_list->_container as $UBEUnit) {
138
+      foreach ($UBEFleet->unit_list->_container as $UBEUnit) {
139 139
         $UBEUnit->ube_analyze_unit($is_simulator);
140 140
       }
141 141
 
@@ -152,10 +152,10 @@  discard block
 block discarded – undo
152 152
       $this->resources_lost_in_metal = array(
153 153
         RES_METAL => 0,
154 154
       );
155
-      foreach($UBEFleet->resources_lost_on_units as $resource_id => $resource_amount) {
155
+      foreach ($UBEFleet->resources_lost_on_units as $resource_id => $resource_amount) {
156 156
         $UBEFleet->resources_lost_in_metal[RES_METAL] += $resource_amount * $resource_exchange_rates[$resource_id];
157 157
       }
158
-      foreach($UBEFleet->cargo_dropped as $resource_id => $resource_amount) {
158
+      foreach ($UBEFleet->cargo_dropped as $resource_id => $resource_amount) {
159 159
         $UBEFleet->resources_lost_in_metal[RES_METAL] += $resource_amount * $resource_exchange_rates[$resource_id];
160 160
       }
161 161
     }
@@ -166,8 +166,8 @@  discard block
 block discarded – undo
166 166
    */
167 167
   public function ube_get_groups() {
168 168
     $result = array();
169
-    foreach($this->_container as $UBEFleet) {
170
-      if($UBEFleet->group_id) {
169
+    foreach ($this->_container as $UBEFleet) {
170
+      if ($UBEFleet->group_id) {
171 171
         $result[$UBEFleet->group_id] = $UBEFleet->group_id;
172 172
       }
173 173
     }
@@ -180,8 +180,8 @@  discard block
 block discarded – undo
180 180
    */
181 181
   public function ube_get_capacity_attackers() {
182 182
     $result = 0;
183
-    foreach($this->_container as $UBEFleet) {
184
-      if($UBEFleet->is_attacker) {
183
+    foreach ($this->_container as $UBEFleet) {
184
+      if ($UBEFleet->is_attacker) {
185 185
         $result += $UBEFleet->fleet_capacity;
186 186
       }
187 187
     }
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
    */
196 196
   public function ube_db_load_from_report_row(array $report_row, UBE $ube) {
197 197
     $query = doquery("SELECT * FROM {{ube_report_fleet}} WHERE `ube_report_id` = {$report_row['ube_report_id']}");
198
-    while($fleet_row = db_fetch($query)) {
198
+    while ($fleet_row = db_fetch($query)) {
199 199
       $objFleet = new UBEFleet();
200 200
       $objFleet->load_from_report($fleet_row, $ube);
201 201
       $this[$objFleet->db_id] = $objFleet;
@@ -209,20 +209,20 @@  discard block
 block discarded – undo
209 209
    * @version 2016-02-25 23:42:45 41a4.68
210 210
    */
211 211
   public function ube_prepare_for_next_round($is_simulator) {
212
-    foreach($this->_container as $fleet_id => $UBEFleet) {
212
+    foreach ($this->_container as $fleet_id => $UBEFleet) {
213 213
       $UBEFleet->prepare_for_next_round($is_simulator);
214 214
     }
215 215
 
216 216
     // Суммируем данные по атакующим и защитникам
217 217
     $this->ube_total[UBE_PLAYER_IS_ATTACKER]->_reset();
218 218
     $this->ube_total[UBE_PLAYER_IS_DEFENDER]->_reset();
219
-    foreach($this->_container as $fleet_id => $UBEFleet) {
219
+    foreach ($this->_container as $fleet_id => $UBEFleet) {
220 220
       $this->ube_total[$UBEFleet->is_attacker]->add_unit_stats_array($UBEFleet->total_stats);
221 221
     }
222 222
 //pvar_dump($this->ube_total);
223 223
 
224 224
     // Высчитываем долю атаки, приходящейся на юнит равную отношению брони юнита к общей броне - крупные цели атакуют чаще
225
-    foreach($this->_container as $fleet_id => $UBEFleet) {
225
+    foreach ($this->_container as $fleet_id => $UBEFleet) {
226 226
       $UBEFleet->calculate_unit_partial_data($this->ube_total[$UBEFleet->is_attacker]);
227 227
     }
228 228
   }
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
    */
237 237
   public function ube_calculate_attack_results(UBE $ube) {
238 238
     // Каждый флот атакует все
239
-    foreach($this->_container as $attack_fleet_data) {
239
+    foreach ($this->_container as $attack_fleet_data) {
240 240
       defined('DEBUG_UBE') ? print("Fleet {$attack_fleet_data->db_id} attacks<br /><div style='margin-left: 30px;'>") : false;
241 241
 
242 242
       $attack_fleet_data->attack_fleets($this, $ube->is_simulator);
@@ -251,8 +251,8 @@  discard block
 block discarded – undo
251 251
    * @version 2016-02-25 23:42:45 41a4.68
252 252
    */
253 253
   public function ube_actualize_sides() {
254
-    foreach($this->_container as $UBEFleet) {
255
-      if($UBEFleet->get_unit_count() > 0) {
254
+    foreach ($this->_container as $UBEFleet) {
255
+      if ($UBEFleet->get_unit_count() > 0) {
256 256
         $this->ube_side_present_at_round_start[$UBEFleet->is_attacker] = 1;
257 257
       }
258 258
     }
@@ -265,8 +265,8 @@  discard block
 block discarded – undo
265 265
    */
266 266
   public function ube_calculate_attack_reapers() {
267 267
     $reapers = 0;
268
-    foreach($this->_container as $fleet_id => $UBERoundFleetCombat) {
269
-      if($UBERoundFleetCombat->is_attacker == UBE_PLAYER_IS_ATTACKER) {
268
+    foreach ($this->_container as $fleet_id => $UBERoundFleetCombat) {
269
+      if ($UBERoundFleetCombat->is_attacker == UBE_PLAYER_IS_ATTACKER) {
270 270
         $reapers += $UBERoundFleetCombat->unit_list->unitCountReapers();
271 271
       }
272 272
     }
@@ -283,10 +283,10 @@  discard block
 block discarded – undo
283 283
 
284 284
     $result = UBE_COMBAT_RESULT_DRAW;
285 285
     // Проверяем результат боя
286
-    if($this->ube_get_sides_count() == 0 || $round >= 10) {
286
+    if ($this->ube_get_sides_count() == 0 || $round >= 10) {
287 287
       // Если кого-то не осталось или не осталось обоих - заканчиваем цикл
288 288
       $result = UBE_COMBAT_RESULT_DRAW_END;
289
-    } elseif($this->ube_get_sides_count() == 1) {
289
+    } elseif ($this->ube_get_sides_count() == 1) {
290 290
       // Если осталась одна сторона - она и выиграла
291 291
       $result = isset($this->ube_side_present_at_round_start[UBE_PLAYER_IS_ATTACKER]) ? UBE_COMBAT_RESULT_WIN : UBE_COMBAT_RESULT_LOSS;
292 292
     }
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
    * @version 41a6.16
304 304
    */
305 305
   public function ubeInitGetAttackers(Fleet $objFleet, UBEPlayerList $players) {
306
-    if($objFleet->group_id) {
306
+    if ($objFleet->group_id) {
307 307
       $fleets_added = $this->dbLoadWhere("`fleet_group` = {$objFleet->group_id}");
308 308
     } else {
309 309
       $this->ube_insert_from_Fleet($objFleet);
Please login to merge, or discard this patch.
classes/UBE/UBEReport.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@
 block discarded – undo
7 7
   /**
8 8
    * @param UBE $ube
9 9
    *
10
-   * @return bool|string
10
+   * @return false|string
11 11
    *
12 12
    * @version 2016-02-25 23:42:45 41a4.68
13 13
    */
Please login to merge, or discard this patch.
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -13,14 +13,14 @@  discard block
 block discarded – undo
13 13
    */
14 14
   public function sn_ube_report_save($ube) {
15 15
     // Если уже есть ИД репорта - значит репорт был взят из таблицы. С таким мы не работаем
16
-    if($ube->get_cypher()) {
16
+    if ($ube->get_cypher()) {
17 17
       return false;
18 18
     }
19 19
 
20 20
     // Генерируем уникальный секретный ключ и проверяем наличие в базе
21 21
     do {
22 22
       $ube->report_cypher = sys_random_string(32);
23
-    } while(classSupernova::$db->doSelectFetchArray("SELECT ube_report_cypher FROM {{ube_report}} WHERE ube_report_cypher = '{$ube->report_cypher}' LIMIT 1 FOR UPDATE"));
23
+    } while (classSupernova::$db->doSelectFetchArray("SELECT ube_report_cypher FROM {{ube_report}} WHERE ube_report_cypher = '{$ube->report_cypher}' LIMIT 1 FOR UPDATE"));
24 24
 
25 25
     // Инициализация таблицы для пакетной вставки информации
26 26
     $sql_perform = array(
@@ -106,21 +106,21 @@  discard block
 block discarded – undo
106 106
 
107 107
     // Сохраняем общую информацию о бое
108 108
     classSupernova::$db->doInsertSet(TABLE_UBE_REPORT, array(
109
-        'ube_report_cypher'             => (string)$ube->report_cypher,
110
-        'ube_report_time_combat'        => (string)date(FMT_DATE_TIME_SQL, $ube->combat_timestamp),
111
-        'ube_report_time_spent'         => (float)$ube->time_spent,
112
-        'ube_report_combat_admin'       => (int)$ube->is_admin_in_combat,
113
-        'ube_report_mission_type'       => (int)$ube->mission_type_id,
114
-        'ube_report_combat_result'      => (int)$ube->combat_result,
115
-        'ube_report_combat_sfr'         => (int)$ube->is_small_fleet_recce,
116
-        'ube_report_planet_id'          => (int)$ube->ube_planet_info[PLANET_ID],
117
-        'ube_report_planet_name'        => (string)$ube->ube_planet_info[PLANET_NAME],
118
-        'ube_report_planet_size'        => (int)$ube->ube_planet_info[PLANET_SIZE],
119
-        'ube_report_planet_galaxy'      => (int)$ube->ube_planet_info[PLANET_GALAXY],
120
-        'ube_report_planet_system'      => (int)$ube->ube_planet_info[PLANET_SYSTEM],
121
-        'ube_report_planet_planet'      => (int)$ube->ube_planet_info[PLANET_PLANET],
122
-        'ube_report_planet_planet_type' => (int)$ube->ube_planet_info[PLANET_TYPE],
123
-        'ube_report_capture_result'     => (int)$ube->capture_result,
109
+        'ube_report_cypher'             => (string) $ube->report_cypher,
110
+        'ube_report_time_combat'        => (string) date(FMT_DATE_TIME_SQL, $ube->combat_timestamp),
111
+        'ube_report_time_spent'         => (float) $ube->time_spent,
112
+        'ube_report_combat_admin'       => (int) $ube->is_admin_in_combat,
113
+        'ube_report_mission_type'       => (int) $ube->mission_type_id,
114
+        'ube_report_combat_result'      => (int) $ube->combat_result,
115
+        'ube_report_combat_sfr'         => (int) $ube->is_small_fleet_recce,
116
+        'ube_report_planet_id'          => (int) $ube->ube_planet_info[PLANET_ID],
117
+        'ube_report_planet_name'        => (string) $ube->ube_planet_info[PLANET_NAME],
118
+        'ube_report_planet_size'        => (int) $ube->ube_planet_info[PLANET_SIZE],
119
+        'ube_report_planet_galaxy'      => (int) $ube->ube_planet_info[PLANET_GALAXY],
120
+        'ube_report_planet_system'      => (int) $ube->ube_planet_info[PLANET_SYSTEM],
121
+        'ube_report_planet_planet'      => (int) $ube->ube_planet_info[PLANET_PLANET],
122
+        'ube_report_planet_planet_type' => (int) $ube->ube_planet_info[PLANET_TYPE],
123
+        'ube_report_capture_result'     => (int) $ube->capture_result,
124 124
       )
125 125
       + $ube->debris->report_generate_array()
126 126
       + $ube->moon_calculator->report_generate_array()
@@ -129,22 +129,22 @@  discard block
 block discarded – undo
129 129
 
130 130
     // Сохраняем общую информацию по игрокам
131 131
     $player_sides = $ube->players->get_player_sides();
132
-    foreach($player_sides as $player_id => $player_side) {
132
+    foreach ($player_sides as $player_id => $player_side) {
133 133
       $sql_perform['ube_report_player'][] = array(
134 134
         $ube_report_id,
135 135
         $player_id,
136 136
 
137
-        "'" . db_escape($ube->players[$player_id]->name) . "'",
137
+        "'".db_escape($ube->players[$player_id]->name)."'",
138 138
         $ube->players[$player_id]->getSide() == UBE_PLAYER_IS_ATTACKER ? 1 : 0,
139 139
 
140
-        (float)$ube->players[$player_id]->player_bonus->calcBonus(P_ATTACK),
141
-        (float)$ube->players[$player_id]->player_bonus->calcBonus(P_SHIELD),
142
-        (float)$ube->players[$player_id]->player_bonus->calcBonus(P_ARMOR),
140
+        (float) $ube->players[$player_id]->player_bonus->calcBonus(P_ATTACK),
141
+        (float) $ube->players[$player_id]->player_bonus->calcBonus(P_SHIELD),
142
+        (float) $ube->players[$player_id]->player_bonus->calcBonus(P_ARMOR),
143 143
       );
144 144
     }
145 145
 
146 146
     // Всякая информация по флотам
147
-    foreach($ube->fleet_list->_container as $fleet_id => $UBEFleet) {
147
+    foreach ($ube->fleet_list->_container as $fleet_id => $UBEFleet) {
148 148
       // Сохраняем общую информацию по флотам
149 149
       $sql_perform['ube_report_fleet'][] = $UBEFleet->sql_generate_array($ube_report_id);
150 150
 
@@ -160,9 +160,9 @@  discard block
 block discarded – undo
160 160
 
161 161
     // Пакетная вставка данных
162 162
     // First row is a list of field names
163
-    foreach($sql_perform as $table_name => &$table_data) {
163
+    foreach ($sql_perform as $table_name => &$table_data) {
164 164
       // If only field names in this table - doing nothing
165
-      if(count($table_data) < 2) {
165
+      if (count($table_data) < 2) {
166 166
         continue;
167 167
       }
168 168
       // Picking up field names
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
     $report_cypher = db_escape($report_cypher);
186 186
 
187 187
     $report_row = classSupernova::$db->doSelectFetchArray("SELECT * FROM {{ube_report}} WHERE ube_report_cypher = '{$report_cypher}' LIMIT 1");
188
-    if(!$report_row) {
188
+    if (!$report_row) {
189 189
       return UBE_REPORT_NOT_FOUND;
190 190
     }
191 191
 
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
    * @param     $template_result
202 202
    */
203 203
   public function sn_ube_report_generate(UBE $ube, &$template_result) {
204
-    if(!is_object($ube)) {
204
+    if (!is_object($ube)) {
205 205
       return;
206 206
     }
207 207
 
@@ -216,15 +216,15 @@  discard block
 block discarded – undo
216 216
 
217 217
     // Координаты, тип и название планеты - если есть
218 218
 //R  $planet_owner_id = $combat_data[UBE_FLEETS][0][UBE_OWNER];
219
-    if(isset($ube->ube_planet_info)) {
219
+    if (isset($ube->ube_planet_info)) {
220 220
       $template_result += $ube->ube_planet_info;
221 221
       $template_result[PLANET_NAME] = str_replace(' ', '&nbsp;', htmlentities($template_result[PLANET_NAME], ENT_COMPAT, 'UTF-8'));
222 222
     }
223 223
 
224 224
     // Обломки
225 225
     $debris = array();
226
-    foreach(array(RES_METAL, RES_CRYSTAL) as $resource_id) {
227
-      if($resource_amount = $ube->debris->debris_get_resource($resource_id)) {
226
+    foreach (array(RES_METAL, RES_CRYSTAL) as $resource_id) {
227
+      if ($resource_amount = $ube->debris->debris_get_resource($resource_id)) {
228 228
         $debris[] = array(
229 229
           'NAME'   => classLocale::$lang['tech'][$resource_id],
230 230
           'AMOUNT' => pretty_number($resource_amount),
Please login to merge, or discard this patch.
classes/userOptions.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -151,6 +151,9 @@
 block discarded – undo
151 151
   }
152 152
 
153 153
 
154
+  /**
155
+   * @param integer $user_id
156
+   */
154 157
   public function __construct($user_id) {
155 158
     $this->user_change($user_id);
156 159
   }
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -122,8 +122,8 @@  discard block
 block discarded – undo
122 122
 
123 123
     $update_cache = false;
124 124
 
125
-    if(!empty($this->to_write)) {
126
-      foreach($this->to_write as $key => &$value) {
125
+    if (!empty($this->to_write)) {
126
+      foreach ($this->to_write as $key => &$value) {
127 127
         $value = is_array($this->data[$key]) ? serialize($this->data[$key]) : $this->data[$key]; // Сериализация для массивов при сохранении в БД
128 128
         $value = array($this->user_id, $key, $value);
129 129
       }
@@ -141,9 +141,9 @@  discard block
 block discarded – undo
141 141
       $update_cache = true;
142 142
     }
143 143
 
144
-    if(!empty($this->to_delete)) {
145
-      foreach($this->to_delete as $key => &$value) {
146
-        $value = is_string($key) ? "'". db_escape($key) . "'" : $key;
144
+    if (!empty($this->to_delete)) {
145
+      foreach ($this->to_delete as $key => &$value) {
146
+        $value = is_string($key) ? "'".db_escape($key)."'" : $key;
147 147
       }
148 148
 
149 149
       classSupernova::$db->doDeleteDanger(
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
           'player_id' => $this->user_id,
153 153
         ),
154 154
         array(
155
-          "`option_id` IN (" . implode(',', $this->to_delete) . ")",
155
+          "`option_id` IN (".implode(',', $this->to_delete).")",
156 156
         )
157 157
       );
158 158
 
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
       $update_cache = true;
161 161
     }
162 162
 
163
-    if($update_cache) {
163
+    if ($update_cache) {
164 164
       $field_name = $this->cached_name();
165 165
       classSupernova::$cache->$field_name = $this->data;
166 166
     }
@@ -179,11 +179,11 @@  discard block
 block discarded – undo
179 179
     $this->load();
180 180
   }
181 181
   protected function cached_name() {
182
-    return 'options_' . $this->user_id;
182
+    return 'options_'.$this->user_id;
183 183
   }
184 184
 
185 185
   protected function load() {
186
-    if($this->loaded) {
186
+    if ($this->loaded) {
187 187
       return;
188 188
     }
189 189
 
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
     $this->to_write = array();
192 192
     $this->to_delete = array();
193 193
 
194
-    if(!$this->user_id) {
194
+    if (!$this->user_id) {
195 195
       $this->loaded = true;
196 196
       return;
197 197
     }
@@ -199,13 +199,13 @@  discard block
 block discarded – undo
199 199
     $field_name = $this->cached_name();
200 200
     $a_data = classSupernova::$cache->$field_name;
201 201
 
202
-    if(!empty($a_data)) {
202
+    if (!empty($a_data)) {
203 203
       $this->data = array_replace_recursive($this->data, $a_data);
204 204
       return;
205 205
     }
206 206
 
207 207
     $query = classSupernova::$db->doSelect("SELECT * FROM `{{player_options}}` WHERE `player_id` = {$this->user_id} FOR UPDATE");
208
-    while($row = db_fetch($query)) {
208
+    while ($row = db_fetch($query)) {
209 209
       // $this->data[$row['option_id']] = $row['value'];
210 210
       $this->data[$row['option_id']] = is_string($row['value']) && ($temp = unserialize($row['value'])) !== false ? $temp : $row['value']; // Десериализация
211 211
     }
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
   }
283 283
 
284 284
   protected function cached_name() {
285
-    return 'options_' . $this->user_id;
285
+    return 'options_'.$this->user_id;
286 286
   }
287 287
 
288 288
   // TODO - serialize/unserialize options
@@ -290,14 +290,14 @@  discard block
 block discarded – undo
290 290
     // Если в массиве индекса только один элемент - значит это просто индекс
291 291
     is_array($option_id) && count($option_id) == 1 ? $option_id = reset($option_id) : false;
292 292
 
293
-    if(!isset($this->data[is_array($option_id) ? reset($option_id) : $option_id])) {
293
+    if (!isset($this->data[is_array($option_id) ? reset($option_id) : $option_id])) {
294 294
       $this->load();
295 295
     }
296 296
 
297
-    if(is_array($option_id)) {
297
+    if (is_array($option_id)) {
298 298
       $result = $this->data;
299
-      foreach($option_id as $sub_key) {
300
-        if(!isset($result) || !isset($result[$sub_key])) {
299
+      foreach ($option_id as $sub_key) {
300
+        if (!isset($result) || !isset($result[$sub_key])) {
301 301
           $result = null;
302 302
           break;
303 303
         }
@@ -315,12 +315,12 @@  discard block
 block discarded – undo
315 315
    * @param null|mixed $value
316 316
    */
317 317
   public function __set($option, $value = null) {
318
-    if(empty($option) || !$this->user_id) {
318
+    if (empty($option) || !$this->user_id) {
319 319
       return;
320 320
     }
321 321
 
322 322
     // Если в массиве индекса только один элемент - значит это просто индекс
323
-    if(is_array($option) && count($option) == 1) {
323
+    if (is_array($option) && count($option) == 1) {
324 324
       // Разворачиваем его в индекс
325 325
       $option = array(reset($option) => $value);
326 326
       unset($value);
@@ -329,13 +329,13 @@  discard block
 block discarded – undo
329 329
 
330 330
     $to_write = array();
331 331
     // Адресация многомерного массива через массив индексов в $option
332
-    if(is_array($option) && isset($value)) {
332
+    if (is_array($option) && isset($value)) {
333 333
       $a_data = &$this->data;
334
-      foreach($option as $option_id) {
334
+      foreach ($option as $option_id) {
335 335
         !is_array($a_data[$option_id]) ? $a_data[$option_id] = array() : false;
336 336
         $a_data = &$a_data[$option_id];
337 337
       }
338
-      if($a_data != $value) {
338
+      if ($a_data != $value) {
339 339
         $a_data = $value;
340 340
         $to_write[reset($option)] = null;
341 341
       }
@@ -343,11 +343,11 @@  discard block
 block discarded – undo
343 343
       // Пакетная запись из массива ключ -> значение
344 344
       !is_array($option) ? $option = array($option => $value) : false;
345 345
 
346
-      foreach($option as $option_id => $option_value) {
347
-        if($this->data[$option_id] !== $option_value) {
346
+      foreach ($option as $option_id => $option_value) {
347
+        if ($this->data[$option_id] !== $option_value) {
348 348
           // TODO - вынести отдельно в обработчик
349
-          if($option_id == PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON &&  $option_value == PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON_HIDDEN) {
350
-            sn_setcookie(SN_COOKIE . '_menu_hidden', '0', time() - PERIOD_WEEK, SN_ROOT_RELATIVE);
349
+          if ($option_id == PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON && $option_value == PLAYER_OPTION_MENU_HIDE_SHOW_BUTTON_HIDDEN) {
350
+            sn_setcookie(SN_COOKIE.'_menu_hidden', '0', time() - PERIOD_WEEK, SN_ROOT_RELATIVE);
351 351
           }
352 352
 
353 353
           $this->data[$option_id] = $option_value;
@@ -356,11 +356,11 @@  discard block
 block discarded – undo
356 356
       }
357 357
     }
358 358
 
359
-    if(!empty($to_write)) {
359
+    if (!empty($to_write)) {
360 360
       $field_name = $this->cached_name();
361 361
       classSupernova::$cache->$field_name = $this->data;
362 362
 
363
-      foreach($to_write as $option_id => &$option_value) {
363
+      foreach ($to_write as $option_id => &$option_value) {
364 364
         $option_value = is_array($this->data[$option_id]) ? serialize($this->data[$option_id]) : $this->data[$option_id]; // Сериализация для массивов при сохранении в БД
365 365
         $option_value = array($this->user_id, $option_id, $option_value);
366 366
       }
@@ -376,26 +376,26 @@  discard block
 block discarded – undo
376 376
   }
377 377
 
378 378
   protected function load() {
379
-    if($this->loaded) {
379
+    if ($this->loaded) {
380 380
       return;
381 381
     }
382 382
 
383 383
     $this->data = $this->defaults;
384 384
 
385
-    if(!$this->user_id) {
385
+    if (!$this->user_id) {
386 386
       return;
387 387
     }
388 388
 
389 389
     $field_name = $this->cached_name();
390 390
     $a_data = classSupernova::$cache->$field_name;
391 391
 
392
-    if(!empty($a_data)) {
392
+    if (!empty($a_data)) {
393 393
       $this->data = array_replace($this->data, $a_data);
394 394
       return;
395 395
     }
396 396
 
397 397
     $query = classSupernova::$db->doSelect("SELECT * FROM `{{player_options}}` WHERE `player_id` = {$this->user_id} FOR UPDATE");
398
-    while($row = db_fetch($query)) {
398
+    while ($row = db_fetch($query)) {
399 399
       // $this->data[$row['option_id']] = $row['value'];
400 400
       $this->data[$row['option_id']] = is_string($row['value']) && ($temp = unserialize($row['value'])) !== false ? $temp : $row['value']; // Десериализация
401 401
     }
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
     return $this->__get($offset);
412 412
   }
413 413
   public function offsetSet($offset, $value) {
414
-    if(!is_null($offset)) {
414
+    if (!is_null($offset)) {
415 415
       // $this->data[$offset] = $value;
416 416
       $this->__set($offset, $value);
417 417
     } else {
Please login to merge, or discard this patch.
classes/RequestInfo.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -87,15 +87,15 @@  discard block
 block discarded – undo
87 87
     // Инфа об устройстве и браузере - общая для всех
88 88
     sn_db_transaction_start();
89 89
     $this->device_cypher = $_COOKIE[SN_COOKIE_D];
90
-    if($this->device_cypher) {
90
+    if ($this->device_cypher) {
91 91
       $cypher_safe = db_escape($this->device_cypher);
92 92
       $device_id = classSupernova::$db->doSelectFetch("SELECT `device_id` FROM {{security_device}} WHERE `device_cypher` = '{$cypher_safe}' LIMIT 1 FOR UPDATE");
93
-      if(!empty($device_id['device_id'])) {
93
+      if (!empty($device_id['device_id'])) {
94 94
         $this->device_id = $device_id['device_id'];
95 95
       }
96 96
     }
97 97
 
98
-    if($this->device_id <= 0) {
98
+    if ($this->device_id <= 0) {
99 99
       do {
100 100
         $cypher_safe = db_escape($this->device_cypher = sys_random_string());
101 101
         $row = classSupernova::$db->doSelectFetch("SELECT `device_id` FROM {{security_device}} WHERE `device_cypher` = '{$cypher_safe}' LIMIT 1 FOR UPDATE");
@@ -118,10 +118,10 @@  discard block
 block discarded – undo
118 118
     $this->page_address_id = db_get_set_unique_id_value($this->page_address, 'url_id', 'security_url', 'url_string');
119 119
     sn_db_transaction_commit();
120 120
 
121
-    if($this->write_full_url) {
121
+    if ($this->write_full_url) {
122 122
       sn_db_transaction_start();
123 123
       $this->page_url = substr($_SERVER['REQUEST_URI'], strlen(SN_ROOT_RELATIVE));
124
-      if(strpos($_SERVER['REQUEST_URI'], '/simulator.php') === 0) {
124
+      if (strpos($_SERVER['REQUEST_URI'], '/simulator.php') === 0) {
125 125
         $this->page_url = '/simulator.php';
126 126
       }
127 127
       $this->page_url_id = db_get_set_unique_id_value($this->page_url, 'url_id', 'security_url', 'url_string');
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
    */
145 145
   public function db_security_entry_insert($user_id_unsafe) {
146 146
     // TODO $user_id = !empty(self::$user['id']) ? self::$user['id'] : 'NULL';
147
-    if(empty($user_id_unsafe)) {
147
+    if (empty($user_id_unsafe)) {
148 148
       // self::flog('Нет ИД пользователя');
149 149
       return true;
150 150
     }
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
   public function db_counter_insert($user_id_unsafe) {
167 167
     global $sys_stop_log_hit;
168 168
 
169
-    if($sys_stop_log_hit || !classSupernova::$config->game_counter) {
169
+    if ($sys_stop_log_hit || !classSupernova::$config->game_counter) {
170 170
       return;
171 171
     }
172 172
 
Please login to merge, or discard this patch.
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.
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.
classes/UBE/UBEDebug.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
    * @version 41a6.49
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.49
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
 
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 //  print("<td>" . $this->units_lost . "</td>");
76 76
 //  print("<td>" . $this->units_restored . "</td>");
77 77
 //  print("<td>" . $this->capacity . "</td>");
78
-    print("<td>" . round($unit->share_of_side_armor, 4) . "</td>");
78
+    print("<td>".round($unit->share_of_side_armor, 4)."</td>");
79 79
     print('</tr>');
80 80
   }
81 81
 
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
    * @version 41a6.49
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,16 +101,16 @@  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
 
108 108
     $classLocale = classLocale::$lang;
109 109
 
110
-    print("[{$attacking_unit_pool->unitId}]{$classLocale['tech'][$attacking_unit_pool->unitId]}" .
111
-      ' attacks ' .
112
-      $defending_fleet_id . '@' . "[{$defending_unit_pool->unitId}]{$classLocale['tech'][$defending_unit_pool->unitId]}" .
113
-      ' with ' . pretty_number($defending_unit_pool->attack_income) .
110
+    print("[{$attacking_unit_pool->unitId}]{$classLocale['tech'][$attacking_unit_pool->unitId]}".
111
+      ' attacks '.
112
+      $defending_fleet_id.'@'."[{$defending_unit_pool->unitId}]{$classLocale['tech'][$defending_unit_pool->unitId]}".
113
+      ' with '.pretty_number($defending_unit_pool->attack_income).
114 114
       '<br>'
115 115
     );
116 116
     $before = clone $defending_unit_pool;
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
    * @version 41a6.49
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,8 +136,8 @@  discard block
 block discarded – undo
136 136
     print(pretty_number($unit->$field));
137 137
     print("</td>");
138 138
     print("<td>");
139
-    if(!empty($before)) {
140
-      print('' . pretty_number($unit->$field - $before->$field) . '');
139
+    if (!empty($before)) {
140
+      print(''.pretty_number($unit->$field - $before->$field).'');
141 141
     }
142 142
     print("</td>");
143 143
   }
Please login to merge, or discard this patch.
classes/UBE/UBERound.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -36,8 +36,8 @@  discard block
 block discarded – undo
36 36
    * @version 2016-02-25 23:42:45 41a4.68
37 37
    */
38 38
   public function make_snapshot(UBEFleetList $UBEFleetList) {
39
-    foreach($UBEFleetList->_container as $fleet_id => $UBEFleet) {
40
-      foreach($UBEFleet->unit_list->_container as $UBEUnit) {
39
+    foreach ($UBEFleetList->_container as $fleet_id => $UBEFleet) {
40
+      foreach ($UBEFleet->unit_list->_container as $UBEUnit) {
41 41
         $this->snapshot[$fleet_id][$UBEUnit->unitId] = new UBESnapshotUnit();
42 42
         $this->snapshot[$fleet_id][$UBEUnit->unitId]->init_from_UBEUnit($UBEUnit);
43 43
       }
@@ -53,12 +53,12 @@  discard block
 block discarded – undo
53 53
    * @version 2016-02-25 23:42:45 41a4.68
54 54
    */
55 55
   public function sql_generate_unit_array(array &$sql_perform_ube_report_unit, &$unit_sort_order, UBEFleetList $UBEFleetList, array $outer_prefix) {
56
-    foreach($this->snapshot as $fleet_id => $fleet_snapshot) {
56
+    foreach ($this->snapshot as $fleet_id => $fleet_snapshot) {
57 57
       $inner_prefix = array(
58 58
         $UBEFleetList[$fleet_id]->owner_id,
59 59
         $fleet_id,
60 60
       );
61
-      foreach($fleet_snapshot as $unit_id => $unit_snapshot) {
61
+      foreach ($fleet_snapshot as $unit_id => $unit_snapshot) {
62 62
         $sql_perform_ube_report_unit[] = array_merge(
63 63
           $outer_prefix,
64 64
           $inner_prefix,
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
       UBE_PLAYER_IS_DEFENDER => array(),
102 102
     );
103 103
 
104
-    foreach($this->snapshot as $fleet_id => $fleet_snapshot) {
104
+    foreach ($this->snapshot as $fleet_id => $fleet_snapshot) {
105 105
       $fleet_owner_id = $ube->fleet_list[$fleet_id]->owner_id;
106 106
       $planet_ube_row = $ube->fleet_list[$fleet_id]->UBE_PLANET;
107 107
 
@@ -111,13 +111,13 @@  discard block
 block discarded – undo
111 111
         'PLAYER_NAME' => htmlentities($ube->players[$fleet_owner_id]->name, ENT_COMPAT, 'UTF-8'),
112 112
       );
113 113
 
114
-      if(is_array($planet_ube_row)) {
114
+      if (is_array($planet_ube_row)) {
115 115
         $template_fleet += $planet_ube_row;
116 116
         $template_fleet[PLANET_NAME] = $template_fleet[PLANET_NAME] ? htmlentities($template_fleet[PLANET_NAME], ENT_COMPAT, 'UTF-8') : '';
117 117
         $template_fleet['PLANET_TYPE_TEXT'] = $lang['sys_planet_type_sh'][$template_fleet['PLANET_TYPE']];
118 118
       }
119 119
 
120
-      foreach($fleet_snapshot as $unit_id => $unit_snapshot) {
120
+      foreach ($fleet_snapshot as $unit_id => $unit_snapshot) {
121 121
         $template_fleet['.']['ship'][] = $unit_snapshot->report_render_unit($prevSnapshot[$fleet_id][$unit_id]);
122 122
       }
123 123
 
Please login to merge, or discard this patch.