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

Failed Conditions
Pull Request — master (#812)
by Dan
04:25
created
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   +17 added lines, -20 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;
@@ -566,8 +565,7 @@  discard block
 block discarded – undo
566 565
 		}
567 566
 		if (($key = array_search($goodID, $this->goodIDs['Buy'])) !== false) {
568 567
 			array_splice($this->goodIDs['Buy'], $key, 1);
569
-		}
570
-		elseif (($key = array_search($goodID, $this->goodIDs['Sell'])) !== false) {
568
+		} elseif (($key = array_search($goodID, $this->goodIDs['Sell'])) !== false) {
571 569
 			array_splice($this->goodIDs['Sell'], $key, 1);
572 570
 		}
573 571
 		
@@ -649,8 +647,7 @@  discard block
 block discarded – undo
649 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 ';
650 648
 			if ($trigger->hasAlliance()) {
651 649
 				$newsMessage .= 'members of ' . $trigger->getAllianceBBLink();
652
-			}
653
-			else {
650
+			} else {
654 651
 				$newsMessage .= $trigger->getBBLink();
655 652
 			}
656 653
 			
@@ -659,8 +656,7 @@  discard block
 block discarded – undo
659 656
 
660 657
 			if ($trigger->hasAlliance()) {
661 658
 				$newsMessage .= 'bounties of <span class="creds">' . $bounty . '</span> credits for the deaths of any raiding members of ' . $trigger->getAllianceBBLink();
662
-			}
663
-			else {
659
+			} else {
664 660
 				$newsMessage .= 'a bounty of <span class="creds">' . $bounty . '</span> credits for the death of ' . $trigger->getBBLink();
665 661
 			}
666 662
 			$newsMessage .= ' prior to the destruction of the port, or until federal forces arrive to defend the port.';
@@ -1005,8 +1001,9 @@  discard block
 block discarded – undo
1005 1001
 		 if ($transactionType == 'Buy') {
1006 1002
 			$relationsEffect = 2 - $relationsEffect;
1007 1003
 			return max($idealPrice, IFloor($idealPrice * $relationsEffect));
1008
-		 } else
1009
-			return min($idealPrice, ICeil($idealPrice * $relationsEffect));
1004
+		 } else {
1005
+		 			return min($idealPrice, ICeil($idealPrice * $relationsEffect));
1006
+		 }
1010 1007
 		}
1011 1008
 //		$range = .11 - .095;
1012 1009
 //		$rand = .095 + $range * mt_rand(0, 32767)/32767;
@@ -1069,8 +1066,7 @@  discard block
 block discarded – undo
1069 1066
 		if ($this->getCredits() > 0) {
1070 1067
 			$container = create_container('skeleton.php', 'port_payout_processing.php');
1071 1068
 			$container['PayoutType'] = 'Loot';
1072
-		}
1073
-		else {
1069
+		} else {
1074 1070
 			$container = create_container('skeleton.php', 'current_sector.php');
1075 1071
 			$container['msg'] = 'This port has already been looted.';
1076 1072
 		}
@@ -1141,9 +1137,9 @@  discard block
 block discarded – undo
1141 1137
 			if ($db->nextRecord()) {
1142 1138
 				self::$CACHE_CACHED_PORTS[$gameID][$sectorID][$accountID] = unserialize(gzuncompress($db->getField('port_info')));
1143 1139
 				self::$CACHE_CACHED_PORTS[$gameID][$sectorID][$accountID]->setCachedTime($db->getInt('visited'));
1140
+			} else {
1141
+							self::$CACHE_CACHED_PORTS[$gameID][$sectorID][$accountID] = false;
1144 1142
 			}
1145
-			else
1146
-				self::$CACHE_CACHED_PORTS[$gameID][$sectorID][$accountID] = false;
1147 1143
 		}
1148 1144
 		return self::$CACHE_CACHED_PORTS[$gameID][$sectorID][$accountID];
1149 1145
 	}
@@ -1189,8 +1185,7 @@  discard block
 block discarded – undo
1189 1185
 								', attack_started = ' . $this->db->escapeNumber($this->getAttackStarted()) .
1190 1186
 								', race_id = ' . $this->db->escapeNumber($this->getRaceID()) . '
1191 1187
 								WHERE ' . $this->SQL . ' LIMIT 1');
1192
-			}
1193
-			else {
1188
+			} else {
1194 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)
1195 1190
 								values
1196 1191
 								(' . $this->db->escapeNumber($this->getGameID()) .
@@ -1273,8 +1268,7 @@  discard block
 block discarded – undo
1273 1268
 						$armourDamage = $this->doArmourDamage(min($damage['MaxDamage'], $damage['Armour']));
1274 1269
 					}
1275 1270
 				}
1276
-			}
1277
-			else { //hit drones behind shields
1271
+			} else { //hit drones behind shields
1278 1272
 				$cdDamage = $this->doCDDamage(IFloor(min($damage['MaxDamage'], $damage['Armour']) * DRONES_BEHIND_SHIELDS_DAMAGE_PERCENT));
1279 1273
 			}
1280 1274
 		}
@@ -1370,8 +1364,11 @@  discard block
 block discarded – undo
1370 1364
 		
1371 1365
 		// News Entry
1372 1366
 		$news = $this->getDisplayName() . ' has been successfully raided by ';
1373
-		if ($killer->hasAlliance()) $news .= 'the members of <span class="yellow">' . $killer->getAllianceBBLink() . '</span>';
1374
-		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
+		}
1375 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) . ')');
1376 1373
 		// Killer gets a relations change and a bounty if port is taken
1377 1374
 		$return['KillerBounty'] = $killer->getExperience() * $this->getLevel();
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   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -227,8 +227,7 @@
 block discarded – undo
227 227
 				}
228 228
 			}
229 229
 			$string = substr($string, 0, -1);
230
-		}
231
-		else {
230
+		} else {
232 231
 			$string = $this->escape(implode($implodeString, $array), $autoQuotes, $quotes);
233 232
 		}
234 233
 		return $string;
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   +20 added lines, -36 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,8 +567,9 @@  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
+			}
585 573
 		}
586 574
 		if ($goodID === false) {
587 575
 			return $this->stockpile;
@@ -596,8 +584,7 @@  discard block
 block discarded – undo
596 584
 		if ($goodID === false) {
597 585
 			$stockpile = $this->getStockpile($goodID);
598 586
 			return count($stockpile) > 0 && max($stockpile) > 0;
599
-		}
600
-		else {
587
+		} else {
601 588
 			return $this->getStockpile($goodID) > 0;
602 589
 		}
603 590
 	}
@@ -831,8 +818,7 @@  discard block
 block discarded – undo
831 818
 				if ($amount != 0) {
832 819
 					$this->db->query('REPLACE INTO planet_has_cargo (game_id, sector_id, good_id, amount) ' .
833 820
 										 'VALUES(' . $this->db->escapeNumber($this->getGameID()) . ', ' . $this->db->escapeNumber($this->getSectorID()) . ', ' . $this->db->escapeNumber($id) . ', ' . $this->db->escapeNumber($amount) . ')');
834
-				}
835
-				else {
821
+				} else {
836 822
 					$this->db->query('DELETE FROM planet_has_cargo WHERE ' . $this->SQL . '
837 823
 										AND good_id = ' . $this->db->escapeNumber($id));
838 824
 				}
@@ -861,8 +847,7 @@  discard block
 block discarded – undo
861 847
 				if ($this->hasBuilding($id)) {
862 848
 					$this->db->query('REPLACE INTO planet_has_building (game_id, sector_id, construction_id, amount) ' .
863 849
 										'VALUES(' . $this->db->escapeNumber($this->gameID) . ', ' . $this->db->escapeNumber($this->sectorID) . ', ' . $this->db->escapeNumber($id) . ', ' . $this->db->escapeNumber($this->getBuilding($id)) . ')');
864
-				}
865
-				else {
850
+				} else {
866 851
 					$this->db->query('DELETE FROM planet_has_building WHERE ' . $this->SQL . '
867 852
 										AND construction_id = ' . $this->db->escapeNumber($id));
868 853
 				}
@@ -1236,8 +1221,7 @@  discard block
 block discarded – undo
1236 1221
 					}
1237 1222
 				}
1238 1223
 
1239
-			}
1240
-			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.
1241 1225
 				$cdDamage = $this->doCDDamage(IFloor(min($damage['MaxDamage'], $damage['Armour']) * DRONES_BEHIND_SHIELDS_DAMAGE_PERCENT), $delayed);
1242 1226
 			}
1243 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   +32 added lines, -35 removed lines patch added patch discarded remove patch
@@ -200,8 +200,7 @@  discard block
 block discarded – undo
200 200
 			$this->newbieWarning = $db->getBoolean('newbie_warning');
201 201
 			$this->nameChanged = $db->getBoolean('name_changed');
202 202
 			$this->combatDronesKamikazeOnMines = $db->getBoolean('combat_drones_kamikaze_on_mines');
203
-		}
204
-		else {
203
+		} else {
205 204
 			throw new PlayerNotFoundException('Invalid accountID: ' . $accountID . ' OR gameID:' . $gameID);
206 205
 		}
207 206
 	}
@@ -335,11 +334,9 @@  discard block
 block discarded – undo
335 334
 			$kickedBy->sendMessage($this->getAccountID(), MSG_PLAYER, 'You were kicked out of the alliance!', false);
336 335
 			$this->actionTaken('PlayerKicked', array('Alliance' => $alliance, 'Player' => $kickedBy));
337 336
 			$kickedBy->actionTaken('KickPlayer', array('Alliance' => $alliance, 'Player' => $this));
338
-		}
339
-		else if ($this->isAllianceLeader()) {
337
+		} else if ($this->isAllianceLeader()) {
340 338
 			$this->actionTaken('DisbandAlliance', array('Alliance' => $alliance));
341
-		}
342
-		else {
339
+		} else {
343 340
 			$this->actionTaken('LeaveAlliance', array('Alliance' => $alliance));
344 341
 			if ($alliance->getLeaderID() != 0 && $alliance->getLeaderID() != ACCOUNT_ID_NHL) {
345 342
 				$this->sendMessage($alliance->getLeaderID(), MSG_PLAYER, 'I left your alliance!', false);
@@ -367,7 +364,9 @@  discard block
 block discarded – undo
367 364
 			try {
368 365
 				$this->sendMessage($alliance->getLeaderID(), MSG_PLAYER, 'I joined your alliance!', false);
369 366
 			} catch (AccountNotFoundException $e) {
370
-				if ($alliance->getLeaderID() != ACCOUNT_ID_NHL) throw $e;
367
+				if ($alliance->getLeaderID() != ACCOUNT_ID_NHL) {
368
+					throw $e;
369
+				}
371 370
 			}
372 371
 
373 372
 			$roleID = ALLIANCE_ROLE_NEW_MEMBER;
@@ -500,7 +499,9 @@  discard block
 block discarded – undo
500 499
 
501 500
 	public function updateTurns() {
502 501
 		// is account validated?
503
-		if (!$this->getAccount()->isValidated()) return;
502
+		if (!$this->getAccount()->isValidated()) {
503
+			return;
504
+		}
504 505
 
505 506
 		// how many turns would he get right now?
506 507
 		$extraTurns = $this->getTurnsGained(TIME);
@@ -712,8 +713,7 @@  discard block
 block discarded – undo
712 713
 			$this->db->query('SELECT * FROM ship_has_name WHERE ' . $this->SQL . ' LIMIT 1');
713 714
 			if ($this->db->nextRecord()) {
714 715
 				$this->customShipName = $this->db->getField('ship_name');
715
-			}
716
-			else {
716
+			} else {
717 717
 				$this->customShipName = false;
718 718
 			}
719 719
 		}
@@ -731,8 +731,7 @@  discard block
 block discarded – undo
731 731
 				$this->knowledge['Nyx'] = $this->db->getInt('nyx');
732 732
 				$this->knowledge['Federation'] = 0;
733 733
 				$this->knowledge['Underground'] = 0;
734
-			}
735
-			else {
734
+			} else {
736 735
 				$this->knowledge['Erebus'] = 0;
737 736
 				$this->knowledge['Aether'] = 0;
738 737
 				$this->knowledge['Tartarus'] = 0;
@@ -859,8 +858,7 @@  discard block
 block discarded – undo
859 858
 		$return['KillerAlign'] = -$relation * $alignChangePerRelation; //Lose relations when killing a peaceful race
860 859
 		if ($return['KillerAlign'] > 0) {
861 860
 			$killer->increaseAlignment($return['KillerAlign']);
862
-		}
863
-		else {
861
+		} else {
864 862
 			$killer->decreaseAlignment(-$return['KillerAlign']);
865 863
 		}
866 864
 		// War setting gives them military pay
@@ -894,8 +892,7 @@  discard block
 block discarded – undo
894 892
 			// If the podded players alignment makes them deputy or member then set bounty
895 893
 			if ($this->getAlignment() >= 100) {
896 894
 				$return['BountyGained']['Type'] = 'HQ';
897
-			}
898
-			else if ($this->getAlignment() <= 100) {
895
+			} else if ($this->getAlignment() <= 100) {
899 896
 				$return['BountyGained']['Type'] = 'UG';
900 897
 			}
901 898
 
@@ -917,16 +914,14 @@  discard block
 block discarded – undo
917 914
 
918 915
 			if ($return['KillerAlign'] > 0) {
919 916
 				$killer->increaseHOF($return['KillerAlign'], array('Killing', 'NPC', 'Alignment', 'Gain'), HOF_PUBLIC);
920
-			}
921
-			else {
917
+			} else {
922 918
 				$killer->increaseHOF(-$return['KillerAlign'], array('Killing', 'NPC', 'Alignment', 'Loss'), HOF_PUBLIC);
923 919
 			}
924 920
 
925 921
 			$killer->increaseHOF($return['BountyGained']['Amount'], array('Killing', 'NPC', 'Money', 'Bounty Gained'), HOF_PUBLIC);
926 922
 
927 923
 			$killer->increaseHOF(1, array('Killing', 'NPC Kills'), HOF_PUBLIC);
928
-		}
929
-		else {
924
+		} else {
930 925
 			$killer->increaseHOF($return['KillerExp'], array('Killing', 'Experience', 'Gained'), HOF_PUBLIC);
931 926
 			$killer->increaseHOF($this->getExperience(), array('Killing', 'Experience', 'Of Traders Killed'), HOF_PUBLIC);
932 927
 
@@ -938,8 +933,7 @@  discard block
 block discarded – undo
938 933
 
939 934
 			if ($return['KillerAlign'] > 0) {
940 935
 				$killer->increaseHOF($return['KillerAlign'], array('Killing', 'Alignment', 'Gain'), HOF_PUBLIC);
941
-			}
942
-			else {
936
+			} else {
943 937
 				$killer->increaseHOF(-$return['KillerAlign'], array('Killing', 'Alignment', 'Loss'), HOF_PUBLIC);
944 938
 			}
945 939
 
@@ -947,8 +941,7 @@  discard block
 block discarded – undo
947 941
 
948 942
 			if ($this->getShip()->getAttackRatingWithMaxCDs() <= MAX_ATTACK_RATING_NEWBIE && $this->hasNewbieStatus() && !$killer->hasNewbieStatus()) { //Newbie kill
949 943
 				$killer->increaseHOF(1, array('Killing', 'Newbie Kills'), HOF_PUBLIC);
950
-			}
951
-			else {
944
+			} else {
952 945
 				$killer->increaseKills(1);
953 946
 				$killer->increaseHOF(1, array('Killing', 'Kills'), HOF_PUBLIC);
954 947
 
@@ -1133,8 +1126,7 @@  discard block
 block discarded – undo
1133 1126
 					if ($bounty['Amount'] > 0 || $bounty['SmrCredits'] > 0) {
1134 1127
 						$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']) . ')');
1135 1128
 					}
1136
-				}
1137
-				else {
1129
+				} else {
1138 1130
 					if ($bounty['Amount'] > 0 || $bounty['SmrCredits'] > 0) {
1139 1131
 						$this->db->query('UPDATE bounty
1140 1132
 							SET amount=' . $this->db->escapeNumber($bounty['Amount']) . ',
@@ -1173,15 +1165,13 @@  discard block
 block discarded – undo
1173 1165
 			$tempTypeList[] = $type;
1174 1166
 			if (is_array($hofChanged)) {
1175 1167
 				$this->doHOFSave($hofChanged, $tempTypeList);
1176
-			}
1177
-			else {
1168
+			} else {
1178 1169
 				$amount = $this->getHOF($tempTypeList);
1179 1170
 				if ($hofChanged == self::HOF_NEW) {
1180 1171
 					if ($amount > 0) {
1181 1172
 						$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) . ')');
1182 1173
 					}
1183
-				}
1184
-				else if ($hofChanged == self::HOF_CHANGED) {
1174
+				} else if ($hofChanged == self::HOF_CHANGED) {
1185 1175
 	//				if($amount > 0)
1186 1176
 						$this->db->query('UPDATE player_hof
1187 1177
 							SET amount=' . $this->db->escapeNumber($amount) . '
@@ -1292,11 +1282,12 @@  discard block
 block discarded – undo
1292 1282
 			$this->tickers = array();
1293 1283
 			//get ticker info
1294 1284
 			$this->db->query('SELECT type,time,expires,recent FROM player_has_ticker WHERE ' . $this->SQL . ' AND expires > ' . $this->db->escapeNumber(TIME));
1295
-			while ($this->db->nextRecord())
1296
-				$this->tickers[$this->db->getField('type')] = array('Type' => $this->db->getField('type'),
1285
+			while ($this->db->nextRecord()) {
1286
+							$this->tickers[$this->db->getField('type')] = array('Type' => $this->db->getField('type'),
1297 1287
 																				'Time' => $this->db->getInt('time'),
1298 1288
 																				'Expires' => $this->db->getInt('expires'),
1299 1289
 																				'Recent' => $this->db->getField('recent'));
1290
+			}
1300 1291
 		}
1301 1292
 		return $this->tickers;
1302 1293
 	}
@@ -1318,9 +1309,15 @@  discard block
 block discarded – undo
1318 1309
 	}
1319 1310
 
1320 1311
 	public function getTurnsLevel() {
1321
-		if (!$this->hasTurns()) return 'NONE';
1322
-		if ($this->getTurns() <= 25) return 'LOW';
1323
-		if ($this->getTurns() <= 75) return 'MEDIUM';
1312
+		if (!$this->hasTurns()) {
1313
+			return 'NONE';
1314
+		}
1315
+		if ($this->getTurns() <= 25) {
1316
+			return 'LOW';
1317
+		}
1318
+		if ($this->getTurns() <= 75) {
1319
+			return 'MEDIUM';
1320
+		}
1324 1321
 		return 'HIGH';
1325 1322
 	}
1326 1323
 
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.
lib/Default/SocialLogins/Twitter.class.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
35 35
 		}
36 36
 		$helper = self::getTwitterObj($_SESSION['TwitterToken']);
37 37
 		$accessToken = $helper->oauth('oauth/access_token',
38
-		                              ['oauth_verifier' => $_REQUEST['oauth_verifier']]);
38
+									  ['oauth_verifier' => $_REQUEST['oauth_verifier']]);
39 39
 		$auth = self::getTwitterObj($accessToken);
40 40
 		$userInfo = $auth->get('account/verify_credentials', ['include_email' => 'true']);
41 41
 		if ($auth->getLastHttpCode() == 200) {
Please login to merge, or discard this patch.
htdocs/login.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -50,7 +50,6 @@
 block discarded – undo
50 50
 	$template->assign('Body', 'login/login.php');
51 51
 	$template->display('login/skeleton.php');
52 52
 
53
-}
54
-catch (Throwable $e) {
53
+} catch (Throwable $e) {
55 54
 	handleException($e);
56 55
 }
Please login to merge, or discard this patch.