public PieceMove(ChessNode start, ChessNode end) { this.board = start.board; this.start = start.GetCord(); this.end = end.GetCord(); playerColor = start.piece.color; }
public ComplexMove(ChessNode start, ChessNode end, ChessNode secondaryStart, ChessNode secondaryEnd, bool valid) : base(start, end) { this.secondaryEnd = secondaryEnd.GetCord(); this.secondaryStart = secondaryStart.GetCord(); this.valid = true; this.validated = true; }
public static bool CheckOverlap(List <PieceMove> moves, BoardCord cord) { foreach (var move in moves) { if (move.CheckOverlap(cord)) { return(true); } } return(false); }
public bool IsValid() { if (valid) { return(true); } else if (validated) { return(false); } // so if we didnt validate the move, we validate it. validated = true; var enemyColor = playerColor == PlayerColor.white ? PlayerColor.black : PlayerColor.white; // we get the state of the game after the move var board = GetNextBoard(); // we get the king position BoardCord kingCord = board.kings[playerColor].node.GetCord(); valid = !board.IsChecked(playerColor); return(valid); }
public bool CheckOverlap(BoardCord cord) { return(end.Overlaps(cord)); }
public bool Overlaps(BoardCord cord) { return(this.x == cord.x && this.y == cord.y); }