Skip to content

Commit

Permalink
ChessPiece: remove improper references
Browse files Browse the repository at this point in the history
See #317.

Here, `$moves` is an array that is not modified, and `$p` is a
ChessPiece instance.
  • Loading branch information
hemberger committed May 26, 2020
1 parent 65a3b83 commit 90b0a79
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/Default/ChessPiece.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,17 @@ public function isSafeMove(array &$board, &$hasMoved, $toX = -1, $toY = -1) {
}

public function isAttacking(array &$board, array &$hasMoved, $king, $x = -1, $y = -1) {
$moves =& $this->getPossibleMoves($board, $hasMoved, null, true);
foreach($moves as &$move) {
$p =& $board[$move[1]][$move[0]];
$moves = $this->getPossibleMoves($board, $hasMoved, null, true);
foreach($moves as $move) {
$p = $board[$move[1]][$move[0]];
if(($move[0] == $x && $move[1] == $y) || ($king === true && $p != null && $p->pieceID == self::KING && $this->colour != $p->colour)) {
return true;
}
}
return false;
}

public function &getPossibleMoves(array &$board, array &$hasMoved, $forAccountID = null, $attackingCheck = false) {
public function getPossibleMoves(array &$board, array &$hasMoved, $forAccountID = null, $attackingCheck = false) {
$moves = array();
if ($forAccountID == null || $this->accountID == $forAccountID) {
if ($this->pieceID == self::PAWN) {
Expand Down

0 comments on commit 90b0a79

Please sign in to comment.