protected Figure(TypeOfFigures type, ColorsOfFigures color) { figureType = type; figureColor = color; onTable = true; imBlocked = false; //initialize this to avoid errors due the weird case of somebody reading this property unitialized O.o }
internal Knight(ColorsOfFigures color) : base(TypeOfFigures.Knight, color, new int[] { 2, 1, 2, -1, -2, 1, -2, -1, 1, 2, 1, -2, -1, 2, -1, -2 }, 1) { }
internal static void repartFigures(ColorsOfFigures firstPlayerColor) { if (firstPlayerColor == ColorsOfFigures.black) { for (int x = 0; x < 8; x++) { cells[x, 0].MyFigure = FiguresBox.getWhiteFigureAtIndex(x); cells[x, 1].MyFigure = FiguresBox.getWhiteFigureAtIndex(x + 8); cells[x, 6].MyFigure = FiguresBox.getBlackFiguresAtIndex(x + 8); cells[x, 7].MyFigure = FiguresBox.getBlackFiguresAtIndex(x); } } else { for (int x = 0; x < 8; x++) { cells[x, 0].MyFigure = FiguresBox.getBlackFiguresAtIndex(x); cells[x, 1].MyFigure = FiguresBox.getBlackFiguresAtIndex(x + 8); cells[x, 6].MyFigure = FiguresBox.getWhiteFigureAtIndex(x + 8); cells[x, 7].MyFigure = FiguresBox.getWhiteFigureAtIndex(x); } } for (int x = 0; x < 8; x++) { for (int y = 0; y < 2; y++) { cells[x, y].MyFigure.PositionX = x; cells[x, y].MyFigure.PositionY = y; } for (int y = 6; y < 8; y++) { cells[x, y].MyFigure.PositionX = x; cells[x, y].MyFigure.PositionY = y; } } }
internal Rook(ColorsOfFigures color) : base(TypeOfFigures.Rook, color, new int[] { 1, 0, -1, 0, 0, -1, 0, 1 }, 8) { }
protected static bool testIfNextCellIsEmptyAndSetRegard(int i, int j, bool[,] arr, ColorsOfFigures color) //note to not use this for pawn. pawh is different because it can't beat a black figure that is next on front of it { if (i >= 0 && i < 8 && j >= 0 && j < 8) { if (ChessBoard.Cells[i, j].Empty) { arr[i, j] = true; //it is possible return(true); //don't interrupt the iterator inside the caller } else { if (ChessBoard.Cells[i, j].MyFigure.Color != color) { arr[i, j] = true; // it is possible } return(false); // cell was occupied by other color figure and caller needs to stop iteration in this path/direction regardles of color, because previous cell is always possible so it shouldn't give a problem } } return(false); //position is not inside the board }
internal FigureRokade(TypeOfFigures type, ColorsOfFigures color, int[] dirArr, int range) : base(type, color, dirArr, range) { }
internal Pawn(ColorsOfFigures color) : base(TypeOfFigures.Pawn, color) { }
internal King(ColorsOfFigures color) : base(TypeOfFigures.King, color, new int[] { 1, 0, -1, 0, 0, -1, 0, 1, 1, 1, -1, -1, 1, -1, -1, 1 }, 1) { }
internal Bishop(ColorsOfFigures color) : base(TypeOfFigures.Bishop, color, new int[] { 1, 1, -1, -1, 1, -1, -1, 1 }, 8) { }
protected AbsMovesFigure(TypeOfFigures type, ColorsOfFigures color) : base(type, color) { }
internal Queen(ColorsOfFigures color) : base(TypeOfFigures.Queen, color, new int[] { 1, 0, -1, 0, 0, -1, 0, 1, //move horizontal vertical 1, 1, -1, -1, 1, -1, -1, 1 // move by diagonal }, 8) { }
protected MovingFigure(TypeOfFigures type, ColorsOfFigures color, int[] dir, int range) : base(type, color) { directions = dir; this.range = range; }