Scrutinizer GitHub App not installed

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

Install GitHub App

Passed
Pull Request — master (#814)
by Dan
04:26
created
engine/Default/shop_hardware_processing.php 1 patch
Braces   +10 added lines, -5 removed lines patch added patch discarded remove patch
@@ -32,11 +32,16 @@
 block discarded – undo
32 32
 	$ship->increaseHardware($hardware_id, $amount);
33 33
 
34 34
 	//HoF
35
-	if ($hardware_id == HARDWARE_COMBAT) $player->increaseHOF($amount, array('Forces', 'Bought', 'Combat Drones'), HOF_ALLIANCE);
36
-	if ($hardware_id == HARDWARE_SCOUT) $player->increaseHOF($amount, array('Forces', 'Bought', 'Scout Drones'), HOF_ALLIANCE);
37
-	if ($hardware_id == HARDWARE_MINE) $player->increaseHOF($amount, array('Forces', 'Bought', 'Mines'), HOF_ALLIANCE);
38
-}
39
-elseif ($action == 'Sell') {
35
+	if ($hardware_id == HARDWARE_COMBAT) {
36
+		$player->increaseHOF($amount, array('Forces', 'Bought', 'Combat Drones'), HOF_ALLIANCE);
37
+	}
38
+	if ($hardware_id == HARDWARE_SCOUT) {
39
+		$player->increaseHOF($amount, array('Forces', 'Bought', 'Scout Drones'), HOF_ALLIANCE);
40
+	}
41
+	if ($hardware_id == HARDWARE_MINE) {
42
+		$player->increaseHOF($amount, array('Forces', 'Bought', 'Mines'), HOF_ALLIANCE);
43
+	}
44
+	} elseif ($action == 'Sell') {
40 45
 	// We only allow selling combat drones
41 46
 	if ($hardware_id != HARDWARE_COMBAT) {
42 47
 		throw new Exception('This item cannot be sold!');
Please login to merge, or discard this patch.
lib/Default/ChessPiece.class.php 1 patch
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -91,8 +91,7 @@  discard block
 block discarded – undo
91 91
 						}
92 92
 					}
93 93
 				}
94
-			}
95
-			elseif ($this->pieceID == self::KING) {
94
+			} elseif ($this->pieceID == self::KING) {
96 95
 				for ($i = -1; $i < 2; $i++) {
97 96
 					for ($j = -1; $j < 2; $j++) {
98 97
 						if ($i != 0 || $j != 0) {
@@ -114,8 +113,7 @@  discard block
 block discarded – undo
114 113
 						$this->addMove($this->x + 2, $this->y, $board, $moves, $hasMoved, $attackingCheck);
115 114
 					}
116 115
 				}
117
-			}
118
-			elseif ($this->pieceID == self::QUEEN) {
116
+			} elseif ($this->pieceID == self::QUEEN) {
119 117
 				$moveX = $this->x;
120 118
 				$moveY = $this->y;
121 119
 				while ($this->addMove(--$moveX, $moveY, $board, $moves, $hasMoved, $attackingCheck) && $board[$moveY][$moveX] == null); //Left
@@ -140,8 +138,7 @@  discard block
 block discarded – undo
140 138
 				$moveX = $this->x;
141 139
 				$moveY = $this->y;
142 140
 				while ($this->addMove(++$moveX, ++$moveY, $board, $moves, $hasMoved, $attackingCheck) && $board[$moveY][$moveX] == null); //Up-Left
143
-			}
144
-			elseif ($this->pieceID == self::ROOK) {
141
+			} elseif ($this->pieceID == self::ROOK) {
145 142
 				$moveX = $this->x;
146 143
 				$moveY = $this->y;
147 144
 				while ($this->addMove(--$moveX, $moveY, $board, $moves, $hasMoved, $attackingCheck) && $board[$moveY][$moveX] == null); //Left
@@ -154,8 +151,7 @@  discard block
 block discarded – undo
154 151
 				$moveX = $this->x;
155 152
 				$moveY = $this->y;
156 153
 				while ($this->addMove($moveX, --$moveY, $board, $moves, $hasMoved, $attackingCheck) && $board[$moveY][$moveX] == null); //Down
157
-			}
158
-			elseif ($this->pieceID == self::BISHOP) {
154
+			} elseif ($this->pieceID == self::BISHOP) {
159 155
 				$moveX = $this->x;
160 156
 				$moveY = $this->y;
161 157
 				while ($this->addMove(--$moveX, --$moveY, $board, $moves, $hasMoved, $attackingCheck) && $board[$moveY][$moveX] == null); //Up-Left
@@ -168,8 +164,7 @@  discard block
 block discarded – undo
168 164
 				$moveX = $this->x;
169 165
 				$moveY = $this->y;
170 166
 				while ($this->addMove(++$moveX, ++$moveY, $board, $moves, $hasMoved, $attackingCheck) && $board[$moveY][$moveX] == null); //Up-Left
171
-			}
172
-			elseif ($this->pieceID == self::KNIGHT) {
167
+			} elseif ($this->pieceID == self::KNIGHT) {
173 168
 				$moveX = $this->x - 1;
174 169
 				$moveY = $this->y - 2;
175 170
 				$this->addMove($moveX, $moveY, $board, $moves, $hasMoved, $attackingCheck); //2up-left
Please login to merge, or discard this patch.
lib/Default/ChessGame.class.php 1 patch
Spacing   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -142,16 +142,16 @@  discard block
 block discarded – undo
142 142
 		$this->resetHasMoved();
143 143
 
144 144
 		try {
145
-			while($db->nextRecord()) {
146
-				if($debugInfo === true) {
145
+			while ($db->nextRecord()) {
146
+				if ($debugInfo === true) {
147 147
 					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;
148 148
 				}
149
-				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())) {
149
+				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 150
 					break;
151 151
 				}
152 152
 			}
153
-		} catch(Exception $e) {
154
-			if($debugInfo === true) {
153
+		} catch (Exception $e) {
154
+			if ($debugInfo === true) {
155 155
 				echo $e->getMessage() . EOL . $e->getTraceAsString() . EOL;
156 156
 			}
157 157
 			// We probably tried an invalid move - move on.
@@ -177,19 +177,19 @@  discard block
 block discarded – undo
177 177
 	}
178 178
 
179 179
 	public function getMoves() {
180
-		if($this->moves == null) {
180
+		if ($this->moves == null) {
181 181
 			$this->db->query('SELECT * FROM chess_game_moves WHERE chess_game_id = ' . $this->db->escapeNumber($this->chessGameID) . ' ORDER BY move_id;');
182 182
 			$this->moves = array();
183 183
 			$mate = false;
184
-			while($this->db->nextRecord()) {
184
+			while ($this->db->nextRecord()) {
185 185
 				$pieceTakenID = $this->db->getField('piece_taken') == null ? null : $this->db->getInt('piece_taken');
186 186
 				$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'));
187 187
 				$mate = $this->db->getField('checked') == 'MATE';
188 188
 			}
189
-			if(!$mate && $this->hasEnded()) {
190
-				if($this->getWinner() != 0) {
189
+			if (!$mate && $this->hasEnded()) {
190
+				if ($this->getWinner() != 0) {
191 191
 					$this->moves[] = ($this->getWinner() == $this->getWhiteID() ? 'Black' : 'White') . ' Resigned.';
192
-				} elseif(count($this->moves) < 2) {
192
+				} elseif (count($this->moves) < 2) {
193 193
 					$this->moves[] = 'Game Cancelled.';
194 194
 				} else {
195 195
 					$this->moves[] = 'Game Drawn.';
@@ -201,29 +201,29 @@  discard block
 block discarded – undo
201 201
 
202 202
 	public function getFENString() {
203 203
 		$fen = '';
204
-		$board =& $this->getBoard();
204
+		$board = & $this->getBoard();
205 205
 		$blanks = 0;
206
-		for($y=0; $y < 8; $y++) {
207
-			if($y > 0) {
206
+		for ($y = 0; $y < 8; $y++) {
207
+			if ($y > 0) {
208 208
 				$fen .= '/';
209 209
 			}
210
-			for($x=0; $x < 8; $x++) {
211
-				if($board[$y][$x] == null) {
210
+			for ($x = 0; $x < 8; $x++) {
211
+				if ($board[$y][$x] == null) {
212 212
 					$blanks++;
213 213
 				} else {
214
-					if($blanks > 0) {
214
+					if ($blanks > 0) {
215 215
 						$fen .= $blanks;
216 216
 						$blanks = 0;
217 217
 					}
218 218
 					$fen .= $board[$y][$x]->getPieceLetter();
219 219
 				}
220 220
 			}
221
-			if($blanks > 0) {
221
+			if ($blanks > 0) {
222 222
 				$fen .= $blanks;
223 223
 				$blanks = 0;
224 224
 			}
225 225
 		}
226
-		switch($this->getCurrentTurnColour()) {
226
+		switch ($this->getCurrentTurnColour()) {
227 227
 			case self::PLAYER_WHITE:
228 228
 				$fen .= ' w ';
229 229
 			break;
@@ -364,62 +364,62 @@  discard block
 block discarded – undo
364 364
 		// This move will be set as the most recent move
365 365
 		$this->lastMove = [
366 366
 			'From' => ['X' => $startX, 'Y' => $startY],
367
-			'To'   => ['X' => $endX,   'Y' => $endY],
367
+			'To'   => ['X' => $endX, 'Y' => $endY],
368 368
 		];
369 369
 
370 370
 		$otherPlayerColour = self::getOtherColour($playerColour);
371
-		if($pieceID == ChessPiece::KING) {
371
+		if ($pieceID == ChessPiece::KING) {
372 372
 			$this->hasMoved[$playerColour][ChessPiece::KING] = true;
373 373
 		}
374 374
 		// Check if the piece moving is a rook and mark it as moved to stop castling.
375
-		if($pieceID == ChessPiece::ROOK && ($startX == 0 || $startX == 7) && ($startY == ($playerColour == self::PLAYER_WHITE ? 7 : 0))) {
376
-			$this->hasMoved[$playerColour][ChessPiece::ROOK][$startX==0?'Queen':'King'] = true;
375
+		if ($pieceID == ChessPiece::ROOK && ($startX == 0 || $startX == 7) && ($startY == ($playerColour == self::PLAYER_WHITE ? 7 : 0))) {
376
+			$this->hasMoved[$playerColour][ChessPiece::ROOK][$startX == 0 ? 'Queen' : 'King'] = true;
377 377
 		}
378 378
 		// 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.
379
-		if($pieceTaken == ChessPiece::ROOK && ($endX == 0 || $endX == 7) && $endY == ($otherPlayerColour == self::PLAYER_WHITE ? 7 : 0)) {
380
-			$this->hasMoved[$otherPlayerColour][ChessPiece::ROOK][$endX==0?'Queen':'King'] = true;
379
+		if ($pieceTaken == ChessPiece::ROOK && ($endX == 0 || $endX == 7) && $endY == ($otherPlayerColour == self::PLAYER_WHITE ? 7 : 0)) {
380
+			$this->hasMoved[$otherPlayerColour][ChessPiece::ROOK][$endX == 0 ? 'Queen' : 'King'] = true;
381 381
 		}
382
-		if($pieceID == ChessPiece::PAWN && ($startY == 1 || $startY == 6) && ($endY == 3 || $endY == 4)) {
382
+		if ($pieceID == ChessPiece::PAWN && ($startY == 1 || $startY == 6) && ($endY == 3 || $endY == 4)) {
383 383
 			$this->hasMoved[ChessPiece::PAWN] = array($endX, $endY);
384 384
 		} else {
385
-			$this->hasMoved[ChessPiece::PAWN] = array(-1,-1);
385
+			$this->hasMoved[ChessPiece::PAWN] = array(-1, -1);
386 386
 		}
387 387
 		return ($castling == 'Queen' ? '0-0-0' : ($castling == 'King' ? '0-0' : ''))
388 388
 			. ChessPiece::getSymbolForPiece($pieceID, $playerColour)
389
-			. chr(ord('a')+$startX)
390
-			. (8-$startY)
389
+			. chr(ord('a') + $startX)
390
+			. (8 - $startY)
391 391
 			. ' '
392 392
 			. ($pieceTaken == null ? '' : ChessPiece::getSymbolForPiece($pieceTaken, $otherPlayerColour))
393
-			. chr(ord('a')+$endX)
394
-			. (8-$endY)
393
+			. chr(ord('a') + $endX)
394
+			. (8 - $endY)
395 395
 			. ($promotionPieceID == null ? '' : ChessPiece::getSymbolForPiece($promotionPieceID, $playerColour))
396 396
 			. ' '
397
-			. ($checking == null ? '' : ($checking == 'CHECK' ? '+' : '++') )
397
+			. ($checking == null ? '' : ($checking == 'CHECK' ? '+' : '++'))
398 398
 			. ($enPassant ? ' e.p.' : '');
399 399
 	}
400 400
 
401 401
 	public function isCheckmated($colour) {
402 402
 		$king = null;
403
-		foreach($this->board as $row) {
404
-			foreach($row as $piece) {
405
-				if($piece != null && $piece->pieceID == ChessPiece::KING && $piece->colour == $colour) {
403
+		foreach ($this->board as $row) {
404
+			foreach ($row as $piece) {
405
+				if ($piece != null && $piece->pieceID == ChessPiece::KING && $piece->colour == $colour) {
406 406
 					$king = $piece;
407 407
 					break;
408 408
 				}
409 409
 			}
410 410
 		}
411
-		if($king == null) {
411
+		if ($king == null) {
412 412
 			throw new Exception('Could not find the king: game id = ' . $this->chessGameID);
413 413
 		}
414
-		if(!self::isPlayerChecked($this->board, $this->getHasMoved(), $colour)) {
414
+		if (!self::isPlayerChecked($this->board, $this->getHasMoved(), $colour)) {
415 415
 			return false;
416 416
 		}
417
-		foreach($this->board as $row) {
418
-			foreach($row as $piece) {
419
-				if($piece != null && $piece->colour == $colour) {
417
+		foreach ($this->board as $row) {
418
+			foreach ($row as $piece) {
419
+				if ($piece != null && $piece->colour == $colour) {
420 420
 					$moves = $piece->getPossibleMoves($this->board, $this->getHasMoved());
421 421
 					//There are moves we can make, we are clearly not checkmated.
422
-					if(count($moves) > 0) {
422
+					if (count($moves) > 0) {
423 423
 						return false;
424 424
 					}
425 425
 				}
@@ -449,72 +449,72 @@  discard block
 block discarded – undo
449 449
 	}
450 450
 
451 451
 	public static function movePiece(array &$board, array &$hasMoved, $x, $y, $toX, $toY, $pawnPromotionPiece = ChessPiece::QUEEN) {
452
-		if(!self::isValidCoord($x, $y, $board)) {
452
+		if (!self::isValidCoord($x, $y, $board)) {
453 453
 			throw new Exception('Invalid from coordinates, x=' . $x . ', y=' . $y);
454 454
 		}
455
-		if(!self::isValidCoord($toX, $toY, $board)) {
455
+		if (!self::isValidCoord($toX, $toY, $board)) {
456 456
 			throw new Exception('Invalid to coordinates, x=' . $toX . ', y=' . $toY);
457 457
 		}
458 458
 		$pieceTaken = $board[$toY][$toX];
459 459
 		$board[$toY][$toX] = $board[$y][$x];
460
-		$p =& $board[$toY][$toX];
460
+		$p = & $board[$toY][$toX];
461 461
 		$board[$y][$x] = null;
462
-		if($p == null) {
462
+		if ($p == null) {
463 463
 			throw new Exception('Trying to move non-existent piece: ' . var_export($board, true));
464 464
 		}
465 465
 		$p->setX($toX);
466 466
 		$p->setY($toY);
467 467
 
468 468
 		$oldPawnMovement = $hasMoved[ChessPiece::PAWN];
469
-		$nextPawnMovement = array(-1,-1);
469
+		$nextPawnMovement = array(-1, -1);
470 470
 		$castling = false;
471 471
 		$enPassant = false;
472 472
 		$rookMoved = false;
473 473
 		$rookTaken = false;
474 474
 		$pawnPromotion = false;
475
-		if($p->pieceID == ChessPiece::KING) {
475
+		if ($p->pieceID == ChessPiece::KING) {
476 476
 			//Castling?
477 477
 			$castling = self::isCastling($x, $toX);
478
-			if($castling !== false) {
478
+			if ($castling !== false) {
479 479
 				$hasMoved[$p->colour][ChessPiece::KING] = true;
480 480
 				$hasMoved[$p->colour][ChessPiece::ROOK][$castling['Type']] = true;
481
-				if($board[$y][$castling['X']] == null) {
481
+				if ($board[$y][$castling['X']] == null) {
482 482
 					throw new Exception('Cannot castle with non-existent castle.');
483 483
 				}
484 484
 				$board[$toY][$castling['ToX']] = $board[$y][$castling['X']];
485 485
 				$board[$toY][$castling['ToX']]->setX($castling['ToX']);
486 486
 				$board[$y][$castling['X']] = null;
487 487
 			}
488
-		} elseif($p->pieceID == ChessPiece::PAWN) {
489
-			if($toY == 0 || $toY == 7) {
488
+		} elseif ($p->pieceID == ChessPiece::PAWN) {
489
+			if ($toY == 0 || $toY == 7) {
490 490
 				$pawnPromotion = $p->promote($pawnPromotionPiece, $board);
491 491
 			}
492 492
 			//Double move to track?
493
-			elseif(($y == 1 || $y == 6) && ($toY == 3 || $toY == 4)) {
493
+			elseif (($y == 1 || $y == 6) && ($toY == 3 || $toY == 4)) {
494 494
 				$nextPawnMovement = array($toX, $toY);
495 495
 			}
496 496
 			//En passant?
497
-			elseif($hasMoved[ChessPiece::PAWN][0] == $toX &&
497
+			elseif ($hasMoved[ChessPiece::PAWN][0] == $toX &&
498 498
 					($hasMoved[ChessPiece::PAWN][1] == 3 && $toY == 2 || $hasMoved[ChessPiece::PAWN][1] == 4 && $toY == 5)) {
499 499
 				$enPassant = true;
500 500
 				$pieceTaken = $board[$hasMoved[ChessPiece::PAWN][1]][$hasMoved[ChessPiece::PAWN][0]];
501
-				if($board[$hasMoved[ChessPiece::PAWN][1]][$hasMoved[ChessPiece::PAWN][0]] == null) {
501
+				if ($board[$hasMoved[ChessPiece::PAWN][1]][$hasMoved[ChessPiece::PAWN][0]] == null) {
502 502
 					throw new Exception('Cannot en passant a non-existent pawn.');
503 503
 				}
504 504
 				$board[$hasMoved[ChessPiece::PAWN][1]][$hasMoved[ChessPiece::PAWN][0]] = null;
505 505
 			}
506
-		} elseif($p->pieceID == ChessPiece::ROOK && ($x == 0 || $x == 7) && $y == ($p->colour == self::PLAYER_WHITE ? 7 : 0)) {
506
+		} elseif ($p->pieceID == ChessPiece::ROOK && ($x == 0 || $x == 7) && $y == ($p->colour == self::PLAYER_WHITE ? 7 : 0)) {
507 507
 			//Rook moved?
508
-			if($hasMoved[$p->colour][ChessPiece::ROOK][$x==0?'Queen':'King'] === false) {
508
+			if ($hasMoved[$p->colour][ChessPiece::ROOK][$x == 0 ? 'Queen' : 'King'] === false) {
509 509
 				// We set rook moved in here as it's used for move info.
510
-				$rookMoved = $x==0?'Queen':'King';
510
+				$rookMoved = $x == 0 ? 'Queen' : 'King';
511 511
 				$hasMoved[$p->colour][ChessPiece::ROOK][$rookMoved] = true;
512 512
 			}
513 513
 		}
514 514
 		// 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.
515
-		if($pieceTaken != null && $pieceTaken->pieceID == ChessPiece::ROOK && ($toX == 0 || $toX == 7) && $toY == ($pieceTaken->colour == self::PLAYER_WHITE ? 7 : 0)) {
516
-			if($hasMoved[$pieceTaken->colour][ChessPiece::ROOK][$toX==0?'Queen':'King'] === false) {
517
-				$rookTaken = $toX==0?'Queen':'King';
515
+		if ($pieceTaken != null && $pieceTaken->pieceID == ChessPiece::ROOK && ($toX == 0 || $toX == 7) && $toY == ($pieceTaken->colour == self::PLAYER_WHITE ? 7 : 0)) {
516
+			if ($hasMoved[$pieceTaken->colour][ChessPiece::ROOK][$toX == 0 ? 'Queen' : 'King'] === false) {
517
+				$rookTaken = $toX == 0 ? 'Queen' : 'King';
518 518
 				$hasMoved[$pieceTaken->colour][ChessPiece::ROOK][$rookTaken] = true;
519 519
 			}
520 520
 		}
@@ -531,18 +531,18 @@  discard block
 block discarded – undo
531 531
 	}
532 532
 
533 533
 	public static function undoMovePiece(array &$board, array &$hasMoved, $x, $y, $toX, $toY, $moveInfo) {
534
-		if(!self::isValidCoord($x, $y, $board)) {
534
+		if (!self::isValidCoord($x, $y, $board)) {
535 535
 			throw new Exception('Invalid from coordinates, x=' . $x . ', y=' . $y);
536 536
 		}
537
-		if(!self::isValidCoord($toX, $toY, $board)) {
537
+		if (!self::isValidCoord($toX, $toY, $board)) {
538 538
 			throw new Exception('Invalid to coordinates, x=' . $toX . ', y=' . $toY);
539 539
 		}
540
-		if($board[$y][$x] != null) {
540
+		if ($board[$y][$x] != null) {
541 541
 			throw new Exception('Undoing move onto another piece? x=' . $x . ', y=' . $y);
542 542
 		}
543 543
 		$board[$y][$x] = $board[$toY][$toX];
544
-		$p =& $board[$y][$x];
545
-		if($p == null) {
544
+		$p = & $board[$y][$x];
545
+		if ($p == null) {
546 546
 			throw new Exception('Trying to undo move of a non-existent piece: ' . var_export($board, true));
547 547
 		}
548 548
 		$board[$toY][$toX] = $moveInfo['PieceTaken'];
@@ -563,24 +563,24 @@  discard block
 block discarded – undo
563 563
 				$board[$y][$castling['X']]->setX($castling['X']);
564 564
 				$board[$toY][$castling['ToX']] = null;
565 565
 			}
566
-		} elseif($moveInfo['EnPassant'] === true) {
566
+		} elseif ($moveInfo['EnPassant'] === true) {
567 567
 			$board[$toY][$toX] = null;
568 568
 			$board[$hasMoved[ChessPiece::PAWN][1]][$hasMoved[ChessPiece::PAWN][0]] = $moveInfo['PieceTaken'];
569
-		} elseif($moveInfo['RookMoved'] !== false) {
569
+		} elseif ($moveInfo['RookMoved'] !== false) {
570 570
 			$hasMoved[$p->colour][ChessPiece::ROOK][$moveInfo['RookMoved']] = false;
571 571
 		}
572
-		if($moveInfo['RookTaken'] !== false) {
572
+		if ($moveInfo['RookTaken'] !== false) {
573 573
 			$hasMoved[$moveInfo['PieceTaken']->colour][ChessPiece::ROOK][$moveInfo['RookTaken']] = false;
574 574
 		}
575 575
 	}
576 576
 
577 577
 	public function tryAlgebraicMove($move) {
578
-		if(strlen($move) != 4 && strlen($move) != 5) {
578
+		if (strlen($move) != 4 && strlen($move) != 5) {
579 579
 			throw new Exception('Move of length "' . strlen($move) . '" is not valid, full move: ' . $move);
580 580
 		}
581 581
 		$aVal = ord('a');
582 582
 		$hVal = ord('h');
583
-		if(ord($move[0]) < $aVal || ord($move[2]) < $aVal
583
+		if (ord($move[0]) < $aVal || ord($move[2]) < $aVal
584 584
 				|| ord($move[0]) > $hVal || ord($move[2]) > $hVal
585 585
 				|| $move[1] < 1 || $move[3] < 1
586 586
 				|| $move[1] > 8 || $move[3] > 8) {
@@ -591,73 +591,73 @@  discard block
 block discarded – undo
591 591
 		$toX = ord($move[2]) - $aVal;
592 592
 		$toY = 8 - $move[3];
593 593
 		$pawnPromotionPiece = null;
594
-		if(isset($move[4])) {
594
+		if (isset($move[4])) {
595 595
 			$pawnPromotionPiece = ChessPiece::getPieceForLetter($move[4]);
596 596
 		}
597 597
 		return $this->tryMove($x, $y, $toX, $toY, $this->getCurrentTurnAccountID(), $pawnPromotionPiece);
598 598
 	}
599 599
 
600 600
 	public function tryMove($x, $y, $toX, $toY, $forAccountID, $pawnPromotionPiece) {
601
-		if($this->hasEnded()) {
601
+		if ($this->hasEnded()) {
602 602
 			return 5;
603 603
 		}
604
-		if($this->getCurrentTurnAccountID() != $forAccountID) {
604
+		if ($this->getCurrentTurnAccountID() != $forAccountID) {
605 605
 			return 4;
606 606
 		}
607 607
 		$lastTurnPlayer = $this->getCurrentTurnPlayer();
608 608
 		$this->getBoard();
609 609
 		$p = $this->board[$y][$x];
610
-		if($p == null || $p->colour != $this->getColourForAccountID($forAccountID)) {
610
+		if ($p == null || $p->colour != $this->getColourForAccountID($forAccountID)) {
611 611
 			return 2;
612 612
 		}
613 613
 
614 614
 		$moves = $p->getPossibleMoves($this->board, $this->getHasMoved(), $forAccountID);
615
-		foreach($moves as $move) {
616
-			if($move[0]==$toX && $move[1]==$toY) {
615
+		foreach ($moves as $move) {
616
+			if ($move[0] == $toX && $move[1] == $toY) {
617 617
 				$chessType = $this->isNPCGame() ? 'Chess (NPC)' : 'Chess';
618 618
 				$currentPlayer = $this->getCurrentTurnPlayer();
619 619
 
620 620
 				$moveInfo = ChessGame::movePiece($this->board, $this->getHasMoved(), $x, $y, $toX, $toY, $pawnPromotionPiece);
621 621
 
622 622
 				//We have taken the move, we should refresh $p
623
-				$p =& $this->board[$toY][$toX];
623
+				$p = & $this->board[$toY][$toX];
624 624
 
625 625
 				$pieceTakenID = null;
626
-				if($moveInfo['PieceTaken'] != null) {
626
+				if ($moveInfo['PieceTaken'] != null) {
627 627
 					$pieceTakenID = $moveInfo['PieceTaken']->pieceID;
628
-					if($moveInfo['PieceTaken']->pieceID == ChessPiece::KING) {
628
+					if ($moveInfo['PieceTaken']->pieceID == ChessPiece::KING) {
629 629
 						throw new Exception('King was taken.');
630 630
 					}
631 631
 				}
632 632
 
633 633
 				$pieceID = $p->pieceID;
634 634
 				$pieceNo = $p->pieceNo;
635
-				if($moveInfo['PawnPromotion'] !== false) {
635
+				if ($moveInfo['PawnPromotion'] !== false) {
636 636
 					$p->pieceID = $moveInfo['PawnPromotion']['PieceID'];
637 637
 					$p->pieceNo = $moveInfo['PawnPromotion']['PieceNo'];
638 638
 				}
639 639
 
640 640
 				$checking = null;
641
-				if($p->isAttacking($this->board, $this->getHasMoved(), true)) {
641
+				if ($p->isAttacking($this->board, $this->getHasMoved(), true)) {
642 642
 					$checking = 'CHECK';
643 643
 				}
644
-				if($this->isCheckmated(self::getOtherColour($p->colour))) {
644
+				if ($this->isCheckmated(self::getOtherColour($p->colour))) {
645 645
 					$checking = 'MATE';
646 646
 				}
647
-				if($this->moves!=null) {
647
+				if ($this->moves != null) {
648 648
 					$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']);
649 649
 				}
650
-				if(self::isPlayerChecked($this->board, $this->getHasMoved(), $p->colour)) {
650
+				if (self::isPlayerChecked($this->board, $this->getHasMoved(), $p->colour)) {
651 651
 					return 3;
652 652
 				}
653 653
 
654 654
 				$otherPlayer = $this->getCurrentTurnPlayer();
655
-				if($moveInfo['PawnPromotion'] !== false) {
655
+				if ($moveInfo['PawnPromotion'] !== false) {
656 656
 					$piecePromotedSymbol = $p->getPieceSymbol();
657
-					$currentPlayer->increaseHOF(1, array($chessType,'Moves','Own Pawns Promoted','Total'), HOF_PUBLIC);
658
-					$otherPlayer->increaseHOF(1, array($chessType,'Moves','Opponent Pawns Promoted','Total'), HOF_PUBLIC);
659
-					$currentPlayer->increaseHOF(1, array($chessType,'Moves','Own Pawns Promoted',$piecePromotedSymbol), HOF_PUBLIC);
660
-					$otherPlayer->increaseHOF(1, array($chessType,'Moves','Opponent Pawns Promoted',$piecePromotedSymbol), HOF_PUBLIC);
657
+					$currentPlayer->increaseHOF(1, array($chessType, 'Moves', 'Own Pawns Promoted', 'Total'), HOF_PUBLIC);
658
+					$otherPlayer->increaseHOF(1, array($chessType, 'Moves', 'Opponent Pawns Promoted', 'Total'), HOF_PUBLIC);
659
+					$currentPlayer->increaseHOF(1, array($chessType, 'Moves', 'Own Pawns Promoted', $piecePromotedSymbol), HOF_PUBLIC);
660
+					$otherPlayer->increaseHOF(1, array($chessType, 'Moves', 'Opponent Pawns Promoted', $piecePromotedSymbol), HOF_PUBLIC);
661 661
 				}
662 662
 
663 663
 				$castlingType = $moveInfo['Castling'] === false ? null : $moveInfo['Castling']['Type'];
@@ -667,36 +667,36 @@  discard block
 block discarded – undo
667 667
 								(' . $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'])) . ');');
668 668
 
669 669
 
670
-				$currentPlayer->increaseHOF(1, array($chessType,'Moves','Total Taken'), HOF_PUBLIC);
671
-				if($moveInfo['PieceTaken'] != null) {
670
+				$currentPlayer->increaseHOF(1, array($chessType, 'Moves', 'Total Taken'), HOF_PUBLIC);
671
+				if ($moveInfo['PieceTaken'] != null) {
672 672
 					$this->db->query('DELETE FROM chess_game_pieces
673 673
 									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) . ';');
674 674
 
675 675
 					$pieceTakenSymbol = $moveInfo['PieceTaken']->getPieceSymbol();
676
-					$currentPlayer->increaseHOF(1, array($chessType,'Moves','Opponent Pieces Taken','Total'), HOF_PUBLIC);
677
-					$otherPlayer->increaseHOF(1, array($chessType,'Moves','Own Pieces Taken','Total'), HOF_PUBLIC);
678
-					$currentPlayer->increaseHOF(1, array($chessType,'Moves','Opponent Pieces Taken',$pieceTakenSymbol), HOF_PUBLIC);
679
-					$otherPlayer->increaseHOF(1, array($chessType,'Moves','Own Pieces Taken',$pieceTakenSymbol), HOF_PUBLIC);
676
+					$currentPlayer->increaseHOF(1, array($chessType, 'Moves', 'Opponent Pieces Taken', 'Total'), HOF_PUBLIC);
677
+					$otherPlayer->increaseHOF(1, array($chessType, 'Moves', 'Own Pieces Taken', 'Total'), HOF_PUBLIC);
678
+					$currentPlayer->increaseHOF(1, array($chessType, 'Moves', 'Opponent Pieces Taken', $pieceTakenSymbol), HOF_PUBLIC);
679
+					$otherPlayer->increaseHOF(1, array($chessType, 'Moves', 'Own Pieces Taken', $pieceTakenSymbol), HOF_PUBLIC);
680 680
 				}
681 681
 				$this->db->query('UPDATE chess_game_pieces
682 682
 							SET x=' . $this->db->escapeNumber($toX) . ', y=' . $this->db->escapeNumber($toY) .
683 683
 								($moveInfo['PawnPromotion'] !== false ? ', piece_id=' . $this->db->escapeNumber($moveInfo['PawnPromotion']['PieceID']) . ', piece_no=' . $this->db->escapeNumber($moveInfo['PawnPromotion']['PieceNo']) : '') . '
684 684
 							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) . ';');
685
-				if($moveInfo['Castling'] !== false) {
685
+				if ($moveInfo['Castling'] !== false) {
686 686
 					$this->db->query('UPDATE chess_game_pieces
687 687
 								SET x=' . $this->db->escapeNumber($moveInfo['Castling']['ToX']) . '
688 688
 								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) . ';');
689 689
 				}
690 690
 				$return = 0;
691
-				if($checking == 'MATE') {
691
+				if ($checking == 'MATE') {
692 692
 					$this->setWinner($forAccountID);
693 693
 					$return = 1;
694 694
 					SmrPlayer::sendMessageFromCasino($lastTurnPlayer->getGameID(), $this->getCurrentTurnAccountID(), 'You have just lost [chess=' . $this->getChessGameID() . '] against [player=' . $lastTurnPlayer->getPlayerID() . '].');
695 695
 				} else {
696 696
 					SmrPlayer::sendMessageFromCasino($lastTurnPlayer->getGameID(), $this->getCurrentTurnAccountID(), 'It is now your turn in [chess=' . $this->getChessGameID() . '] against [player=' . $lastTurnPlayer->getPlayerID() . '].');
697
-					if($checking == 'CHECK') {
698
-						$currentPlayer->increaseHOF(1, array($chessType,'Moves','Check Given'), HOF_PUBLIC);
699
-						$otherPlayer->increaseHOF(1, array($chessType,'Moves','Check Received'), HOF_PUBLIC);
697
+					if ($checking == 'CHECK') {
698
+						$currentPlayer->increaseHOF(1, array($chessType, 'Moves', 'Check Given'), HOF_PUBLIC);
699
+						$otherPlayer->increaseHOF(1, array($chessType, 'Moves', 'Check Received'), HOF_PUBLIC);
700 700
 					}
701 701
 				}
702 702
 				$currentPlayer->saveHOF();
Please login to merge, or discard this patch.
templates/Default/engine/Default/combat_log_viewer.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -20,11 +20,11 @@
 block discarded – undo
20 20
 	$this->includeTemplate('includes/ForceFullCombatResults.inc', array('FullForceCombatResults'=>$CombatResults));
21 21
 } elseif ($CombatResultsType == 'PORT') {
22 22
 	$this->includeTemplate('includes/PortFullCombatResults.inc', array('FullPortCombatResults'=>$CombatResults,
23
-	                                                                  'MinimalDisplay'=>false,
24
-	                                                                  'AlreadyDestroyed'=>false));
23
+																	  'MinimalDisplay'=>false,
24
+																	  'AlreadyDestroyed'=>false));
25 25
 } elseif ($CombatResultsType == 'PLANET') {
26 26
 	$this->includeTemplate('includes/PlanetFullCombatResults.inc', array('FullPlanetCombatResults'=>$CombatResults,
27
-	                                                                    'MinimalDisplay'=>false,
28
-	                                                                    'AlreadyDestroyed'=>false));
27
+																		'MinimalDisplay'=>false,
28
+																		'AlreadyDestroyed'=>false));
29 29
 }
30 30
 ?>
Please login to merge, or discard this patch.