Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Passed
Push — master ( 1f1eac...f120a4 )
by Dan
04:33
created
lib/Default/SmrPlanet.class.php 1 patch
Braces   +47 added lines, -54 removed lines patch added patch discarded remove patch
@@ -151,26 +151,19 @@  discard block
 block discarded – undo
151 151
 		$level = $this->getLevel();
152 152
 		if ($level < 9) {
153 153
 			return .0404;
154
-		}
155
-		elseif ($level < 19) {
154
+		} elseif ($level < 19) {
156 155
 			return .0609;
157
-		}
158
-		elseif ($level < 29) {
156
+		} elseif ($level < 29) {
159 157
 			return .1236;
160
-		}
161
-		elseif ($level < 39) {
158
+		} elseif ($level < 39) {
162 159
 			return .050625;
163
-		}
164
-		elseif ($level < 49) {
160
+		} elseif ($level < 49) {
165 161
 			return .0404;
166
-		}
167
-		elseif ($level < 59) {
162
+		} elseif ($level < 59) {
168 163
 			return .030225;
169
-		}
170
-		elseif ($level < 69) {
164
+		} elseif ($level < 69) {
171 165
 			return .0201;
172
-		}
173
-		else {
166
+		} else {
174 167
 			return .018081;
175 168
 		}
176 169
 	}
@@ -383,8 +376,7 @@  discard block
 block discarded – undo
383 376
 		}
384 377
 		if ($delayed === false) {
385 378
 			$this->setShields($this->getShields() - $number);
386
-		}
387
-		else {
379
+		} else {
388 380
 			$this->delayedShieldsDelta -= $number;
389 381
 		}
390 382
 	}
@@ -395,8 +387,7 @@  discard block
 block discarded – undo
395 387
 		}
396 388
 		if ($delayed === false) {
397 389
 			$this->setShields($this->getShields() + $number);
398
-		}
399
-		else {
390
+		} else {
400 391
 			$this->delayedShieldsDelta += $number;
401 392
 		}
402 393
 	}
@@ -428,8 +419,7 @@  discard block
 block discarded – undo
428 419
 		}
429 420
 		if ($delayed === false) {
430 421
 			$this->setArmour($this->getArmour() - $number);
431
-		}
432
-		else {
422
+		} else {
433 423
 			$this->delayedArmourDelta -= $number;
434 424
 		}
435 425
 	}
@@ -440,8 +430,7 @@  discard block
 block discarded – undo
440 430
 		}
441 431
 		if ($delayed === false) {
442 432
 			$this->setArmour($this->getArmour() + $number);
443
-		}
444
-		else {
433
+		} else {
445 434
 			$this->delayedArmourDelta += $number;
446 435
 		}
447 436
 	}
@@ -473,8 +462,7 @@  discard block
 block discarded – undo
473 462
 		}
474 463
 		if ($delayed === false) {
475 464
 			$this->setCDs($this->getCDs() - $number);
476
-		}
477
-		else {
465
+		} else {
478 466
 			$this->delayedCDsDelta -= $number;
479 467
 		}
480 468
 	}
@@ -485,8 +473,7 @@  discard block
 block discarded – undo
485 473
 		}
486 474
 		if ($delayed === false) {
487 475
 			$this->setCDs($this->getCDs() + $number);
488
-		}
489
-		else {
476
+		} else {
490 477
 			$this->delayedCDsDelta += $number;
491 478
 		}
492 479
 	}
@@ -580,13 +567,16 @@  discard block
 block discarded – undo
580 567
 			// get supplies from db
581 568
 			$this->db->query('SELECT good_id, amount FROM planet_has_cargo WHERE ' . $this->SQL);
582 569
 			// adding cargo and amount to array
583
-			while ($this->db->nextRecord())
584
-				$this->stockpile[$this->db->getInt('good_id')] = $this->db->getInt('amount');
570
+			while ($this->db->nextRecord()) {
571
+							$this->stockpile[$this->db->getInt('good_id')] = $this->db->getInt('amount');
572
+			}
573
+		}
574
+		if ($goodID === false) {
575
+					return $this->stockpile;
576
+		}
577
+		if (isset($this->stockpile[$goodID])) {
578
+					return $this->stockpile[$goodID];
585 579
 		}
586
-		if ($goodID === false)
587
-			return $this->stockpile;
588
-		if (isset($this->stockpile[$goodID]))
589
-			return $this->stockpile[$goodID];
590 580
 		return 0;
591 581
 	}
592 582
 
@@ -594,8 +584,7 @@  discard block
 block discarded – undo
594 584
 		if ($goodID === false) {
595 585
 			$stockpile = $this->getStockpile($goodID);
596 586
 			return count($stockpile) > 0 && max($stockpile) > 0;
597
-		}
598
-		else {
587
+		} else {
599 588
 			return $this->getStockpile($goodID) > 0;
600 589
 		}
601 590
 	}
@@ -612,14 +601,16 @@  discard block
 block discarded – undo
612 601
 	}
613 602
 
614 603
 	public function decreaseStockpile($goodID, $amount) {
615
-		if ($amount < 0)
616
-			throw new Exception('Trying to decrease negative stockpile.');
604
+		if ($amount < 0) {
605
+					throw new Exception('Trying to decrease negative stockpile.');
606
+		}
617 607
 		$this->setStockpile($goodID, $this->getStockpile($goodID) - $amount);
618 608
 	}
619 609
 
620 610
 	public function increaseStockpile($goodID, $amount) {
621
-		if ($amount < 0)
622
-			throw new Exception('Trying to increase negative stockpile.');
611
+		if ($amount < 0) {
612
+					throw new Exception('Trying to increase negative stockpile.');
613
+		}
623 614
 		$this->setStockpile($goodID, $this->getStockpile($goodID) + $amount);
624 615
 	}
625 616
 
@@ -653,8 +644,9 @@  discard block
 block discarded – undo
653 644
 	}
654 645
 
655 646
 	public function setBuilding($buildingTypeID, $number) {
656
-		if ($this->getBuilding($buildingTypeID) == $number)
657
-			return;
647
+		if ($this->getBuilding($buildingTypeID) == $number) {
648
+					return;
649
+		}
658 650
 
659 651
 		$this->buildings[$buildingTypeID] = $number;
660 652
 		$this->hasChangedBuildings[$buildingTypeID] = true;
@@ -826,8 +818,7 @@  discard block
 block discarded – undo
826 818
 				if ($amount != 0) {
827 819
 					$this->db->query('REPLACE INTO planet_has_cargo (game_id, sector_id, good_id, amount) ' .
828 820
 										 'VALUES(' . $this->db->escapeNumber($this->getGameID()) . ', ' . $this->db->escapeNumber($this->getSectorID()) . ', ' . $this->db->escapeNumber($id) . ', ' . $this->db->escapeNumber($amount) . ')');
829
-				}
830
-				else {
821
+				} else {
831 822
 					$this->db->query('DELETE FROM planet_has_cargo WHERE ' . $this->SQL . '
832 823
 										AND good_id = ' . $this->db->escapeNumber($id));
833 824
 				}
@@ -856,8 +847,7 @@  discard block
 block discarded – undo
856 847
 				if ($this->hasBuilding($id)) {
857 848
 					$this->db->query('REPLACE INTO planet_has_building (game_id, sector_id, construction_id, amount) ' .
858 849
 										'VALUES(' . $this->db->escapeNumber($this->gameID) . ', ' . $this->db->escapeNumber($this->sectorID) . ', ' . $this->db->escapeNumber($id) . ', ' . $this->db->escapeNumber($this->getBuilding($id)) . ')');
859
-				}
860
-				else {
850
+				} else {
861 851
 					$this->db->query('DELETE FROM planet_has_building WHERE ' . $this->SQL . '
862 852
 										AND construction_id = ' . $this->db->escapeNumber($id));
863 853
 				}
@@ -1106,23 +1096,27 @@  discard block
 block discarded – undo
1106 1096
 	}
1107 1097
 
1108 1098
 	public function hasEnemyTraders(AbstractSmrPlayer $player) {
1109
-		if (!$this->hasOtherTraders($player))
1110
-			return false;
1099
+		if (!$this->hasOtherTraders($player)) {
1100
+					return false;
1101
+		}
1111 1102
 		$otherPlayers = $this->getOtherTraders($player);
1112 1103
 		foreach ($otherPlayers as $otherPlayer) {
1113
-			if (!$player->traderNAPAlliance($otherPlayer))
1114
-				return true;
1104
+			if (!$player->traderNAPAlliance($otherPlayer)) {
1105
+							return true;
1106
+			}
1115 1107
 		}
1116 1108
 		return false;
1117 1109
 	}
1118 1110
 
1119 1111
 	public function hasFriendlyTraders(AbstractSmrPlayer $player) {
1120
-		if (!$this->hasOtherTraders($player))
1121
-			return false;
1112
+		if (!$this->hasOtherTraders($player)) {
1113
+					return false;
1114
+		}
1122 1115
 		$otherPlayers = $this->getOtherTraders($player);
1123 1116
 		foreach ($otherPlayers as $otherPlayer) {
1124
-			if ($player->traderNAPAlliance($otherPlayer))
1125
-				return true;
1117
+			if ($player->traderNAPAlliance($otherPlayer)) {
1118
+							return true;
1119
+			}
1126 1120
 		}
1127 1121
 		return false;
1128 1122
 	}
@@ -1227,8 +1221,7 @@  discard block
 block discarded – undo
1227 1221
 					}
1228 1222
 				}
1229 1223
 
1230
-			}
1231
-			else { // hit drones behind shields - we should only use this reduced damage branch if we cannot hit shields.
1224
+			} else { // hit drones behind shields - we should only use this reduced damage branch if we cannot hit shields.
1232 1225
 				$cdDamage = $this->doCDDamage(IFloor(min($damage['MaxDamage'], $damage['Armour']) * DRONES_BEHIND_SHIELDS_DAMAGE_PERCENT), $delayed);
1233 1226
 			}
1234 1227
 		}
Please login to merge, or discard this patch.
lib/Default/SmrCombatDrones.class.php 1 patch
Braces   +13 added lines, -7 removed lines patch added patch discarded remove patch
@@ -13,8 +13,7 @@  discard block
 block discarded – undo
13 13
 			$this->maxDamage = 2;
14 14
 			$this->shieldDamage = 2;
15 15
 			$this->armourDamage = 2;
16
-		}
17
-		else {
16
+		} else {
18 17
 			$this->maxDamage = 1;
19 18
 			$this->shieldDamage = 1;
20 19
 			$this->armourDamage = 1;
@@ -84,8 +83,9 @@  discard block
 block discarded – undo
84 83
 		$weaponShip = $weaponPlayer->getShip();
85 84
 		$targetShip = $targetPlayer->getShip();
86 85
 		$mrDiff = $targetShip->getMR() - $weaponShip->getMR();
87
-		if ($mrDiff > 0)
88
-			$modifiedAccuracy -= $this->getBaseAccuracy() * ($mrDiff / MR_FACTOR) / 100;
86
+		if ($mrDiff > 0) {
87
+					$modifiedAccuracy -= $this->getBaseAccuracy() * ($mrDiff / MR_FACTOR) / 100;
88
+		}
89 89
 	
90 90
 		return max(0, min(100, $modifiedAccuracy));
91 91
 	}
@@ -127,8 +127,10 @@  discard block
 block discarded – undo
127 127
 	}
128 128
 	
129 129
 	public function &getModifiedDamageAgainstForces(AbstractSmrPlayer $weaponPlayer, SmrForce $forces) {
130
-		if (!$this->canShootForces()) // If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods.
130
+		if (!$this->canShootForces()) {
131
+			// If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods.
131 132
 			return array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover());
133
+		}
132 134
 		$damage =& $this->getModifiedDamage();
133 135
 		$damage['Launched'] = ICeil($this->getNumberOfCDs() * $this->getModifiedAccuracyAgainstForces($weaponPlayer, $forces) / 100);
134 136
 		$damage['Kamikaze'] = 0;
@@ -149,8 +151,10 @@  discard block
 block discarded – undo
149 151
 	}
150 152
 	
151 153
 	public function &getModifiedDamageAgainstPort(AbstractSmrPlayer $weaponPlayer, SmrPort $port) {
152
-		if (!$this->canShootPorts()) // If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods.
154
+		if (!$this->canShootPorts()) {
155
+			// If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods.
153 156
 			return array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover());
157
+		}
154 158
 		$damage =& $this->getModifiedDamage();
155 159
 		$damage['Launched'] = ICeil($this->getNumberOfCDs() * $this->getModifiedAccuracyAgainstPort($weaponPlayer, $port) / 100);
156 160
 		$damage['MaxDamage'] = ICeil($damage['Launched'] * $damage['MaxDamage']);
@@ -161,8 +165,10 @@  discard block
 block discarded – undo
161 165
 	}
162 166
 	
163 167
 	public function &getModifiedDamageAgainstPlanet(AbstractSmrPlayer $weaponPlayer, SmrPlanet $planet) {
164
-		if (!$this->canShootPlanets()) // If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods.
168
+		if (!$this->canShootPlanets()) {
169
+			// If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods.
165 170
 			return array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover());
171
+		}
166 172
 		$damage =& $this->getModifiedDamage();
167 173
 		$damage['Launched'] = ICeil($this->getNumberOfCDs() * $this->getModifiedAccuracyAgainstPlanet($weaponPlayer, $planet) / 100);
168 174
 		$planetMod = self::PLANET_DAMAGE_MOD;
Please login to merge, or discard this patch.
lib/Default/AbstractSmrPort.class.php 1 patch
Braces   +131 added lines, -97 removed lines patch added patch discarded remove patch
@@ -153,8 +153,7 @@  discard block
 block discarded – undo
153 153
 			$this->checkDefenses();
154 154
 			$this->getGoods();
155 155
 			$this->checkForUpgrade();
156
-		}
157
-		else {
156
+		} else {
158 157
 			$this->shields = 0;
159 158
 			$this->combatDrones = 0;
160 159
 			$this->armour = 0;
@@ -302,8 +301,9 @@  discard block
 block discarded – undo
302 301
 				$x['TransactionType'] = 'Buy';
303 302
 			}
304 303
 			$di = Plotter::findDistanceToX($x, $this->getSector(), true);
305
-			if (is_object($di))
306
-				$di = $di->getRelativeDistance();
304
+			if (is_object($di)) {
305
+							$di = $di->getRelativeDistance();
306
+			}
307 307
 			$this->goodDistances[$goodID] = max(1, $di);
308 308
 		}
309 309
 		return $this->goodDistances[$goodID];
@@ -329,12 +329,14 @@  discard block
 block discarded – undo
329 329
 	}
330 330
 	
331 331
 	private function setGoodAmount($goodID, $amount, $doUpdate = true) {
332
-		if ($this->isCachedVersion())
333
-			throw new Exception('Cannot update a cached port!');
332
+		if ($this->isCachedVersion()) {
333
+					throw new Exception('Cannot update a cached port!');
334
+		}
334 335
 		// The new amount must be between 0 and the max for this good
335 336
 		$amount = max(0, min($amount, $this->getGood($goodID)['Max']));
336
-		if ($this->getGoodAmount($goodID) == $amount)
337
-			return;
337
+		if ($this->getGoodAmount($goodID) == $amount) {
338
+					return;
339
+		}
338 340
 		$this->goodAmounts[$goodID] = $amount;
339 341
 
340 342
 		if ($doUpdate) {
@@ -401,8 +403,9 @@  discard block
 block discarded – undo
401 403
 	}
402 404
 	
403 405
 	public function checkForUpgrade() {
404
-		if ($this->isCachedVersion())
405
-			throw new Exception('Cannot upgrade a cached port!');
406
+		if ($this->isCachedVersion()) {
407
+					throw new Exception('Cannot upgrade a cached port!');
408
+		}
406 409
 		$upgrades = 0;
407 410
 		while ($this->upgrade >= $this->getUpgradeRequirement() && $this->level < 9) {
408 411
 			++$upgrades;
@@ -418,8 +421,9 @@  discard block
 block discarded – undo
418 421
 	 * ports to a specific level.
419 422
 	 */
420 423
 	public function upgradeToLevel($level) {
421
-		if ($this->isCachedVersion())
422
-			throw new Exception('Cannot upgrade a cached port!');
424
+		if ($this->isCachedVersion()) {
425
+					throw new Exception('Cannot upgrade a cached port!');
426
+		}
423 427
 		while ($this->getLevel() < $level) {
424 428
 			$this->doUpgrade();
425 429
 		}
@@ -523,8 +527,9 @@  discard block
 block discarded – undo
523 527
 	 * calling this function directly.
524 528
 	 */
525 529
 	public function addPortGood($goodID, $type) {
526
-		if ($this->isCachedVersion())
527
-			throw new Exception('Cannot update a cached port!');
530
+		if ($this->isCachedVersion()) {
531
+					throw new Exception('Cannot update a cached port!');
532
+		}
528 533
 		if ($this->hasGood($goodID, $type)) {
529 534
 			return;
530 535
 		}
@@ -549,8 +554,9 @@  discard block
 block discarded – undo
549 554
 	 * calling this function directly.
550 555
 	 */
551 556
 	public function removePortGood($goodID) {
552
-		if ($this->isCachedVersion())
553
-			throw new Exception('Cannot update a cached port!');
557
+		if ($this->isCachedVersion()) {
558
+					throw new Exception('Cannot update a cached port!');
559
+		}
554 560
 		if (!$this->hasGood($goodID)) {
555 561
 			return;
556 562
 		}
@@ -559,8 +565,7 @@  discard block
 block discarded – undo
559 565
 		}
560 566
 		if (($key = array_search($goodID, $this->goodIDs['Buy'])) !== false) {
561 567
 			array_splice($this->goodIDs['Buy'], $key, 1);
562
-		}
563
-		elseif (($key = array_search($goodID, $this->goodIDs['Sell'])) !== false) {
568
+		} elseif (($key = array_search($goodID, $this->goodIDs['Sell'])) !== false) {
564 569
 			array_splice($this->goodIDs['Sell'], $key, 1);
565 570
 		}
566 571
 		
@@ -600,8 +605,9 @@  discard block
 block discarded – undo
600 605
 	}
601 606
 
602 607
 	protected function doDowngrade() {
603
-		if ($this->isCachedVersion())
604
-			throw new Exception('Cannot downgrade a cached port!');
608
+		if ($this->isCachedVersion()) {
609
+					throw new Exception('Cannot downgrade a cached port!');
610
+		}
605 611
 
606 612
 		$goodClass = $this->getGoodClassAtLevel();
607 613
 		$this->selectAndRemoveGood($goodClass);
@@ -620,8 +626,9 @@  discard block
 block discarded – undo
620 626
 	}
621 627
 	
622 628
 	public function attackedBy(AbstractSmrPlayer $trigger, array $attackers) {
623
-		if ($this->isCachedVersion())
624
-			throw new Exception('Cannot attack a cached port!');
629
+		if ($this->isCachedVersion()) {
630
+					throw new Exception('Cannot attack a cached port!');
631
+		}
625 632
 			
626 633
 		$trigger->increaseHOF(1, array('Combat', 'Port', 'Number Of Triggers'), HOF_PUBLIC);
627 634
 		foreach ($attackers as $attacker) {
@@ -640,8 +647,7 @@  discard block
 block discarded – undo
640 647
 			$newsMessage = '<span class="red bold">*MAYDAY* *MAYDAY*</span> A distress beacon has been activated by the port in sector ' . Globals::getSectorBBLink($this->getSectorID()) . '. It is under attack by ';
641 648
 			if ($trigger->hasAlliance()) {
642 649
 				$newsMessage .= 'members of ' . $trigger->getAllianceBBLink();
643
-			}
644
-			else {
650
+			} else {
645 651
 				$newsMessage .= $trigger->getBBLink();
646 652
 			}
647 653
 			
@@ -650,8 +656,7 @@  discard block
 block discarded – undo
650 656
 
651 657
 			if ($trigger->hasAlliance()) {
652 658
 				$newsMessage .= 'bounties of <span class="creds">' . $bounty . '</span> credits for the deaths of any raiding members of ' . $trigger->getAllianceBBLink();
653
-			}
654
-			else {
659
+			} else {
655 660
 				$newsMessage .= 'a bounty of <span class="creds">' . $bounty . '</span> credits for the death of ' . $trigger->getBBLink();
656 661
 			}
657 662
 			$newsMessage .= ' prior to the destruction of the port, or until federal forces arrive to defend the port.';
@@ -665,34 +670,43 @@  discard block
 block discarded – undo
665 670
 	}
666 671
 	
667 672
 	public function setShields($shields) {
668
-		if ($this->isCachedVersion())
669
-			throw new Exception('Cannot update a cached port!');
670
-		if ($shields < 0)
671
-			$shields = 0;
672
-		if ($this->shields == $shields)
673
-			return;
673
+		if ($this->isCachedVersion()) {
674
+					throw new Exception('Cannot update a cached port!');
675
+		}
676
+		if ($shields < 0) {
677
+					$shields = 0;
678
+		}
679
+		if ($this->shields == $shields) {
680
+					return;
681
+		}
674 682
 		$this->shields = $shields;
675 683
 		$this->hasChanged = true;
676 684
 	}
677 685
 	
678 686
 	public function setArmour($armour) {
679
-		if ($this->isCachedVersion())
680
-			throw new Exception('Cannot update a cached port!');
681
-		if ($armour < 0)
682
-			$armour = 0;
683
-		if ($this->armour == $armour)
684
-			return;
687
+		if ($this->isCachedVersion()) {
688
+					throw new Exception('Cannot update a cached port!');
689
+		}
690
+		if ($armour < 0) {
691
+					$armour = 0;
692
+		}
693
+		if ($this->armour == $armour) {
694
+					return;
695
+		}
685 696
 		$this->armour = $armour;
686 697
 		$this->hasChanged = true;
687 698
 	}
688 699
 	
689 700
 	public function setCDs($combatDrones) {
690
-		if ($this->isCachedVersion())
691
-			throw new Exception('Cannot update a cached port!');
692
-		if ($combatDrones < 0)
693
-			$combatDrones = 0;
694
-		if ($this->combatDrones == $combatDrones)
695
-			return;
701
+		if ($this->isCachedVersion()) {
702
+					throw new Exception('Cannot update a cached port!');
703
+		}
704
+		if ($combatDrones < 0) {
705
+					$combatDrones = 0;
706
+		}
707
+		if ($this->combatDrones == $combatDrones) {
708
+					return;
709
+		}
696 710
 		$this->combatDrones = $combatDrones;
697 711
 		$this->hasChanged = true;
698 712
 	}
@@ -702,84 +716,99 @@  discard block
 block discarded – undo
702 716
 	}
703 717
 
704 718
 	public function setCredits($credits) {
705
-		if ($this->isCachedVersion())
706
-			throw new Exception('Cannot update a cached port!');
707
-		if ($this->credits == $credits)
708
-			return;
719
+		if ($this->isCachedVersion()) {
720
+					throw new Exception('Cannot update a cached port!');
721
+		}
722
+		if ($this->credits == $credits) {
723
+					return;
724
+		}
709 725
 		$this->credits = $credits;
710 726
 		$this->hasChanged = true;
711 727
 	}
712 728
 	
713 729
 	public function decreaseCredits($credits) {
714
-		if ($credits < 0)
715
-			throw new Exception('Cannot decrease negative credits.');
730
+		if ($credits < 0) {
731
+					throw new Exception('Cannot decrease negative credits.');
732
+		}
716 733
 		$this->setCredits($this->getCredits() - $credits);
717 734
 	}
718 735
 	
719 736
 	public function increaseCredits($credits) {
720
-		if ($credits < 0)
721
-			throw new Exception('Cannot increase negative credits.');
737
+		if ($credits < 0) {
738
+					throw new Exception('Cannot increase negative credits.');
739
+		}
722 740
 		$this->setCredits($this->getCredits() + $credits);
723 741
 	}
724 742
 	
725 743
 	public function setUpgrade($upgrade) {
726
-		if ($this->isCachedVersion())
727
-			throw new Exception('Cannot update a cached port!');
744
+		if ($this->isCachedVersion()) {
745
+					throw new Exception('Cannot update a cached port!');
746
+		}
728 747
 		if ($this->getLevel() == $this->getMaxLevel()) {
729 748
 			$upgrade = 0;
730 749
 		}
731
-		if ($this->upgrade == $upgrade)
732
-			return;
750
+		if ($this->upgrade == $upgrade) {
751
+					return;
752
+		}
733 753
 		$this->upgrade = $upgrade;
734 754
 		$this->hasChanged = true;
735 755
 		$this->checkForUpgrade();
736 756
 	}
737 757
 	
738 758
 	public function decreaseUpgrade($upgrade) {
739
-		if ($upgrade < 0)
740
-			throw new Exception('Cannot decrease negative upgrade.');
759
+		if ($upgrade < 0) {
760
+					throw new Exception('Cannot decrease negative upgrade.');
761
+		}
741 762
 		$this->setUpgrade($this->getUpgrade() - $upgrade);
742 763
 	}
743 764
 	
744 765
 	public function increaseUpgrade($upgrade) {
745
-		if ($upgrade < 0)
746
-			throw new Exception('Cannot increase negative upgrade.');
766
+		if ($upgrade < 0) {
767
+					throw new Exception('Cannot increase negative upgrade.');
768
+		}
747 769
 		$this->setUpgrade($this->getUpgrade() + $upgrade);
748 770
 	}
749 771
 	
750 772
 	public function setLevel($level) {
751
-		if ($this->isCachedVersion())
752
-			throw new Exception('Cannot update a cached port!');
753
-		if ($this->level == $level)
754
-			return;
773
+		if ($this->isCachedVersion()) {
774
+					throw new Exception('Cannot update a cached port!');
775
+		}
776
+		if ($this->level == $level) {
777
+					return;
778
+		}
755 779
 		$this->level = $level;
756 780
 		$this->hasChanged = true;
757 781
 	}
758 782
 	
759 783
 	public function increaseLevel($level) {
760
-		if ($level < 0)
761
-			throw new Exception('Cannot increase negative level.');
784
+		if ($level < 0) {
785
+					throw new Exception('Cannot increase negative level.');
786
+		}
762 787
 		$this->setLevel($this->getLevel() + $level);
763 788
 	}
764 789
 	
765 790
 	public function decreaseLevel($level) {
766
-		if ($level < 0)
767
-			throw new Exception('Cannot increase negative level.');
791
+		if ($level < 0) {
792
+					throw new Exception('Cannot increase negative level.');
793
+		}
768 794
 		$this->setLevel($this->getLevel() - $level);
769 795
 	}
770 796
 	
771 797
 	public function setExperience($experience) {
772
-		if ($this->isCachedVersion())
773
-			throw new Exception('Cannot update a cached port!');
774
-		if ($this->experience == $experience)
775
-			return;
798
+		if ($this->isCachedVersion()) {
799
+					throw new Exception('Cannot update a cached port!');
800
+		}
801
+		if ($this->experience == $experience) {
802
+					return;
803
+		}
776 804
 		$this->experience = $experience;
777 805
 		$this->hasChanged = true;
778 806
 	}
779 807
 	
780 808
 	public function increaseExperience($experience) {
781
-		if ($experience < 0)
782
-			throw new Exception('Cannot increase negative experience.');
809
+		if ($experience < 0) {
810
+					throw new Exception('Cannot increase negative experience.');
811
+		}
783 812
 		$this->setExperience($this->getExperience() + $experience);
784 813
 	}
785 814
 	
@@ -804,8 +833,9 @@  discard block
 block discarded – undo
804 833
 	}
805 834
 	
806 835
 	public function setRaceID($raceID) {
807
-		if ($this->raceID == $raceID)
808
-			return;
836
+		if ($this->raceID == $raceID) {
837
+					return;
838
+		}
809 839
 		$this->raceID = $raceID;
810 840
 		$this->hasChanged = true;
811 841
 		$this->cacheIsValid = false;
@@ -883,8 +913,9 @@  discard block
 block discarded – undo
883 913
 	}
884 914
 	
885 915
 	public function getReinforcePercent() {
886
-		if (!$this->isUnderAttack())
887
-			return 0;
916
+		if (!$this->isUnderAttack()) {
917
+					return 0;
918
+		}
888 919
 		return min(1, max(0, ($this->getReinforceTime() - TIME) / ($this->getReinforceTime() - $this->getAttackStarted())));
889 920
 	}
890 921
 	
@@ -905,8 +936,9 @@  discard block
 block discarded – undo
905 936
 	}
906 937
 	
907 938
 	private function setAttackStarted($time) {
908
-		if ($this->attackStarted == $time)
909
-			return;
939
+		if ($this->attackStarted == $time) {
940
+					return;
941
+		}
910 942
 		$this->attackStarted = TIME;
911 943
 		$this->hasChanged = true;
912 944
 	}
@@ -970,10 +1002,10 @@  discard block
 block discarded – undo
970 1002
 		 {
971 1003
 			$relationsEffect = 2 - $relationsEffect;
972 1004
 			return max($idealPrice, IFloor($idealPrice * $relationsEffect));
1005
+		 } else {
1006
+		 			return min($idealPrice, ICeil($idealPrice * $relationsEffect));
973 1007
 		 }
974
-		 else
975
-			return min($idealPrice, ICeil($idealPrice * $relationsEffect));
976
-//		$range = .11 - .095;
1008
+		 //		$range = .11 - .095;
977 1009
 //		$rand = .095 + $range * mt_rand(0, 32767)/32767;
978 1010
 //
979 1011
 //		if($transactionType == 'Buy')
@@ -1034,8 +1066,7 @@  discard block
 block discarded – undo
1034 1066
 		if ($this->getCredits() > 0) {
1035 1067
 			$container = create_container('skeleton.php', 'port_payout_processing.php');
1036 1068
 			$container['PayoutType'] = 'Loot';
1037
-		}
1038
-		else {
1069
+		} else {
1039 1070
 			$container = create_container('skeleton.php', 'current_sector.php');
1040 1071
 			$container['msg'] = 'This port has already been looted.';
1041 1072
 		}
@@ -1106,9 +1137,9 @@  discard block
 block discarded – undo
1106 1137
 			if ($db->nextRecord()) {
1107 1138
 				self::$CACHE_CACHED_PORTS[$gameID][$sectorID][$accountID] = unserialize(gzuncompress($db->getField('port_info')));
1108 1139
 				self::$CACHE_CACHED_PORTS[$gameID][$sectorID][$accountID]->setCachedTime($db->getInt('visited'));
1140
+			} else {
1141
+							self::$CACHE_CACHED_PORTS[$gameID][$sectorID][$accountID] = false;
1109 1142
 			}
1110
-			else
1111
-				self::$CACHE_CACHED_PORTS[$gameID][$sectorID][$accountID] = false;
1112 1143
 		}
1113 1144
 		return self::$CACHE_CACHED_PORTS[$gameID][$sectorID][$accountID];
1114 1145
 	}
@@ -1154,8 +1185,7 @@  discard block
 block discarded – undo
1154 1185
 								', attack_started = ' . $this->db->escapeNumber($this->getAttackStarted()) .
1155 1186
 								', race_id = ' . $this->db->escapeNumber($this->getRaceID()) . '
1156 1187
 								WHERE ' . $this->SQL . ' LIMIT 1');
1157
-			}
1158
-			else {
1188
+			} else {
1159 1189
 				$this->db->query('INSERT INTO port (game_id,sector_id,experience,shields,armour,combat_drones,level,credits,upgrade,reinforce_time,attack_started,race_id)
1160 1190
 								values
1161 1191
 								(' . $this->db->escapeNumber($this->getGameID()) .
@@ -1234,11 +1264,11 @@  discard block
 block discarded – undo
1234 1264
 					$cdDamage = $this->doCDDamage(min($damage['MaxDamage'], $damage['Armour']));
1235 1265
 					$damage['Armour'] -= $cdDamage;
1236 1266
 					$damage['MaxDamage'] -= $cdDamage;
1237
-					if (!$this->hasCDs() && ($cdDamage == 0 || $damage['Rollover']))
1238
-						$armourDamage = $this->doArmourDamage(min($damage['MaxDamage'], $damage['Armour']));
1267
+					if (!$this->hasCDs() && ($cdDamage == 0 || $damage['Rollover'])) {
1268
+											$armourDamage = $this->doArmourDamage(min($damage['MaxDamage'], $damage['Armour']));
1269
+					}
1239 1270
 				}
1240
-			}
1241
-			else { //hit drones behind shields
1271
+			} else { //hit drones behind shields
1242 1272
 				$cdDamage = $this->doCDDamage(IFloor(min($damage['MaxDamage'], $damage['Armour']) * DRONES_BEHIND_SHIELDS_DAMAGE_PERCENT));
1243 1273
 			}
1244 1274
 		}
@@ -1334,8 +1364,11 @@  discard block
 block discarded – undo
1334 1364
 		
1335 1365
 		// News Entry
1336 1366
 		$news = $this->getDisplayName() . ' has been successfully raided by ';
1337
-		if ($killer->hasAlliance()) $news .= 'the members of <span class="yellow">' . $killer->getAllianceBBLink() . '</span>';
1338
-		else $news .= $killer->getBBLink();
1367
+		if ($killer->hasAlliance()) {
1368
+			$news .= 'the members of <span class="yellow">' . $killer->getAllianceBBLink() . '</span>';
1369
+		} else {
1370
+			$news .= $killer->getBBLink();
1371
+		}
1339 1372
 		$this->db->query('INSERT INTO news (game_id, time, news_message, type,killer_id,killer_alliance,dead_id) VALUES (' . $this->db->escapeNumber($this->getGameID()) . ', ' . $this->db->escapeNumber(TIME) . ', ' . $this->db->escapeString($news) . ', \'REGULAR\',' . $this->db->escapeNumber($killer->getAccountID()) . ',' . $this->db->escapeNumber($killer->getAllianceID()) . ',' . $this->db->escapeNumber(ACCOUNT_ID_PORT) . ')');
1340 1373
 		// Killer gets a relations change and a bounty if port is taken
1341 1374
 		$return['KillerBounty'] = $killer->getExperience() * $this->getLevel();
@@ -1351,8 +1384,9 @@  discard block
 block discarded – undo
1351 1384
 
1352 1385
 	public function hasX(/*Object*/ $x) {
1353 1386
 		if (is_array($x) && $x['Type'] == 'Good') { // instanceof Good) - No Good class yet, so array is the best we can do
1354
-			if (isset($x['ID']))
1355
-				return $this->hasGood($x['ID'], isset($x['TransactionType']) ? $x['TransactionType'] : false);
1387
+			if (isset($x['ID'])) {
1388
+							return $this->hasGood($x['ID'], isset($x['TransactionType']) ? $x['TransactionType'] : false);
1389
+			}
1356 1390
 		}
1357 1391
 		return false;
1358 1392
 	}
Please login to merge, or discard this patch.
engine/Default/rankings_alliance_vs_alliance.php 1 patch
Braces   +17 added lines, -10 removed lines patch added patch discarded remove patch
@@ -62,8 +62,7 @@  discard block
 block discarded – undo
62 62
 			} elseif ($showBold) {
63 63
 				$style = 'class="bold"';
64 64
 			}
65
-		}
66
-		else {
65
+		} else {
67 66
 			$db2->query('SELECT kills FROM alliance_vs_alliance
68 67
 						WHERE alliance_id_2 = ' . $db2->escapeNumber($curr_id) . '
69 68
 							AND alliance_id_1 = ' . $db2->escapeNumber($id) . '
@@ -104,11 +103,15 @@  discard block
 block discarded – undo
104 103
 	if ($id > 0) {
105 104
 		$killer_alliance = SmrAlliance::getAlliance($id, $player->getGameID());
106 105
 		$alliance_name = $killer_alliance->getAllianceDisplayName();
106
+	} elseif ($id == 0) {
107
+		$alliance_name = 'No Alliance';
108
+	} elseif ($id == ALLIANCE_VS_FORCES) {
109
+		$alliance_name = '<span class="yellow">Forces</span>';
110
+	} elseif ($id == ALLIANCE_VS_PLANETS) {
111
+		$alliance_name = '<span class="yellow">Planets</span>';
112
+	} elseif ($id == ALLIANCE_VS_PORTS) {
113
+		$alliance_name = '<span class="yellow">Ports</span>';
107 114
 	}
108
-	elseif ($id == 0) $alliance_name = 'No Alliance';
109
-	elseif ($id == ALLIANCE_VS_FORCES) $alliance_name = '<span class="yellow">Forces</span>';
110
-	elseif ($id == ALLIANCE_VS_PLANETS) $alliance_name = '<span class="yellow">Planets</span>';
111
-	elseif ($id == ALLIANCE_VS_PORTS) $alliance_name = '<span class="yellow">Ports</span>';
112 115
 
113 116
 	$kills[] = [
114 117
 		'Name' => $alliance_name,
@@ -126,11 +129,15 @@  discard block
 block discarded – undo
126 129
 	if ($id > 0) {
127 130
 		$killer_alliance = SmrAlliance::getAlliance($id, $player->getGameID());
128 131
 		$alliance_name = $killer_alliance->getAllianceDisplayName();
132
+	} elseif ($id == 0) {
133
+		$alliance_name = 'No Alliance';
134
+	} elseif ($id == ALLIANCE_VS_FORCES) {
135
+		$alliance_name = '<span class="yellow">Forces</span>';
136
+	} elseif ($id == ALLIANCE_VS_PLANETS) {
137
+		$alliance_name = '<span class="yellow">Planets</span>';
138
+	} elseif ($id == ALLIANCE_VS_PORTS) {
139
+		$alliance_name = '<span class="yellow">Ports</span>';
129 140
 	}
130
-	elseif ($id == 0) $alliance_name = 'No Alliance';
131
-	elseif ($id == ALLIANCE_VS_FORCES) $alliance_name = '<span class="yellow">Forces</span>';
132
-	elseif ($id == ALLIANCE_VS_PLANETS) $alliance_name = '<span class="yellow">Planets</span>';
133
-	elseif ($id == ALLIANCE_VS_PORTS) $alliance_name = '<span class="yellow">Ports</span>';
134 141
 
135 142
 	$deaths[] = [
136 143
 		'Name' => $alliance_name,
Please login to merge, or discard this patch.
lib/Default/AbstractSmrPlayer.class.php 1 patch
Braces   +214 added lines, -147 removed lines patch added patch discarded remove patch
@@ -76,8 +76,9 @@  discard block
 block discarded – undo
76 76
 		return $this->getNewbieTurns() > 0;
77 77
 	}
78 78
 	public function setNewbieTurns($newbieTurns) {
79
-		if ($this->newbieTurns == $newbieTurns)
80
-			return;
79
+		if ($this->newbieTurns == $newbieTurns) {
80
+					return;
81
+		}
81 82
 		$this->newbieTurns = $newbieTurns;
82 83
 		$this->hasChanged = true;
83 84
 	}
@@ -87,8 +88,9 @@  discard block
 block discarded – undo
87 88
 	}
88 89
 
89 90
 	public function setShipTypeID($shipID) {
90
-		if ($this->shipID == $shipID)
91
-			return;
91
+		if ($this->shipID == $shipID) {
92
+					return;
93
+		}
92 94
 		$this->shipID = $shipID;
93 95
 		$this->hasChanged = true;
94 96
 	}
@@ -198,8 +200,9 @@  discard block
 block discarded – undo
198 200
 		}
199 201
 
200 202
 		$ship = $this->getShip();
201
-		if ($ship->hasIllegalGoods())
202
-			return false;
203
+		if ($ship->hasIllegalGoods()) {
204
+					return false;
205
+		}
203 206
 
204 207
 		if ($ship->getAttackRating() <= $this->getSafeAttackRating()) {
205 208
 			foreach ($sector->getFedRaceIDs() as $fedRaceID) {
@@ -240,8 +243,9 @@  discard block
 block discarded – undo
240 243
 	}
241 244
 
242 245
 	public function setDead($bool) {
243
-		if ($this->dead == $bool)
244
-			return;
246
+		if ($this->dead == $bool) {
247
+					return;
248
+		}
245 249
 		$this->dead = $bool;
246 250
 		$this->hasChanged = true;
247 251
 	}
@@ -251,14 +255,16 @@  discard block
 block discarded – undo
251 255
 	}
252 256
 
253 257
 	public function increaseKills($kills) {
254
-		if ($kills < 0)
255
-			throw new Exception('Trying to increase negative kills.');
258
+		if ($kills < 0) {
259
+					throw new Exception('Trying to increase negative kills.');
260
+		}
256 261
 		$this->setKills($this->kills + $kills);
257 262
 	}
258 263
 
259 264
 	public function setKills($kills) {
260
-		if ($this->kills == $kills)
261
-			return;
265
+		if ($this->kills == $kills) {
266
+					return;
267
+		}
262 268
 		$this->kills = $kills;
263 269
 		$this->hasChanged = true;
264 270
 	}
@@ -268,14 +274,16 @@  discard block
 block discarded – undo
268 274
 	}
269 275
 
270 276
 	public function increaseDeaths($deaths) {
271
-		if ($deaths < 0)
272
-			throw new Exception('Trying to increase negative deaths.');
277
+		if ($deaths < 0) {
278
+					throw new Exception('Trying to increase negative deaths.');
279
+		}
273 280
 		$this->setDeaths($this->getDeaths() + $deaths);
274 281
 	}
275 282
 
276 283
 	public function setDeaths($deaths) {
277
-		if ($this->deaths == $deaths)
278
-			return;
284
+		if ($this->deaths == $deaths) {
285
+					return;
286
+		}
279 287
 		$this->deaths = $deaths;
280 288
 		$this->hasChanged = true;
281 289
 	}
@@ -297,24 +305,29 @@  discard block
 block discarded – undo
297 305
 	}
298 306
 
299 307
 	public function increaseAlignment($align) {
300
-		if ($align < 0)
301
-			throw new Exception('Trying to increase negative align.');
302
-		if ($align == 0)
303
-			return;
308
+		if ($align < 0) {
309
+					throw new Exception('Trying to increase negative align.');
310
+		}
311
+		if ($align == 0) {
312
+					return;
313
+		}
304 314
 		$align += $this->alignment;
305 315
 		$this->setAlignment($align);
306 316
 	}
307 317
 	public function decreaseAlignment($align) {
308
-		if ($align < 0)
309
-			throw new Exception('Trying to decrease negative align.');
310
-		if ($align == 0)
311
-			return;
318
+		if ($align < 0) {
319
+					throw new Exception('Trying to decrease negative align.');
320
+		}
321
+		if ($align == 0) {
322
+					return;
323
+		}
312 324
 		$align = $this->alignment - $align;
313 325
 		$this->setAlignment($align);
314 326
 	}
315 327
 	public function setAlignment($align) {
316
-		if ($this->alignment == $align)
317
-			return;
328
+		if ($this->alignment == $align) {
329
+					return;
330
+		}
318 331
 		$this->alignment = $align;
319 332
 		$this->hasChanged = true;
320 333
 	}
@@ -332,8 +345,9 @@  discard block
 block discarded – undo
332 345
 	 * This value is rounded because it is used primarily in HTML img widths.
333 346
 	 */
334 347
 	public function getNextLevelPercentAcquired() : int {
335
-		if ($this->getNextLevelExperience() == $this->getThisLevelExperience())
336
-			return 100;
348
+		if ($this->getNextLevelExperience() == $this->getThisLevelExperience()) {
349
+					return 100;
350
+		}
337 351
 		return max(0, min(100, IRound(($this->getExperience() - $this->getThisLevelExperience()) / ($this->getNextLevelExperience() - $this->getThisLevelExperience()) * 100)));
338 352
 	}
339 353
 
@@ -343,8 +357,10 @@  discard block
 block discarded – undo
343 357
 
344 358
 	public function getNextLevelExperience() {
345 359
 		$LEVELS_REQUIREMENTS = Globals::getLevelRequirements();
346
-		if (!isset($LEVELS_REQUIREMENTS[$this->getLevelID() + 1]))
347
-			return $this->getThisLevelExperience(); //Return current level experience if on last level.
360
+		if (!isset($LEVELS_REQUIREMENTS[$this->getLevelID() + 1])) {
361
+					return $this->getThisLevelExperience();
362
+		}
363
+		//Return current level experience if on last level.
348 364
 		return $LEVELS_REQUIREMENTS[$this->getLevelID() + 1]['Requirement'];
349 365
 	}
350 366
 
@@ -354,12 +370,15 @@  discard block
 block discarded – undo
354 370
 	}
355 371
 
356 372
 	public function setExperience($experience) {
357
-		if ($this->experience == $experience)
358
-			return;
359
-		if ($experience < MIN_EXPERIENCE)
360
-			$experience = MIN_EXPERIENCE;
361
-		if ($experience > MAX_EXPERIENCE)
362
-			$experience = MAX_EXPERIENCE;
373
+		if ($this->experience == $experience) {
374
+					return;
375
+		}
376
+		if ($experience < MIN_EXPERIENCE) {
377
+					$experience = MIN_EXPERIENCE;
378
+		}
379
+		if ($experience > MAX_EXPERIENCE) {
380
+					$experience = MAX_EXPERIENCE;
381
+		}
363 382
 		$this->experience = $experience;
364 383
 		$this->hasChanged = true;
365 384
 
@@ -369,46 +388,57 @@  discard block
 block discarded – undo
369 388
 	}
370 389
 
371 390
 	public function increaseCredits($credits) {
372
-		if ($credits < 0)
373
-			throw new Exception('Trying to increase negative credits.');
374
-		if ($credits == 0)
375
-			return;
391
+		if ($credits < 0) {
392
+					throw new Exception('Trying to increase negative credits.');
393
+		}
394
+		if ($credits == 0) {
395
+					return;
396
+		}
376 397
 		$credits += $this->credits;
377 398
 		$this->setCredits($credits);
378 399
 	}
379 400
 	public function decreaseCredits($credits) {
380
-		if ($credits < 0)
381
-			throw new Exception('Trying to decrease negative credits.');
382
-		if ($credits == 0)
383
-			return;
401
+		if ($credits < 0) {
402
+					throw new Exception('Trying to decrease negative credits.');
403
+		}
404
+		if ($credits == 0) {
405
+					return;
406
+		}
384 407
 		$credits = $this->credits - $credits;
385 408
 		$this->setCredits($credits);
386 409
 	}
387 410
 	public function setCredits($credits) {
388
-		if ($this->credits == $credits)
389
-			return;
390
-		if ($credits < 0)
391
-			throw new Exception('Trying to set negative credits.');
392
-		if ($credits > MAX_MONEY)
393
-			$credits = MAX_MONEY;
411
+		if ($this->credits == $credits) {
412
+					return;
413
+		}
414
+		if ($credits < 0) {
415
+					throw new Exception('Trying to set negative credits.');
416
+		}
417
+		if ($credits > MAX_MONEY) {
418
+					$credits = MAX_MONEY;
419
+		}
394 420
 		$this->credits = $credits;
395 421
 		$this->hasChanged = true;
396 422
 	}
397 423
 
398 424
 	public function increaseExperience($experience) {
399
-		if ($experience < 0)
400
-			throw new Exception('Trying to increase negative experience.');
401
-		if ($experience == 0)
402
-			return;
425
+		if ($experience < 0) {
426
+					throw new Exception('Trying to increase negative experience.');
427
+		}
428
+		if ($experience == 0) {
429
+					return;
430
+		}
403 431
 		$newExperience = $this->experience + $experience;
404 432
 		$this->setExperience($newExperience);
405 433
 		$this->increaseHOF($experience, array('Experience', 'Total', 'Gain'), HOF_PUBLIC);
406 434
 	}
407 435
 	public function decreaseExperience($experience) {
408
-		if ($experience < 0)
409
-			throw new Exception('Trying to decrease negative experience.');
410
-		if ($experience == 0)
411
-			return;
436
+		if ($experience < 0) {
437
+					throw new Exception('Trying to decrease negative experience.');
438
+		}
439
+		if ($experience == 0) {
440
+					return;
441
+		}
412 442
 		$newExperience = $this->experience - $experience;
413 443
 		$this->setExperience($newExperience);
414 444
 		$this->decreaseHOF($experience, array('Experience', 'Total', 'Loss'), HOF_PUBLIC);
@@ -419,8 +449,9 @@  discard block
 block discarded – undo
419 449
 	}
420 450
 
421 451
 	public function setLandedOnPlanet($bool) {
422
-		if ($this->landedOnPlanet == $bool)
423
-			return;
452
+		if ($this->landedOnPlanet == $bool) {
453
+					return;
454
+		}
424 455
 		$this->landedOnPlanet = $bool;
425 456
 		$this->hasChanged = true;
426 457
 	}
@@ -434,7 +465,9 @@  discard block
 block discarded – undo
434 465
 		if ($this->level === null) {
435 466
 			$LEVELS_REQUIREMENTS = Globals::getLevelRequirements();
436 467
 			foreach ($LEVELS_REQUIREMENTS as $level_id => $require) {
437
-				if ($this->getExperience() >= $require['Requirement']) continue;
468
+				if ($this->getExperience() >= $require['Requirement']) {
469
+					continue;
470
+				}
438 471
 				$this->level = $level_id - 1;
439 472
 				return $this->level;
440 473
 			}
@@ -512,8 +545,9 @@  discard block
 block discarded – undo
512 545
 	}
513 546
 
514 547
 	public function setRaceID($raceID) {
515
-		if ($this->raceID == $raceID)
516
-			return;
548
+		if ($this->raceID == $raceID) {
549
+					return;
550
+		}
517 551
 		$this->raceID = $raceID;
518 552
 		$this->hasChanged = true;
519 553
 	}
@@ -535,8 +569,9 @@  discard block
 block discarded – undo
535 569
 	}
536 570
 
537 571
 	protected function setAllianceID($ID) {
538
-		if ($this->allianceID == $ID)
539
-			return;
572
+		if ($this->allianceID == $ID) {
573
+					return;
574
+		}
540 575
 		$this->allianceID = $ID;
541 576
 		if ($this->allianceID != 0) {
542 577
 			$status = $this->hasNewbieStatus() ? 'NEWBIE' : 'VETERAN';
@@ -553,8 +588,7 @@  discard block
 block discarded – undo
553 588
 	public function getAllianceDisplayName($linked = false, $includeAllianceID = false) {
554 589
 		if ($this->hasAlliance()) {
555 590
 			return $this->getAlliance()->getAllianceDisplayName($linked, $includeAllianceID);
556
-		}
557
-		else {
591
+		} else {
558 592
 			return 'No Alliance';
559 593
 		}
560 594
 	}
@@ -582,8 +616,9 @@  discard block
 block discarded – undo
582 616
 	}
583 617
 
584 618
 	public function setCombatDronesKamikazeOnMines($bool) {
585
-		if ($this->combatDronesKamikazeOnMines == $bool)
586
-			return;
619
+		if ($this->combatDronesKamikazeOnMines == $bool) {
620
+					return;
621
+		}
587 622
 		$this->combatDronesKamikazeOnMines = $bool;
588 623
 		$this->hasChanged = true;
589 624
 	}
@@ -656,21 +691,24 @@  discard block
 block discarded – undo
656 691
 	}
657 692
 
658 693
 	public function setMilitaryPayment($amount) {
659
-		if ($this->militaryPayment == $amount)
660
-			return;
694
+		if ($this->militaryPayment == $amount) {
695
+					return;
696
+		}
661 697
 		$this->militaryPayment = $amount;
662 698
 		$this->hasChanged = true;
663 699
 	}
664 700
 
665 701
 	public function increaseMilitaryPayment($amount) {
666
-		if ($amount < 0)
667
-			throw new Exception('Trying to increase negative military payment.');
702
+		if ($amount < 0) {
703
+					throw new Exception('Trying to increase negative military payment.');
704
+		}
668 705
 		$this->setMilitaryPayment($this->getMilitaryPayment() + $amount);
669 706
 	}
670 707
 
671 708
 	public function decreaseMilitaryPayment($amount) {
672
-		if ($amount < 0)
673
-			throw new Exception('Trying to decrease negative military payment.');
709
+		if ($amount < 0) {
710
+					throw new Exception('Trying to decrease negative military payment.');
711
+		}
674 712
 		$this->setMilitaryPayment($this->getMilitaryPayment() - $amount);
675 713
 	}
676 714
 
@@ -713,10 +751,11 @@  discard block
 block discarded – undo
713 751
 
714 752
 	protected function getNextBountyID() : int {
715 753
 		$keys = array_keys($this->getBounties());
716
-		if (count($keys) > 0)
717
-			return max($keys) + 1;
718
-		else
719
-			return 0;
754
+		if (count($keys) > 0) {
755
+					return max($keys) + 1;
756
+		} else {
757
+					return 0;
758
+		}
720 759
 	}
721 760
 
722 761
 	protected function setBounty(array $bounty) : void {
@@ -731,22 +770,25 @@  discard block
 block discarded – undo
731 770
 	}
732 771
 
733 772
 	public function increaseBountyAmount(int $bountyID, int $amount) : void {
734
-		if ($amount < 0)
735
-			throw new Exception('Trying to increase negative bounty.');
773
+		if ($amount < 0) {
774
+					throw new Exception('Trying to increase negative bounty.');
775
+		}
736 776
 		$this->setBountyAmount($this->getBountyAmount($bountyID) + $amount);
737 777
 	}
738 778
 
739 779
 	public function decreaseBountyAmount(int $bountyID, int $amount) : void {
740
-		if ($amount < 0)
741
-			throw new Exception('Trying to decrease negative bounty.');
780
+		if ($amount < 0) {
781
+					throw new Exception('Trying to decrease negative bounty.');
782
+		}
742 783
 		$this->setBountyAmount($this->getBountyAmount($bountyID) + $amount);
743 784
 	}
744 785
 
745 786
 	public function getCurrentBounty(string $type) : array {
746 787
 		$bounties = $this->getBounties();
747 788
 		foreach ($bounties as $bounty) {
748
-			if ($bounty['Claimer'] == 0 && $bounty['Type'] == $type)
749
-				return $bounty;
789
+			if ($bounty['Claimer'] == 0 && $bounty['Type'] == $type) {
790
+							return $bounty;
791
+			}
750 792
 		}
751 793
 		return $this->createBounty($type);
752 794
 	}
@@ -754,8 +796,9 @@  discard block
 block discarded – undo
754 796
 	public function hasCurrentBounty(string $type) : bool {
755 797
 		$bounties = $this->getBounties();
756 798
 		foreach ($bounties as $bounty) {
757
-			if ($bounty['Claimer'] == 0 && $bounty['Type'] == $type)
758
-				return true;
799
+			if ($bounty['Claimer'] == 0 && $bounty['Type'] == $type) {
800
+							return true;
801
+			}
759 802
 		}
760 803
 		return false;
761 804
 	}
@@ -767,21 +810,24 @@  discard block
 block discarded – undo
767 810
 
768 811
 	protected function setCurrentBountyAmount(string $type, int $amount) : void {
769 812
 		$bounty = $this->getCurrentBounty($type);
770
-		if ($bounty['Amount'] == $amount)
771
-			return;
813
+		if ($bounty['Amount'] == $amount) {
814
+					return;
815
+		}
772 816
 		$bounty['Amount'] = $amount;
773 817
 		$this->setBounty($bounty);
774 818
 	}
775 819
 
776 820
 	public function increaseCurrentBountyAmount(string $type, int $amount) : void {
777
-		if ($amount < 0)
778
-			throw new Exception('Trying to increase negative current bounty.');
821
+		if ($amount < 0) {
822
+					throw new Exception('Trying to increase negative current bounty.');
823
+		}
779 824
 		$this->setCurrentBountyAmount($type, $this->getCurrentBountyAmount($type) + $amount);
780 825
 	}
781 826
 
782 827
 	public function decreaseCurrentBountyAmount(string $type, int $amount) : void {
783
-		if ($amount < 0)
784
-			throw new Exception('Trying to decrease negative current bounty.');
828
+		if ($amount < 0) {
829
+					throw new Exception('Trying to decrease negative current bounty.');
830
+		}
785 831
 		$this->setCurrentBountyAmount($type, $this->getCurrentBountyAmount($type) - $amount);
786 832
 	}
787 833
 
@@ -792,21 +838,24 @@  discard block
 block discarded – undo
792 838
 
793 839
 	protected function setCurrentBountySmrCredits(string $type, int $credits) : void {
794 840
 		$bounty = $this->getCurrentBounty($type);
795
-		if ($bounty['SmrCredits'] == $credits)
796
-			return;
841
+		if ($bounty['SmrCredits'] == $credits) {
842
+					return;
843
+		}
797 844
 		$bounty['SmrCredits'] = $credits;
798 845
 		$this->setBounty($bounty);
799 846
 	}
800 847
 
801 848
 	public function increaseCurrentBountySmrCredits(string $type, int $credits) : void {
802
-		if ($credits < 0)
803
-			throw new Exception('Trying to increase negative current bounty.');
849
+		if ($credits < 0) {
850
+					throw new Exception('Trying to increase negative current bounty.');
851
+		}
804 852
 		$this->setCurrentBountySmrCredits($type, $this->getCurrentBountySmrCredits($type) + $credits);
805 853
 	}
806 854
 
807 855
 	public function decreaseCurrentBountySmrCredits(string $type, int $credits) : void {
808
-		if ($credits < 0)
809
-			throw new Exception('Trying to decrease negative current bounty.');
856
+		if ($credits < 0) {
857
+					throw new Exception('Trying to decrease negative current bounty.');
858
+		}
810 859
 		$this->setCurrentBountySmrCredits($type, $this->getCurrentBountySmrCredits($type) - $credits);
811 860
 	}
812 861
 
@@ -824,51 +873,59 @@  discard block
 block discarded – undo
824 873
 
825 874
 	public function getHOF(array $typeList = null) {
826 875
 		$this->getHOFData();
827
-		if ($typeList == null)
828
-			return $this->HOF;
876
+		if ($typeList == null) {
877
+					return $this->HOF;
878
+		}
829 879
 		$hof = $this->HOF;
830 880
 		foreach ($typeList as $type) {
831
-			if (!isset($hof[$type]))
832
-				return 0;
881
+			if (!isset($hof[$type])) {
882
+							return 0;
883
+			}
833 884
 			$hof = $hof[$type];
834 885
 		}
835 886
 		return $hof;
836 887
 	}
837 888
 
838 889
 	public function increaseHOF($amount, array $typeList, $visibility) {
839
-		if ($amount < 0)
840
-			throw new Exception('Trying to increase negative HOF: ' . implode(':', $typeList));
841
-		if ($amount == 0)
842
-			return;
890
+		if ($amount < 0) {
891
+					throw new Exception('Trying to increase negative HOF: ' . implode(':', $typeList));
892
+		}
893
+		if ($amount == 0) {
894
+					return;
895
+		}
843 896
 		$this->setHOF($this->getHOF($typeList) + $amount, $typeList, $visibility);
844 897
 	}
845 898
 
846 899
 	public function decreaseHOF($amount, array $typeList, $visibility) {
847
-		if ($amount < 0)
848
-			throw new Exception('Trying to decrease negative HOF: ' . implode(':', $typeList));
849
-		if ($amount == 0)
850
-			return;
900
+		if ($amount < 0) {
901
+					throw new Exception('Trying to decrease negative HOF: ' . implode(':', $typeList));
902
+		}
903
+		if ($amount == 0) {
904
+					return;
905
+		}
851 906
 		$this->setHOF($this->getHOF($typeList) - $amount, $typeList, $visibility);
852 907
 	}
853 908
 
854 909
 	public function setHOF($amount, array $typeList, $visibility) {
855
-		if (is_array($this->getHOF($typeList)))
856
-			throw new Exception('Trying to overwrite a HOF type: ' . implode(':', $typeList));
910
+		if (is_array($this->getHOF($typeList))) {
911
+					throw new Exception('Trying to overwrite a HOF type: ' . implode(':', $typeList));
912
+		}
857 913
 		if ($this->isNPC()) {
858 914
 			// Don't store HOF for NPCs.
859 915
 			return;
860 916
 		}
861
-		if ($this->getHOF($typeList) == $amount)
862
-			return;
863
-		if ($amount < 0)
864
-			$amount = 0;
917
+		if ($this->getHOF($typeList) == $amount) {
918
+					return;
919
+		}
920
+		if ($amount < 0) {
921
+					$amount = 0;
922
+		}
865 923
 		$this->getHOF();
866 924
 
867 925
 		$hofType = implode(':', $typeList);
868 926
 		if (!isset(self::$HOFVis[$hofType])) {
869 927
 			self::$hasHOFVisChanged[$hofType] = self::HOF_NEW;
870
-		}
871
-		else if (self::$HOFVis[$hofType] != $visibility) {
928
+		} else if (self::$HOFVis[$hofType] != $visibility) {
872 929
 			self::$hasHOFVisChanged[$hofType] = self::HOF_CHANGED;
873 930
 		}
874 931
 		self::$HOFVis[$hofType] = $visibility;
@@ -877,8 +934,9 @@  discard block
 block discarded – undo
877 934
 		$hofChanged =& $this->hasHOFChanged;
878 935
 		$new = false;
879 936
 		foreach ($typeList as $type) {
880
-			if (!isset($hofChanged[$type]))
881
-				$hofChanged[$type] = array();
937
+			if (!isset($hofChanged[$type])) {
938
+							$hofChanged[$type] = array();
939
+			}
882 940
 			if (!isset($hof[$type])) {
883 941
 				$hof[$type] = array();
884 942
 				$new = true;
@@ -888,8 +946,9 @@  discard block
 block discarded – undo
888 946
 		}
889 947
 		if ($hofChanged == null) {
890 948
 			$hofChanged = self::HOF_CHANGED;
891
-			if ($new)
892
-				$hofChanged = self::HOF_NEW;
949
+			if ($new) {
950
+							$hofChanged = self::HOF_NEW;
951
+			}
893 952
 		}
894 953
 		$hof = $amount;
895 954
 	}
@@ -954,8 +1013,9 @@  discard block
 block discarded – undo
954 1013
 	}
955 1014
 
956 1015
 	public function setLastActive($lastActive) {
957
-		if ($this->lastActive == $lastActive)
958
-			return;
1016
+		if ($this->lastActive == $lastActive) {
1017
+					return;
1018
+		}
959 1019
 		$this->lastActive = $lastActive;
960 1020
 		$this->hasChanged = true;
961 1021
 	}
@@ -965,8 +1025,9 @@  discard block
 block discarded – undo
965 1025
 	}
966 1026
 
967 1027
 	public function setLastCPLAction($time) {
968
-		if ($this->lastCPLAction == $time)
969
-			return;
1028
+		if ($this->lastCPLAction == $time) {
1029
+					return;
1030
+		}
970 1031
 		$this->lastCPLAction = $time;
971 1032
 		$this->hasChanged = true;
972 1033
 	}
@@ -1007,8 +1068,9 @@  discard block
 block discarded – undo
1007 1068
 
1008 1069
 	protected function getMission($missionID) {
1009 1070
 		$missions = $this->getMissions();
1010
-		if (isset($missions[$missionID]))
1011
-			return $missions[$missionID];
1071
+		if (isset($missions[$missionID])) {
1072
+					return $missions[$missionID];
1073
+		}
1012 1074
 		return false;
1013 1075
 	}
1014 1076
 
@@ -1067,8 +1129,9 @@  discard block
 block discarded – undo
1067 1129
 	public function addMission($missionID, $step = 0) {
1068 1130
 		$this->getMissions();
1069 1131
 
1070
-		if (isset($this->missions[$missionID]))
1071
-			return;
1132
+		if (isset($this->missions[$missionID])) {
1133
+					return;
1134
+		}
1072 1135
 		$sector = 0;
1073 1136
 
1074 1137
 		$mission = array(
@@ -1097,8 +1160,7 @@  discard block
 block discarded – undo
1097 1160
 		if ($mission['On Step'] >= count(MISSIONS[$missionID]['Steps'])) {
1098 1161
 			// If we have completed this mission just use false to indicate no current task.
1099 1162
 			$currentStep = false;
1100
-		}
1101
-		else {
1163
+		} else {
1102 1164
 			$currentStep = MISSIONS[$missionID]['Steps'][$mission['On Step']];
1103 1165
 			$currentStep['Text'] = str_replace(array('<Race>', '<Sector>', '<Starting Sector>', '<trader>'), array($this->getRaceID(), $mission['Sector'], $mission['Starting Sector'], $this->playerName), $currentStep['Text']);
1104 1166
 			if (isset($currentStep['Task'])) {
@@ -1106,8 +1168,7 @@  discard block
 block discarded – undo
1106 1168
 			}
1107 1169
 			if (isset($currentStep['Level'])) {
1108 1170
 				$currentStep['Level'] = str_replace('<Player Level>', $this->getLevelID(), $currentStep['Level']);
1109
-			}
1110
-			else {
1171
+			} else {
1111 1172
 				$currentStep['Level'] = 0;
1112 1173
 			}
1113 1174
 		}
@@ -1235,12 +1296,15 @@  discard block
 block discarded – undo
1235 1296
 	}
1236 1297
 
1237 1298
 	public function canSee(AbstractSmrPlayer $otherPlayer) {
1238
-		if (!$otherPlayer->getShip()->isCloaked())
1239
-			return true;
1240
-		if ($this->sameAlliance($otherPlayer))
1241
-			return true;
1242
-		if ($this->getExperience() >= $otherPlayer->getExperience())
1243
-			return true;
1299
+		if (!$otherPlayer->getShip()->isCloaked()) {
1300
+					return true;
1301
+		}
1302
+		if ($this->sameAlliance($otherPlayer)) {
1303
+					return true;
1304
+		}
1305
+		if ($this->getExperience() >= $otherPlayer->getExperience()) {
1306
+					return true;
1307
+		}
1244 1308
 		return false;
1245 1309
 	}
1246 1310
 
@@ -1293,10 +1357,12 @@  discard block
 block discarded – undo
1293 1357
 	}
1294 1358
 
1295 1359
 	public function meetsAlignmentRestriction($restriction) {
1296
-		if ($restriction < 0)
1297
-			return $this->getAlignment() <= $restriction;
1298
-		if ($restriction > 0)
1299
-			return $this->getAlignment() >= $restriction;
1360
+		if ($restriction < 0) {
1361
+					return $this->getAlignment() <= $restriction;
1362
+		}
1363
+		if ($restriction > 0) {
1364
+					return $this->getAlignment() >= $restriction;
1365
+		}
1300 1366
 		return true;
1301 1367
 	}
1302 1368
 
@@ -1319,8 +1385,9 @@  discard block
 block discarded – undo
1319 1385
 		if (!isset($this->visitedSectors)) {
1320 1386
 			$this->visitedSectors = array();
1321 1387
 			$this->db->query('SELECT sector_id FROM player_visited_sector WHERE ' . $this->SQL);
1322
-			while ($this->db->nextRecord())
1323
-				$this->visitedSectors[$this->db->getInt('sector_id')] = false;
1388
+			while ($this->db->nextRecord()) {
1389
+							$this->visitedSectors[$this->db->getInt('sector_id')] = false;
1390
+			}
1324 1391
 		}
1325 1392
 		return !isset($this->visitedSectors[$sectorID]);
1326 1393
 	}
Please login to merge, or discard this patch.
lib/Default/Routes/RouteGenerator.class.php 1 patch
Braces   +36 added lines, -30 removed lines patch added patch discarded remove patch
@@ -52,15 +52,16 @@  discard block
 block discarded – undo
52 52
 	private static function getContinueRoutes(int $maxNumPorts, int $startSectorId, Route $routeToContinue, array $forwardRoutes, array $routeLists, bool $lastGoodIsNothing) : void {
53 53
 		foreach ($forwardRoutes as $currentStepRoute) {
54 54
 			$currentStepBuySector = $currentStepRoute->getBuySectorId();
55
-			if ($lastGoodIsNothing && ($lastGoodIsNothing = GOOD_NOTHING === $currentStepRoute->getGoodID()))
56
-				continue; // Don't do two nothings in a row
55
+			if ($lastGoodIsNothing && ($lastGoodIsNothing = GOOD_NOTHING === $currentStepRoute->getGoodID())) {
56
+							continue;
57
+			}
58
+			// Don't do two nothings in a row
57 59
 			if ($currentStepBuySector >= $startSectorId) { // Not already checked or back to start
58 60
 				if ($currentStepBuySector === $startSectorId) { // Route returns to start
59 61
 					$mpr = new MultiplePortRoute($routeToContinue, $currentStepRoute);
60 62
 					self::addExpRoute($mpr);
61 63
 					self::addMoneyRoute($mpr);
62
-				}
63
-				else if ($maxNumPorts > 1 && !$routeToContinue->containsPort($currentStepBuySector)) {
64
+				} else if ($maxNumPorts > 1 && !$routeToContinue->containsPort($currentStepBuySector)) {
64 65
 					$mpr = new MultiplePortRoute($routeToContinue, $currentStepRoute);
65 66
 					self::getContinueRoutes($maxNumPorts - 1, $startSectorId, $mpr, $routeLists[$currentStepBuySector], $routeLists, $lastGoodIsNothing);
66 67
 				}
@@ -76,17 +77,21 @@  discard block
 block discarded – undo
76 77
 				echo 'Error with Race ID: '.$sectors[$currentSectorId]->getPort()->getRaceID();
77 78
 				continue;
78 79
 			}
79
-			if($races[$raceID]===false)
80
-				continue;
80
+			if($races[$raceID]===false) {
81
+							continue;
82
+			}
81 83
 			$rl = array();
82 84
 			foreach ($d as $targetSectorId => $distance) {
83
-				if (!$races[$sectors[$targetSectorId]->getPort()->getRaceID()])
84
-					continue;
85
-				if($routesForPort!==-1 && $currentSectorId !== $routesForPort && $targetSectorId !== $routesForPort)
86
-					continue;
85
+				if (!$races[$sectors[$targetSectorId]->getPort()->getRaceID()]) {
86
+									continue;
87
+				}
88
+				if($routesForPort!==-1 && $currentSectorId !== $routesForPort && $targetSectorId !== $routesForPort) {
89
+									continue;
90
+				}
87 91
 
88
-				if ($goods[GOOD_NOTHING]===true)
89
-					$rl[] = new OneWayRoute($currentSectorId, $targetSectorId, $raceID, $sectors[$targetSectorId]->getPort()->getRaceID(), 0, 0, $distance, GOOD_NOTHING);
92
+				if ($goods[GOOD_NOTHING]===true) {
93
+									$rl[] = new OneWayRoute($currentSectorId, $targetSectorId, $raceID, $sectors[$targetSectorId]->getPort()->getRaceID(), 0, 0, $distance, GOOD_NOTHING);
94
+				}
90 95
 
91 96
 				foreach (\Globals::getGoods() as $goodId => $value) {
92 97
 					if ($goods[$goodId]===true) {
@@ -105,13 +110,16 @@  discard block
 block discarded – undo
105 110
 	public static function generateOneWayRoutes(array $sectors, array $distances, array $goods, array $races, int $routesForPort) : array {
106 111
 		self::initialize();
107 112
 		foreach ($distances as $currentSectorId => $d) {
108
-			if ($races[$sectors[$currentSectorId]->getPort()->getRaceID()]===false)
109
-				continue;
113
+			if ($races[$sectors[$currentSectorId]->getPort()->getRaceID()]===false) {
114
+							continue;
115
+			}
110 116
 			foreach ($d as $targetSectorId => $distance) {
111
-				if ($races[$sectors[$targetSectorId]->getPort()->getRaceID()]===false)
112
-					continue;
113
-				if($routesForPort!==-1 && $currentSectorId !== $routesForPort && $targetSectorId !== $routesForPort)
114
-					continue;
117
+				if ($races[$sectors[$targetSectorId]->getPort()->getRaceID()]===false) {
118
+									continue;
119
+				}
120
+				if($routesForPort!==-1 && $currentSectorId !== $routesForPort && $targetSectorId !== $routesForPort) {
121
+									continue;
122
+				}
115 123
 
116 124
 				foreach (\Globals::getGoods() as $goodId => $value) {
117 125
 					if ($goods[$goodId]===true) {
@@ -162,15 +170,14 @@  discard block
 block discarded – undo
162 170
 		foreach (self::$expRoutes as $multi => $routesByMulti) {
163 171
 			if(count($routesByMulti)+$i < $trimToBestXRoutes) {
164 172
 				$i += count($routesByMulti);
165
-			}
166
-			else if($i > $trimToBestXRoutes) {
173
+			} else if($i > $trimToBestXRoutes) {
167 174
 				unset(self::$expRoutes[$multi]);
168
-			}
169
-			else {
175
+			} else {
170 176
 				foreach($routesByMulti as $key => $value) {
171 177
 					$i++;
172
-					if($i < $trimToBestXRoutes)
173
-						continue;
178
+					if($i < $trimToBestXRoutes) {
179
+											continue;
180
+					}
174 181
 					if($i === $trimToBestXRoutes) {
175 182
 						self::$dontAddWorseThan[self::EXP_ROUTE] = $multi;
176 183
 						continue;
@@ -185,16 +192,15 @@  discard block
 block discarded – undo
185 192
 		foreach (self::$moneyRoutes as $multi => $routesByMulti) {
186 193
 			if(count($routesByMulti)+$i < $trimToBestXRoutes) {
187 194
 				$i += count($routesByMulti);
188
-			}
189
-			else if($i > $trimToBestXRoutes) {
195
+			} else if($i > $trimToBestXRoutes) {
190 196
 				unset(self::$moneyRoutes[$multi]);
191 197
 				continue;
192
-			}
193
-			else {
198
+			} else {
194 199
 				foreach($routesByMulti as $key => $value) {
195 200
 					$i++;
196
-					if($i < $trimToBestXRoutes)
197
-						continue;
201
+					if($i < $trimToBestXRoutes) {
202
+											continue;
203
+					}
198 204
 					if($i === $trimToBestXRoutes) {
199 205
 						self::$dontAddWorseThan[self::MONEY_ROUTE] = $multi;
200 206
 						continue;
Please login to merge, or discard this patch.
lib/Default/Routes/OneWayRoute.class.php 1 patch
Braces   +5 added lines, -4 removed lines patch added patch discarded remove patch
@@ -82,10 +82,11 @@
 block discarded – undo
82 82
 	}
83 83
 
84 84
 	public function getTurnsForRoute() : int {
85
-		if ($this->goodId === GOOD_NOTHING)
86
-			$tradeTurns = 0;
87
-		else
88
-			$tradeTurns = 2 * TURNS_PER_TRADE;
85
+		if ($this->goodId === GOOD_NOTHING) {
86
+					$tradeTurns = 0;
87
+		} else {
88
+					$tradeTurns = 2 * TURNS_PER_TRADE;
89
+		}
89 90
 		return $this->distance->getTurns() + $tradeTurns;
90 91
 	}
91 92
 
Please login to merge, or discard this patch.
lib/Default/AbstractSmrAccount.class.php 1 patch
Braces   +226 added lines, -165 removed lines patch added patch discarded remove patch
@@ -99,8 +99,9 @@  discard block
 block discarded – undo
99 99
 		if (empty($login)) { return null; }
100 100
 		$db = new SmrMySqlDatabase();
101 101
 		$db->query('SELECT account_id FROM account WHERE login = '.$db->escapeString($login).' LIMIT 1');
102
-		if($db->nextRecord())
103
-			return self::getAccount($db->getInt('account_id'), $forceUpdate);
102
+		if($db->nextRecord()) {
103
+					return self::getAccount($db->getInt('account_id'), $forceUpdate);
104
+		}
104 105
 		$return = null;
105 106
 		return $return;
106 107
 	}
@@ -235,10 +236,10 @@  discard block
 block discarded – undo
235 236
 			$this->template			= $row['template'];
236 237
 			$this->colourScheme		= $row['colour_scheme'];
237 238
 
238
-			if(empty($this->hofName))
239
-				$this->hofName=$this->login;
240
-		}
241
-		else {
239
+			if(empty($this->hofName)) {
240
+							$this->hofName=$this->login;
241
+			}
242
+		} else {
242 243
 			throw new AccountNotFoundException('Account ID '.$accountID.' does not exist!');
243 244
 		}
244 245
 	}
@@ -260,8 +261,7 @@  discard block
 block discarded – undo
260 261
 				'Reason' => $this->db->getField('reason'),
261 262
 				'ReasonID' => $this->db->getInt('reason_id')
262 263
 			);
263
-		}
264
-		else {
264
+		} else {
265 265
 			return false;
266 266
 		}
267 267
 	}
@@ -317,15 +317,18 @@  discard block
 block discarded – undo
317 317
 		if ($curr_ip != 'unknown' && $curr_ip != 'unknown...' && $curr_ip != 'unknown, unknown') {
318 318
 			$curr_ip = $fi.'.'.$se.'.'.$th.'.'.$fo;
319 319
 			$host = gethostbyaddr($curr_ip);
320
-		} else $host = 'unknown';
320
+		} else {
321
+			$host = 'unknown';
322
+		}
321 323
 
322 324
 		// save...first make sure there isn't one for these keys (someone could double click and get error)
323 325
 		$this->db->query('REPLACE INTO account_has_ip (account_id, time, ip, host) VALUES ('.$this->db->escapeNumber($this->account_id).', '.$this->db->escapeNumber(TIME).', '.$this->db->escapeString($curr_ip).', '.$this->db->escapeString($host).')');
324 326
 	}
325 327
 
326 328
 	public function updateLastLogin() {
327
-		if($this->last_login == TIME)
328
-			return;
329
+		if($this->last_login == TIME) {
330
+					return;
331
+		}
329 332
 		$this->last_login = TIME;
330 333
 		$this->hasChanged = true;
331 334
 		$this->update();
@@ -336,8 +339,9 @@  discard block
 block discarded – undo
336 339
 	}
337 340
 
338 341
 	public function setLoggingEnabled($bool) {
339
-		if($this->logging==$bool)
340
-			return;
342
+		if($this->logging==$bool) {
343
+					return;
344
+		}
341 345
 		$this->logging=$bool;
342 346
 		$this->hasChanged = true;
343 347
 		$this->update();
@@ -386,12 +390,14 @@  discard block
 block discarded – undo
386 390
 
387 391
 	public function getHOF(array $typeList = null) {
388 392
 		$this->getHOFData();
389
-		if($typeList==null)
390
-			return $this->HOF;
393
+		if($typeList==null) {
394
+					return $this->HOF;
395
+		}
391 396
 		$hof=$this->HOF;
392 397
 		foreach($typeList as $type) {
393
-			if(!isset($hof[$type]))
394
-				return 0;
398
+			if(!isset($hof[$type])) {
399
+							return 0;
400
+			}
395 401
 			$hof = $hof[$type];
396 402
 		}
397 403
 		return $hof;
@@ -399,10 +405,11 @@  discard block
 block discarded – undo
399 405
 
400 406
 	public function getRankName() {
401 407
 		$rankings = Globals::getUserRanking();
402
-		if(isset($rankings[$this->getRank()]))
403
-			return $rankings[$this->getRank()];
404
-		else
405
-			return end($rankings);
408
+		if(isset($rankings[$this->getRank()])) {
409
+					return $rankings[$this->getRank()];
410
+		} else {
411
+					return end($rankings);
412
+		}
406 413
 	}
407 414
 
408 415
 	public function getScore() {
@@ -418,15 +425,17 @@  discard block
 block discarded – undo
418 425
 
419 426
 	public function getIndividualScores(SmrPlayer $player = null) {
420 427
 		$gameID=0;
421
-		if($player!=null)
422
-			$gameID = $player->getGameID();
428
+		if($player!=null) {
429
+					$gameID = $player->getGameID();
430
+		}
423 431
 		if(!isset($this->individualScores[$gameID])) {
424 432
 			$this->individualScores[$gameID] = array();
425 433
 			foreach(self::USER_RANKINGS_SCORE as $statScore) {
426
-				if($player==null)
427
-					$stat = $this->getHOF($statScore[0]);
428
-				else
429
-					$stat = $player->getHOF($statScore[0]);
434
+				if($player==null) {
435
+									$stat = $this->getHOF($statScore[0]);
436
+				} else {
437
+									$stat = $player->getHOF($statScore[0]);
438
+				}
430 439
 				$this->individualScores[$gameID][]=array('Stat'=>$statScore[0],'Score'=>pow($stat*$statScore[1],self::USER_RANKINGS_EACH_STAT_POW)*$statScore[2]);
431 440
 			}
432 441
 		}
@@ -435,16 +444,19 @@  discard block
 block discarded – undo
435 444
 
436 445
 	public function getRank() : int {
437 446
 		$rank = ICeil(pow($this->getScore(),self::USER_RANKINGS_TOTAL_SCORE_POW)/self::USER_RANKINGS_RANK_BOUNDARY);
438
-		if($rank<1)
439
-			$rank=1;
440
-		if($rank > $this->maxRankAchieved)
441
-			$this->updateMaxRankAchieved($rank);
447
+		if($rank<1) {
448
+					$rank=1;
449
+		}
450
+		if($rank > $this->maxRankAchieved) {
451
+					$this->updateMaxRankAchieved($rank);
452
+		}
442 453
 		return $rank;
443 454
 	}
444 455
 
445 456
 	protected function updateMaxRankAchieved($rank) {
446
-		if($rank <= $this->maxRankAchieved)
447
-			throw new Exception('Trying to set max rank achieved to a lower value: ' . $rank);
457
+		if($rank <= $this->maxRankAchieved) {
458
+					throw new Exception('Trying to set max rank achieved to a lower value: ' . $rank);
459
+		}
448 460
 		$delta = $rank - $this->maxRankAchieved;
449 461
 		if($this->hasReferrer()) {
450 462
 			$this->getReferrer()->increaseSmrRewardCredits($delta * CREDITS_PER_DOLLAR);
@@ -491,12 +503,15 @@  discard block
 block discarded – undo
491 503
 	}
492 504
 
493 505
 	public function decreaseTotalSmrCredits($totalCredits) {
494
-		if($totalCredits==0)
495
-			return;
496
-		if($totalCredits<0)
497
-			throw new Exception('You cannot use negative total credits');
498
-		if($totalCredits>$this->getTotalSmrCredits())
499
-			throw new Exception('You do not have that many credits in total to use');
506
+		if($totalCredits==0) {
507
+					return;
508
+		}
509
+		if($totalCredits<0) {
510
+					throw new Exception('You cannot use negative total credits');
511
+		}
512
+		if($totalCredits>$this->getTotalSmrCredits()) {
513
+					throw new Exception('You do not have that many credits in total to use');
514
+		}
500 515
 
501 516
 		$rewardCredits=$this->rewardCredits;
502 517
 		$credits=$this->credits;
@@ -505,10 +520,11 @@  discard block
 block discarded – undo
505 520
 			$credits+=$rewardCredits;
506 521
 			$rewardCredits=0;
507 522
 		}
508
-		if($this->credits==0 && $this->rewardCredits==0)
509
-			$this->db->query('REPLACE INTO account_has_credits (account_id, credits_left, reward_credits) VALUES('.$this->db->escapeNumber($this->getAccountID()).', '.$this->db->escapeNumber($credits).','.$this->db->escapeNumber($rewardCredits).')');
510
-		else
511
-			$this->db->query('UPDATE account_has_credits SET credits_left='.$this->db->escapeNumber($credits).', reward_credits='.$this->db->escapeNumber($rewardCredits).' WHERE '.$this->SQL.' LIMIT 1');
523
+		if($this->credits==0 && $this->rewardCredits==0) {
524
+					$this->db->query('REPLACE INTO account_has_credits (account_id, credits_left, reward_credits) VALUES('.$this->db->escapeNumber($this->getAccountID()).', '.$this->db->escapeNumber($credits).','.$this->db->escapeNumber($rewardCredits).')');
525
+		} else {
526
+					$this->db->query('UPDATE account_has_credits SET credits_left='.$this->db->escapeNumber($credits).', reward_credits='.$this->db->escapeNumber($rewardCredits).' WHERE '.$this->SQL.' LIMIT 1');
527
+		}
512 528
 		$this->credits=$credits;
513 529
 		$this->rewardCredits=$rewardCredits;
514 530
 	}
@@ -524,48 +540,59 @@  discard block
 block discarded – undo
524 540
 	}
525 541
 
526 542
 	public function setSmrCredits($credits) {
527
-		if($this->getSmrCredits()==$credits)
528
-			return;
529
-		if($this->credits==0 && $this->rewardCredits==0)
530
-			$this->db->query('REPLACE INTO account_has_credits (account_id, credits_left) VALUES('.$this->db->escapeNumber($this->getAccountID()).', '.$this->db->escapeNumber($credits).')');
531
-		else
532
-			$this->db->query('UPDATE account_has_credits SET credits_left='.$this->db->escapeNumber($credits).' WHERE '.$this->SQL.' LIMIT 1');
543
+		if($this->getSmrCredits()==$credits) {
544
+					return;
545
+		}
546
+		if($this->credits==0 && $this->rewardCredits==0) {
547
+					$this->db->query('REPLACE INTO account_has_credits (account_id, credits_left) VALUES('.$this->db->escapeNumber($this->getAccountID()).', '.$this->db->escapeNumber($credits).')');
548
+		} else {
549
+					$this->db->query('UPDATE account_has_credits SET credits_left='.$this->db->escapeNumber($credits).' WHERE '.$this->SQL.' LIMIT 1');
550
+		}
533 551
 		$this->credits=$credits;
534 552
 	}
535 553
 
536 554
 	public function increaseSmrCredits($credits) {
537
-		if($credits==0)
538
-			return;
539
-		if($credits<0)
540
-			throw new Exception('You cannot gain negative credits');
555
+		if($credits==0) {
556
+					return;
557
+		}
558
+		if($credits<0) {
559
+					throw new Exception('You cannot gain negative credits');
560
+		}
541 561
 		$this->setSmrCredits($this->getSmrCredits()+$credits);
542 562
 	}
543 563
 
544 564
 	public function decreaseSmrCredits($credits) {
545
-		if($credits==0)
546
-			return;
547
-		if($credits<0)
548
-			throw new Exception('You cannot use negative credits');
549
-		if($credits>$this->getSmrCredits())
550
-			throw new Exception('You cannot use more credits than you have');
565
+		if($credits==0) {
566
+					return;
567
+		}
568
+		if($credits<0) {
569
+					throw new Exception('You cannot use negative credits');
570
+		}
571
+		if($credits>$this->getSmrCredits()) {
572
+					throw new Exception('You cannot use more credits than you have');
573
+		}
551 574
 		$this->setSmrCredits($this->getSmrCredits()-$credits);
552 575
 	}
553 576
 
554 577
 	public function setSmrRewardCredits($credits) {
555
-		if($this->getSmrRewardCredits()==$credits)
556
-			return;
557
-		if($this->credits==0 && $this->rewardCredits==0)
558
-			$this->db->query('REPLACE INTO account_has_credits (account_id, reward_credits) VALUES('.$this->db->escapeNumber($this->getAccountID()).', '.$this->db->escapeNumber($credits).')');
559
-		else
560
-			$this->db->query('UPDATE account_has_credits SET reward_credits='.$this->db->escapeNumber($credits).' WHERE '.$this->SQL.' LIMIT 1');
578
+		if($this->getSmrRewardCredits()==$credits) {
579
+					return;
580
+		}
581
+		if($this->credits==0 && $this->rewardCredits==0) {
582
+					$this->db->query('REPLACE INTO account_has_credits (account_id, reward_credits) VALUES('.$this->db->escapeNumber($this->getAccountID()).', '.$this->db->escapeNumber($credits).')');
583
+		} else {
584
+					$this->db->query('UPDATE account_has_credits SET reward_credits='.$this->db->escapeNumber($credits).' WHERE '.$this->SQL.' LIMIT 1');
585
+		}
561 586
 		$this->rewardCredits=$credits;
562 587
 	}
563 588
 
564 589
 	public function increaseSmrRewardCredits($credits) {
565
-		if($credits==0)
566
-			return;
567
-		if($credits<0)
568
-			throw new Exception('You cannot gain negative reward credits');
590
+		if($credits==0) {
591
+					return;
592
+		}
593
+		if($credits<0) {
594
+					throw new Exception('You cannot gain negative reward credits');
595
+		}
569 596
 		$this->setSmrRewardCredits($this->getSmrRewardCredits()+$credits);
570 597
 	}
571 598
 
@@ -601,8 +628,9 @@  discard block
 block discarded – undo
601 628
 	}
602 629
 
603 630
 	public function hasOldAccountID($dbName=false) {
604
-		if($dbName===false)
605
-			return count($this->getOldAccountIDs())!=0;
631
+		if($dbName===false) {
632
+					return count($this->getOldAccountIDs())!=0;
633
+		}
606 634
 		return $this->getOldAccountID($dbName)!=0;
607 635
 	}
608 636
 
@@ -681,8 +709,9 @@  discard block
 block discarded – undo
681 709
 	}
682 710
 
683 711
 	public function setFontSize($size) {
684
-		if($this->fontSize==$size)
685
-			return;
712
+		if($this->fontSize==$size) {
713
+					return;
714
+		}
686 715
 		$this->fontSize = $size;
687 716
 		$this->hasChanged = true;
688 717
 		$this->update();
@@ -695,8 +724,9 @@  discard block
 block discarded – undo
695 724
 
696 725
 	// sets the extra CSS file linked in preferences
697 726
 	public function setCssLink($link) {
698
-		if($this->cssLink==$link)
699
-			return;
727
+		if($this->cssLink==$link) {
728
+					return;
729
+		}
700 730
 		$this->cssLink = $link;
701 731
 		$this->hasChanged = true;
702 732
 		$this->update();
@@ -707,10 +737,12 @@  discard block
 block discarded – undo
707 737
 	}
708 738
 
709 739
 	public function setTemplate($template) {
710
-		if($this->template==$template)
711
-			return;
712
-		if(!in_array($template,array_keys(Globals::getAvailableTemplates())))
713
-			throw new Exception('Template not allowed: '.$template);
740
+		if($this->template==$template) {
741
+					return;
742
+		}
743
+		if(!in_array($template,array_keys(Globals::getAvailableTemplates()))) {
744
+					throw new Exception('Template not allowed: '.$template);
745
+		}
714 746
 		$this->db->query('UPDATE account SET template = ' . $this->db->escapeString($template) . ' WHERE '.$this->SQL.' LIMIT 1');
715 747
 		$this->template = $template;
716 748
 		$colourSchemes = Globals::getAvailableColourSchemes($template);
@@ -722,10 +754,12 @@  discard block
 block discarded – undo
722 754
 	}
723 755
 
724 756
 	public function setColourScheme($colourScheme) {
725
-		if($this->colourScheme==$colourScheme)
726
-			return;
727
-		if(!in_array($colourScheme,array_keys(Globals::getAvailableColourSchemes($this->getTemplate()))))
728
-			throw new Exception('Colour scheme not allowed: '.$colourScheme);
757
+		if($this->colourScheme==$colourScheme) {
758
+					return;
759
+		}
760
+		if(!in_array($colourScheme,array_keys(Globals::getAvailableColourSchemes($this->getTemplate())))) {
761
+					throw new Exception('Colour scheme not allowed: '.$colourScheme);
762
+		}
729 763
 		$this->colourScheme = $colourScheme;
730 764
 		$this->hasChanged = true;
731 765
 		$this->update();
@@ -759,8 +793,9 @@  discard block
 block discarded – undo
759 793
 	}
760 794
 
761 795
 	public function setHofName($name) {
762
-		if($this->hofName==$name)
763
-			return;
796
+		if($this->hofName==$name) {
797
+					return;
798
+		}
764 799
 		$this->hofName = $name;
765 800
 		$this->hasChanged = true;
766 801
 		$this->update();
@@ -771,8 +806,9 @@  discard block
 block discarded – undo
771 806
 	}
772 807
 
773 808
 	public function setIrcNick($nick) {
774
-		if($this->ircNick==$nick)
775
-			return;
809
+		if($this->ircNick==$nick) {
810
+					return;
811
+		}
776 812
 		$this->ircNick = $nick;
777 813
 		$this->hasChanged = true;
778 814
 		$this->update();
@@ -800,8 +836,9 @@  discard block
 block discarded – undo
800 836
 	}
801 837
 
802 838
 	public function setShortDateFormat($format) {
803
-		if($this->dateShort==$format)
804
-			return;
839
+		if($this->dateShort==$format) {
840
+					return;
841
+		}
805 842
 		$this->dateShort = $format;
806 843
 		$this->hasChanged = true;
807 844
 		$this->update();
@@ -812,8 +849,9 @@  discard block
 block discarded – undo
812 849
 	}
813 850
 
814 851
 	public function setShortTimeFormat($format) {
815
-		if($this->timeShort==$format)
816
-			return;
852
+		if($this->timeShort==$format) {
853
+					return;
854
+		}
817 855
 		$this->timeShort = $format;
818 856
 		$this->hasChanged = true;
819 857
 		$this->update();
@@ -824,16 +862,18 @@  discard block
 block discarded – undo
824 862
 	}
825 863
 
826 864
 	protected function setValidationCode($code) {
827
-		if($this->validation_code == $code)
828
-			return;
865
+		if($this->validation_code == $code) {
866
+					return;
867
+		}
829 868
 		$this->validation_code=$code;
830 869
 		$this->hasChanged=true;
831 870
 		$this->update();
832 871
 	}
833 872
 
834 873
 	public function setValidated($bool) {
835
-		if($this->validated == $bool)
836
-			return;
874
+		if($this->validated == $bool) {
875
+					return;
876
+		}
837 877
 		$this->validated = $bool;
838 878
 		$this->hasChanged = true;
839 879
 		$this->update();
@@ -906,8 +946,9 @@  discard block
 block discarded – undo
906 946
 	}
907 947
 
908 948
 	protected function setPasswordReset($passwordReset) {
909
-		if($this->passwordReset == $passwordReset)
910
-			return;
949
+		if($this->passwordReset == $passwordReset) {
950
+					return;
951
+		}
911 952
 		$this->passwordReset=$passwordReset;
912 953
 		$this->hasChanged=true;
913 954
 		$this->update();
@@ -918,8 +959,9 @@  discard block
 block discarded – undo
918 959
 	}
919 960
 
920 961
 	public function setDisplayShipImages($yesNo) {
921
-		if($this->images == $yesNo)
922
-			return;
962
+		if($this->images == $yesNo) {
963
+					return;
964
+		}
923 965
 		$this->images = $yesNo;
924 966
 		$this->hasChanged = true;
925 967
 		$this->update();
@@ -930,8 +972,9 @@  discard block
 block discarded – undo
930 972
 	}
931 973
 
932 974
 	public function setUseAJAX($bool) {
933
-		if($this->useAJAX == $bool)
934
-			return;
975
+		if($this->useAJAX == $bool) {
976
+					return;
977
+		}
935 978
 		$this->useAJAX=$bool;
936 979
 		$this->hasChanged=true;
937 980
 		$this->update();
@@ -942,8 +985,9 @@  discard block
 block discarded – undo
942 985
 	}
943 986
 
944 987
 	public function setDefaultCSSEnabled($bool) {
945
-		if($this->defaultCSSEnabled == $bool)
946
-			return;
988
+		if($this->defaultCSSEnabled == $bool) {
989
+					return;
990
+		}
947 991
 		$this->defaultCSSEnabled=$bool;
948 992
 		$this->hasChanged=true;
949 993
 		$this->update();
@@ -953,8 +997,7 @@  discard block
 block discarded – undo
953 997
 		if($hotkeyType!==false) {
954 998
 			if(isset($this->hotkeys[$hotkeyType])) {
955 999
 				return $this->hotkeys[$hotkeyType];
956
-			}
957
-			else {
1000
+			} else {
958 1001
 				return array();
959 1002
 			}
960 1003
 		}
@@ -962,8 +1005,9 @@  discard block
 block discarded – undo
962 1005
 	}
963 1006
 
964 1007
 	public function setHotkey($hotkeyType,$binding) {
965
-		if($this->getHotkeys($hotkeyType) == $binding)
966
-			return;
1008
+		if($this->getHotkeys($hotkeyType) == $binding) {
1009
+					return;
1010
+		}
967 1011
 		$this->hotkeys[$hotkeyType] = $binding;
968 1012
 		$this->hasChanged=true;
969 1013
 		$this->update();
@@ -978,26 +1022,31 @@  discard block
 block discarded – undo
978 1022
 	}
979 1023
 
980 1024
 	public function setMessageNotifications($messageTypeID,$num) {
981
-		if($this->getMessageNotifications($messageTypeID) == $num)
982
-			return;
1025
+		if($this->getMessageNotifications($messageTypeID) == $num) {
1026
+					return;
1027
+		}
983 1028
 		$this->messageNotifications[$messageTypeID]=$num;
984 1029
 		$this->hasChanged=true;
985 1030
 		$this->update();
986 1031
 	}
987 1032
 
988 1033
 	public function increaseMessageNotifications($messageTypeID,$num) {
989
-		if($num==0)
990
-			return;
991
-		if($num<0)
992
-			throw new Exception('You cannot increase by a negative amount');
1034
+		if($num==0) {
1035
+					return;
1036
+		}
1037
+		if($num<0) {
1038
+					throw new Exception('You cannot increase by a negative amount');
1039
+		}
993 1040
 		$this->setMessageNotifications($messageTypeID, $this->getMessageNotifications($messageTypeID) + $num);
994 1041
 	}
995 1042
 
996 1043
 	public function decreaseMessageNotifications($messageTypeID,$num) {
997
-		if($num==0)
998
-			return;
999
-		if($num<0)
1000
-			throw new Exception('You cannot decrease by a negative amount');
1044
+		if($num==0) {
1045
+					return;
1046
+		}
1047
+		if($num<0) {
1048
+					throw new Exception('You cannot decrease by a negative amount');
1049
+		}
1001 1050
 		$this->setMessageNotifications($messageTypeID, $this->getMessageNotifications($messageTypeID) - $num);
1002 1051
 	}
1003 1052
 
@@ -1006,8 +1055,9 @@  discard block
 block discarded – undo
1006 1055
 	}
1007 1056
 
1008 1057
 	public function setCenterGalaxyMapOnPlayer($bool) {
1009
-		if($this->centerGalaxyMapOnPlayer == $bool)
1010
-			return;
1058
+		if($this->centerGalaxyMapOnPlayer == $bool) {
1059
+					return;
1060
+		}
1011 1061
 		$this->centerGalaxyMapOnPlayer=$bool;
1012 1062
 		$this->hasChanged=true;
1013 1063
 		$this->update();
@@ -1022,8 +1072,9 @@  discard block
 block discarded – undo
1022 1072
 	}
1023 1073
 
1024 1074
 	public function setMailBanned($time) {
1025
-		if($this->mailBanned == $time)
1026
-			return;
1075
+		if($this->mailBanned == $time) {
1076
+					return;
1077
+		}
1027 1078
 		$this->mailBanned=$time;
1028 1079
 		$this->hasChanged=true;
1029 1080
 	}
@@ -1077,53 +1128,59 @@  discard block
 block discarded – undo
1077 1128
 
1078 1129
 	public function setPoints($numPoints,$lastUpdate=false) {
1079 1130
 		$numPoints = max($numPoints,0);
1080
-		if($this->getPoints()==$numPoints)
1081
-			return;
1082
-		if ($this->points==0)
1083
-			$this->db->query('INSERT INTO account_has_points (account_id, points, last_update) VALUES ('.$this->db->escapeNumber($this->getAccountID()).', '.$this->db->escapeNumber($numPoints).', '.$this->db->escapeNumber($lastUpdate?$lastUpdate:TIME).')');
1084
-		else if($numPoints<=0)
1085
-			$this->db->query('DELETE FROM account_has_points WHERE '.$this->SQL.' LIMIT 1');
1086
-		else
1087
-			$this->db->query('UPDATE account_has_points SET points = '.$this->db->escapeNumber($numPoints).($lastUpdate ? ', last_update = '.$this->db->escapeNumber(TIME) : '').' WHERE '.$this->SQL.' LIMIT 1');
1131
+		if($this->getPoints()==$numPoints) {
1132
+					return;
1133
+		}
1134
+		if ($this->points==0) {
1135
+					$this->db->query('INSERT INTO account_has_points (account_id, points, last_update) VALUES ('.$this->db->escapeNumber($this->getAccountID()).', '.$this->db->escapeNumber($numPoints).', '.$this->db->escapeNumber($lastUpdate?$lastUpdate:TIME).')');
1136
+		} else if($numPoints<=0) {
1137
+					$this->db->query('DELETE FROM account_has_points WHERE '.$this->SQL.' LIMIT 1');
1138
+		} else {
1139
+					$this->db->query('UPDATE account_has_points SET points = '.$this->db->escapeNumber($numPoints).($lastUpdate ? ', last_update = '.$this->db->escapeNumber(TIME) : '').' WHERE '.$this->SQL.' LIMIT 1');
1140
+		}
1088 1141
 		$this->points=$numPoints;
1089 1142
 	}
1090 1143
 
1091 1144
 	public function removePoints($numPoints,$lastUpdate=false) {
1092
-		if($numPoints>0)
1093
-			$this->setPoints($this->getPoints()-$numPoints,$lastUpdate);
1145
+		if($numPoints>0) {
1146
+					$this->setPoints($this->getPoints()-$numPoints,$lastUpdate);
1147
+		}
1094 1148
 	}
1095 1149
 
1096 1150
 	public function addPoints($numPoints,SmrAccount $admin,$reasonID,$suspicion) {
1097 1151
 		//do we have points
1098 1152
 		$this->setPoints($this->getPoints() + $numPoints,TIME);
1099 1153
 		$totalPoints = $this->getPoints();
1100
-		if ($totalPoints < 10)
1101
-			return false;//leave scripts its only a warning
1102
-		elseif ($totalPoints < 20)
1103
-			$days = 2;
1104
-		elseif ($totalPoints < 30)
1105
-			$days = 4;
1106
-		elseif ($totalPoints < 50)
1107
-			$days = 7;
1108
-		elseif ($totalPoints < 75)
1109
-			$days = 15 ;
1110
-		elseif ($totalPoints < 100)
1111
-			$days = 30;
1112
-		elseif ($totalPoints < 125)
1113
-			$days = 60;
1114
-		elseif ($totalPoints < 150)
1115
-			$days = 120;
1116
-		elseif ($totalPoints < 175)
1117
-			$days = 240;
1118
-		elseif ($totalPoints < 200)
1119
-			$days = 480;
1120
-		else
1121
-			$days = 0; //Forever/indefinite
1154
+		if ($totalPoints < 10) {
1155
+					return false;
1156
+		}
1157
+		//leave scripts its only a warning
1158
+		elseif ($totalPoints < 20) {
1159
+					$days = 2;
1160
+		} elseif ($totalPoints < 30) {
1161
+					$days = 4;
1162
+		} elseif ($totalPoints < 50) {
1163
+					$days = 7;
1164
+		} elseif ($totalPoints < 75) {
1165
+					$days = 15 ;
1166
+		} elseif ($totalPoints < 100) {
1167
+					$days = 30;
1168
+		} elseif ($totalPoints < 125) {
1169
+					$days = 60;
1170
+		} elseif ($totalPoints < 150) {
1171
+					$days = 120;
1172
+		} elseif ($totalPoints < 175) {
1173
+					$days = 240;
1174
+		} elseif ($totalPoints < 200) {
1175
+					$days = 480;
1176
+		} else {
1177
+					$days = 0;
1178
+		}
1179
+		//Forever/indefinite
1122 1180
 
1123 1181
 		if($days==0) {
1124 1182
 			$expireTime = 0;
1125
-		}
1126
-		else {
1183
+		} else {
1127 1184
 			$expireTime = TIME + $days * 86400;
1128 1185
 		}
1129 1186
 		$this->banAccount($expireTime,$admin,$reasonID,$suspicion);
@@ -1178,26 +1235,30 @@  discard block
 block discarded – undo
1178 1235
 			$player->update();
1179 1236
 		}
1180 1237
 		$this->log(LOG_TYPE_ACCOUNT_CHANGES, 'Account closed by ' . $admin->getLogin() . '.');
1181
-		if($removeExceptions!==false)
1182
-			$this->db->query('DELETE FROM account_exceptions WHERE ' . $this->SQL);
1238
+		if($removeExceptions!==false) {
1239
+					$this->db->query('DELETE FROM account_exceptions WHERE ' . $this->SQL);
1240
+		}
1183 1241
 	}
1184 1242
 
1185 1243
 	public function unbanAccount(SmrAccount $admin = null,$currException=false) {
1186 1244
 		$adminID = 0;
1187
-		if($admin!==null)
1188
-			$adminID = $admin->getAccountID();
1245
+		if($admin!==null) {
1246
+					$adminID = $admin->getAccountID();
1247
+		}
1189 1248
 		$this->db->query('DELETE FROM account_is_closed WHERE ' . $this->SQL . ' LIMIT 1');
1190 1249
 		$this->db->query('INSERT INTO account_has_closing_history
1191 1250
 						(account_id, time, admin_id, action)
1192 1251
 						VALUES(' . $this->db->escapeNumber($this->getAccountID()) . ', ' . $this->db->escapeNumber(TIME) . ', ' . $this->db->escapeNumber($adminID) . ', ' . $this->db->escapeString('Opened') . ')');
1193 1252
 		$this->db->query('UPDATE player SET last_turn_update = GREATEST(' . $this->db->escapeNumber(TIME) . ', last_turn_update) WHERE ' . $this->SQL);
1194
-		if($admin!==null)
1195
-			$this->log(LOG_TYPE_ACCOUNT_CHANGES, 'Account reopened by ' . $admin->getLogin() . '.');
1196
-		else
1197
-			$this->log(LOG_TYPE_ACCOUNT_CHANGES, 'Account automatically reopened.');
1198
-		if($currException!==false)
1199
-			$this->db->query('REPLACE INTO account_exceptions (account_id, reason)
1253
+		if($admin!==null) {
1254
+					$this->log(LOG_TYPE_ACCOUNT_CHANGES, 'Account reopened by ' . $admin->getLogin() . '.');
1255
+		} else {
1256
+					$this->log(LOG_TYPE_ACCOUNT_CHANGES, 'Account automatically reopened.');
1257
+		}
1258
+		if($currException!==false) {
1259
+					$this->db->query('REPLACE INTO account_exceptions (account_id, reason)
1200 1260
 							VALUES (' . $this->db->escapeNumber($this->getAccountID()) . ', ' . $this->db->escapeString($currException) . ')');
1261
+		}
1201 1262
 	}
1202 1263
 
1203 1264
 	public function getToggleAJAXHREF() {
Please login to merge, or discard this patch.
lib/Default/SmrWeapon.class.php 1 patch
Braces   +20 added lines, -11 removed lines patch added patch discarded remove patch
@@ -12,17 +12,19 @@  discard block
 block discarded – undo
12 12
 
13 13
 	
14 14
 	protected static function initialiseDatabase() {
15
-		if (self::$db == null)
16
-			self::$db = new SmrMySqlDatabase();
15
+		if (self::$db == null) {
16
+					self::$db = new SmrMySqlDatabase();
17
+		}
17 18
 	}
18 19
 
19 20
 	public static function getWeapon($weaponTypeID, $forceUpdate = false, $db = null) {
20 21
 		if ($forceUpdate || !isset(self::$CACHE_WEAPONS[$weaponTypeID])) {
21 22
 			$w = new SmrWeapon($weaponTypeID, $db);
22
-			if ($w->exists())
23
-				self::$CACHE_WEAPONS[$weaponTypeID] = $w;
24
-			else
25
-				self::$CACHE_WEAPONS[$weaponTypeID] = false;
23
+			if ($w->exists()) {
24
+							self::$CACHE_WEAPONS[$weaponTypeID] = $w;
25
+			} else {
26
+							self::$CACHE_WEAPONS[$weaponTypeID] = false;
27
+			}
26 28
 		}
27 29
 		return self::$CACHE_WEAPONS[$weaponTypeID];
28 30
 	}
@@ -151,8 +153,9 @@  discard block
 block discarded – undo
151 153
 		$weaponShip = $weaponPlayer->getShip();
152 154
 		$targetShip = $targetPlayer->getShip();
153 155
 		$mrDiff = $targetShip->getMR() - $weaponShip->getMR();
154
-		if ($mrDiff > 0)
155
-			$modifiedAccuracy -= $this->getBaseAccuracy() * ($mrDiff / MR_FACTOR) / 100;
156
+		if ($mrDiff > 0) {
157
+					$modifiedAccuracy -= $this->getBaseAccuracy() * ($mrDiff / MR_FACTOR) / 100;
158
+		}
156 159
 	
157 160
 		return $modifiedAccuracy;
158 161
 	}
@@ -190,22 +193,28 @@  discard block
 block discarded – undo
190 193
 	}
191 194
 	
192 195
 	public function &getModifiedDamageAgainstForces(AbstractSmrPlayer $weaponPlayer, SmrForce $forces) {
193
-		if (!$this->canShootForces()) // If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods.
196
+		if (!$this->canShootForces()) {
197
+			// If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods.
194 198
 			return array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover());
199
+		}
195 200
 		$damage =& $this->getModifiedDamage();
196 201
 		return $damage;
197 202
 	}
198 203
 	
199 204
 	public function &getModifiedDamageAgainstPort(AbstractSmrPlayer $weaponPlayer, SmrPort $port) {
200
-		if (!$this->canShootPorts()) // If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods.
205
+		if (!$this->canShootPorts()) {
206
+			// If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods.
201 207
 			return array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover());
208
+		}
202 209
 		$damage =& $this->getModifiedDamage();
203 210
 		return $damage;
204 211
 	}
205 212
 	
206 213
 	public function &getModifiedDamageAgainstPlanet(AbstractSmrPlayer $weaponPlayer, SmrPlanet $planet) {
207
-		if (!$this->canShootPlanets()) // If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods.
214
+		if (!$this->canShootPlanets()) {
215
+			// If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods.
208 216
 			return array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover());
217
+		}
209 218
 		$damage =& $this->getModifiedDamage();
210 219
 		
211 220
 		$planetMod = self::PLANET_DAMAGE_MOD;
Please login to merge, or discard this patch.