Esempio n. 1
0
 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
 }
Esempio n. 2
0
 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)
 {
 }
Esempio n. 3
0
 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;
         }
     }
 }
Esempio n. 4
0
 internal Rook(ColorsOfFigures color) :
     base(TypeOfFigures.Rook, color, new int[] { 1, 0, -1, 0, 0, -1, 0, 1 }, 8)
 {
 }
Esempio n. 5
0
 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
 }
Esempio n. 6
0
 internal FigureRokade(TypeOfFigures type, ColorsOfFigures color, int[] dirArr, int range) :
     base(type, color, dirArr, range)
 {
 }
Esempio n. 7
0
 internal Pawn(ColorsOfFigures color) : base(TypeOfFigures.Pawn, color)
 {
 }
Esempio n. 8
0
 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)
 {
 }
Esempio n. 9
0
 internal Bishop(ColorsOfFigures color) :
     base(TypeOfFigures.Bishop, color, new int[] { 1, 1, -1, -1, 1, -1, -1, 1 }, 8)
 {
 }
Esempio n. 10
0
 protected AbsMovesFigure(TypeOfFigures type, ColorsOfFigures color) : base(type, color)
 {
 }
Esempio n. 11
0
 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)
 {
 }
Esempio n. 12
0
 protected MovingFigure(TypeOfFigures type, ColorsOfFigures color, int[] dir, int range) : base(type, color)
 {
     directions = dir;
     this.range = range;
 }