Ejemplo n.º 1
0
 public void AddMoveIfLegal(int x, int y, ref ChessTile[,] tiles, ref bool[,] moveArray)
 {
     if (MoveOnBoard(x, y))
     {
         ChessTile toTile           = tiles[x, y];
         bool      noThreatAndEmpty = toTile.ThreatenedBy(isBlack).Count == 0 && !toTile.HasPiece();
         bool      canTake          = toTile.HasEnemyPiece(isBlack) && toTile.Figure.ProtectedBy().Count == 0;
         moveArray[x, y] = noThreatAndEmpty || canTake;
     }
 }
Ejemplo n.º 2
0
    public List <ChessFigure> ProtectedBy()
    {
        // Change the piece's color to see if it's threatened by anything and then change it back
        isBlack = !isBlack;
        List <ChessFigure> piecesProtecting = Tile.ThreatenedBy(isBlack);

        isBlack = !isBlack;

        return(piecesProtecting);
    }