public void move(King 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 + 20, x.Grid[s.X, s.Y].Y + 6); 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; }
public Boolean checkcheck(Board x, King c) { int p = 100; int q = 40; Point [] checkpossibs = new Point [500]; x.a = 0; /*Checks whether the king is in check, by checking all of the oppossing * player's moves and seeing whether they can eat the king*/ for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { x.piecelocate(p, q); if (board[x.numx, x.numy] != 0) { checkpossibs = x.findpeice(x.Grid[x.numx, x.numy], x); } q+= 80; } q = 40; p += 80; } for(int i = 0; i < x.a; i++) { if (Grid[checkpossibs[i].X, checkpossibs[i].Y].Contains(c.getcoords())) { x.a = 0; return true; } } x.a = 0; return false; }