Exemple #1
0
 public PieceMove(ChessNode start, ChessNode end)
 {
     this.board  = start.board;
     this.start  = start.GetCord();
     this.end    = end.GetCord();
     playerColor = start.piece.color;
 }
Exemple #2
0
 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;
 }
Exemple #3
0
 public static bool CheckOverlap(List <PieceMove> moves, BoardCord cord)
 {
     foreach (var move in moves)
     {
         if (move.CheckOverlap(cord))
         {
             return(true);
         }
     }
     return(false);
 }
Exemple #4
0
    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);
    }
Exemple #5
0
 public bool CheckOverlap(BoardCord cord)
 {
     return(end.Overlaps(cord));
 }
Exemple #6
0
 public bool Overlaps(BoardCord cord)
 {
     return(this.x == cord.x && this.y == cord.y);
 }