mirror of
https://github.com/2OOP/pism.git
synced 2026-02-04 10:54:51 +00:00
Fixed compilation errors
This commit is contained in:
@@ -6,6 +6,7 @@ import org.toop.app.widget.view.GameView;
|
|||||||
import org.toop.framework.eventbus.EventFlow;
|
import org.toop.framework.eventbus.EventFlow;
|
||||||
import org.toop.framework.networking.events.NetworkEvents;
|
import org.toop.framework.networking.events.NetworkEvents;
|
||||||
import org.toop.game.Game;
|
import org.toop.game.Game;
|
||||||
|
import org.toop.game.records.Move;
|
||||||
|
|
||||||
import java.util.concurrent.BlockingQueue;
|
import java.util.concurrent.BlockingQueue;
|
||||||
import java.util.concurrent.LinkedBlockingQueue;
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
@@ -18,7 +19,7 @@ public abstract class BaseGameThread<TGame extends Game, TAI, TCanvas> {
|
|||||||
protected final GameInformation information;
|
protected final GameInformation information;
|
||||||
protected final int myTurn;
|
protected final int myTurn;
|
||||||
protected final Runnable onGameOver;
|
protected final Runnable onGameOver;
|
||||||
protected final BlockingQueue<Game.Move> moveQueue;
|
protected final BlockingQueue<Move> moveQueue;
|
||||||
|
|
||||||
protected final TGame game;
|
protected final TGame game;
|
||||||
protected final TAI ai;
|
protected final TAI ai;
|
||||||
@@ -84,7 +85,7 @@ public abstract class BaseGameThread<TGame extends Game, TAI, TCanvas> {
|
|||||||
final char value = getSymbolForTurn(currentTurn);
|
final char value = getSymbolForTurn(currentTurn);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
moveQueue.put(new Game.Move(cell, value));
|
moveQueue.put(new Move(cell, value));
|
||||||
} catch (InterruptedException _) {}
|
} catch (InterruptedException _) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public final class ReversiGame {
|
|||||||
|
|
||||||
private final int myTurn;
|
private final int myTurn;
|
||||||
private final Runnable onGameOver;
|
private final Runnable onGameOver;
|
||||||
private final BlockingQueue<Game.Move> moveQueue;
|
private final BlockingQueue<Move> moveQueue;
|
||||||
|
|
||||||
private final Reversi game;
|
private final Reversi game;
|
||||||
private final ReversiAI ai;
|
private final ReversiAI ai;
|
||||||
@@ -213,7 +213,7 @@ public final class ReversiGame {
|
|||||||
primary.gameOver(false, information.players[1].name);
|
primary.gameOver(false, information.players[1].name);
|
||||||
gameOver();
|
gameOver();
|
||||||
}
|
}
|
||||||
} else if (state == Game.State.DRAW) {
|
} else if (state == GameState.DRAW) {
|
||||||
primary.gameOver(false, "");
|
primary.gameOver(false, "");
|
||||||
game.play(move);
|
game.play(move);
|
||||||
}
|
}
|
||||||
@@ -289,7 +289,7 @@ public final class ReversiGame {
|
|||||||
if (information.players[game.getCurrentTurn()].isHuman) {
|
if (information.players[game.getCurrentTurn()].isHuman) {
|
||||||
final Move[] legalMoves = game.getLegalMoves();
|
final Move[] legalMoves = game.getLegalMoves();
|
||||||
|
|
||||||
for (final Game.Move legalMove : legalMoves) {
|
for (final Move legalMove : legalMoves) {
|
||||||
canvas.drawLegalPosition(legalMove.position(), game.getCurrentPlayer());
|
canvas.drawLegalPosition(legalMove.position(), game.getCurrentPlayer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ public final class TicTacToeGame {
|
|||||||
|
|
||||||
private final int myTurn;
|
private final int myTurn;
|
||||||
private final Runnable onGameOver;
|
private final Runnable onGameOver;
|
||||||
private final BlockingQueue<Game.Move> moveQueue;
|
private final BlockingQueue<Move> moveQueue;
|
||||||
|
|
||||||
private final TicTacToe game;
|
private final TicTacToe game;
|
||||||
private final TicTacToeAI ai;
|
private final TicTacToeAI ai;
|
||||||
@@ -152,10 +152,10 @@ public final class TicTacToeGame {
|
|||||||
canvas.drawO(Color.ROYALBLUE, move.position());
|
canvas.drawO(Color.ROYALBLUE, move.position());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state != Game.State.NORMAL) {
|
if (state != GameState.NORMAL) {
|
||||||
if (state == Game.State.WIN) {
|
if (state == GameState.WIN) {
|
||||||
primary.gameOver(true, information.players[currentTurn].name);
|
primary.gameOver(true, information.players[currentTurn].name);
|
||||||
} else if (state == Game.State.DRAW) {
|
} else if (state == GameState.DRAW) {
|
||||||
primary.gameOver(false, "");
|
primary.gameOver(false, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ import org.toop.app.GameInformation;
|
|||||||
import org.toop.app.canvas.TicTacToeCanvas;
|
import org.toop.app.canvas.TicTacToeCanvas;
|
||||||
import org.toop.framework.eventbus.EventFlow;
|
import org.toop.framework.eventbus.EventFlow;
|
||||||
import org.toop.framework.networking.events.NetworkEvents;
|
import org.toop.framework.networking.events.NetworkEvents;
|
||||||
import org.toop.game.Game;
|
import org.toop.game.enumerators.GameState;
|
||||||
|
import org.toop.game.records.Move;
|
||||||
import org.toop.game.tictactoe.TicTacToe;
|
import org.toop.game.tictactoe.TicTacToe;
|
||||||
import org.toop.game.tictactoe.TicTacToeAI;
|
import org.toop.game.tictactoe.TicTacToeAI;
|
||||||
|
|
||||||
@@ -47,7 +48,7 @@ public final class TicTacToeGameThread extends BaseGameThread<TicTacToe, TicTacT
|
|||||||
return turn == 0 ? "X" : "O";
|
return turn == 0 ? "X" : "O";
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawMove(Game.Move move) {
|
private void drawMove(Move move) {
|
||||||
if (move.value() == 'X') canvas.drawX(Color.RED, move.position());
|
if (move.value() == 'X') canvas.drawX(Color.RED, move.position());
|
||||||
else canvas.drawO(Color.BLUE, move.position());
|
else canvas.drawO(Color.BLUE, move.position());
|
||||||
}
|
}
|
||||||
@@ -66,11 +67,11 @@ public final class TicTacToeGameThread extends BaseGameThread<TicTacToe, TicTacT
|
|||||||
playerChar = myTurn == 0? 'O' : 'X';
|
playerChar = myTurn == 0? 'O' : 'X';
|
||||||
}
|
}
|
||||||
|
|
||||||
final Game.Move move = new Game.Move(Integer.parseInt(response.move()), playerChar);
|
final Move move = new Move(Integer.parseInt(response.move()), playerChar);
|
||||||
final Game.State state = game.play(move);
|
final GameState state = game.play(move);
|
||||||
|
|
||||||
if (state != Game.State.NORMAL) {
|
if (state != GameState.NORMAL) {
|
||||||
if (state == Game.State.WIN) {
|
if (state == GameState.WIN) {
|
||||||
if (response.player().equalsIgnoreCase(information.players[0].name)) {
|
if (response.player().equalsIgnoreCase(information.players[0].name)) {
|
||||||
primary.gameOver(true, information.players[0].name);
|
primary.gameOver(true, information.players[0].name);
|
||||||
gameOver();
|
gameOver();
|
||||||
@@ -78,7 +79,7 @@ public final class TicTacToeGameThread extends BaseGameThread<TicTacToe, TicTacT
|
|||||||
primary.gameOver(false, information.players[1].name);
|
primary.gameOver(false, information.players[1].name);
|
||||||
gameOver();
|
gameOver();
|
||||||
}
|
}
|
||||||
} else if (state == Game.State.DRAW) {
|
} else if (state == GameState.DRAW) {
|
||||||
if (game.getLegalMoves().length == 0) {
|
if (game.getLegalMoves().length == 0) {
|
||||||
primary.gameOver(false, "");
|
primary.gameOver(false, "");
|
||||||
gameOver();
|
gameOver();
|
||||||
@@ -105,7 +106,7 @@ public final class TicTacToeGameThread extends BaseGameThread<TicTacToe, TicTacT
|
|||||||
position = moveQueue.take().position();
|
position = moveQueue.take().position();
|
||||||
} catch (InterruptedException _) {}
|
} catch (InterruptedException _) {}
|
||||||
} else {
|
} else {
|
||||||
final Game.Move move;
|
final Move move;
|
||||||
if (information.players[1].name.equalsIgnoreCase("pism")) {
|
if (information.players[1].name.equalsIgnoreCase("pism")) {
|
||||||
move = ai.findWorstMove(game,9);
|
move = ai.findWorstMove(game,9);
|
||||||
}else{
|
}else{
|
||||||
@@ -126,14 +127,14 @@ public final class TicTacToeGameThread extends BaseGameThread<TicTacToe, TicTacT
|
|||||||
final int currentTurn = game.getCurrentTurn();
|
final int currentTurn = game.getCurrentTurn();
|
||||||
setGameLabels(currentTurn == myTurn);
|
setGameLabels(currentTurn == myTurn);
|
||||||
|
|
||||||
Game.Move move = null;
|
Move move = null;
|
||||||
|
|
||||||
if (information.players[currentTurn].isHuman) {
|
if (information.players[currentTurn].isHuman) {
|
||||||
try {
|
try {
|
||||||
final Game.Move wants = moveQueue.take();
|
final Move wants = moveQueue.take();
|
||||||
final Game.Move[] legalMoves = game.getLegalMoves();
|
final Move[] legalMoves = game.getLegalMoves();
|
||||||
|
|
||||||
for (final Game.Move legalMove : legalMoves) {
|
for (final Move legalMove : legalMoves) {
|
||||||
if (legalMove.position() == wants.position() &&
|
if (legalMove.position() == wants.position() &&
|
||||||
legalMove.value() == wants.value()) {
|
legalMove.value() == wants.value()) {
|
||||||
move = wants;
|
move = wants;
|
||||||
@@ -160,13 +161,13 @@ public final class TicTacToeGameThread extends BaseGameThread<TicTacToe, TicTacT
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Game.State state = game.play(move);
|
final GameState state = game.play(move);
|
||||||
drawMove(move);
|
drawMove(move);
|
||||||
|
|
||||||
if (state != Game.State.NORMAL) {
|
if (state != GameState.NORMAL) {
|
||||||
if (state == Game.State.WIN) {
|
if (state == GameState.WIN) {
|
||||||
primary.gameOver(information.players[currentTurn].isHuman, information.players[currentTurn].name);
|
primary.gameOver(information.players[currentTurn].isHuman, information.players[currentTurn].name);
|
||||||
} else if (state == Game.State.DRAW) {
|
} else if (state == GameState.DRAW) {
|
||||||
primary.gameOver(false, "");
|
primary.gameOver(false, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user