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

Completed
Push — master ( 3938d8...8d8584 )
by Dan
29s queued 20s
created
lib/Default/Menu.class.php 3 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -100,16 +100,16 @@
 block discarded – undo
100 100
 		$container['view_game_id'] = $var['view_game_id'];
101 101
 		$container['game_name'] = $var['game_name'];
102 102
 		$menuItems[] = ['Link' => SmrSession::getNewHREF($container),
103
-		                'Text' => 'Game Details'];
103
+						'Text' => 'Game Details'];
104 104
 		$container['body'] = 'history_games_detail.php';
105 105
 		$menuItems[] = ['Link' => SmrSession::getNewHREF($container),
106
-		                'Text' => 'Extended Stats'];
106
+						'Text' => 'Extended Stats'];
107 107
 		$container['body'] = 'history_games_hof.php';
108 108
 		$menuItems[] = ['Link' => SmrSession::getNewHREF($container),
109
-		                'Text' => 'Hall of Fame'];
109
+						'Text' => 'Hall of Fame'];
110 110
 		$container['body'] = 'history_games_news.php';
111 111
 		$menuItems[] = ['Link' => SmrSession::getNewHREF($container),
112
-		                'Text' => 'Game News'];
112
+						'Text' => 'Game News'];
113 113
 		// make the selected index bold
114 114
 		$boldItem =& $menuItems[$selected_index]['Text'];
115 115
 		$boldItem = '<b>' . $boldItem . '</b>';
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 		$menuItems[] = array('Link'=>Globals::getPlanetListHREF($alliance_id), 'Text'=>'Defense');
13 13
 		$menuItems[] = array('Link'=>Globals::getPlanetListFinancialHREF($alliance_id), 'Text'=>'Financial');
14 14
 		// make the selected index bold
15
-		$boldItem =& $menuItems[$selected_index]['Text'];
15
+		$boldItem = & $menuItems[$selected_index]['Text'];
16 16
 		$boldItem = '<span class="bold">' . $boldItem . '</span>';
17 17
 		$template->assign('MenuItems', $menuItems);
18 18
 	}
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 		$menuItems[] = ['Link' => SmrSession::getNewHREF($container),
108 108
 		                'Text' => 'Game News'];
109 109
 		// make the selected index bold
110
-		$boldItem =& $menuItems[$selected_index]['Text'];
110
+		$boldItem = & $menuItems[$selected_index]['Text'];
111 111
 		$boldItem = '<b>' . $boldItem . '</b>';
112 112
 		$template->assign('MenuItems', $menuItems);
113 113
 	}
Please login to merge, or discard this patch.
Braces   +32 added lines, -27 removed lines patch added patch discarded remove patch
@@ -22,8 +22,7 @@  discard block
 block discarded – undo
22 22
 
23 23
 		if ($alliance_id) {
24 24
 			$in_alliance = ($alliance_id == $player->getAllianceID());
25
-		}
26
-		else {
25
+		} else {
27 26
 			$in_alliance = $player->hasAlliance();
28 27
 		}
29 28
 		if (!$in_alliance) {
@@ -36,8 +35,7 @@  discard block
 block discarded – undo
36 35
 				$mbRead = $db->getBoolean('mb_read');
37 36
 				$modRead = $db->getBoolean('mod_read');
38 37
 				$planetLand = $db->getBoolean('planet_land');
39
-			}
40
-			else {
38
+			} else {
41 39
 				$mbRead = FALSE;
42 40
 				$modRead = FALSE;
43 41
 				$planetLand = FALSE;
@@ -247,9 +245,10 @@  discard block
 block discarded – undo
247 245
 		$menu_items[] = create_link(create_container('skeleton.php', 'bank_personal.php'),
248 246
 														'Personal Account', 'nav');
249 247
 
250
-		if ($player->hasAlliance())
251
-			$menu_items[] = create_link(create_container('skeleton.php', 'bank_alliance.php'),
248
+		if ($player->hasAlliance()) {
249
+					$menu_items[] = create_link(create_container('skeleton.php', 'bank_alliance.php'),
252 250
 															'Alliance Account', 'nav');
251
+		}
253 252
 
254 253
 		$menu_items[] = create_link(create_container('skeleton.php', 'bank_anon.php'),
255 254
 														'Anonymous Account', 'nav');
@@ -272,12 +271,14 @@  discard block
 block discarded – undo
272 271
 		$menu_items[] = create_link($container, 'Send Message', 'nav');
273 272
 
274 273
 		if ($player->getRaceID() == $race_id) {
275
-			if ($player->isOnCouncil())
276
-				$menu_items[] = create_link(create_container('skeleton.php', 'council_vote.php'),
274
+			if ($player->isOnCouncil()) {
275
+							$menu_items[] = create_link(create_container('skeleton.php', 'council_vote.php'),
277 276
 																'Voting Center', 'nav');
278
-			if ($player->isPresident())
279
-				$menu_items[] = create_link(create_container('skeleton.php', 'council_embassy.php'),
277
+			}
278
+			if ($player->isPresident()) {
279
+							$menu_items[] = create_link(create_container('skeleton.php', 'council_embassy.php'),
280 280
 																'Embassy', 'nav');
281
+			}
281 282
 		}
282 283
 
283 284
 		create_menu($menu_items);
@@ -306,8 +307,9 @@  discard block
 block discarded – undo
306 307
 	public static function navigation(Template $template, AbstractSmrPlayer $player) {
307 308
 		$menuItems = array();
308 309
 		$menuItems[] = array('Link'=>Globals::getPlotCourseHREF(), 'Text'=>'Plot A Course');
309
-		if (!$player->isLandedOnPlanet())
310
-			$menuItems[] = array('Link'=>Globals::getLocalMapHREF(), 'Text'=>'Local Map');
310
+		if (!$player->isLandedOnPlanet()) {
311
+					$menuItems[] = array('Link'=>Globals::getLocalMapHREF(), 'Text'=>'Local Map');
312
+		}
311 313
 		$menuItems[] = array('Link'=>'map_galaxy.php" target="gal_map', 'Text'=>'Galaxy Map');
312 314
 		$template->assign('MenuItems', $menuItems);
313 315
 	}
@@ -328,14 +330,16 @@  discard block
 block discarded – undo
328 330
 	$return .= ('<tr>');
329 331
 	foreach ($menu as $number => $entry) {
330 332
 		// insert spacer
331
-		if ($number > 0)
332
-			$return .= ('<td>&nbsp;|&nbsp;</td>');
333
+		if ($number > 0) {
334
+					$return .= ('<td>&nbsp;|&nbsp;</td>');
335
+		}
333 336
 
334 337
 		// if this is the active entry we mark it
335
-		if ($number == $active_level1)
336
-			$active = ' class="bold"';
337
-		else
338
-			$active = '';
338
+		if ($number == $active_level1) {
339
+					$active = ' class="bold"';
340
+		} else {
341
+					$active = '';
342
+		}
339 343
 
340 344
 		// echo entry itself
341 345
 		$return .= ('<td ' . $active . '> ' . $entry['entry'] . '</td>');
@@ -349,17 +353,18 @@  discard block
 block discarded – undo
349 353
 		if (isset($entry['submenu']) && $number == $active_level1) {
350 354
 			$return .= ('<td><small>');
351 355
 			foreach ($entry['submenu'] as $sub_number => $sub_entry) {
352
-				if ($sub_number > 0)
353
-					$return .= (' | ');
354
-
355
-				if ($sub_number == $active_level2)
356
-					$return .= ('<span class="bold">' . $sub_entry . '</span>');
357
-				else
358
-					$return .= ($sub_entry);
356
+				if ($sub_number > 0) {
357
+									$return .= (' | ');
358
+				}
359
+
360
+				if ($sub_number == $active_level2) {
361
+									$return .= ('<span class="bold">' . $sub_entry . '</span>');
362
+				} else {
363
+									$return .= ($sub_entry);
364
+				}
359 365
 			}
360 366
 			$return .= ('</small></td>');
361
-		}
362
-		else {
367
+		} else {
363 368
 			// if it's not the first entry we have to put
364 369
 			// additional empty cell for the spacer
365 370
 			//if ($number > 0)
Please login to merge, or discard this patch.
lib/Default/SmrPlanetType.class.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	/**
41 41
 	 * Access properties of structures that this planet type can build.
42 42
 	 */
43
-	public function structureTypes($structureID=false) {
43
+	public function structureTypes($structureID = false) {
44 44
 		if (!isset($this->structures)) {
45 45
 			foreach (static::STRUCTURES as $ID => $Info) {
46 46
 				$this->structures[$ID] = new SmrPlanetStructureType($ID, $Info);
@@ -77,12 +77,12 @@  discard block
 block discarded – undo
77 77
 			'exp_gain' => 540,
78 78
 		],
79 79
 	];
80
-	public function name()         { return "Terran Planet"; }
81
-	public function imageLink()    { return "images/planet1.png"; }
82
-	public function description()  { return "A lush world, with forests, seas, sweeping meadows, and indigenous lifeforms."; }
80
+	public function name() { return "Terran Planet"; }
81
+	public function imageLink() { return "images/planet1.png"; }
82
+	public function description() { return "A lush world, with forests, seas, sweeping meadows, and indigenous lifeforms."; }
83 83
 	public function maxAttackers() { return 10; }
84
-	public function maxLanded()    { return self::MAX_LANDED_UNLIMITED; }
85
-	public function menuOptions()  { return self::DEFAULT_MENU_OPTIONS; }
84
+	public function maxLanded() { return self::MAX_LANDED_UNLIMITED; }
85
+	public function menuOptions() { return self::DEFAULT_MENU_OPTIONS; }
86 86
 }
87 87
 
88 88
 class AridPlanet extends SmrPlanetType {
@@ -106,12 +106,12 @@  discard block
 block discarded – undo
106 106
 			'exp_gain' => 180,
107 107
 		],
108 108
 	];
109
-	public function name()         { return "Arid Planet"; }
110
-	public function imageLink()    { return "images/planet2.png"; }
111
-	public function description()  { return "A world mostly devoid of surface water, but capable of supporting life."; }
109
+	public function name() { return "Arid Planet"; }
110
+	public function imageLink() { return "images/planet2.png"; }
111
+	public function description() { return "A world mostly devoid of surface water, but capable of supporting life."; }
112 112
 	public function maxAttackers() { return 5; }
113
-	public function maxLanded()    { return 5; }
114
-	public function menuOptions()  { return ['CONSTRUCTION', 'DEFENSE', 'STOCKPILE', 'OWNERSHIP']; }
113
+	public function maxLanded() { return 5; }
114
+	public function menuOptions() { return ['CONSTRUCTION', 'DEFENSE', 'STOCKPILE', 'OWNERSHIP']; }
115 115
 }
116 116
 
117 117
 class DwarfPlanet extends SmrPlanetType {
@@ -135,12 +135,12 @@  discard block
 block discarded – undo
135 135
 			'exp_gain' => 540,
136 136
 		],
137 137
 	];
138
-	public function name()         { return "Dwarf Planet"; }
139
-	public function imageLink()    { return "images/planet3.png"; }
140
-	public function description()  { return "A smaller than usual planet, with no native life present."; }
138
+	public function name() { return "Dwarf Planet"; }
139
+	public function imageLink() { return "images/planet3.png"; }
140
+	public function description() { return "A smaller than usual planet, with no native life present."; }
141 141
 	public function maxAttackers() { return 5; }
142
-	public function maxLanded()    { return self::MAX_LANDED_UNLIMITED; }
143
-	public function menuOptions()  { return self::DEFAULT_MENU_OPTIONS; }
142
+	public function maxLanded() { return self::MAX_LANDED_UNLIMITED; }
143
+	public function menuOptions() { return self::DEFAULT_MENU_OPTIONS; }
144 144
 }
145 145
 
146 146
 class ProtoPlanet extends SmrPlanetType {
@@ -170,12 +170,12 @@  discard block
 block discarded – undo
170 170
 			'exp_gain' => 540,
171 171
 		],
172 172
 	];
173
-	public function name()         { return "Protoplanet"; }
174
-	public function imageLink()    { return "images/planet5.png"; }
175
-	public function description()  { return "A developing planet, not yet able to support the infrastructure of advanced technologies."; }
173
+	public function name() { return "Protoplanet"; }
174
+	public function imageLink() { return "images/planet5.png"; }
175
+	public function description() { return "A developing planet, not yet able to support the infrastructure of advanced technologies."; }
176 176
 	public function maxAttackers() { return 5; }
177
-	public function maxLanded()    { return 5; }
178
-	public function menuOptions()  { return self::DEFAULT_MENU_OPTIONS; }
177
+	public function maxLanded() { return 5; }
178
+	public function menuOptions() { return self::DEFAULT_MENU_OPTIONS; }
179 179
 }
180 180
 
181 181
 class DefenseWorld extends SmrPlanetType {
@@ -205,10 +205,10 @@  discard block
 block discarded – undo
205 205
 			'exp_gain' => 9,
206 206
 		],
207 207
 	];
208
-	public function name()         { return "Defense World"; }
209
-	public function imageLink()    { return "images/planet4.png"; }
210
-	public function description()  { return "A fully armed and operational battle station loaded with excessive firepower."; }
208
+	public function name() { return "Defense World"; }
209
+	public function imageLink() { return "images/planet4.png"; }
210
+	public function description() { return "A fully armed and operational battle station loaded with excessive firepower."; }
211 211
 	public function maxAttackers() { return 10; }
212
-	public function maxLanded()    { return self::MAX_LANDED_UNLIMITED; }
213
-	public function menuOptions()  { return self::DEFAULT_MENU_OPTIONS; }
212
+	public function maxLanded() { return self::MAX_LANDED_UNLIMITED; }
213
+	public function menuOptions() { return self::DEFAULT_MENU_OPTIONS; }
214 214
 }
Please login to merge, or discard this patch.
lib/Default/Sorter.class.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 	private static $reverseOrder;
5 5
 
6 6
 	private static function cmpStrProp($a, $b) {
7
-		return (self::$reverseOrder?-1:1)*strcasecmp($a->{self::$sortKey}, $b->{self::$sortKey});
7
+		return (self::$reverseOrder ?-1 : 1) * strcasecmp($a->{self::$sortKey}, $b->{self::$sortKey});
8 8
 	}
9 9
 
10 10
 	private static function cmpNumElement($a, $b) {
@@ -20,8 +20,8 @@  discard block
 block discarded – undo
20 20
 	}
21 21
 
22 22
 	public static function cmpNum($a, $b) {
23
-		if($a == $b) return 0;
24
-		return (self::$reverseOrder?-1:1)*($a < $b ? -1 : 1);
23
+		if ($a == $b) return 0;
24
+		return (self::$reverseOrder ?-1 : 1) * ($a < $b ? -1 : 1);
25 25
 	}
26 26
 
27 27
 	public static function sortByStrProp(array &$array, $property, $reverseOrder = false) {
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,9 @@
 block discarded – undo
20 20
 	}
21 21
 
22 22
 	public static function cmpNum($a, $b) {
23
-		if($a == $b) return 0;
23
+		if($a == $b) {
24
+			return 0;
25
+		}
24 26
 		return (self::$reverseOrder?-1:1)*($a < $b ? -1 : 1);
25 27
 	}
26 28
 
Please login to merge, or discard this patch.
lib/Default/AbstractSmrPort.class.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -960,7 +960,7 @@
 block discarded – undo
960 960
 	
961 961
 	public function calculateExperiencePercent($idealPrice, $offerPrice, $bargainPrice, $transactionType) {
962 962
 		if (($transactionType == 'Sell' && $bargainPrice < $offerPrice) ||
963
-		    ($transactionType == 'Buy' && $bargainPrice > $offerPrice)) {
963
+			($transactionType == 'Buy' && $bargainPrice > $offerPrice)) {
964 964
 			return 0;
965 965
 		}
966 966
 		if ($bargainPrice == $idealPrice || $transactionType == 'Steal') {
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1180,7 +1180,7 @@  discard block
 block discarded – undo
1180 1180
 			do {
1181 1181
 				$targetPlayer = $targetPlayers[array_rand($targetPlayers)];
1182 1182
 			} while ($results['TotalShotsPerTargetPlayer'][$targetPlayer->getAccountID()] > min($results['TotalShotsPerTargetPlayer']));
1183
-			$results['Weapons'][$orderID] =& $weapon->shootPlayerAsPort($this, $targetPlayer);
1183
+			$results['Weapons'][$orderID] = & $weapon->shootPlayerAsPort($this, $targetPlayer);
1184 1184
 			$results['TotalShotsPerTargetPlayer'][$targetPlayer->getAccountID()]++;
1185 1185
 			if ($results['Weapons'][$orderID]['Hit']) {
1186 1186
 				$results['TotalDamage'] += $results['Weapons'][$orderID]['ActualDamage']['TotalDamage'];
@@ -1189,7 +1189,7 @@  discard block
 block discarded – undo
1189 1189
 		}
1190 1190
 		if ($this->hasCDs()) {
1191 1191
 			$thisCDs = new SmrCombatDrones($this->getGameID(), $this->getCDs(), true);
1192
-			$results['Drones'] =& $thisCDs->shootPlayerAsPort($this, $targetPlayers[array_rand($targetPlayers)]);
1192
+			$results['Drones'] = & $thisCDs->shootPlayerAsPort($this, $targetPlayers[array_rand($targetPlayers)]);
1193 1193
 			$results['TotalDamage'] += $results['Drones']['ActualDamage']['TotalDamage'];
1194 1194
 			$results['TotalDamagePerTargetPlayer'][$results['Drones']['TargetPlayer']->getAccountID()] += $results['Drones']['ActualDamage']['TotalDamage'];
1195 1195
 		}
Please login to merge, or discard this 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.
lib/Default/MySqlDatabase.class.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
 	public function __construct($dbName) {
14 14
 		if (!self::$dbConn) {
15 15
 			self::$dbConn = new mysqli(self::$host, self::$user, self::$password,
16
-			                           $dbName, self::$port, self::$socket);
16
+									   $dbName, self::$port, self::$socket);
17 17
 			if (self::$dbConn->connect_errno) {
18 18
 				$this->error('Connection failed: ' . self::$dbConn->connect_error);
19 19
 			}
Please login to merge, or discard this patch.
Braces   +42 added lines, -33 removed lines patch added patch discarded remove patch
@@ -63,8 +63,9 @@  discard block
 block discarded – undo
63 63
 	}
64 64
 	
65 65
 	public function nextRecord() {
66
-		if (!$this->dbResult)
67
-			$this->error('No resource to get record from.');
66
+		if (!$this->dbResult) {
67
+					$this->error('No resource to get record from.');
68
+		}
68 69
 		
69 70
 		if ($this->dbRecord = $this->dbResult->fetch_assoc()) {
70 71
 			return true;
@@ -79,9 +80,10 @@  discard block
 block discarded – undo
79 80
 	}
80 81
 	
81 82
 	public function getBoolean($name) {
82
-		if ($this->dbRecord[$name] == 'TRUE')
83
-			return true;
84
-//		if($this->dbRecord[$name] == 'FALSE')
83
+		if ($this->dbRecord[$name] == 'TRUE') {
84
+					return true;
85
+		}
86
+		//		if($this->dbRecord[$name] == 'FALSE')
85 87
 		return false;
86 88
 //		throw new Exception('Field is not a boolean');
87 89
 	}
@@ -114,8 +116,9 @@  discard block
 block discarded – undo
114 116
 	
115 117
 	public function getObject($name, $compressed = false) {
116 118
 		$object = $this->getField($name);
117
-		if ($compressed === true)
118
-			$object = gzuncompress($object);
119
+		if ($compressed === true) {
120
+					$object = gzuncompress($object);
121
+		}
119 122
 		return unserialize($object);
120 123
 	}
121 124
 	
@@ -157,38 +160,43 @@  discard block
 block discarded – undo
157 160
 	
158 161
 	public function escape($escape, $autoQuotes = true, $quotes = true) {
159 162
 		if (is_bool($escape)) {
160
-			if ($autoQuotes)
161
-				return $this->escapeBoolean($escape);
162
-			else
163
-				return $this->escapeBoolean($escape, $quotes);
163
+			if ($autoQuotes) {
164
+							return $this->escapeBoolean($escape);
165
+			} else {
166
+							return $this->escapeBoolean($escape, $quotes);
167
+			}
164 168
 		}
165 169
 		if (is_numeric($escape)) {
166 170
 			return $this->escapeNumber($escape);
167 171
 		}
168 172
 		if (is_string($escape)) {
169
-			if ($autoQuotes)
170
-				return $this->escapeString($escape);
171
-			else
172
-				return $this->escapeString($escape, $quotes);
173
+			if ($autoQuotes) {
174
+							return $this->escapeString($escape);
175
+			} else {
176
+							return $this->escapeString($escape, $quotes);
177
+			}
173 178
 		}
174 179
 		if (is_array($escape)) {
175 180
 			return $this->escapeArray($escape, $autoQuotes, $quotes);
176 181
 		}
177 182
 		if (is_object($escape)) {
178
-			if ($autoQuotes)
179
-				return $this->escapeObject($escape);
180
-			else
181
-				return $this->escapeObject($escape, $quotes);
183
+			if ($autoQuotes) {
184
+							return $this->escapeObject($escape);
185
+			} else {
186
+							return $this->escapeObject($escape, $quotes);
187
+			}
182 188
 		}
183 189
 	}
184 190
 	
185 191
 	public function escapeString($string, $quotes = true, $nullable = false) {
186
-		if ($nullable === true && ($string === null || $string === ''))
187
-			return 'NULL';
188
-		if ($string === true)
189
-			$string = 'TRUE';
190
-		else if ($string === false)
191
-			$string = 'FALSE';
192
+		if ($nullable === true && ($string === null || $string === '')) {
193
+					return 'NULL';
194
+		}
195
+		if ($string === true) {
196
+					$string = 'TRUE';
197
+		} else if ($string === false) {
198
+					$string = 'FALSE';
199
+		}
192 200
 		if (is_array($string)) {
193 201
 			$escapedString = '';
194 202
 			foreach ($string as $value) {
@@ -210,14 +218,14 @@  discard block
 block discarded – undo
210 218
 		$string = '';
211 219
 		if ($escapeIndividually) {
212 220
 			foreach ($array as $value) {
213
-				if (is_array($value))
214
-					$string .= $this->escapeArray($value, $autoQuotes, $quotes, $implodeString, $escapeIndividually) . $implodeString;
215
-				else
216
-					$string .= $this->escape($value, $autoQuotes, $quotes) . $implodeString;
221
+				if (is_array($value)) {
222
+									$string .= $this->escapeArray($value, $autoQuotes, $quotes, $implodeString, $escapeIndividually) . $implodeString;
223
+				} else {
224
+									$string .= $this->escape($value, $autoQuotes, $quotes) . $implodeString;
225
+				}
217 226
 			}
218 227
 			$string = substr($string, 0, -1);
219
-		}
220
-		else {
228
+		} else {
221 229
 			$string = $this->escape(implode($implodeString, $array), $autoQuotes, $quotes);
222 230
 		}
223 231
 		return $string;
@@ -250,8 +258,9 @@  discard block
 block discarded – undo
250 258
 	}
251 259
 	
252 260
 	public function escapeObject($object, $compress = false, $quotes = true, $nullable = false) {
253
-		if ($compress === true)
254
-			return $this->escapeBinary(gzcompress(serialize($object)));
261
+		if ($compress === true) {
262
+					return $this->escapeBinary(gzcompress(serialize($object)));
263
+		}
255 264
 		return $this->escapeString(serialize($object), $quotes, $nullable);
256 265
 	}
257 266
 
Please login to merge, or discard this patch.
lib/Default/ChessGame.class.php 2 patches
Braces   +13 added lines, -26 removed lines patch added patch discarded remove patch
@@ -81,8 +81,7 @@  discard block
 block discarded – undo
81 81
 			$this->blackID = $this->db->getInt('black_id');
82 82
 			$this->winner = $this->db->getInt('winner_id');
83 83
 			$this->resetHasMoved();
84
-		}
85
-		else {
84
+		} else {
86 85
 			throw new Exception('Chess game not found: ' . $chessGameID);
87 86
 		}
88 87
 	}
@@ -149,8 +148,7 @@  discard block
 block discarded – undo
149 148
 					break;
150 149
 				}
151 150
 			}
152
-		}
153
-		catch(Exception $e) {
151
+		} catch(Exception $e) {
154 152
 			if($debugInfo === true) {
155 153
 				echo $e->getMessage() . EOL . $e->getTraceAsString() . EOL;
156 154
 			}
@@ -189,11 +187,9 @@  discard block
 block discarded – undo
189 187
 			if(!$mate && $this->hasEnded()) {
190 188
 				if($this->getWinner() != 0) {
191 189
 					$this->moves[] = ($this->getWinner() == $this->getWhiteID() ? 'Black' : 'White') . ' Resigned.';
192
-				}
193
-				else if(count($this->moves) < 2) {
190
+				} else if(count($this->moves) < 2) {
194 191
 					$this->moves[] = 'Game Cancelled.';
195
-				}
196
-				else {
192
+				} else {
197 193
 					$this->moves[] = 'Game Drawn.';
198 194
 				}
199 195
 			}
@@ -212,8 +208,7 @@  discard block
 block discarded – undo
212 208
 			for($x=0; $x < 8; $x++) {
213 209
 				if($board[$y][$x] == null) {
214 210
 					$blanks++;
215
-				}
216
-				else {
211
+				} else {
217 212
 					if($blanks > 0) {
218 213
 						$fen .= $blanks;
219 214
 						$blanks = 0;
@@ -268,8 +263,7 @@  discard block
 block discarded – undo
268 263
 					$fen .= '3';
269 264
 				break;
270 265
 			}
271
-		}
272
-		else {
266
+		} else {
273 267
 			$fen .= '-';
274 268
 		}
275 269
 		$fen .= ' 0 ' . floor(count($this->moves)/2);
@@ -386,8 +380,7 @@  discard block
 block discarded – undo
386 380
 		}
387 381
 		if($pieceID == ChessPiece::PAWN && ($startY == 1 || $startY == 6) && ($endY == 3 || $endY == 4)) {
388 382
 			$this->hasMoved[ChessPiece::PAWN] = array($endX, $endY);
389
-		}
390
-		else {
383
+		} else {
391 384
 			$this->hasMoved[ChessPiece::PAWN] = array(-1,-1);
392 385
 		}
393 386
 		return ($castling == 'Queen' ? '0-0-0' : ($castling == 'King' ? '0-0' : ''))
@@ -493,8 +486,7 @@  discard block
 block discarded – undo
493 486
 				$board[$toY][$castling['ToX']]->setX($castling['ToX']);
494 487
 				$board[$y][$castling['X']] = null;
495 488
 			}
496
-		}
497
-		else if($p->pieceID == ChessPiece::PAWN) {
489
+		} else if($p->pieceID == ChessPiece::PAWN) {
498 490
 			if($toY == 0 || $toY == 7) {
499 491
 				$pawnPromotion = $p->promote($pawnPromotionPiece, $board);
500 492
 			}
@@ -512,8 +504,7 @@  discard block
 block discarded – undo
512 504
 				}
513 505
 				$board[$hasMoved[ChessPiece::PAWN][1]][$hasMoved[ChessPiece::PAWN][0]] = null;
514 506
 			}
515
-		}
516
-		else if($p->pieceID == ChessPiece::ROOK && ($x == 0 || $x == 7) && $y == ($p->colour == self::PLAYER_WHITE ? 7 : 0)) {
507
+		} else if($p->pieceID == ChessPiece::ROOK && ($x == 0 || $x == 7) && $y == ($p->colour == self::PLAYER_WHITE ? 7 : 0)) {
517 508
 			//Rook moved?
518 509
 			if($hasMoved[$p->colour][ChessPiece::ROOK][$x==0?'Queen':'King'] === false) {
519 510
 				// We set rook moved in here as it's used for move info.
@@ -573,12 +564,10 @@  discard block
 block discarded – undo
573 564
 				$board[$y][$castling['X']]->setX($castling['X']);
574 565
 				$board[$toY][$castling['ToX']] = null;
575 566
 			}
576
-		}
577
-		else if($moveInfo['EnPassant'] === true) {
567
+		} else if($moveInfo['EnPassant'] === true) {
578 568
 			$board[$toY][$toX] = null;
579 569
 			$board[$hasMoved[ChessPiece::PAWN][1]][$hasMoved[ChessPiece::PAWN][0]] = $moveInfo['PieceTaken'];
580
-		}
581
-		else if($moveInfo['RookMoved'] !== false) {
570
+		} else if($moveInfo['RookMoved'] !== false) {
582 571
 			$hasMoved[$p->colour][ChessPiece::ROOK][$moveInfo['RookMoved']] = false;
583 572
 		}
584 573
 		if($moveInfo['RookTaken'] !== false) {
@@ -702,8 +691,7 @@  discard block
 block discarded – undo
702 691
 					$this->setWinner($forAccountID);
703 692
 					$return = 1;
704 693
 					SmrPlayer::sendMessageFromCasino($lastTurnPlayer->getGameID(), $this->getCurrentTurnAccountID(), 'You have just lost [chess=' . $this->getChessGameID() . '] against [player=' . $lastTurnPlayer->getPlayerID() . '].');
705
-				}
706
-				else {
694
+				} else {
707 695
 					SmrPlayer::sendMessageFromCasino($lastTurnPlayer->getGameID(), $this->getCurrentTurnAccountID(), 'It is now your turn in [chess=' . $this->getChessGameID() . '] against [player=' . $lastTurnPlayer->getPlayerID() . '].');
708 696
 					if($checking == 'CHECK') {
709 697
 						$currentPlayer->increaseHOF(1, array($chessType,'Moves','Check Given'), HOF_PUBLIC);
@@ -853,8 +841,7 @@  discard block
 block discarded – undo
853 841
 							SET end_time=' . $this->db->escapeNumber(TIME) . '
854 842
 							WHERE chess_game_id=' . $this->db->escapeNumber($this->chessGameID) . ';');
855 843
 			return 1;
856
-		}
857
-		else {
844
+		} else {
858 845
 			$loserColour = $this->getColourForAccountID($accountID);
859 846
 			$winnerAccountID = $this->getColourID(self::getOtherColour($loserColour));
860 847
 			$results = $this->setWinner($winnerAccountID);
Please login to merge, or discard this patch.
Spacing   +148 added lines, -149 removed lines patch added patch discarded remove patch
@@ -33,9 +33,9 @@  discard block
 block discarded – undo
33 33
 					JOIN chess_game ON account_id = black_id OR account_id = white_id
34 34
 					WHERE end_time > ' . TIME . ' OR end_time IS NULL;');
35 35
 		$games = array();
36
-		while($db->nextRecord()) {
36
+		while ($db->nextRecord()) {
37 37
 			$game = self::getChessGame($db->getInt('chess_game_id'), $forceUpdate);
38
-			if($game->getCurrentTurnAccount()->isNPC()) {
38
+			if ($game->getCurrentTurnAccount()->isNPC()) {
39 39
 				$games[] = $game;
40 40
 			}
41 41
 		}
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 		$db = new SmrMySqlDatabase();
47 47
 		$db->query('SELECT chess_game_id FROM chess_game WHERE game_id = ' . $db->escapeNumber($player->getGameID()) . ' AND (black_id = ' . $db->escapeNumber($player->getAccountID()) . ' OR white_id = ' . $db->escapeNumber($player->getAccountID()) . ') AND (end_time > ' . TIME . ' OR end_time IS NULL);');
48 48
 		$games = array();
49
-		while($db->nextRecord()) {
49
+		while ($db->nextRecord()) {
50 50
 			$games[] = self::getChessGame($db->getInt('chess_game_id'));
51 51
 		}
52 52
 		return $games;
@@ -56,14 +56,14 @@  discard block
 block discarded – undo
56 56
 		$db = new SmrMySqlDatabase();
57 57
 		$db->query('SELECT chess_game_id FROM chess_game WHERE black_id = ' . $db->escapeNumber($accountID) . ' OR white_id = ' . $db->escapeNumber($accountID) . ';');
58 58
 		$games = array();
59
-		while($db->nextRecord()) {
59
+		while ($db->nextRecord()) {
60 60
 			$games[] = self::getChessGame($db->getInt('chess_game_id'));
61 61
 		}
62 62
 		return $games;
63 63
 	}
64 64
 
65
-	public static function getChessGame($chessGameID,$forceUpdate = false) {
66
-		if($forceUpdate || !isset(self::$CACHE_CHESS_GAMES[$chessGameID])) {
65
+	public static function getChessGame($chessGameID, $forceUpdate = false) {
66
+		if ($forceUpdate || !isset(self::$CACHE_CHESS_GAMES[$chessGameID])) {
67 67
 			self::$CACHE_CHESS_GAMES[$chessGameID] = new ChessGame($chessGameID);
68 68
 		}
69 69
 		return self::$CACHE_CHESS_GAMES[$chessGameID];
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 		$this->db->query('SELECT *
75 75
 						FROM chess_game
76 76
 						WHERE chess_game_id=' . $this->db->escapeNumber($chessGameID) . ' LIMIT 1;');
77
-		if($this->db->nextRecord()) {
77
+		if ($this->db->nextRecord()) {
78 78
 			$this->chessGameID = $chessGameID;
79 79
 			$this->gameID = $this->db->getInt('game_id');
80 80
 			$this->startDate = $this->db->getInt('start_time');
@@ -94,9 +94,9 @@  discard block
 block discarded – undo
94 94
 	}
95 95
 
96 96
 	public static function isPlayerChecked(array &$board, array &$hasMoved, $colour) {
97
-		foreach($board as &$row) {
98
-			foreach($row as &$p) {
99
-				if($p != null && $p->colour != $colour && $p->isAttacking($board, $hasMoved, true)) {
97
+		foreach ($board as &$row) {
98
+			foreach ($row as &$p) {
99
+				if ($p != null && $p->colour != $colour && $p->isAttacking($board, $hasMoved, true)) {
100 100
 					return true;
101 101
 				}
102 102
 			}
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 					'King' => false
121 121
 				)
122 122
 			),
123
-			ChessPiece::PAWN => array(-1,-1)
123
+			ChessPiece::PAWN => array(-1, -1)
124 124
 		);
125 125
 	}
126 126
 
@@ -143,17 +143,17 @@  discard block
 block discarded – undo
143 143
 		$this->resetHasMoved();
144 144
 
145 145
 		try {
146
-			while($db->nextRecord()) {
147
-				if($debugInfo === true) {
146
+			while ($db->nextRecord()) {
147
+				if ($debugInfo === true) {
148 148
 					echo 'x=', $db->getInt('start_x'), ', y=', $db->getInt('start_y'), ', endX=', $db->getInt('end_x'), ', endY=', $db->getInt('end_y'), ', forAccountID=', $db->getInt('move_id') % 2 == 1 ? $this->getWhiteID() : $this->getBlackID(), EOL;
149 149
 				}
150
-				if(0 != $this->tryMove($db->getInt('start_x'), $db->getInt('start_y'), $db->getInt('end_x'), $db->getInt('end_y'), $db->getInt('move_id') % 2 == 1 ? $this->getWhiteID() : $this->getBlackID())) {
150
+				if (0 != $this->tryMove($db->getInt('start_x'), $db->getInt('start_y'), $db->getInt('end_x'), $db->getInt('end_y'), $db->getInt('move_id') % 2 == 1 ? $this->getWhiteID() : $this->getBlackID())) {
151 151
 					break;
152 152
 				}
153 153
 			}
154 154
 		}
155
-		catch(Exception $e) {
156
-			if($debugInfo === true) {
155
+		catch (Exception $e) {
156
+			if ($debugInfo === true) {
157 157
 				echo $e->getMessage() . EOL . $e->getTraceAsString() . EOL;
158 158
 			}
159 159
 			// We probably tried an invalid move - move on.
@@ -161,10 +161,10 @@  discard block
 block discarded – undo
161 161
 	}
162 162
 
163 163
 	public function getBoard() {
164
-		if($this->board == null) {
164
+		if ($this->board == null) {
165 165
 			$this->db->query('SELECT * FROM chess_game_pieces WHERE chess_game_id=' . $this->db->escapeNumber($this->chessGameID) . ';');
166 166
 			$pieces = array();
167
-			while($this->db->nextRecord()) {
167
+			while ($this->db->nextRecord()) {
168 168
 				$accountID = $this->db->getInt('account_id');
169 169
 				$pieces[] = new ChessPiece($this->chessGameID, $accountID, $this->getColourForAccountID($accountID), $this->db->getInt('piece_id'), $this->db->getInt('x'), $this->db->getInt('y'), $this->db->getInt('piece_no'));
170 170
 			}
@@ -179,20 +179,20 @@  discard block
 block discarded – undo
179 179
 	}
180 180
 
181 181
 	public function getMoves() {
182
-		if($this->moves == null) {
182
+		if ($this->moves == null) {
183 183
 			$this->db->query('SELECT * FROM chess_game_moves WHERE chess_game_id = ' . $this->db->escapeNumber($this->chessGameID) . ' ORDER BY move_id;');
184 184
 			$this->moves = array();
185 185
 			$mate = false;
186
-			while($this->db->nextRecord()) {
186
+			while ($this->db->nextRecord()) {
187 187
 				$pieceTakenID = $this->db->getField('piece_taken') == null ? null : $this->db->getInt('piece_taken');
188 188
 				$this->moves[] = $this->createMove($this->db->getInt('piece_id'), $this->db->getInt('start_x'), $this->db->getInt('start_y'), $this->db->getInt('end_x'), $this->db->getInt('end_y'), $pieceTakenID, $this->db->getField('checked'), $this->db->getInt('move_id') % 2 == 1 ? self::PLAYER_WHITE : self::PLAYER_BLACK, $this->db->getField('castling'), $this->db->getBoolean('en_passant'), $this->db->getInt('promote_piece_id'));
189 189
 				$mate = $this->db->getField('checked') == 'MATE';
190 190
 			}
191
-			if(!$mate && $this->hasEnded()) {
192
-				if($this->getWinner() != 0) {
191
+			if (!$mate && $this->hasEnded()) {
192
+				if ($this->getWinner() != 0) {
193 193
 					$this->moves[] = ($this->getWinner() == $this->getWhiteID() ? 'Black' : 'White') . ' Resigned.';
194 194
 				}
195
-				else if(count($this->moves) < 2) {
195
+				else if (count($this->moves) < 2) {
196 196
 					$this->moves[] = 'Game Cancelled.';
197 197
 				}
198 198
 				else {
@@ -205,30 +205,30 @@  discard block
 block discarded – undo
205 205
 
206 206
 	public function getFENString() {
207 207
 		$fen = '';
208
-		$board =& $this->getBoard();
208
+		$board = & $this->getBoard();
209 209
 		$blanks = 0;
210
-		for($y=0; $y < 8; $y++) {
211
-			if($y > 0) {
210
+		for ($y = 0; $y < 8; $y++) {
211
+			if ($y > 0) {
212 212
 				$fen .= '/';
213 213
 			}
214
-			for($x=0; $x < 8; $x++) {
215
-				if($board[$y][$x] == null) {
214
+			for ($x = 0; $x < 8; $x++) {
215
+				if ($board[$y][$x] == null) {
216 216
 					$blanks++;
217 217
 				}
218 218
 				else {
219
-					if($blanks > 0) {
219
+					if ($blanks > 0) {
220 220
 						$fen .= $blanks;
221 221
 						$blanks = 0;
222 222
 					}
223 223
 					$fen .= $board[$y][$x]->getPieceLetter();
224 224
 				}
225 225
 			}
226
-			if($blanks > 0) {
226
+			if ($blanks > 0) {
227 227
 				$fen .= $blanks;
228 228
 				$blanks = 0;
229 229
 			}
230 230
 		}
231
-		switch($this->getCurrentTurnColour()) {
231
+		switch ($this->getCurrentTurnColour()) {
232 232
 			case self::PLAYER_WHITE:
233 233
 				$fen .= ' w ';
234 234
 			break;
@@ -239,30 +239,30 @@  discard block
 block discarded – undo
239 239
 
240 240
 		// Castling
241 241
 		$castling = '';
242
-		if($this->hasMoved[self::PLAYER_WHITE][ChessPiece::KING] !== true) {
243
-			if($this->hasMoved[self::PLAYER_WHITE][ChessPiece::ROOK]['King'] !== true) {
242
+		if ($this->hasMoved[self::PLAYER_WHITE][ChessPiece::KING] !== true) {
243
+			if ($this->hasMoved[self::PLAYER_WHITE][ChessPiece::ROOK]['King'] !== true) {
244 244
 				$castling .= 'K';
245 245
 			}
246
-			if($this->hasMoved[self::PLAYER_WHITE][ChessPiece::ROOK]['Queen'] !== true) {
246
+			if ($this->hasMoved[self::PLAYER_WHITE][ChessPiece::ROOK]['Queen'] !== true) {
247 247
 				$castling .= 'Q';
248 248
 			}
249 249
 		}
250
-		if($this->hasMoved[self::PLAYER_BLACK][ChessPiece::KING] !== true) {
251
-			if($this->hasMoved[self::PLAYER_BLACK][ChessPiece::ROOK]['King'] !== true) {
250
+		if ($this->hasMoved[self::PLAYER_BLACK][ChessPiece::KING] !== true) {
251
+			if ($this->hasMoved[self::PLAYER_BLACK][ChessPiece::ROOK]['King'] !== true) {
252 252
 				$castling .= 'k';
253 253
 			}
254
-			if($this->hasMoved[self::PLAYER_BLACK][ChessPiece::ROOK]['Queen'] !== true) {
254
+			if ($this->hasMoved[self::PLAYER_BLACK][ChessPiece::ROOK]['Queen'] !== true) {
255 255
 				$castling .= 'q';
256 256
 			}
257 257
 		}
258
-		if($castling == '') {
258
+		if ($castling == '') {
259 259
 			$castling = '-';
260 260
 		}
261 261
 		$fen .= $castling . ' ';
262 262
 
263
-		if($this->hasMoved[ChessPiece::PAWN][0] != -1) {
263
+		if ($this->hasMoved[ChessPiece::PAWN][0] != -1) {
264 264
 			$fen .= chr(ord('a') + $this->hasMoved[ChessPiece::PAWN][0]);
265
-			switch($this->hasMoved[ChessPiece::PAWN][1]) {
265
+			switch ($this->hasMoved[ChessPiece::PAWN][1]) {
266 266
 				case 3:
267 267
 					$fen .= '6';
268 268
 				break;
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 		else {
275 275
 			$fen .= '-';
276 276
 		}
277
-		$fen .= ' 0 ' . floor(count($this->moves)/2);
277
+		$fen .= ' 0 ' . floor(count($this->moves) / 2);
278 278
 
279 279
 		return $fen;
280 280
 	}
@@ -282,14 +282,14 @@  discard block
 block discarded – undo
282 282
 	private static function parsePieces(array $pieces) {
283 283
 		$board = array();
284 284
 		$row = array();
285
-		for($i=0;$i<8;$i++) {
285
+		for ($i = 0; $i < 8; $i++) {
286 286
 			$row[] = null;
287 287
 		}
288
-		for($i=0;$i<8;$i++) {
288
+		for ($i = 0; $i < 8; $i++) {
289 289
 			$board[] = $row;
290 290
 		}
291
-		foreach($pieces as $piece) {
292
-			if($board[$piece->getY()][$piece->getX()] != null) {
291
+		foreach ($pieces as $piece) {
292
+			if ($board[$piece->getY()][$piece->getX()] != null) {
293 293
 				throw new Exception('Two pieces found in the same tile.');
294 294
 			}
295 295
 			$board[$piece->getY()][$piece->getX()] = $piece;
@@ -300,8 +300,7 @@  discard block
 block discarded – undo
300 300
 	public static function getStandardGame($chessGameID, AbstractSmrPlayer $whitePlayer, AbstractSmrPlayer $blackPlayer) {
301 301
 		$white = $whitePlayer->getAccountID();
302 302
 		$black = $blackPlayer->getAccountID();
303
-		return array
304
-			(
303
+		return array(
305 304
 				new ChessPiece($chessGameID, $black, self::PLAYER_BLACK, ChessPiece::ROOK, 0, 0),
306 305
 				new ChessPiece($chessGameID, $black, self::PLAYER_BLACK, ChessPiece::KNIGHT, 1, 0),
307 306
 				new ChessPiece($chessGameID, $black, self::PLAYER_BLACK, ChessPiece::BISHOP, 2, 0),
@@ -341,7 +340,7 @@  discard block
 block discarded – undo
341 340
 	}
342 341
 
343 342
 	public static function insertNewGame($startDate, $endDate, AbstractSmrPlayer $whitePlayer, AbstractSmrPlayer $blackPlayer) {
344
-		if($startDate == null) {
343
+		if ($startDate == null) {
345 344
 			throw new Exception('Start date cannot be null.');
346 345
 		}
347 346
 
@@ -359,7 +358,7 @@  discard block
 block discarded – undo
359 358
 	private static function insertPieces($chessGameID, AbstractSmrPlayer $whitePlayer, AbstractSmrPlayer $blackPlayer) {
360 359
 		$db = new SmrMySqlDatabase();
361 360
 		$pieces = self::getStandardGame($chessGameID, $whitePlayer, $blackPlayer);
362
-		foreach($pieces as $p) {
361
+		foreach ($pieces as $p) {
363 362
 			$db->query('INSERT INTO chess_game_pieces' .
364 363
 			'(chess_game_id,account_id,piece_id,x,y)' .
365 364
 			'values' .
@@ -371,63 +370,63 @@  discard block
 block discarded – undo
371 370
 		// This move will be set as the most recent move
372 371
 		$this->lastMove = [
373 372
 			'From' => ['X' => $startX, 'Y' => $startY],
374
-			'To'   => ['X' => $endX,   'Y' => $endY],
373
+			'To'   => ['X' => $endX, 'Y' => $endY],
375 374
 		];
376 375
 
377 376
 		$otherPlayerColour = self::getOtherColour($playerColour);
378
-		if($pieceID == ChessPiece::KING) {
377
+		if ($pieceID == ChessPiece::KING) {
379 378
 			$this->hasMoved[$playerColour][ChessPiece::KING] = true;
380 379
 		}
381 380
 		// Check if the piece moving is a rook and mark it as moved to stop castling.
382
-		if($pieceID == ChessPiece::ROOK && ($startX == 0 || $startX == 7) && ($startY == ($playerColour == self::PLAYER_WHITE ? 7 : 0))) {
383
-			$this->hasMoved[$playerColour][ChessPiece::ROOK][$startX==0?'Queen':'King'] = true;
381
+		if ($pieceID == ChessPiece::ROOK && ($startX == 0 || $startX == 7) && ($startY == ($playerColour == self::PLAYER_WHITE ? 7 : 0))) {
382
+			$this->hasMoved[$playerColour][ChessPiece::ROOK][$startX == 0 ? 'Queen' : 'King'] = true;
384 383
 		}
385 384
 		// Check if we've taken a rook and marked them as moved, if they've already moved this does nothing, but if they were taken before moving this stops an issue with trying to castle with a non-existent castle.
386
-		if($pieceTaken == ChessPiece::ROOK && ($endX == 0 || $endX == 7) && $endY == ($otherPlayerColour == self::PLAYER_WHITE ? 7 : 0)) {
387
-			$this->hasMoved[$otherPlayerColour][ChessPiece::ROOK][$endX==0?'Queen':'King'] = true;
385
+		if ($pieceTaken == ChessPiece::ROOK && ($endX == 0 || $endX == 7) && $endY == ($otherPlayerColour == self::PLAYER_WHITE ? 7 : 0)) {
386
+			$this->hasMoved[$otherPlayerColour][ChessPiece::ROOK][$endX == 0 ? 'Queen' : 'King'] = true;
388 387
 		}
389
-		if($pieceID == ChessPiece::PAWN && ($startY == 1 || $startY == 6) && ($endY == 3 || $endY == 4)) {
388
+		if ($pieceID == ChessPiece::PAWN && ($startY == 1 || $startY == 6) && ($endY == 3 || $endY == 4)) {
390 389
 			$this->hasMoved[ChessPiece::PAWN] = array($endX, $endY);
391 390
 		}
392 391
 		else {
393
-			$this->hasMoved[ChessPiece::PAWN] = array(-1,-1);
392
+			$this->hasMoved[ChessPiece::PAWN] = array(-1, -1);
394 393
 		}
395 394
 		return ($castling == 'Queen' ? '0-0-0' : ($castling == 'King' ? '0-0' : ''))
396 395
 			. ChessPiece::getSymbolForPiece($pieceID, $playerColour)
397
-			. chr(ord('a')+$startX)
398
-			. (8-$startY)
396
+			. chr(ord('a') + $startX)
397
+			. (8 - $startY)
399 398
 			. ' '
400 399
 			. ($pieceTaken == null ? '' : ChessPiece::getSymbolForPiece($pieceTaken, $otherPlayerColour))
401
-			. chr(ord('a')+$endX)
402
-			. (8-$endY)
400
+			. chr(ord('a') + $endX)
401
+			. (8 - $endY)
403 402
 			. ($promotionPieceID == null ? '' : ChessPiece::getSymbolForPiece($promotionPieceID, $playerColour))
404 403
 			. ' '
405
-			. ($checking == null ? '' : ($checking == 'CHECK' ? '+' : '++') )
404
+			. ($checking == null ? '' : ($checking == 'CHECK' ? '+' : '++'))
406 405
 			. ($enPassant ? ' e.p.' : '');
407 406
 	}
408 407
 
409 408
 	public function isCheckmated($colour) {
410 409
 		$king = null;
411
-		foreach($this->board as $row) {
412
-			foreach($row as $piece) {
413
-				if($piece != null && $piece->pieceID == ChessPiece::KING && $piece->colour == $colour) {
410
+		foreach ($this->board as $row) {
411
+			foreach ($row as $piece) {
412
+				if ($piece != null && $piece->pieceID == ChessPiece::KING && $piece->colour == $colour) {
414 413
 					$king = $piece;
415 414
 					break;
416 415
 				}
417 416
 			}
418 417
 		}
419
-		if($king == null) {
418
+		if ($king == null) {
420 419
 			throw new Exception('Could not find the king: game id = ' . $this->chessGameID);
421 420
 		}
422
-		if(!self::isPlayerChecked($this->board, $this->getHasMoved(), $colour)) {
421
+		if (!self::isPlayerChecked($this->board, $this->getHasMoved(), $colour)) {
423 422
 			return false;
424 423
 		}
425
-		foreach($this->board as $row) {
426
-			foreach($row as $piece) {
427
-				if($piece != null && $piece->colour == $colour) {
424
+		foreach ($this->board as $row) {
425
+			foreach ($row as $piece) {
426
+				if ($piece != null && $piece->colour == $colour) {
428 427
 					$moves = $piece->getPossibleMoves($this->board, $this->getHasMoved());
429 428
 					//There are moves we can make, we are clearly not checkmated.
430
-					if(count($moves) > 0) {
429
+					if (count($moves) > 0) {
431 430
 						return false;
432 431
 					}
433 432
 				}
@@ -438,15 +437,15 @@  discard block
 block discarded – undo
438 437
 
439 438
 	public static function isCastling($x, $toX) {
440 439
 		$movement = $toX - $x;
441
-		if(abs($movement) == 2) {
440
+		if (abs($movement) == 2) {
442 441
 			//To the left.
443
-			if($movement == -2) {
442
+			if ($movement == -2) {
444 443
 				return array('Type' => 'Queen',
445 444
 						'X' => 0,
446 445
 						'ToX' => 3
447 446
 					);
448 447
 			} //To the right
449
-			else if($movement == 2) {
448
+			else if ($movement == 2) {
450 449
 				return array('Type' => 'King',
451 450
 						'X' => 7,
452 451
 						'ToX' => 5
@@ -457,36 +456,36 @@  discard block
 block discarded – undo
457 456
 	}
458 457
 
459 458
 	public static function movePiece(array &$board, array &$hasMoved, $x, $y, $toX, $toY, $pawnPromotionPiece = ChessPiece::QUEEN) {
460
-		if(!self::isValidCoord($x, $y, $board)) {
459
+		if (!self::isValidCoord($x, $y, $board)) {
461 460
 			throw new Exception('Invalid from coordinates, x=' . $x . ', y=' . $y);
462 461
 		}
463
-		if(!self::isValidCoord($toX, $toY, $board)) {
462
+		if (!self::isValidCoord($toX, $toY, $board)) {
464 463
 			throw new Exception('Invalid to coordinates, x=' . $toX . ', y=' . $toY);
465 464
 		}
466 465
 		$pieceTaken = $board[$toY][$toX];
467 466
 		$board[$toY][$toX] = $board[$y][$x];
468
-		$p =& $board[$toY][$toX];
467
+		$p = & $board[$toY][$toX];
469 468
 		$board[$y][$x] = null;
470
-		if($p == null) {
469
+		if ($p == null) {
471 470
 			throw new Exception('Trying to move non-existent piece: ' . var_export($board, true));
472 471
 		}
473 472
 		$p->setX($toX);
474 473
 		$p->setY($toY);
475 474
 
476 475
 		$oldPawnMovement = $hasMoved[ChessPiece::PAWN];
477
-		$nextPawnMovement = array(-1,-1);
476
+		$nextPawnMovement = array(-1, -1);
478 477
 		$castling = false;
479 478
 		$enPassant = false;
480 479
 		$rookMoved = false;
481 480
 		$rookTaken = false;
482 481
 		$pawnPromotion = false;
483
-		if($p->pieceID == ChessPiece::KING) {
482
+		if ($p->pieceID == ChessPiece::KING) {
484 483
 			//Castling?
485 484
 			$castling = self::isCastling($x, $toX);
486
-			if($castling !== false) {
485
+			if ($castling !== false) {
487 486
 				$hasMoved[$p->colour][ChessPiece::KING] = true;
488 487
 				$hasMoved[$p->colour][ChessPiece::ROOK][$castling['Type']] = true;
489
-				if($board[$y][$castling['X']] == null) {
488
+				if ($board[$y][$castling['X']] == null) {
490 489
 					throw new Exception('Cannot castle with non-existent castle.');
491 490
 				}
492 491
 				$board[$toY][$castling['ToX']] = $board[$y][$castling['X']];
@@ -494,37 +493,37 @@  discard block
 block discarded – undo
494 493
 				$board[$y][$castling['X']] = null;
495 494
 			}
496 495
 		}
497
-		else if($p->pieceID == ChessPiece::PAWN) {
498
-			if($toY == 0 || $toY == 7) {
496
+		else if ($p->pieceID == ChessPiece::PAWN) {
497
+			if ($toY == 0 || $toY == 7) {
499 498
 				$pawnPromotion = $p->promote($pawnPromotionPiece, $board);
500 499
 			}
501 500
 			//Double move to track?
502
-			else if(($y == 1 || $y == 6) && ($toY == 3 || $toY == 4)) {
501
+			else if (($y == 1 || $y == 6) && ($toY == 3 || $toY == 4)) {
503 502
 				$nextPawnMovement = array($toX, $toY);
504 503
 			}
505 504
 			//En passant?
506
-			else if($hasMoved[ChessPiece::PAWN][0] == $toX &&
505
+			else if ($hasMoved[ChessPiece::PAWN][0] == $toX &&
507 506
 					($hasMoved[ChessPiece::PAWN][1] == 3 && $toY == 2 || $hasMoved[ChessPiece::PAWN][1] == 4 && $toY == 5)) {
508 507
 				$enPassant = true;
509 508
 				$pieceTaken = $board[$hasMoved[ChessPiece::PAWN][1]][$hasMoved[ChessPiece::PAWN][0]];
510
-				if($board[$hasMoved[ChessPiece::PAWN][1]][$hasMoved[ChessPiece::PAWN][0]] == null) {
509
+				if ($board[$hasMoved[ChessPiece::PAWN][1]][$hasMoved[ChessPiece::PAWN][0]] == null) {
511 510
 					throw new Exception('Cannot en passant a non-existent pawn.');
512 511
 				}
513 512
 				$board[$hasMoved[ChessPiece::PAWN][1]][$hasMoved[ChessPiece::PAWN][0]] = null;
514 513
 			}
515 514
 		}
516
-		else if($p->pieceID == ChessPiece::ROOK && ($x == 0 || $x == 7) && $y == ($p->colour == self::PLAYER_WHITE ? 7 : 0)) {
515
+		else if ($p->pieceID == ChessPiece::ROOK && ($x == 0 || $x == 7) && $y == ($p->colour == self::PLAYER_WHITE ? 7 : 0)) {
517 516
 			//Rook moved?
518
-			if($hasMoved[$p->colour][ChessPiece::ROOK][$x==0?'Queen':'King'] === false) {
517
+			if ($hasMoved[$p->colour][ChessPiece::ROOK][$x == 0 ? 'Queen' : 'King'] === false) {
519 518
 				// We set rook moved in here as it's used for move info.
520
-				$rookMoved = $x==0?'Queen':'King';
519
+				$rookMoved = $x == 0 ? 'Queen' : 'King';
521 520
 				$hasMoved[$p->colour][ChessPiece::ROOK][$rookMoved] = true;
522 521
 			}
523 522
 		}
524 523
 		// Check if we've taken a rook and marked them as moved, if they've already moved this does nothing, but if they were taken before moving this stops an issue with trying to castle with a non-existent castle.
525
-		if($pieceTaken != null && $pieceTaken->pieceID == ChessPiece::ROOK && ($toX == 0 || $toX == 7) && $toY == ($pieceTaken->colour == self::PLAYER_WHITE ? 7 : 0)) {
526
-			if($hasMoved[$pieceTaken->colour][ChessPiece::ROOK][$toX==0?'Queen':'King'] === false) {
527
-				$rookTaken = $toX==0?'Queen':'King';
524
+		if ($pieceTaken != null && $pieceTaken->pieceID == ChessPiece::ROOK && ($toX == 0 || $toX == 7) && $toY == ($pieceTaken->colour == self::PLAYER_WHITE ? 7 : 0)) {
525
+			if ($hasMoved[$pieceTaken->colour][ChessPiece::ROOK][$toX == 0 ? 'Queen' : 'King'] === false) {
526
+				$rookTaken = $toX == 0 ? 'Queen' : 'King';
528 527
 				$hasMoved[$pieceTaken->colour][ChessPiece::ROOK][$rookTaken] = true;
529 528
 			}
530 529
 		}
@@ -541,18 +540,18 @@  discard block
 block discarded – undo
541 540
 	}
542 541
 
543 542
 	public static function undoMovePiece(array &$board, array &$hasMoved, $x, $y, $toX, $toY, $moveInfo) {
544
-		if(!self::isValidCoord($x, $y, $board)) {
543
+		if (!self::isValidCoord($x, $y, $board)) {
545 544
 			throw new Exception('Invalid from coordinates, x=' . $x . ', y=' . $y);
546 545
 		}
547
-		if(!self::isValidCoord($toX, $toY, $board)) {
546
+		if (!self::isValidCoord($toX, $toY, $board)) {
548 547
 			throw new Exception('Invalid to coordinates, x=' . $toX . ', y=' . $toY);
549 548
 		}
550
-		if($board[$y][$x] != null) {
549
+		if ($board[$y][$x] != null) {
551 550
 			throw new Exception('Undoing move onto another piece? x=' . $x . ', y=' . $y);
552 551
 		}
553 552
 		$board[$y][$x] = $board[$toY][$toX];
554
-		$p =& $board[$y][$x];
555
-		if($p == null) {
553
+		$p = & $board[$y][$x];
554
+		if ($p == null) {
556 555
 			throw new Exception('Trying to undo move of a non-existent piece: ' . var_export($board, true));
557 556
 		}
558 557
 		$board[$toY][$toX] = $moveInfo['PieceTaken'];
@@ -561,12 +560,12 @@  discard block
 block discarded – undo
561 560
 
562 561
 		$hasMoved[ChessPiece::PAWN] = $moveInfo['OldPawnMovement'];
563 562
 		//Castling
564
-		if($p->pieceID == ChessPiece::KING) {
563
+		if ($p->pieceID == ChessPiece::KING) {
565 564
 			$castling = self::isCastling($x, $toX);
566
-			if($castling !== false) {
565
+			if ($castling !== false) {
567 566
 				$hasMoved[$p->colour][ChessPiece::KING] = false;
568 567
 				$hasMoved[$p->colour][ChessPiece::ROOK][$castling['Type']] = false;
569
-				if($board[$toY][$castling['ToX']] == null) {
568
+				if ($board[$toY][$castling['ToX']] == null) {
570 569
 					throw new Exception('Cannot undo castle with non-existent castle.');
571 570
 				}
572 571
 				$board[$y][$castling['X']] = $board[$toY][$castling['ToX']];
@@ -574,25 +573,25 @@  discard block
 block discarded – undo
574 573
 				$board[$toY][$castling['ToX']] = null;
575 574
 			}
576 575
 		}
577
-		else if($moveInfo['EnPassant'] === true) {
576
+		else if ($moveInfo['EnPassant'] === true) {
578 577
 			$board[$toY][$toX] = null;
579 578
 			$board[$hasMoved[ChessPiece::PAWN][1]][$hasMoved[ChessPiece::PAWN][0]] = $moveInfo['PieceTaken'];
580 579
 		}
581
-		else if($moveInfo['RookMoved'] !== false) {
580
+		else if ($moveInfo['RookMoved'] !== false) {
582 581
 			$hasMoved[$p->colour][ChessPiece::ROOK][$moveInfo['RookMoved']] = false;
583 582
 		}
584
-		if($moveInfo['RookTaken'] !== false) {
583
+		if ($moveInfo['RookTaken'] !== false) {
585 584
 			$hasMoved[$moveInfo['PieceTaken']->colour][ChessPiece::ROOK][$moveInfo['RookTaken']] = false;
586 585
 		}
587 586
 	}
588 587
 
589 588
 	public function tryAlgebraicMove($move) {
590
-		if(strlen($move) != 4 && strlen($move) != 5) {
589
+		if (strlen($move) != 4 && strlen($move) != 5) {
591 590
 			throw new Exception('Move of length "' . strlen($move) . '" is not valid, full move: ' . $move);
592 591
 		}
593 592
 		$aVal = ord('a');
594 593
 		$hVal = ord('h');
595
-		if(ord($move[0]) < $aVal || ord($move[2]) < $aVal
594
+		if (ord($move[0]) < $aVal || ord($move[2]) < $aVal
596 595
 				|| ord($move[0]) > $hVal || ord($move[2]) > $hVal
597 596
 				|| $move[1] < 1 || $move[3] < 1
598 597
 				|| $move[1] > 8 || $move[3] > 8) {
@@ -603,73 +602,73 @@  discard block
 block discarded – undo
603 602
 		$toX = ord($move[2]) - $aVal;
604 603
 		$toY = 8 - $move[3];
605 604
 		$pawnPromotionPiece = null;
606
-		if(isset($move[4])) {
605
+		if (isset($move[4])) {
607 606
 			$pawnPromotionPiece = ChessPiece::getPieceForLetter($move[4]);
608 607
 		}
609 608
 		return $this->tryMove($x, $y, $toX, $toY, $this->getCurrentTurnAccountID(), $pawnPromotionPiece);
610 609
 	}
611 610
 
612 611
 	public function tryMove($x, $y, $toX, $toY, $forAccountID, $pawnPromotionPiece) {
613
-		if($this->hasEnded()) {
612
+		if ($this->hasEnded()) {
614 613
 			return 5;
615 614
 		}
616
-		if($this->getCurrentTurnAccountID() != $forAccountID) {
615
+		if ($this->getCurrentTurnAccountID() != $forAccountID) {
617 616
 			return 4;
618 617
 		}
619 618
 		$lastTurnPlayer = $this->getCurrentTurnPlayer();
620 619
 		$this->getBoard();
621 620
 		$p = $this->board[$y][$x];
622
-		if($p == null || $p->colour != $this->getColourForAccountID($forAccountID)) {
621
+		if ($p == null || $p->colour != $this->getColourForAccountID($forAccountID)) {
623 622
 			return 2;
624 623
 		}
625 624
 
626 625
 		$moves = $p->getPossibleMoves($this->board, $this->getHasMoved(), $forAccountID);
627
-		foreach($moves as $move) {
628
-			if($move[0]==$toX && $move[1]==$toY) {
626
+		foreach ($moves as $move) {
627
+			if ($move[0] == $toX && $move[1] == $toY) {
629 628
 				$chessType = $this->isNPCGame() ? 'Chess (NPC)' : 'Chess';
630 629
 				$currentPlayer = $this->getCurrentTurnPlayer();
631 630
 
632 631
 				$moveInfo = ChessGame::movePiece($this->board, $this->getHasMoved(), $x, $y, $toX, $toY, $pawnPromotionPiece);
633 632
 
634 633
 				//We have taken the move, we should refresh $p
635
-				$p =& $this->board[$toY][$toX];
634
+				$p = & $this->board[$toY][$toX];
636 635
 
637 636
 				$pieceTakenID = null;
638
-				if($moveInfo['PieceTaken'] != null) {
637
+				if ($moveInfo['PieceTaken'] != null) {
639 638
 					$pieceTakenID = $moveInfo['PieceTaken']->pieceID;
640
-					if($moveInfo['PieceTaken']->pieceID == ChessPiece::KING) {
639
+					if ($moveInfo['PieceTaken']->pieceID == ChessPiece::KING) {
641 640
 						throw new Exception('King was taken.');
642 641
 					}
643 642
 				}
644 643
 
645 644
 				$pieceID = $p->pieceID;
646 645
 				$pieceNo = $p->pieceNo;
647
-				if($moveInfo['PawnPromotion'] !== false) {
646
+				if ($moveInfo['PawnPromotion'] !== false) {
648 647
 					$p->pieceID = $moveInfo['PawnPromotion']['PieceID'];
649 648
 					$p->pieceNo = $moveInfo['PawnPromotion']['PieceNo'];
650 649
 				}
651 650
 
652 651
 				$checking = null;
653
-				if($p->isAttacking($this->board, $this->getHasMoved(), true)) {
652
+				if ($p->isAttacking($this->board, $this->getHasMoved(), true)) {
654 653
 					$checking = 'CHECK';
655 654
 				}
656
-				if($this->isCheckmated(self::getOtherColour($p->colour))) {
655
+				if ($this->isCheckmated(self::getOtherColour($p->colour))) {
657 656
 					$checking = 'MATE';
658 657
 				}
659
-				if($this->moves!=null) {
658
+				if ($this->moves != null) {
660 659
 					$this->moves[] = $this->createMove($pieceID, $x, $y, $toX, $toY, $pieceTakenID, $checking, $this->getCurrentTurnColour(), $moveInfo['Castling']['Type'], $moveInfo['EnPassant'], $moveInfo['PawnPromotion'] === false ? null : $moveInfo['PawnPromotion']['PieceID']);
661 660
 				}
662
-				if(self::isPlayerChecked($this->board, $this->getHasMoved(), $p->colour)) {
661
+				if (self::isPlayerChecked($this->board, $this->getHasMoved(), $p->colour)) {
663 662
 					return 3;
664 663
 				}
665 664
 
666 665
 				$otherPlayer = $this->getCurrentTurnPlayer();
667
-				if($moveInfo['PawnPromotion'] !== false) {
666
+				if ($moveInfo['PawnPromotion'] !== false) {
668 667
 					$piecePromotedSymbol = $p->getPieceSymbol();
669
-					$currentPlayer->increaseHOF(1, array($chessType,'Moves','Own Pawns Promoted','Total'), HOF_PUBLIC);
670
-					$otherPlayer->increaseHOF(1, array($chessType,'Moves','Opponent Pawns Promoted','Total'), HOF_PUBLIC);
671
-					$currentPlayer->increaseHOF(1, array($chessType,'Moves','Own Pawns Promoted',$piecePromotedSymbol), HOF_PUBLIC);
672
-					$otherPlayer->increaseHOF(1, array($chessType,'Moves','Opponent Pawns Promoted',$piecePromotedSymbol), HOF_PUBLIC);
668
+					$currentPlayer->increaseHOF(1, array($chessType, 'Moves', 'Own Pawns Promoted', 'Total'), HOF_PUBLIC);
669
+					$otherPlayer->increaseHOF(1, array($chessType, 'Moves', 'Opponent Pawns Promoted', 'Total'), HOF_PUBLIC);
670
+					$currentPlayer->increaseHOF(1, array($chessType, 'Moves', 'Own Pawns Promoted', $piecePromotedSymbol), HOF_PUBLIC);
671
+					$otherPlayer->increaseHOF(1, array($chessType, 'Moves', 'Opponent Pawns Promoted', $piecePromotedSymbol), HOF_PUBLIC);
673 672
 				}
674 673
 
675 674
 				$castlingType = $moveInfo['Castling'] === false ? null : $moveInfo['Castling']['Type'];
@@ -679,37 +678,37 @@  discard block
 block discarded – undo
679 678
 								(' . $this->db->escapeNumber($p->chessGameID) . ',' . $this->db->escapeNumber($pieceID) . ',' . $this->db->escapeNumber($x) . ',' . $this->db->escapeNumber($y) . ',' . $this->db->escapeNumber($toX) . ',' . $this->db->escapeNumber($toY) . ',' . $this->db->escapeString($checking, true, true) . ',' . ($moveInfo['PieceTaken'] == null ? 'NULL' : $this->db->escapeNumber($moveInfo['PieceTaken']->pieceID)) . ',' . $this->db->escapeString($castlingType, true, true) . ',' . $this->db->escapeBoolean($moveInfo['EnPassant']) . ',' . ($moveInfo['PawnPromotion'] == false ? 'NULL' : $this->db->escapeNumber($moveInfo['PawnPromotion']['PieceID'])) . ');');
680 679
 
681 680
 
682
-				$currentPlayer->increaseHOF(1, array($chessType,'Moves','Total Taken'), HOF_PUBLIC);
683
-				if($moveInfo['PieceTaken'] != null) {
681
+				$currentPlayer->increaseHOF(1, array($chessType, 'Moves', 'Total Taken'), HOF_PUBLIC);
682
+				if ($moveInfo['PieceTaken'] != null) {
684 683
 					$this->db->query('DELETE FROM chess_game_pieces
685 684
 									WHERE chess_game_id=' . $this->db->escapeNumber($this->chessGameID) . ' AND account_id=' . $this->db->escapeNumber($moveInfo['PieceTaken']->accountID) . ' AND piece_id=' . $this->db->escapeNumber($moveInfo['PieceTaken']->pieceID) . ' AND piece_no=' . $this->db->escapeNumber($moveInfo['PieceTaken']->pieceNo) . ';');
686 685
 
687 686
 					$pieceTakenSymbol = $moveInfo['PieceTaken']->getPieceSymbol();
688
-					$currentPlayer->increaseHOF(1, array($chessType,'Moves','Opponent Pieces Taken','Total'), HOF_PUBLIC);
689
-					$otherPlayer->increaseHOF(1, array($chessType,'Moves','Own Pieces Taken','Total'), HOF_PUBLIC);
690
-					$currentPlayer->increaseHOF(1, array($chessType,'Moves','Opponent Pieces Taken',$pieceTakenSymbol), HOF_PUBLIC);
691
-					$otherPlayer->increaseHOF(1, array($chessType,'Moves','Own Pieces Taken',$pieceTakenSymbol), HOF_PUBLIC);
687
+					$currentPlayer->increaseHOF(1, array($chessType, 'Moves', 'Opponent Pieces Taken', 'Total'), HOF_PUBLIC);
688
+					$otherPlayer->increaseHOF(1, array($chessType, 'Moves', 'Own Pieces Taken', 'Total'), HOF_PUBLIC);
689
+					$currentPlayer->increaseHOF(1, array($chessType, 'Moves', 'Opponent Pieces Taken', $pieceTakenSymbol), HOF_PUBLIC);
690
+					$otherPlayer->increaseHOF(1, array($chessType, 'Moves', 'Own Pieces Taken', $pieceTakenSymbol), HOF_PUBLIC);
692 691
 				}
693 692
 				$this->db->query('UPDATE chess_game_pieces
694 693
 							SET x=' . $this->db->escapeNumber($toX) . ', y=' . $this->db->escapeNumber($toY) .
695 694
 								($moveInfo['PawnPromotion'] !== false ? ', piece_id=' . $this->db->escapeNumber($moveInfo['PawnPromotion']['PieceID']) . ', piece_no=' . $this->db->escapeNumber($moveInfo['PawnPromotion']['PieceNo']) : '') . '
696 695
 							WHERE chess_game_id=' . $this->db->escapeNumber($this->chessGameID) . ' AND account_id=' . $this->db->escapeNumber($p->accountID) . ' AND piece_id=' . $this->db->escapeNumber($pieceID) . ' AND piece_no=' . $this->db->escapeNumber($pieceNo) . ';');
697
-				if($moveInfo['Castling'] !== false) {
696
+				if ($moveInfo['Castling'] !== false) {
698 697
 					$this->db->query('UPDATE chess_game_pieces
699 698
 								SET x=' . $this->db->escapeNumber($moveInfo['Castling']['ToX']) . '
700 699
 								WHERE chess_game_id=' . $this->db->escapeNumber($this->chessGameID) . ' AND account_id=' . $this->db->escapeNumber($p->accountID) . ' AND x = ' . $this->db->escapeNumber($moveInfo['Castling']['X']) . ' AND y = ' . $this->db->escapeNumber($y) . ';');
701 700
 				}
702 701
 				$return = 0;
703
-				if($checking == 'MATE') {
702
+				if ($checking == 'MATE') {
704 703
 					$this->setWinner($forAccountID);
705 704
 					$return = 1;
706 705
 					SmrPlayer::sendMessageFromCasino($lastTurnPlayer->getGameID(), $this->getCurrentTurnAccountID(), 'You have just lost [chess=' . $this->getChessGameID() . '] against [player=' . $lastTurnPlayer->getPlayerID() . '].');
707 706
 				}
708 707
 				else {
709 708
 					SmrPlayer::sendMessageFromCasino($lastTurnPlayer->getGameID(), $this->getCurrentTurnAccountID(), 'It is now your turn in [chess=' . $this->getChessGameID() . '] against [player=' . $lastTurnPlayer->getPlayerID() . '].');
710
-					if($checking == 'CHECK') {
711
-						$currentPlayer->increaseHOF(1, array($chessType,'Moves','Check Given'), HOF_PUBLIC);
712
-						$otherPlayer->increaseHOF(1, array($chessType,'Moves','Check Received'), HOF_PUBLIC);
709
+					if ($checking == 'CHECK') {
710
+						$currentPlayer->increaseHOF(1, array($chessType, 'Moves', 'Check Given'), HOF_PUBLIC);
711
+						$otherPlayer->increaseHOF(1, array($chessType, 'Moves', 'Check Received'), HOF_PUBLIC);
713 712
 					}
714 713
 				}
715 714
 				$currentPlayer->saveHOF();
@@ -748,10 +747,10 @@  discard block
 block discarded – undo
748 747
 	}
749 748
 
750 749
 	public function getColourID($colour) {
751
-		if($colour == self::PLAYER_WHITE) {
750
+		if ($colour == self::PLAYER_WHITE) {
752 751
 			return $this->getWhiteID();
753 752
 		}
754
-		if($colour == self::PLAYER_BLACK) {
753
+		if ($colour == self::PLAYER_BLACK) {
755 754
 			return $this->getBlackID();
756 755
 		}
757 756
 	}
@@ -761,10 +760,10 @@  discard block
 block discarded – undo
761 760
 	}
762 761
 
763 762
 	public function getColourForAccountID($accountID) {
764
-		if($accountID == $this->getWhiteID()) {
763
+		if ($accountID == $this->getWhiteID()) {
765 764
 			return self::PLAYER_WHITE;
766 765
 		}
767
-		if($accountID == $this->getBlackID()) {
766
+		if ($accountID == $this->getBlackID()) {
768 767
 			return self::PLAYER_BLACK;
769 768
 		}
770 769
 		return false;
@@ -792,8 +791,8 @@  discard block
 block discarded – undo
792 791
 		$winningPlayer = $this->getColourPlayer($winnerColour);
793 792
 		$losingPlayer = $this->getColourPlayer(self::getOtherColour($winnerColour));
794 793
 		$chessType = $this->isNPCGame() ? 'Chess (NPC)' : 'Chess';
795
-		$winningPlayer->increaseHOF(1, array($chessType,'Games','Won'), HOF_PUBLIC);
796
-		$losingPlayer->increaseHOF(1, array($chessType,'Games','Lost'), HOF_PUBLIC);
794
+		$winningPlayer->increaseHOF(1, array($chessType, 'Games', 'Won'), HOF_PUBLIC);
795
+		$losingPlayer->increaseHOF(1, array($chessType, 'Games', 'Lost'), HOF_PUBLIC);
797 796
 		return array('Winner' => $winningPlayer, 'Loser' => $losingPlayer);
798 797
 	}
799 798
 
@@ -834,21 +833,21 @@  discard block
 block discarded – undo
834 833
 	}
835 834
 
836 835
 	public static function getOtherColour($colour) {
837
-		if($colour == self::PLAYER_WHITE) {
836
+		if ($colour == self::PLAYER_WHITE) {
838 837
 			return self::PLAYER_BLACK;
839 838
 		}
840
-		if($colour == self::PLAYER_BLACK) {
839
+		if ($colour == self::PLAYER_BLACK) {
841 840
 			return self::PLAYER_WHITE;
842 841
 		}
843 842
 		return false;
844 843
 	}
845 844
 
846 845
 	public function resign($accountID) {
847
-		if($this->hasEnded() || !$this->getColourForAccountID($accountID)) {
846
+		if ($this->hasEnded() || !$this->getColourForAccountID($accountID)) {
848 847
 			return false;
849 848
 		}
850 849
 		// If only 1 person has moved then just end the game.
851
-		if(count($this->getMoves()) < 2) {
850
+		if (count($this->getMoves()) < 2) {
852 851
 			$this->endDate = TIME;
853 852
 			$this->db->query('UPDATE chess_game
854 853
 							SET end_time=' . $this->db->escapeNumber(TIME) . '
@@ -860,17 +859,17 @@  discard block
 block discarded – undo
860 859
 			$winnerAccountID = $this->getColourID(self::getOtherColour($loserColour));
861 860
 			$results = $this->setWinner($winnerAccountID);
862 861
 			$chessType = $this->isNPCGame() ? 'Chess (NPC)' : 'Chess';
863
-			$results['Loser']->increaseHOF(1, array($chessType,'Games','Resigned'), HOF_PUBLIC);
862
+			$results['Loser']->increaseHOF(1, array($chessType, 'Games', 'Resigned'), HOF_PUBLIC);
864 863
 			SmrPlayer::sendMessageFromCasino($results['Winner']->getGameID(), $results['Winner']->getPlayerID(), '[player=' . $results['Loser']->getPlayerID() . '] just resigned against you in [chess=' . $this->getChessGameID() . '].');
865 864
 			return 0;
866 865
 		}
867 866
 	}
868 867
 
869 868
 	public function getPlayGameHREF() {
870
-		return SmrSession::getNewHREF(create_container('skeleton.php','chess_play.php',array('ChessGameID' => $this->chessGameID)));
869
+		return SmrSession::getNewHREF(create_container('skeleton.php', 'chess_play.php', array('ChessGameID' => $this->chessGameID)));
871 870
 	}
872 871
 
873 872
 	public function getResignHREF() {
874
-		return SmrSession::getNewHREF(create_container('skeleton.php','chess_resign_processing.php',array('ChessGameID' => $this->chessGameID)));
873
+		return SmrSession::getNewHREF(create_container('skeleton.php', 'chess_resign_processing.php', array('ChessGameID' => $this->chessGameID)));
875 874
 	}
876 875
 }
Please login to merge, or discard this patch.
lib/Default/SmrPlanet.class.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -707,7 +707,7 @@
 block discarded – undo
707 707
 		if ($buildingTypeID === false) {
708 708
 			$structs = $this->typeInfo::STRUCTURES;
709 709
 			return array_combine(array_keys($structs),
710
-			                     array_column($structs, 'max_amount'));
710
+								 array_column($structs, 'max_amount'));
711 711
 		}
712 712
 		return $this->getStructureTypes($buildingTypeID)->maxAmount();
713 713
 	}
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1146,7 +1146,7 @@  discard block
 block discarded – undo
1146 1146
 		$results['DeadBeforeShot'] = false;
1147 1147
 		$weapons = $this->getWeapons();
1148 1148
 		foreach ($weapons as $orderID => $weapon) {
1149
-			$results['Weapons'][$orderID] =& $weapon->shootPlayerAsPlanet($this, $targetPlayers[array_rand($targetPlayers)]);
1149
+			$results['Weapons'][$orderID] = & $weapon->shootPlayerAsPlanet($this, $targetPlayers[array_rand($targetPlayers)]);
1150 1150
 			if ($results['Weapons'][$orderID]['Hit']) {
1151 1151
 				$results['TotalDamage'] += $results['Weapons'][$orderID]['ActualDamage']['TotalDamage'];
1152 1152
 				$results['TotalDamagePerTargetPlayer'][$results['Weapons'][$orderID]['TargetPlayer']->getAccountID()] += $results['Weapons'][$orderID]['ActualDamage']['TotalDamage'];
@@ -1154,7 +1154,7 @@  discard block
 block discarded – undo
1154 1154
 		}
1155 1155
 		if ($this->hasCDs()) {
1156 1156
 			$thisCDs = new SmrCombatDrones($this->getGameID(), $this->getCDs(), true);
1157
-			$results['Drones'] =& $thisCDs->shootPlayerAsPlanet($this, $targetPlayers[array_rand($targetPlayers)]);
1157
+			$results['Drones'] = & $thisCDs->shootPlayerAsPlanet($this, $targetPlayers[array_rand($targetPlayers)]);
1158 1158
 			$results['TotalDamage'] += $results['Drones']['ActualDamage']['TotalDamage'];
1159 1159
 			$results['TotalDamagePerTargetPlayer'][$results['Drones']['TargetPlayer']->getAccountID()] += $results['Drones']['ActualDamage']['TotalDamage'];
1160 1160
 		}
Please login to merge, or discard this 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/SmrPlayer.class.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -197,7 +197,7 @@
 block discarded – undo
197 197
 		while ($this->db->nextRecord()) {
198 198
 			try {
199 199
 				$otherPlayer = SmrPlayer::getPlayer($this->db->getInt('from_account_id'),
200
-				                                    $this->getGameID(), $forceUpdate);
200
+													$this->getGameID(), $forceUpdate);
201 201
 			} catch (PlayerNotFoundException $e) {
202 202
 				// Skip players that have not joined this game
203 203
 				continue;
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 	/**
208 208
 	 * Insert a new player into the database. Returns the new player object.
209 209
 	 */
210
-	public static function createPlayer($accountID, $gameID, $playerName, $raceID, $isNewbie, $npc=false) {
210
+	public static function createPlayer($accountID, $gameID, $playerName, $raceID, $isNewbie, $npc = false) {
211 211
 		// Put the player in a sector with an HQ
212 212
 		$startSectorID = self::getHome($gameID, $raceID);
213 213
 
@@ -1163,13 +1163,13 @@  discard block
 block discarded – undo
1163 1163
 			$this->db->query('SELECT type,amount FROM player_hof WHERE ' . $this->SQL);
1164 1164
 			$this->HOF = array();
1165 1165
 			while ($this->db->nextRecord()) {
1166
-				$hof =& $this->HOF;
1166
+				$hof = & $this->HOF;
1167 1167
 				$typeList = explode(':', $this->db->getField('type'));
1168 1168
 				foreach ($typeList as $type) {
1169 1169
 					if (!isset($hof[$type])) {
1170 1170
 						$hof[$type] = array();
1171 1171
 					}
1172
-					$hof =& $hof[$type];
1172
+					$hof = & $hof[$type];
1173 1173
 				}
1174 1174
 				$hof = $this->db->getFloat('amount');
1175 1175
 			}
@@ -1611,7 +1611,7 @@  discard block
 block discarded – undo
1611 1611
 			create_error('The saved sector must be in the box!');
1612 1612
 		}
1613 1613
 
1614
-		$storedDestinations =& $this->getStoredDestinations();
1614
+		$storedDestinations = & $this->getStoredDestinations();
1615 1615
 		foreach ($storedDestinations as &$sd) {
1616 1616
 			if ($sd['SectorID'] == $sectorID) {
1617 1617
 				$sd['OffsetTop'] = $offsetTop;
Please login to merge, or discard this patch.
Braces   +182 added lines, -138 removed lines patch added patch discarded remove patch
@@ -58,8 +58,9 @@  discard block
 block discarded – undo
58 58
 	public static function getSectorPlayersByAlliances($gameID, $sectorID, array $allianceIDs, $forceUpdate = false) {
59 59
 		$players = self::getSectorPlayers($gameID, $sectorID, $forceUpdate); // Don't use & as we do an unset
60 60
 		foreach ($players as $accountID => $player) {
61
-			if (!in_array($player->getAllianceID(), $allianceIDs))
62
-				unset($players[$accountID]);
61
+			if (!in_array($player->getAllianceID(), $allianceIDs)) {
62
+							unset($players[$accountID]);
63
+			}
63 64
 		}
64 65
 		return $players;
65 66
 	}
@@ -198,8 +199,7 @@  discard block
 block discarded – undo
198 199
 			$this->newbieWarning = $db->getBoolean('newbie_warning');
199 200
 			$this->nameChanged = $db->getBoolean('name_changed');
200 201
 			$this->combatDronesKamikazeOnMines = $db->getBoolean('combat_drones_kamikaze_on_mines');
201
-		}
202
-		else {
202
+		} else {
203 203
 			throw new PlayerNotFoundException('Invalid accountID: ' . $accountID . ' OR gameID:' . $gameID);
204 204
 		}
205 205
 	}
@@ -285,22 +285,25 @@  discard block
 block discarded – undo
285 285
 	protected function setZoom($zoom) {
286 286
 		// Set the zoom level between [1, 9]
287 287
 		$zoom = max(1, min(9, $zoom));
288
-		if ($this->zoom == $zoom)
289
-			return;
288
+		if ($this->zoom == $zoom) {
289
+					return;
290
+		}
290 291
 		$this->zoom = $zoom;
291 292
 		$this->hasChanged = true;
292 293
 //		$this->db->query('UPDATE player SET zoom = ' . $zoom . ' WHERE ' . $this->SQL . ' LIMIT 1');
293 294
 	}
294 295
 
295 296
 	public function increaseZoom($zoom) {
296
-		if ($zoom < 0)
297
-			throw new Exception('Trying to increase negative zoom.');
297
+		if ($zoom < 0) {
298
+					throw new Exception('Trying to increase negative zoom.');
299
+		}
298 300
 		$this->setZoom($this->getZoom() + $zoom);
299 301
 	}
300 302
 
301 303
 	public function decreaseZoom($zoom) {
302
-		if ($zoom < 0)
303
-			throw new Exception('Trying to decrease negative zoom.');
304
+		if ($zoom < 0) {
305
+					throw new Exception('Trying to decrease negative zoom.');
306
+		}
304 307
 		$this->setZoom($this->getZoom() - $zoom);
305 308
 	}
306 309
 
@@ -315,8 +318,9 @@  discard block
 block discarded – undo
315 318
 	}
316 319
 
317 320
 	public function setLastSectorID($lastSectorID) {
318
-		if ($this->lastSectorID == $lastSectorID)
319
-			return;
321
+		if ($this->lastSectorID == $lastSectorID) {
322
+					return;
323
+		}
320 324
 		$this->lastSectorID = $lastSectorID;
321 325
 		$this->hasChanged = true;
322 326
 //		$this->db->query('UPDATE player SET last_sector_id = '.$this->lastSectorID.' WHERE '.$this->SQL.' LIMIT 1');
@@ -329,11 +333,9 @@  discard block
 block discarded – undo
329 333
 			$kickedBy->sendMessage($this->getAccountID(), MSG_PLAYER, 'You were kicked out of the alliance!', false);
330 334
 			$this->actionTaken('PlayerKicked', array('Alliance' => $alliance, 'Player' => $kickedBy));
331 335
 			$kickedBy->actionTaken('KickPlayer', array('Alliance' => $alliance, 'Player' => $this));
332
-		}
333
-		else if ($this->isAllianceLeader()) {
336
+		} else if ($this->isAllianceLeader()) {
334 337
 			$this->actionTaken('DisbandAlliance', array('Alliance' => $alliance));
335
-		}
336
-		else {
338
+		} else {
337 339
 			$this->actionTaken('LeaveAlliance', array('Alliance' => $alliance));
338 340
 			if ($alliance->getLeaderID() != 0 && $alliance->getLeaderID() != ACCOUNT_ID_NHL) {
339 341
 				$this->sendMessage($alliance->getLeaderID(), MSG_PLAYER, 'I left your alliance!', false);
@@ -361,7 +363,9 @@  discard block
 block discarded – undo
361 363
 			try {
362 364
 				$this->sendMessage($alliance->getLeaderID(), MSG_PLAYER, 'I joined your alliance!', false);
363 365
 			} catch (AccountNotFoundException $e) {
364
-				if ($alliance->getLeaderID() != ACCOUNT_ID_NHL) throw $e;
366
+				if ($alliance->getLeaderID() != ACCOUNT_ID_NHL) {
367
+					throw $e;
368
+				}
365 369
 			}
366 370
 
367 371
 			$roleID = ALLIANCE_ROLE_NEW_MEMBER;
@@ -381,8 +385,9 @@  discard block
 block discarded – undo
381 385
 	}
382 386
 
383 387
 	private function setAllianceJoinable($time) {
384
-		if ($this->allianceJoinable == $time)
385
-			return;
388
+		if ($this->allianceJoinable == $time) {
389
+					return;
390
+		}
386 391
 		$this->allianceJoinable = $time;
387 392
 		$this->hasChanged = true;
388 393
 	}
@@ -392,8 +397,9 @@  discard block
 block discarded – undo
392 397
 	}
393 398
 
394 399
 	public function setAttackColour($colour) {
395
-		if ($this->attackColour == $colour)
396
-			return;
400
+		if ($this->attackColour == $colour) {
401
+					return;
402
+		}
397 403
 		$this->attackColour = $colour;
398 404
 		$this->hasChanged = true;
399 405
 //		$this->db->query('UPDATE player SET attack_warning = ' . $this->db->escapeString($this->attackColour) . ' WHERE ' . $this->SQL . ' LIMIT 1');
@@ -404,28 +410,35 @@  discard block
 block discarded – undo
404 410
 	}
405 411
 
406 412
 	public function increaseBank($credits) {
407
-		if ($credits < 0)
408
-			throw new Exception('Trying to increase negative credits.');
409
-		if ($credits == 0)
410
-			return;
413
+		if ($credits < 0) {
414
+					throw new Exception('Trying to increase negative credits.');
415
+		}
416
+		if ($credits == 0) {
417
+					return;
418
+		}
411 419
 		$credits += $this->bank;
412 420
 		$this->setBank($credits);
413 421
 	}
414 422
 	public function decreaseBank($credits) {
415
-		if ($credits < 0)
416
-			throw new Exception('Trying to decrease negative credits.');
417
-		if ($credits == 0)
418
-			return;
423
+		if ($credits < 0) {
424
+					throw new Exception('Trying to decrease negative credits.');
425
+		}
426
+		if ($credits == 0) {
427
+					return;
428
+		}
419 429
 		$credits = $this->bank - $credits;
420 430
 		$this->setBank($credits);
421 431
 	}
422 432
 	public function setBank($credits) {
423
-		if ($this->bank == $credits)
424
-			return;
425
-		if ($credits < 0)
426
-			throw new Exception('Trying to set negative credits.');
427
-		if ($credits > MAX_MONEY)
428
-			throw new Exception('Trying to set more than max credits.');
433
+		if ($this->bank == $credits) {
434
+					return;
435
+		}
436
+		if ($credits < 0) {
437
+					throw new Exception('Trying to set negative credits.');
438
+		}
439
+		if ($credits > MAX_MONEY) {
440
+					throw new Exception('Trying to set more than max credits.');
441
+		}
429 442
 		$this->bank = $credits;
430 443
 		$this->hasChanged = true;
431 444
 //		$this->db->query('UPDATE player SET bank = '.$this->bank.' WHERE '.$this->SQL.' LIMIT 1');
@@ -436,8 +449,9 @@  discard block
 block discarded – undo
436 449
 	}
437 450
 
438 451
 	private function setLastNewsUpdate($time) {
439
-		if ($this->lastNewsUpdate == $time)
440
-			return;
452
+		if ($this->lastNewsUpdate == $time) {
453
+					return;
454
+		}
441 455
 		$this->lastNewsUpdate = $time;
442 456
 		$this->hasChanged = true;
443 457
 //		$this->db->query('UPDATE player SET last_news_update = ' . $time . ' WHERE ' . $this->SQL . ' LIMIT 1');
@@ -484,7 +498,9 @@  discard block
 block discarded – undo
484 498
 
485 499
 	public function updateTurns() {
486 500
 		// is account validated?
487
-		if (!$this->getAccount()->isValidated()) return;
501
+		if (!$this->getAccount()->isValidated()) {
502
+			return;
503
+		}
488 504
 
489 505
 		// how many turns would he get right now?
490 506
 		$extraTurns = $this->getTurnsGained(TIME);
@@ -503,8 +519,9 @@  discard block
 block discarded – undo
503 519
 	}
504 520
 
505 521
 	public function setIgnoreGlobals($bool) {
506
-		if ($this->ignoreGlobals == $bool)
507
-			return;
522
+		if ($this->ignoreGlobals == $bool) {
523
+					return;
524
+		}
508 525
 		$this->ignoreGlobals = $bool;
509 526
 		$this->hasChanged = true;
510 527
 //		$this->db->query('UPDATE player SET ignore_globals = '.$this->db->escapeBoolean($bool).' WHERE '.$this->SQL.' LIMIT 1');
@@ -516,8 +533,9 @@  discard block
 block discarded – undo
516 533
 	}
517 534
 
518 535
 	public function setLastPort($lastPort) {
519
-		if ($this->lastPort == $lastPort)
520
-			return;
536
+		if ($this->lastPort == $lastPort) {
537
+					return;
538
+		}
521 539
 		$this->lastPort = $lastPort;
522 540
 		$this->hasChanged = true;
523 541
 //		$this->db->query('UPDATE player SET last_port = ' . $this->lastPort . ' WHERE ' . $this->SQL . ' LIMIT 1');
@@ -528,8 +546,9 @@  discard block
 block discarded – undo
528 546
 	}
529 547
 
530 548
 	public function setDisplayMissions($bool) {
531
-		if ($this->displayMissions == $bool)
532
-			return;
549
+		if ($this->displayMissions == $bool) {
550
+					return;
551
+		}
533 552
 		$this->displayMissions = $bool;
534 553
 		$this->hasChanged = true;
535 554
 	}
@@ -544,8 +563,9 @@  discard block
 block discarded – undo
544 563
 	 * which does not acquire a sector lock.
545 564
 	 */
546 565
 	public function setDisplayWeapons($bool) {
547
-		if ($this->displayWeapons == $bool)
548
-			return;
566
+		if ($this->displayWeapons == $bool) {
567
+					return;
568
+		}
549 569
 		$this->displayWeapons = $bool;
550 570
 		$this->db->query('UPDATE player SET display_weapons=' . $this->db->escapeBoolean($this->displayWeapons) . ' WHERE ' . $this->SQL);
551 571
 	}
@@ -555,8 +575,9 @@  discard block
 block discarded – undo
555 575
 	}
556 576
 
557 577
 	public function setForceDropMessages($bool) {
558
-		if ($this->forceDropMessages == $bool)
559
-			return;
578
+		if ($this->forceDropMessages == $bool) {
579
+					return;
580
+		}
560 581
 		$this->forceDropMessages = $bool;
561 582
 		$this->hasChanged = true;
562 583
 	}
@@ -588,8 +609,9 @@  discard block
 block discarded – undo
588 609
 	}
589 610
 
590 611
 	public function setLastTurnUpdate($time) {
591
-		if ($this->lastTurnUpdate == $time)
592
-			return;
612
+		if ($this->lastTurnUpdate == $time) {
613
+					return;
614
+		}
593 615
 		$this->lastTurnUpdate = $time;
594 616
 		$this->hasChanged = true;
595 617
 //		$sql = $this->db->query('UPDATE player SET last_turn_update = ' . $this->lastTurnUpdate . ' WHERE '. $this->SQL . ' LIMIT 1');
@@ -629,27 +651,33 @@  discard block
 block discarded – undo
629 651
 	}
630 652
 
631 653
 	public function increaseRelations($relations, $raceID) {
632
-		if ($relations < 0)
633
-			throw new Exception('Trying to increase negative relations.');
634
-		if ($relations == 0)
635
-			return;
654
+		if ($relations < 0) {
655
+					throw new Exception('Trying to increase negative relations.');
656
+		}
657
+		if ($relations == 0) {
658
+					return;
659
+		}
636 660
 		$relations += $this->getPureRelation($raceID);
637 661
 		$this->setRelations($relations, $raceID);
638 662
 	}
639 663
 	public function decreaseRelations($relations, $raceID) {
640
-		if ($relations < 0)
641
-			throw new Exception('Trying to decrease negative relations.');
642
-		if ($relations == 0)
643
-			return;
664
+		if ($relations < 0) {
665
+					throw new Exception('Trying to decrease negative relations.');
666
+		}
667
+		if ($relations == 0) {
668
+					return;
669
+		}
644 670
 		$relations = $this->getPureRelation($raceID) - $relations;
645 671
 		$this->setRelations($relations, $raceID);
646 672
 	}
647 673
 	public function setRelations($relations, $raceID) {
648 674
 		$this->getRelations();
649
-		if ($this->pureRelations[$raceID] == $relations)
650
-			return;
651
-		if ($relations < MIN_RELATIONS)
652
-			$relations = MIN_RELATIONS;
675
+		if ($this->pureRelations[$raceID] == $relations) {
676
+					return;
677
+		}
678
+		if ($relations < MIN_RELATIONS) {
679
+					$relations = MIN_RELATIONS;
680
+		}
653 681
 		$relationsDiff = IRound($relations - $this->pureRelations[$raceID]);
654 682
 		$this->pureRelations[$raceID] = $relations;
655 683
 		$this->relations[$raceID] += $relationsDiff;
@@ -684,8 +712,7 @@  discard block
 block discarded – undo
684 712
 			$this->db->query('SELECT * FROM ship_has_name WHERE ' . $this->SQL . ' LIMIT 1');
685 713
 			if ($this->db->nextRecord()) {
686 714
 				$this->customShipName = $this->db->getField('ship_name');
687
-			}
688
-			else {
715
+			} else {
689 716
 				$this->customShipName = false;
690 717
 			}
691 718
 		}
@@ -703,8 +730,7 @@  discard block
 block discarded – undo
703 730
 				$this->knowledge['Nyx'] = $this->db->getInt('nyx');
704 731
 				$this->knowledge['Federation'] = 0;
705 732
 				$this->knowledge['Underground'] = 0;
706
-			}
707
-			else {
733
+			} else {
708 734
 				$this->knowledge['Erebus'] = 0;
709 735
 				$this->knowledge['Aether'] = 0;
710 736
 				$this->knowledge['Tartarus'] = 0;
@@ -713,10 +739,12 @@  discard block
 block discarded – undo
713 739
 				$this->knowledge['Underground'] = 0;
714 740
 			}
715 741
 		}
716
-		if ($knowledgeType === false)
717
-			return $this->knowledge;
718
-		if (isset($this->knowledge[$knowledgeType]))
719
-			return $this->knowledge[$knowledgeType];
742
+		if ($knowledgeType === false) {
743
+					return $this->knowledge;
744
+		}
745
+		if (isset($this->knowledge[$knowledgeType])) {
746
+					return $this->knowledge[$knowledgeType];
747
+		}
720 748
 		return false;
721 749
 	}
722 750
 
@@ -729,9 +757,10 @@  discard block
 block discarded – undo
729 757
 		$sector->diedHere($this);
730 758
 
731 759
 		// if we are in an alliance we increase their deaths
732
-		if ($this->hasAlliance())
733
-			$this->db->query('UPDATE alliance SET alliance_deaths = alliance_deaths + 1
760
+		if ($this->hasAlliance()) {
761
+					$this->db->query('UPDATE alliance SET alliance_deaths = alliance_deaths + 1
734 762
 							WHERE game_id = ' . $this->db->escapeNumber($this->getGameID()) . ' AND alliance_id = ' . $this->db->escapeNumber($this->getAllianceID()) . ' LIMIT 1');
763
+		}
735 764
 
736 765
 		// record death stat
737 766
 		$this->increaseHOF(1, array('Dying', 'Deaths'), HOF_PUBLIC);
@@ -744,8 +773,9 @@  discard block
 block discarded – undo
744 773
 		$newCredits = IRound($this->getShip()->getCost() / 4);
745 774
 		$old_speed = $this->getShip()->getSpeed();
746 775
 
747
-		if ($newCredits < 100000)
748
-			$newCredits = 100000;
776
+		if ($newCredits < 100000) {
777
+					$newCredits = 100000;
778
+		}
749 779
 		$this->setCredits($newCredits);
750 780
 
751 781
 		$this->setSectorID($this::getHome($this->getGameID(), $this->getRaceID()));
@@ -820,14 +850,14 @@  discard block
 block discarded – undo
820 850
 		$relation = $relations[$killer->getRaceID()];
821 851
 
822 852
 		$alignChangePerRelation = 0.1;
823
-		if ($relation >= RELATIONS_PEACE || $relation <= RELATIONS_WAR)
824
-			$alignChangePerRelation = 0.04;
853
+		if ($relation >= RELATIONS_PEACE || $relation <= RELATIONS_WAR) {
854
+					$alignChangePerRelation = 0.04;
855
+		}
825 856
 
826 857
 		$return['KillerAlign'] = -$relation * $alignChangePerRelation; //Lose relations when killing a peaceful race
827 858
 		if ($return['KillerAlign'] > 0) {
828 859
 			$killer->increaseAlignment($return['KillerAlign']);
829
-		}
830
-		else {
860
+		} else {
831 861
 			$killer->decreaseAlignment(-$return['KillerAlign']);
832 862
 		}
833 863
 		// War setting gives them military pay
@@ -861,8 +891,7 @@  discard block
 block discarded – undo
861 891
 			// If the podded players alignment makes them deputy or member then set bounty
862 892
 			if ($this->getAlignment() >= 100) {
863 893
 				$return['BountyGained']['Type'] = 'HQ';
864
-			}
865
-			else if ($this->getAlignment() <= 100) {
894
+			} else if ($this->getAlignment() <= 100) {
866 895
 				$return['BountyGained']['Type'] = 'UG';
867 896
 			}
868 897
 
@@ -884,16 +913,14 @@  discard block
 block discarded – undo
884 913
 
885 914
 			if ($return['KillerAlign'] > 0) {
886 915
 				$killer->increaseHOF($return['KillerAlign'], array('Killing', 'NPC', 'Alignment', 'Gain'), HOF_PUBLIC);
887
-			}
888
-			else {
916
+			} else {
889 917
 				$killer->increaseHOF(-$return['KillerAlign'], array('Killing', 'NPC', 'Alignment', 'Loss'), HOF_PUBLIC);
890 918
 			}
891 919
 
892 920
 			$killer->increaseHOF($return['BountyGained']['Amount'], array('Killing', 'NPC', 'Money', 'Bounty Gained'), HOF_PUBLIC);
893 921
 
894 922
 			$killer->increaseHOF(1, array('Killing', 'NPC Kills'), HOF_PUBLIC);
895
-		}
896
-		else {
923
+		} else {
897 924
 			$killer->increaseHOF($return['KillerExp'], array('Killing', 'Experience', 'Gained'), HOF_PUBLIC);
898 925
 			$killer->increaseHOF($this->getExperience(), array('Killing', 'Experience', 'Of Traders Killed'), HOF_PUBLIC);
899 926
 
@@ -905,8 +932,7 @@  discard block
 block discarded – undo
905 932
 
906 933
 			if ($return['KillerAlign'] > 0) {
907 934
 				$killer->increaseHOF($return['KillerAlign'], array('Killing', 'Alignment', 'Gain'), HOF_PUBLIC);
908
-			}
909
-			else {
935
+			} else {
910 936
 				$killer->increaseHOF(-$return['KillerAlign'], array('Killing', 'Alignment', 'Loss'), HOF_PUBLIC);
911 937
 			}
912 938
 
@@ -914,8 +940,7 @@  discard block
 block discarded – undo
914 940
 
915 941
 			if ($this->getShip()->getAttackRatingWithMaxCDs() <= MAX_ATTACK_RATING_NEWBIE && $this->hasNewbieStatus() && !$killer->hasNewbieStatus()) { //Newbie kill
916 942
 				$killer->increaseHOF(1, array('Killing', 'Newbie Kills'), HOF_PUBLIC);
917
-			}
918
-			else {
943
+			} else {
919 944
 				$killer->increaseKills(1);
920 945
 				$killer->increaseHOF(1, array('Killing', 'Kills'), HOF_PUBLIC);
921 946
 
@@ -1097,20 +1122,21 @@  discard block
 block discarded – undo
1097 1122
 				$bountyChanged = false;
1098 1123
 				$bounty = $this->getBounty($key);
1099 1124
 				if ($bounty['New'] === true) {
1100
-					if ($bounty['Amount'] > 0 || $bounty['SmrCredits'] > 0)
1101
-						$this->db->query('INSERT INTO bounty (account_id,game_id,type,amount,smr_credits,claimer_id,time) VALUES (' . $this->db->escapeNumber($this->getAccountID()) . ',' . $this->db->escapeNumber($this->getGameID()) . ',' . $this->db->escapeString($bounty['Type']) . ',' . $this->db->escapeNumber($bounty['Amount']) . ',' . $this->db->escapeNumber($bounty['SmrCredits']) . ',' . $this->db->escapeNumber($bounty['Claimer']) . ',' . $this->db->escapeNumber($bounty['Time']) . ')');
1102
-				}
1103
-				else {
1104
-					if ($bounty['Amount'] > 0 || $bounty['SmrCredits'] > 0)
1105
-						$this->db->query('UPDATE bounty
1125
+					if ($bounty['Amount'] > 0 || $bounty['SmrCredits'] > 0) {
1126
+											$this->db->query('INSERT INTO bounty (account_id,game_id,type,amount,smr_credits,claimer_id,time) VALUES (' . $this->db->escapeNumber($this->getAccountID()) . ',' . $this->db->escapeNumber($this->getGameID()) . ',' . $this->db->escapeString($bounty['Type']) . ',' . $this->db->escapeNumber($bounty['Amount']) . ',' . $this->db->escapeNumber($bounty['SmrCredits']) . ',' . $this->db->escapeNumber($bounty['Claimer']) . ',' . $this->db->escapeNumber($bounty['Time']) . ')');
1127
+					}
1128
+				} else {
1129
+					if ($bounty['Amount'] > 0 || $bounty['SmrCredits'] > 0) {
1130
+											$this->db->query('UPDATE bounty
1106 1131
 							SET amount=' . $this->db->escapeNumber($bounty['Amount']) . ',
1107 1132
 							smr_credits=' . $this->db->escapeNumber($bounty['SmrCredits']) . ',
1108 1133
 							type=' . $this->db->escapeString($bounty['Type']) . ',
1109 1134
 							claimer_id=' . $this->db->escapeNumber($bounty['Claimer']) . ',
1110 1135
 							time=' . $this->db->escapeNumber($bounty['Time']) . '
1111 1136
 							WHERE bounty_id=' . $this->db->escapeNumber($bounty['ID']) . ' AND ' . $this->SQL . ' LIMIT 1');
1112
-					else
1113
-						$this->db->query('DELETE FROM bounty WHERE bounty_id=' . $this->db->escapeNumber($bounty['ID']) . ' AND ' . $this->SQL . ' LIMIT 1');
1137
+					} else {
1138
+											$this->db->query('DELETE FROM bounty WHERE bounty_id=' . $this->db->escapeNumber($bounty['ID']) . ' AND ' . $this->SQL . ' LIMIT 1');
1139
+					}
1114 1140
 				}
1115 1141
 			}
1116 1142
 		}
@@ -1118,14 +1144,16 @@  discard block
 block discarded – undo
1118 1144
 	}
1119 1145
 
1120 1146
 	public function saveHOF() {
1121
-		if ($this->hasHOFChanged !== false)
1122
-			$this->doHOFSave($this->hasHOFChanged);
1147
+		if ($this->hasHOFChanged !== false) {
1148
+					$this->doHOFSave($this->hasHOFChanged);
1149
+		}
1123 1150
 		if (!empty(self::$hasHOFVisChanged)) {
1124 1151
 			foreach (self::$hasHOFVisChanged as $hofType => $changeType) {
1125
-				if ($changeType == self::HOF_NEW)
1126
-					$this->db->query('INSERT INTO hof_visibility (type, visibility) VALUES (' . $this->db->escapeString($hofType) . ',' . $this->db->escapeString(self::$HOFVis[$hofType]) . ')');
1127
-				else
1128
-					$this->db->query('UPDATE hof_visibility SET visibility = ' . $this->db->escapeString(self::$HOFVis[$hofType]) . ' WHERE type = ' . $this->db->escapeString($hofType) . ' LIMIT 1');
1152
+				if ($changeType == self::HOF_NEW) {
1153
+									$this->db->query('INSERT INTO hof_visibility (type, visibility) VALUES (' . $this->db->escapeString($hofType) . ',' . $this->db->escapeString(self::$HOFVis[$hofType]) . ')');
1154
+				} else {
1155
+									$this->db->query('UPDATE hof_visibility SET visibility = ' . $this->db->escapeString(self::$HOFVis[$hofType]) . ' WHERE type = ' . $this->db->escapeString($hofType) . ' LIMIT 1');
1156
+				}
1129 1157
 				unset(self::$hasHOFVisChanged[$hofType]);
1130 1158
 			}
1131 1159
 		}
@@ -1136,14 +1164,13 @@  discard block
 block discarded – undo
1136 1164
 			$tempTypeList[] = $type;
1137 1165
 			if (is_array($hofChanged)) {
1138 1166
 				$this->doHOFSave($hofChanged, $tempTypeList);
1139
-			}
1140
-			else {
1167
+			} else {
1141 1168
 				$amount = $this->getHOF($tempTypeList);
1142 1169
 				if ($hofChanged == self::HOF_NEW) {
1143
-					if ($amount > 0)
1144
-						$this->db->query('INSERT INTO player_hof (account_id,game_id,type,amount) VALUES (' . $this->db->escapeNumber($this->getAccountID()) . ',' . $this->db->escapeNumber($this->getGameID()) . ',' . $this->db->escapeArray($tempTypeList, false, true, ':', false) . ',' . $this->db->escapeNumber($amount) . ')');
1145
-				}
1146
-				else if ($hofChanged == self::HOF_CHANGED) {
1170
+					if ($amount > 0) {
1171
+											$this->db->query('INSERT INTO player_hof (account_id,game_id,type,amount) VALUES (' . $this->db->escapeNumber($this->getAccountID()) . ',' . $this->db->escapeNumber($this->getGameID()) . ',' . $this->db->escapeArray($tempTypeList, false, true, ':', false) . ',' . $this->db->escapeNumber($amount) . ')');
1172
+					}
1173
+				} else if ($hofChanged == self::HOF_CHANGED) {
1147 1174
 	//				if($amount > 0)
1148 1175
 						$this->db->query('UPDATE player_hof
1149 1176
 							SET amount=' . $this->db->escapeNumber($amount) . '
@@ -1254,11 +1281,12 @@  discard block
 block discarded – undo
1254 1281
 			$this->tickers = array();
1255 1282
 			//get ticker info
1256 1283
 			$this->db->query('SELECT type,time,expires,recent FROM player_has_ticker WHERE ' . $this->SQL . ' AND expires > ' . $this->db->escapeNumber(TIME));
1257
-			while ($this->db->nextRecord())
1258
-				$this->tickers[$this->db->getField('type')] = array('Type' => $this->db->getField('type'),
1284
+			while ($this->db->nextRecord()) {
1285
+							$this->tickers[$this->db->getField('type')] = array('Type' => $this->db->getField('type'),
1259 1286
 																				'Time' => $this->db->getInt('time'),
1260 1287
 																				'Expires' => $this->db->getInt('expires'),
1261 1288
 																				'Recent' => $this->db->getField('recent'));
1289
+			}
1262 1290
 		}
1263 1291
 		return $this->tickers;
1264 1292
 	}
@@ -1269,8 +1297,9 @@  discard block
 block discarded – undo
1269 1297
 
1270 1298
 	public function getTicker($tickerType) {
1271 1299
 		$tickers = $this->getTickers();
1272
-		if (isset($tickers[$tickerType]))
1273
-			return $tickers[$tickerType];
1300
+		if (isset($tickers[$tickerType])) {
1301
+					return $tickers[$tickerType];
1302
+		}
1274 1303
 		return false;
1275 1304
 	}
1276 1305
 
@@ -1279,9 +1308,15 @@  discard block
 block discarded – undo
1279 1308
 	}
1280 1309
 
1281 1310
 	public function getTurnsLevel() {
1282
-		if (!$this->hasTurns()) return 'NONE';
1283
-		if ($this->getTurns() <= 25) return 'LOW';
1284
-		if ($this->getTurns() <= 75) return 'MEDIUM';
1311
+		if (!$this->hasTurns()) {
1312
+			return 'NONE';
1313
+		}
1314
+		if ($this->getTurns() <= 25) {
1315
+			return 'LOW';
1316
+		}
1317
+		if ($this->getTurns() <= 75) {
1318
+			return 'MEDIUM';
1319
+		}
1285 1320
 		return 'HIGH';
1286 1321
 	}
1287 1322
 
@@ -1359,8 +1394,9 @@  discard block
 block discarded – undo
1359 1394
 
1360 1395
 	public function sendGlobalMessage($message, $canBeIgnored = true) {
1361 1396
 		if ($canBeIgnored) {
1362
-			if ($this->getAccount()->isMailBanned())
1363
-				create_error('You are currently banned from sending messages');
1397
+			if ($this->getAccount()->isMailBanned()) {
1398
+							create_error('You are currently banned from sending messages');
1399
+			}
1364 1400
 		}
1365 1401
 		$this->sendMessageToBox(BOX_GLOBALS, $message);
1366 1402
 
@@ -1383,12 +1419,14 @@  discard block
 block discarded – undo
1383 1419
 	public function sendMessage($receiverID, $messageTypeID, $message, $canBeIgnored = true, $unread = true, $expires = false, $senderDelete = false) {
1384 1420
 		//get expire time
1385 1421
 		if ($canBeIgnored) {
1386
-			if ($this->getAccount()->isMailBanned())
1387
-				create_error('You are currently banned from sending messages');
1422
+			if ($this->getAccount()->isMailBanned()) {
1423
+							create_error('You are currently banned from sending messages');
1424
+			}
1388 1425
 			// Don't send messages to players ignoring us
1389 1426
 			$this->db->query('SELECT account_id FROM message_blacklist WHERE account_id=' . $this->db->escapeNumber($receiverID) . ' AND blacklisted_id=' . $this->db->escapeNumber($this->getAccountID()) . ' LIMIT 1');
1390
-			if ($this->db->nextRecord())
1391
-				return;
1427
+			if ($this->db->nextRecord()) {
1428
+							return;
1429
+			}
1392 1430
 		}
1393 1431
 
1394 1432
 		$message = word_filter($message);
@@ -1469,32 +1507,36 @@  discard block
 block discarded – undo
1469 1507
 
1470 1508
 	public static function sendMessageFromAdmin($gameID, $receiverID, $message, $expires = false) {
1471 1509
 		//get expire time
1472
-		if ($expires === false)
1473
-			$expires = TIME + 86400 * 365;
1510
+		if ($expires === false) {
1511
+					$expires = TIME + 86400 * 365;
1512
+		}
1474 1513
 		// send him the message
1475 1514
 		self::doMessageSending(ACCOUNT_ID_ADMIN, $receiverID, $gameID, MSG_ADMIN, $message, $expires);
1476 1515
 	}
1477 1516
 
1478 1517
 	public static function sendMessageFromAllianceAmbassador($gameID, $receiverID, $message, $expires = false) {
1479 1518
 		//get expire time
1480
-		if ($expires === false)
1481
-			$expires = TIME + 86400 * 31;
1519
+		if ($expires === false) {
1520
+					$expires = TIME + 86400 * 31;
1521
+		}
1482 1522
 		// send him the message
1483 1523
 		self::doMessageSending(ACCOUNT_ID_ALLIANCE_AMBASSADOR, $receiverID, $gameID, MSG_ALLIANCE, $message, $expires);
1484 1524
 	}
1485 1525
 
1486 1526
 	public static function sendMessageFromCasino($gameID, $receiverID, $message, $expires = false) {
1487 1527
 		//get expire time
1488
-		if ($expires === false)
1489
-			$expires = TIME + 86400 * 7;
1528
+		if ($expires === false) {
1529
+					$expires = TIME + 86400 * 7;
1530
+		}
1490 1531
 		// send him the message
1491 1532
 		self::doMessageSending(ACCOUNT_ID_CASINO, $receiverID, $gameID, MSG_CASINO, $message, $expires);
1492 1533
 	}
1493 1534
 
1494 1535
 	public static function sendMessageFromRace($raceID, $gameID, $receiverID, $message, $expires = false) {
1495 1536
 		//get expire time
1496
-		if ($expires === false)
1497
-			$expires = TIME + 86400 * 5;
1537
+		if ($expires === false) {
1538
+					$expires = TIME + 86400 * 5;
1539
+		}
1498 1540
 		// send him the message
1499 1541
 		self::doMessageSending(ACCOUNT_ID_GROUP_RACES + $raceID, $receiverID, $gameID, MSG_POLITICAL, $message, $expires);
1500 1542
 	}
@@ -1537,11 +1579,11 @@  discard block
 block discarded – undo
1537 1579
 	public function setPlottedCourse(Distance $plottedCourse) {
1538 1580
 		$hadPlottedCourse = $this->hasPlottedCourse();
1539 1581
 		$this->plottedCourse = $plottedCourse;
1540
-		if ($this->plottedCourse->getTotalSectors() > 0)
1541
-			$this->db->query('REPLACE INTO player_plotted_course
1582
+		if ($this->plottedCourse->getTotalSectors() > 0) {
1583
+					$this->db->query('REPLACE INTO player_plotted_course
1542 1584
 				(account_id, game_id, course)
1543 1585
 				VALUES(' . $this->db->escapeNumber($this->getAccountID()) . ', ' . $this->db->escapeNumber($this->getGameID()) . ', ' . $this->db->escapeBinary(serialize($this->plottedCourse)) . ')');
1544
-		else if ($hadPlottedCourse) {
1586
+		} else if ($hadPlottedCourse) {
1545 1587
 			$this->deletePlottedCourse();
1546 1588
 		}
1547 1589
 	}
@@ -1551,12 +1593,14 @@  discard block
 block discarded – undo
1551 1593
 	}
1552 1594
 
1553 1595
 	public function isPartOfCourse($sectorOrSectorID) {
1554
-		if (!$this->hasPlottedCourse())
1555
-			return false;
1556
-		if ($sectorOrSectorID instanceof SmrSector)
1557
-			$sectorID = $sectorOrSectorID->getSectorID();
1558
-		else
1559
-			$sectorID = $sectorOrSectorID;
1596
+		if (!$this->hasPlottedCourse()) {
1597
+					return false;
1598
+		}
1599
+		if ($sectorOrSectorID instanceof SmrSector) {
1600
+					$sectorID = $sectorOrSectorID->getSectorID();
1601
+		} else {
1602
+					$sectorID = $sectorOrSectorID;
1603
+		}
1560 1604
 		return $this->getPlottedCourse()->isInPath($sectorID);
1561 1605
 	}
1562 1606
 
Please login to merge, or discard this patch.
lib/Default/DummyPlayer.class.php 2 patches
Braces   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -53,8 +53,9 @@  discard block
 block discarded – undo
53 53
 	}
54 54
 	
55 55
 	public function setAllianceID($ID) {
56
-		if($this->allianceID == $ID)
57
-			return;
56
+		if($this->allianceID == $ID) {
57
+					return;
58
+		}
58 59
 		$this->allianceID=$ID;
59 60
 	}
60 61
 	
@@ -93,8 +94,7 @@  discard block
 block discarded – undo
93 94
 		if($db->nextRecord()) {
94 95
 			$return = unserialize($db->getField('info'));
95 96
 			return $return;
96
-		}
97
-		else {
97
+		} else {
98 98
 			$return = new DummyPlayer();
99 99
 			return $return;
100 100
 		}
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -1,31 +1,31 @@  discard block
 block discarded – undo
1 1
 <?php declare(strict_types=1);
2 2
 
3 3
 class DummyPlayer extends AbstractSmrPlayer {
4
-	public function __construct($gameID=0,$playerName='Dummy',$raceID=1,$experience=1000,$alignment=100,$allianceID=0,$shipTypeID=60) {
4
+	public function __construct($gameID = 0, $playerName = 'Dummy', $raceID = 1, $experience = 1000, $alignment = 100, $allianceID = 0, $shipTypeID = 60) {
5 5
 		parent::__construct();
6 6
 		$this->accountID				= 0;
7
-		$this->gameID					= (int) $gameID;
8
-		$this->playerName				= (string) $playerName;
7
+		$this->gameID = (int)$gameID;
8
+		$this->playerName = (string)$playerName;
9 9
 		$this->playerID					= 0;
10 10
 		$this->sectorID					= 0;
11
-		$this->lastSectorID				= 0;
11
+		$this->lastSectorID = 0;
12 12
 		$this->turns					= 1000;
13
-		$this->newbieTurns				= 0;
13
+		$this->newbieTurns = 0;
14 14
 		$this->lastNewsUpdate			= 0;
15 15
 		$this->dead						= false;
16 16
 		$this->landedOnPlanet			= false;
17
-		$this->lastActive				= 0;
18
-		$this->lastCPLAction			= 0;
19
-		$this->raceID					= (int) $raceID;
20
-		$this->credits					= 0;
21
-		$this->experience				= (int) $experience;
22
-		$this->alignment				= (int) $alignment;
23
-		$this->militaryPayment			= 0;
24
-		$this->allianceID				= (int) $allianceID;
25
-		$this->shipID					= (int) $shipTypeID;
17
+		$this->lastActive = 0;
18
+		$this->lastCPLAction = 0;
19
+		$this->raceID = (int)$raceID;
20
+		$this->credits = 0;
21
+		$this->experience				= (int)$experience;
22
+		$this->alignment = (int)$alignment;
23
+		$this->militaryPayment = 0;
24
+		$this->allianceID				= (int)$allianceID;
25
+		$this->shipID					= (int)$shipTypeID;
26 26
 		$this->kills					= 0;
27 27
 		$this->deaths					= 0;
28
-		$this->lastPort					= 0;
28
+		$this->lastPort = 0;
29 29
 		$this->bank						= 0;
30 30
 		$this->zoom						= 0;
31 31
 		
@@ -53,9 +53,9 @@  discard block
 block discarded – undo
53 53
 	}
54 54
 	
55 55
 	public function setAllianceID($ID) {
56
-		if($this->allianceID == $ID)
56
+		if ($this->allianceID == $ID)
57 57
 			return;
58
-		$this->allianceID=$ID;
58
+		$this->allianceID = $ID;
59 59
 	}
60 60
 	
61 61
 	public function &killPlayerByPlayer(AbstractSmrPlayer $killer) {
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 		$db = new SmrMySqlDatabase();
82 82
 		$db->query('REPLACE INTO cached_dummys ' .
83 83
 					'(type, id, info) ' .
84
-					'VALUES (\'DummyPlayer\', '.$db->escapeString($this->getPlayerName()).', '.$db->escapeString($cache).')');	
84
+					'VALUES (\'DummyPlayer\', ' . $db->escapeString($this->getPlayerName()) . ', ' . $db->escapeString($cache) . ')');	
85 85
 		 unserialize($cache);
86 86
 	}
87 87
 	
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 		$db->query('SELECT info FROM cached_dummys
91 91
 					WHERE type = \'DummyPlayer\'
92 92
 						AND id = ' . $db->escapeString($name) . ' LIMIT 1');
93
-		if($db->nextRecord()) {
93
+		if ($db->nextRecord()) {
94 94
 			$return = unserialize($db->getField('info'));
95 95
 			return $return;
96 96
 		}
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 		$db->query('SELECT id FROM cached_dummys
106 106
 					WHERE type = \'DummyPlayer\'');
107 107
 		$dummyNames = array();
108
-		while($db->nextRecord()) {
108
+		while ($db->nextRecord()) {
109 109
 			$dummyNames[] = $db->getField('id');
110 110
 		}
111 111
 		return $dummyNames;
Please login to merge, or discard this patch.