public bool testCheck(Collor collor) { if (!kingCheck(collor)) { return(false); } foreach (Piece x in pieceGame(collor)) { bool[,] mat = x.possiMov(); for (int i = 0; i < tab.lines; i++) { for (int j = 0; j < tab.coluns; j++) { if (mat[i, j]) { Position orig = x.position; Position desti = new Position(i, j); Piece capturedPiece = exMovi(x.position, desti); bool testCheck = kingCheck(collor); cancelMov(orig, desti, capturedPiece); if (!testCheck) { return(false); } } } } } return(true); }
public Piece(Collor collor, Board board) { this.position = null; this.collor = collor; this.board = board; this.amountOfMov = 0; }
public bool CheckMate(Collor collor) { if (!InChedk(collor)) { return(false); } foreach (Piece xequeMate in PiecesOnBoardChess(collor)) { bool[,] xeque = xequeMate.CharacteringMove(); for (int i = 0; i < chess.lines; i++) { for (int j = 0; j < chess.collumns; j++) { if (xeque[i, j]) { Position take = xequeMate.position; Position put = new Position(i, j); Piece captured = Movable(take, put); bool inXequeMate = InChedk(collor); RewindMove(take, put, captured); if (!inXequeMate) { return(false); } } } } } return(true); }
/// <summary> Constructor da classe Peça.</summary> /// <param name="board"></param> /// <param name="collor"></param> public Piece(Board board, Collor collor) { position = null; this.board = board; this.collor = collor; movement = 0; Console.OutputEncoding = System.Text.Encoding.Unicode; // para as imagens das peças. }
private Collor opponent(Collor collor) { if (collor == Collor.White) { return(Collor.Black); } else { return(Collor.White); } }
/// <summary>Peça adverçaria.</summary> /// <param name="collor"></param> /// <returns></returns> private Collor AnotherPlayer(Collor collor) { if (collor == Collor.WHITE) { return(Collor.BLACK); } else { return(Collor.WHITE); } }
/// <summary>Devolve o rei de dada cor.</summary> /// <param name="collor"></param> /// <returns>null se não existir rei.</returns> private Piece TheKing(Collor collor) { foreach (Piece found in PiecesOnBoardChess(collor)) { if (found is King) { return(found); } } return(null); }
private Piece king(Collor collor) { foreach (Piece x in pieceGame(collor)) { if (x is King) { return(x); } } return(null); }
public HashSet <Piece> piecesCaptured(Collor collor) { HashSet <Piece> aux = new HashSet <Piece>(); foreach (Piece x in capturated) { if (x.collor == collor) { aux.Add(x); } } return(aux); }
/// <summary>Conjunto das peças capturadas separadas por cor.</summary> /// <param name="collor"></param> /// <returns></returns> public HashSet <Piece> PiecesCaptureSepareteCollor(Collor collor) { HashSet <Piece> separetePieceCollor = new HashSet <Piece>(); foreach (Piece x in captured) { if (x.collor.Equals(collor)) { separetePieceCollor.Add(x); } } return(separetePieceCollor); }
/// <summary>Conjunto das peças em jogo.</summary> /// <param name="collor"></param> /// <returns></returns> public HashSet <Piece> PiecesOnBoardChess(Collor collor) { HashSet <Piece> piecesOnBoard = new HashSet <Piece>(); foreach (Piece fill in pieces) { if (fill.collor.Equals(collor)) { piecesOnBoard.Add(fill); } } piecesOnBoard.ExceptWith(PiecesCaptureSepareteCollor(collor));// exceto essa cor. return(piecesOnBoard); }
public HashSet <Piece> pieceGame(Collor collor) { HashSet <Piece> aux = new HashSet <Piece>(); foreach (Piece x in pieces) { if (x.collor == collor) { aux.Add(x); } } aux.ExceptWith(piecesCaptured(collor)); return(aux); }
public bool kingCheck(Collor collor) { Piece K = king(collor); if (K == null) { throw new BoardException("Dont have King " + collor + " on the board"); } foreach (Piece x in pieceGame(opponent(collor))) { bool[,] mat = x.possiMov(); if (mat[K.position.line, K.position.column]) { return(true); } } return(false); }
/// <summary>Está em xeque.</summary> /// <param name="collor"></param> /// <returns></returns> public bool InChedk(Collor collor) { Piece king = TheKing(collor); if (king == null) { throw new ExceptionChess($"{image[2]}Not have of collor the king {collor} on board chess."); } foreach (Piece move in PiecesOnBoardChess(AnotherPlayer(collor))) { bool[,] movePossible = move.CharacteringMove(); if (movePossible[king.position.line, king.position.collumn]) { return(true); } } return(false); }
public King(Board board, Collor collor, ChessMatch match) : base(collor, board) { this.match = match; }
public Knight(Board board, Collor collor) : base(board, collor) { }
/// <summary>Construtor da classe Rei (King).</summary> /// <param name="board"></param> /// <param name="collor"></param> public King(Board board, Collor collor, GameManager situation) : base(board, collor) { this.situation = situation; }
public Queen(Board board, Collor collor) : base(collor, board) { }
public Bishop(Board board, Collor collor) : base(board, collor) { }
public Pawn(Board board, Collor collor, GameManager passant) : base(board, collor) { this.passant = passant; }
public Tower(Board board, Collor collor) : base(collor, board) { }
public Bishop(Board board, Collor collor) : base(collor, board) { }
public Knight(Board board, Collor collor) : base(collor, board) { }
/// <summary>Construtor.</summary> /// <param name="board"></param> /// <param name="collor"></param> public Rock(Board board, Collor collor) : base(board, collor) { }
public Queen(Board board, Collor collor) : base(board, collor) { }