public bool knightCheck(BoardCell cell) { bool isValid = false; if (cell.yAxis == this.yPos + 1 && this.xPos + 2 == cell.xAxis) { isValid = true; } else if (cell.yAxis == this.yPos - 1 && this.xPos + 2 == cell.xAxis) { isValid = true; } else if (cell.yAxis == this.yPos - 1 && this.xPos - 2 == cell.xAxis) { isValid = true; } else if (cell.yAxis == this.yPos + 1 && this.xPos - 2 == cell.xAxis) { isValid = true; } else if (cell.yAxis == this.yPos - 2 && this.xPos + 1 == cell.xAxis) { isValid = true; } else if (cell.yAxis == this.yPos - 2 && this.xPos - 1 == cell.xAxis) { isValid = true; } else if (cell.yAxis == this.yPos + 2 && this.xPos - 1 == cell.xAxis) { isValid = true; } else if (cell.yAxis == this.yPos + 2 && this.xPos + 1 == cell.xAxis) { isValid = true; } return(isValid); }
public bool bishopCheck(BoardCell cell) { bool isValid = false; if (cell.xAxis - this.xPos == cell.yAxis - this.yPos) { isValid = true; } else if (this.xPos - cell.xAxis == this.yPos - cell.yAxis) { isValid = true; } else if (this.yPos - cell.yAxis == cell.xAxis - this.xPos) { isValid = true; } else if (this.xPos - cell.xAxis == cell.yAxis - this.yPos) { isValid = true; } return(isValid); }
public override bool isBlocked(BoardCell cell) { return(this.isRookBlocked(cell)); }
public override bool isValidMove(BoardCell cell) { return(this.rookCheck(cell)); }
//Checks if move accurate for pawn public bool pawnCheck(BoardCell cell) { bool isValid = false; //moveset for the players direction if (this._isHuman) { if (this.isFIrstTurn) { if (cell.xAxis == this.xPos && this.yPos + 2 == cell.yAxis) { isValid = true; } else if (cell.xAxis == this.xPos && this.yPos + 1 == cell.yAxis) { isValid = true; } else if (cell.isOccupied) { for (int x = 0; x < StateOfPlay.activePieces.Count; x++) { if (StateOfPlay.activePieces[x].xPos == cell.xAxis && StateOfPlay.activePieces[x].yPos == cell.yAxis) { if (!(StateOfPlay.activePieces[x]._isHuman)) { if ((cell.xAxis == this.xPos + 1 || cell.xAxis == this.xPos - 1) && this.yPos + 1 == cell.yAxis) { isValid = true; } } } } } } } else //movest for cpu direction { if (this.isFIrstTurn) { if (cell.xAxis == this.xPos && this.yPos - 2 == cell.yAxis) { isValid = true; } } else if (cell.xAxis == this.xPos && this.yPos - 1 == cell.yAxis) { isValid = true; } //checks if cell has friendly pieve in the way else if (cell.isOccupied) { for (int x = 0; x < StateOfPlay.activePieces.Count; x++) { if (StateOfPlay.activePieces[x].xPos == cell.xAxis && StateOfPlay.activePieces[x].yPos == cell.yAxis) { if (StateOfPlay.activePieces[x]._isHuman) { if ((cell.xAxis == this.xPos + 1 || cell.xAxis == this.xPos - 1) && this.yPos - 1 == cell.yAxis) { isValid = true; } } } } } } return(isValid); }
//method to change coordinates of chess piece public static void movePiece(ChessPiece piece, BoardCell cell) { piece.xPos = cell.xAxis; piece.yPos = cell.yAxis; cell.isOccupied = true; }
//empty constuctor for copying //constructor for copying parameters public virtual bool isValidMove(BoardCell cell) { return(false); }