Exemplo n.º 1
0
 public void setpieces()
 {
     /*Sets peices in coordinates, and unseen board of ints that lets the
      * program see whether a space is occupied by a black or white pices*/
     for (int i = 0; i < 8; i++)
     {
         blackpawns[i] = new Pawn(1, i);
         board[i, 6] = 1;
     }
     for (int i = 0; i < 8; i++)
     {
         whitepawns[i] = new Pawn(2, i);
         board[i, 1] = -1;
     }
     for (int i = 0; i < 2; i++)
     {
         blackrooks[i] = new Rook(1, i);
         board[i * 7, 7] = 2;
     }
     for (int i = 0; i < 2; i++)
     {
         whiterooks[i] = new Rook(2, i);
         board[i * 7, 0] = -2;
     }
     for (int i = 0; i < 2; i++)
     {
         blacknights[i] = new Knight(1, i);
         board[i * 5 + 1, 7] = 3;
     }
     for (int i = 0; i < 2; i++)
     {
         whiteknights[i] = new Knight(2, i);
         board[i * 5 + 1, 0] = -3;
     }
     for (int i = 0; i < 2; i++)
     {
         blackbishops[i] = new Bishop(1, i);
         board[i * 3 + 2, 7] = 4;
     }
     for (int i = 0; i < 2; i++)
     {
         whitebishops[i] = new Bishop(2, i);
         board[i * 3 + 2, 0] = -4;
     }
     board[3, 7] = 5;
     board[4, 7] = 6;
     board[3, 0] = -6;
     board[4, 0] = -5;
 }
Exemplo n.º 2
0
 public void move(Rook c, Point s, Board x, int a)
 {
     int t = x.board[s.X, s.Y];
     Boolean skip = true;
     x.cannotmove = false;
     int numx2 = x.numx;
     int numy2 = x.numy;
     Point unmove = new Point(c.coords.X, c.coords.Y);
     if (x.board[s.X, s.Y] != 0 && x.board[s.X, s.Y] * a < 0)
     {
         if (x.checkmachecker)
         {
             skip = false;
         }
         else
         {
             x.eat(s, x);
         }
     }
     c.coords = new Point(x.Grid[s.X, s.Y].X + 22, x.Grid[s.X, s.Y].Y + 10);
     x.board[s.X, s.Y] = a;
     Boolean kingcheck= false;
     x.turner = x.turner * -1;
     if (skip)
     {
         if (x.turncount % 2 == 0)
         {
             kingcheck = x.checkcheck(x, x.whiteking);
         }
         else
         {
             kingcheck = x.checkcheck(x, x.blacking);
         }
     }
     if (kingcheck || x.checkmachecker)
     {
         c.coords = new Point(unmove.X, unmove.Y);
         x.board[s.X, s.Y] = t;
         x.board[numx2, numy2] = a;
         if (kingcheck)
         {
             x.cannotmove = true;
         }
     }
     x.numx = numx2;
     x.numy = numy2;
     x.turner = x.turner * -1;
 }
Exemplo n.º 3
0
 public void geteaten(Rook c, Board x, int a)
 {
     if (a == 1)
     {
         if (x.count == 4)
         {
             x.count = 0;
             x.n += 70;
         }
         c.coords = new Point(x.n, x.m + (70 * x.count));
         x.count++;
     }
     else
     {
         if (x.count2 == 4)
         {
             x.count2 = 0;
             x.o += 70;
         }
         c.coords = new Point(x.o, x.p + (70 * x.count2));
         x.count2++;
     }
 }