public void reset() { board.reset(); ismarked = false; whiteTurn = true; check = false; checkmate = false; draw = false; if (playerBoth) { playerWhite = true; } possibleMoves = Rules.checkMoves(board, whiteTurn, true); if (playerWhite != whiteTurn) { Opponent.move(board, possibleMoves, whiteTurn, difficulty); whiteTurn = !whiteTurn; possibleMoves = Rules.checkMoves(board, whiteTurn, true); } }
public void tryMove(int x, int y) { if (checkmate) { return; } if (posIsPlayer(x, y)) { ismarked = false; } if (ismarked) { for (int i = 0; i < possiblePos.Count; i++) { if (possiblePos[i].x == x && possiblePos[i].y == y) { board.move(new Move(marked, new Position(y, x)), true); whiteTurn = !whiteTurn; if (playerBoth) { playerWhite = !playerWhite; } possibleMoves = Rules.checkMoves(board, whiteTurn, true); if (playerWhite != whiteTurn && possibleMoves.Count > 0) { Opponent.move(board, possibleMoves, whiteTurn, difficulty); whiteTurn = !whiteTurn; possibleMoves = Rules.checkMoves(board, whiteTurn, true); } checkCheck(); break; } } ismarked = false; } else { int start = 7; if (playerWhite) { start = 1; } if ((int)board.pieces[y, x] >= start && (int)board.pieces[y, x] < start + 6) { possiblePos.Clear(); for (int i = 0; i < possibleMoves.Count; i++) { if (possibleMoves[i].source.x == x && possibleMoves[i].source.y == y) { possiblePos.Add(possibleMoves[i].target); } } if (possiblePos.Count > 0) { ismarked = true; marked.x = x; marked.y = y; } } } }