mirror of
https://github.com/2OOP/pism.git
synced 2026-02-04 19:04:49 +00:00
Compare commits
10 Commits
0132981d94
...
297-Fixing
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e5e79bb9b0 | ||
|
|
a982345791 | ||
|
|
d1176f2151 | ||
|
|
39df1be6ee | ||
|
|
4b80072042 | ||
|
|
e6e931b565 | ||
|
|
e5ad144783 | ||
|
|
550ee5874b | ||
|
|
1ae79daef0 | ||
|
|
cd8eb99559 |
@@ -21,7 +21,7 @@ import org.toop.game.games.reversi.BitboardReversi;
|
|||||||
import org.toop.game.games.tictactoe.BitboardTicTacToe;
|
import org.toop.game.games.tictactoe.BitboardTicTacToe;
|
||||||
import org.toop.game.players.ArtificialPlayer;
|
import org.toop.game.players.ArtificialPlayer;
|
||||||
import org.toop.game.players.OnlinePlayer;
|
import org.toop.game.players.OnlinePlayer;
|
||||||
import org.toop.game.players.RandomAI;
|
import org.toop.game.players.ai.RandomAI;
|
||||||
import org.toop.local.AppContext;
|
import org.toop.local.AppContext;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -223,7 +223,7 @@ public final class Server {
|
|||||||
Player<BitboardReversi>[] players = new Player[2];
|
Player<BitboardReversi>[] players = new Player[2];
|
||||||
players[(myTurn + 1) % 2] = new OnlinePlayer<>(response.opponent());
|
players[(myTurn + 1) % 2] = new OnlinePlayer<>(response.opponent());
|
||||||
players[myTurn] = new ArtificialPlayer<>(new RandomAI<BitboardReversi>(), user);
|
players[myTurn] = new ArtificialPlayer<>(new RandomAI<BitboardReversi>(), user);
|
||||||
gameController = new ReversiBitController(players);}
|
gameController = new ReversiBitController(players, false);}
|
||||||
default -> new ErrorPopup("Unsupported game type.");
|
default -> new ErrorPopup("Unsupported game type.");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,6 +108,7 @@ public abstract class BitGameCanvas<T extends TurnBasedGame<T>> implements GameC
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void render() {
|
private void render() {
|
||||||
graphics.setFill(backgroundColor);
|
graphics.setFill(backgroundColor);
|
||||||
graphics.fillRect(0, 0, width, height);
|
graphics.fillRect(0, 0, width, height);
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package org.toop.app.canvas;
|
||||||
|
|
||||||
|
public interface BitLegalMoveDrawer {
|
||||||
|
void showLegalMove(long move, int currentPlayerIndex);
|
||||||
|
}
|
||||||
@@ -4,12 +4,15 @@ import javafx.scene.paint.Color;
|
|||||||
import org.toop.app.App;
|
import org.toop.app.App;
|
||||||
import org.toop.game.games.reversi.BitboardReversi;
|
import org.toop.game.games.reversi.BitboardReversi;
|
||||||
|
|
||||||
import java.util.Arrays;
|
public class ReversiBitCanvas extends BitGameCanvas<BitboardReversi> implements BitLegalMoveDrawer {
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
public class ReversiBitCanvas extends BitGameCanvas<BitboardReversi> {
|
private final boolean switchColors;
|
||||||
public ReversiBitCanvas() {
|
private final boolean local;
|
||||||
|
|
||||||
|
public ReversiBitCanvas(boolean switchColors, boolean local) {
|
||||||
super(Color.GRAY, new Color(0f, 0.4f, 0.2f, 1f), (App.getHeight() / 4) * 3, (App.getHeight() / 4) * 3, 8, 8, 5, true);
|
super(Color.GRAY, new Color(0f, 0.4f, 0.2f, 1f), (App.getHeight() / 4) * 3, (App.getHeight() / 4) * 3, 8, 8, 5, true);
|
||||||
|
this.switchColors = switchColors;
|
||||||
|
this.local = local;
|
||||||
canvas.setOnMouseMoved(event -> {
|
canvas.setOnMouseMoved(event -> {
|
||||||
double mouseX = event.getX();
|
double mouseX = event.getX();
|
||||||
double mouseY = event.getY();
|
double mouseY = event.getY();
|
||||||
@@ -36,7 +39,39 @@ public class ReversiBitCanvas extends BitGameCanvas<BitboardReversi> {
|
|||||||
public void redraw(BitboardReversi gameCopy) {
|
public void redraw(BitboardReversi gameCopy) {
|
||||||
clearAll();
|
clearAll();
|
||||||
long[] board = gameCopy.getBoard();
|
long[] board = gameCopy.getBoard();
|
||||||
|
if (switchColors && local) {
|
||||||
|
loopOverBoard(board[0], (i) -> drawDot(Color.BLACK, i));
|
||||||
|
loopOverBoard(board[1], (i) -> drawDot(Color.WHITE, i));
|
||||||
|
} else {
|
||||||
loopOverBoard(board[0], (i) -> drawDot(Color.WHITE, i));
|
loopOverBoard(board[0], (i) -> drawDot(Color.WHITE, i));
|
||||||
loopOverBoard(board[1], (i) -> drawDot(Color.BLACK, i));
|
loopOverBoard(board[1], (i) -> drawDot(Color.BLACK, i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void showLegalMove(long move, int currentPlayerIndex) {
|
||||||
|
int idx = Long.numberOfTrailingZeros(move);
|
||||||
|
drawLegalMove(idx, currentPlayerIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawLegalMove(int cell, int player) {
|
||||||
|
Color innerColor;
|
||||||
|
if (switchColors) {
|
||||||
|
if (player == 0) {
|
||||||
|
innerColor = new Color(0.0f, 0.0f, 0.0f, 0.6f);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
innerColor = new Color(1.0f, 1.0f, 1.0f, 0.75f);
|
||||||
|
}
|
||||||
|
this.drawInnerDot(innerColor, cell, false);
|
||||||
|
} else {
|
||||||
|
if (player == 1) {
|
||||||
|
innerColor = new Color(0.0f, 0.0f, 0.0f, 0.6f);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
innerColor = new Color(1.0f, 1.0f, 1.0f, 0.75f);
|
||||||
|
}
|
||||||
|
this.drawInnerDot(innerColor, cell, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ public class TicTacToeBitCanvas extends BitGameCanvas<BitboardTicTacToe>{
|
|||||||
private void drawMoves(long[] gameBoard){
|
private void drawMoves(long[] gameBoard){
|
||||||
loopOverBoard(gameBoard[0], (i) -> drawX(Color.RED, i));
|
loopOverBoard(gameBoard[0], (i) -> drawX(Color.RED, i));
|
||||||
loopOverBoard(gameBoard[1], (i) -> drawO(Color.BLUE, i));
|
loopOverBoard(gameBoard[1], (i) -> drawO(Color.BLUE, i));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import javafx.geometry.Pos;
|
|||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.toop.app.canvas.GameCanvas;
|
import org.toop.app.canvas.GameCanvas;
|
||||||
|
import org.toop.app.canvas.BitLegalMoveDrawer;
|
||||||
import org.toop.app.widget.WidgetContainer;
|
import org.toop.app.widget.WidgetContainer;
|
||||||
import org.toop.app.widget.view.GameView;
|
import org.toop.app.widget.view.GameView;
|
||||||
import org.toop.framework.eventbus.EventFlow;
|
import org.toop.framework.eventbus.EventFlow;
|
||||||
@@ -18,7 +19,7 @@ import org.toop.framework.gameFramework.view.GUIEvents;
|
|||||||
import org.toop.framework.networking.events.NetworkEvents;
|
import org.toop.framework.networking.events.NetworkEvents;
|
||||||
import org.toop.game.players.LocalPlayer;
|
import org.toop.game.players.LocalPlayer;
|
||||||
|
|
||||||
public class GenericGameController<T extends TurnBasedGame<T>> implements GameController {
|
public class GenericGameController<T extends TurnBasedGame<T>, C extends GameCanvas<T>> implements GameController {
|
||||||
protected final EventFlow eventFlow = new EventFlow();
|
protected final EventFlow eventFlow = new EventFlow();
|
||||||
|
|
||||||
// Logger for logging
|
// Logger for logging
|
||||||
@@ -27,18 +28,22 @@ public class GenericGameController<T extends TurnBasedGame<T>> implements GameCo
|
|||||||
// Reference to gameView view
|
// Reference to gameView view
|
||||||
protected final GameView gameView;
|
protected final GameView gameView;
|
||||||
|
|
||||||
|
// Reference to String gametype
|
||||||
|
protected final String gameType;
|
||||||
|
|
||||||
// Reference to game canvas
|
// Reference to game canvas
|
||||||
protected final GameCanvas<T> canvas;
|
protected final C canvas;
|
||||||
|
|
||||||
protected final TurnBasedGame<T> game; // Reference to game instance
|
protected final TurnBasedGame<T> game; // Reference to game instance
|
||||||
private final ThreadBehaviour gameThreadBehaviour;
|
private final ThreadBehaviour gameThreadBehaviour;
|
||||||
|
|
||||||
// TODO: Change gameType to automatically happen with either dependency injection or something else.
|
// TODO: Change gameType to automatically happen with either dependency injection or something else.
|
||||||
public GenericGameController(GameCanvas<T> canvas, T game, ThreadBehaviour gameThreadBehaviour, String gameType) {
|
public GenericGameController(C canvas, T game, ThreadBehaviour gameThreadBehaviour, String gameType) {
|
||||||
logger.info("Creating: " + this.getClass());
|
logger.info("Creating: " + this.getClass());
|
||||||
|
|
||||||
this.canvas = canvas;
|
this.canvas = canvas;
|
||||||
this.game = game;
|
this.game = game;
|
||||||
|
this.gameType = gameType;
|
||||||
this.gameThreadBehaviour = gameThreadBehaviour;
|
this.gameThreadBehaviour = gameThreadBehaviour;
|
||||||
|
|
||||||
// Tell thread how to send moves
|
// Tell thread how to send moves
|
||||||
@@ -55,7 +60,7 @@ public class GenericGameController<T extends TurnBasedGame<T>> implements GameCo
|
|||||||
// Listen to updates
|
// Listen to updates
|
||||||
eventFlow
|
eventFlow
|
||||||
.listen(GUIEvents.GameEnded.class, this::onGameFinish, false)
|
.listen(GUIEvents.GameEnded.class, this::onGameFinish, false)
|
||||||
.listen(GUIEvents.PlayerAttemptedMove.class, event -> {if (getCurrentPlayer() instanceof LocalPlayer<T> lp){lp.setMove(event.move());}}, false);
|
.listen(GUIEvents.PlayerAttemptedMove.class, event -> {if (getCurrentPlayer() instanceof LocalPlayer<T> lp){lp.setLastMove(event.move());}}, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start(){
|
public void start(){
|
||||||
@@ -136,5 +141,21 @@ public class GenericGameController<T extends TurnBasedGame<T>> implements GameCo
|
|||||||
@Override
|
@Override
|
||||||
public void updateUI() {
|
public void updateUI() {
|
||||||
canvas.redraw(game.deepCopy());
|
canvas.redraw(game.deepCopy());
|
||||||
|
gameView.updatePlayerInfo(
|
||||||
|
true,
|
||||||
|
getCurrentPlayer().getName(),
|
||||||
|
game.getCurrentTurn() == 0 ? "X" : "O",
|
||||||
|
getPlayer((game.getCurrentTurn() + 1 ) % 2).getName(),
|
||||||
|
this.gameType
|
||||||
|
);
|
||||||
|
// draw legal moves for bit canvasses
|
||||||
|
if (canvas instanceof BitLegalMoveDrawer) {
|
||||||
|
long movesLoop = game.getLegalMoves();
|
||||||
|
while (movesLoop != 0) {
|
||||||
|
long move = 1L << Long.numberOfTrailingZeros(movesLoop);
|
||||||
|
((BitLegalMoveDrawer) canvas).showLegalMove(move, getCurrentPlayerIndex());
|
||||||
|
movesLoop &= movesLoop - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,17 @@
|
|||||||
package org.toop.app.gameControllers;
|
package org.toop.app.gameControllers;
|
||||||
|
|
||||||
|
import javafx.scene.paint.Color;
|
||||||
import org.toop.app.canvas.ReversiBitCanvas;
|
import org.toop.app.canvas.ReversiBitCanvas;
|
||||||
import org.toop.framework.gameFramework.model.game.threadBehaviour.ThreadBehaviour;
|
import org.toop.framework.gameFramework.model.game.threadBehaviour.ThreadBehaviour;
|
||||||
import org.toop.framework.gameFramework.model.player.Player;
|
import org.toop.framework.gameFramework.model.player.Player;
|
||||||
import org.toop.game.gameThreads.LocalThreadBehaviour;
|
import org.toop.game.gameThreads.LocalThreadBehaviour;
|
||||||
import org.toop.game.gameThreads.OnlineThreadBehaviour;
|
import org.toop.game.gameThreads.OnlineThreadBehaviour;
|
||||||
import org.toop.game.games.reversi.BitboardReversi;
|
import org.toop.game.games.reversi.BitboardReversi;
|
||||||
|
import org.toop.game.players.LocalPlayer;
|
||||||
import org.toop.game.players.OnlinePlayer;
|
import org.toop.game.players.OnlinePlayer;
|
||||||
|
|
||||||
public class ReversiBitController extends GenericGameController<BitboardReversi> {
|
public class ReversiBitController extends GenericGameController<BitboardReversi, ReversiBitCanvas> {
|
||||||
public ReversiBitController(Player<BitboardReversi>[] players) {
|
public ReversiBitController(Player<BitboardReversi>[] players, boolean switchColors) {
|
||||||
BitboardReversi game = new BitboardReversi(players);
|
BitboardReversi game = new BitboardReversi(players);
|
||||||
ThreadBehaviour thread = new LocalThreadBehaviour<>(game);
|
ThreadBehaviour thread = new LocalThreadBehaviour<>(game);
|
||||||
for (Player<BitboardReversi> player : players) {
|
for (Player<BitboardReversi> player : players) {
|
||||||
@@ -17,6 +19,6 @@ public class ReversiBitController extends GenericGameController<BitboardReversi>
|
|||||||
thread = new OnlineThreadBehaviour<>(game);
|
thread = new OnlineThreadBehaviour<>(game);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super(new ReversiBitCanvas(), game, thread, "Reversi");
|
super(new ReversiBitCanvas(switchColors, players[0] instanceof LocalPlayer<BitboardReversi> || players[1] instanceof LocalPlayer<BitboardReversi>), game, thread, "Reversi");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import org.toop.game.gameThreads.OnlineThreadBehaviour;
|
|||||||
import org.toop.game.games.tictactoe.BitboardTicTacToe;
|
import org.toop.game.games.tictactoe.BitboardTicTacToe;
|
||||||
import org.toop.game.players.OnlinePlayer;
|
import org.toop.game.players.OnlinePlayer;
|
||||||
|
|
||||||
public class TicTacToeBitController extends GenericGameController<BitboardTicTacToe> {
|
public class TicTacToeBitController extends GenericGameController<BitboardTicTacToe, TicTacToeBitCanvas > {
|
||||||
public TicTacToeBitController(Player<BitboardTicTacToe>[] players) {
|
public TicTacToeBitController(Player<BitboardTicTacToe>[] players) {
|
||||||
BitboardTicTacToe game = new BitboardTicTacToe(players);
|
BitboardTicTacToe game = new BitboardTicTacToe(players);
|
||||||
ThreadBehaviour thread = new LocalThreadBehaviour<>(game);
|
ThreadBehaviour thread = new LocalThreadBehaviour<>(game);
|
||||||
|
|||||||
@@ -16,14 +16,15 @@ import org.toop.app.widget.tutorial.Connect4TutorialWidget;
|
|||||||
import org.toop.app.widget.tutorial.ReversiTutorialWidget;
|
import org.toop.app.widget.tutorial.ReversiTutorialWidget;
|
||||||
import org.toop.app.widget.tutorial.TicTacToeTutorialWidget;
|
import org.toop.app.widget.tutorial.TicTacToeTutorialWidget;
|
||||||
import org.toop.local.AppContext;
|
import org.toop.local.AppContext;
|
||||||
|
import org.toop.local.AppSettings;
|
||||||
|
|
||||||
public final class GameView extends ViewWidget {
|
public final class GameView extends ViewWidget {
|
||||||
private final Text playerHeader;
|
private final Text playerHeader;
|
||||||
private final Text turnHeader;
|
private final Text turnHeader;
|
||||||
private final Text player1Header;
|
private final Text player1Header;
|
||||||
private final Text player2Header;
|
private final Text player2Header;
|
||||||
private Circle player1Icon;
|
private final Circle player1Icon;
|
||||||
private Circle player2Icon;
|
private final Circle player2Icon;
|
||||||
private final Button forfeitButton;
|
private final Button forfeitButton;
|
||||||
private final Button exitButton;
|
private final Button exitButton;
|
||||||
private final TextField chatInput;
|
private final TextField chatInput;
|
||||||
@@ -94,7 +95,7 @@ public final class GameView extends ViewWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void nextPlayer(boolean isMe, String currentPlayer, String currentMove, String nextPlayer, char GameType) {
|
public void updatePlayerInfo(boolean isMe, String currentPlayer, String currentMove, String nextPlayer, String GameType) {
|
||||||
Platform.runLater(() -> {
|
Platform.runLater(() -> {
|
||||||
if (!(hasSet)) {
|
if (!(hasSet)) {
|
||||||
playerHeader.setText(currentPlayer + " vs. " + nextPlayer);
|
playerHeader.setText(currentPlayer + " vs. " + nextPlayer);
|
||||||
@@ -112,8 +113,8 @@ public final class GameView extends ViewWidget {
|
|||||||
new GameOverPopup(iWon, winner).show(Pos.CENTER);
|
new GameOverPopup(iWon, winner).show(Pos.CENTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setPlayerHeaders(boolean isMe, String currentPlayer, String nextPlayer, char GameType) {
|
private void setPlayerHeaders(boolean isMe, String currentPlayer, String nextPlayer, String GameType) {
|
||||||
if (GameType == 'T') {
|
if (GameType.equals("TicTacToe")) {
|
||||||
if (isMe) {
|
if (isMe) {
|
||||||
player1Header.setText("X: " + currentPlayer);
|
player1Header.setText("X: " + currentPlayer);
|
||||||
player2Header.setText("O: " + nextPlayer);
|
player2Header.setText("O: " + nextPlayer);
|
||||||
@@ -124,15 +125,16 @@ public final class GameView extends ViewWidget {
|
|||||||
}
|
}
|
||||||
setPlayerInfoTTT();
|
setPlayerInfoTTT();
|
||||||
}
|
}
|
||||||
else if (GameType == 'R') {
|
else if (GameType.equals("Reversi")) {
|
||||||
if (isMe) {
|
boolean swap = AppSettings.getSettings().getSwitchReversi();
|
||||||
player1Header.setText(currentPlayer);
|
if (!swap) {
|
||||||
player2Header.setText(nextPlayer);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
player1Header.setText(nextPlayer);
|
player1Header.setText(nextPlayer);
|
||||||
player2Header.setText(currentPlayer);
|
player2Header.setText(currentPlayer);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
player1Header.setText(currentPlayer);
|
||||||
|
player2Header.setText(nextPlayer);
|
||||||
|
}
|
||||||
setPlayerInfoReversi();
|
setPlayerInfoReversi();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -166,8 +168,8 @@ public final class GameView extends ViewWidget {
|
|||||||
var playerInfo = Primitive.vbox(
|
var playerInfo = Primitive.vbox(
|
||||||
playerHeader,
|
playerHeader,
|
||||||
Primitive.separator(),
|
Primitive.separator(),
|
||||||
player1box,
|
player2box,
|
||||||
player2box
|
player1box
|
||||||
);
|
);
|
||||||
|
|
||||||
player1Icon.setRadius(player1Header.fontProperty().map(Font::getSize).getValue());
|
player1Icon.setRadius(player1Header.fontProperty().map(Font::getSize).getValue());
|
||||||
|
|||||||
@@ -2,9 +2,6 @@ package org.toop.app.widget.view;
|
|||||||
|
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import org.toop.app.GameInformation;
|
import org.toop.app.GameInformation;
|
||||||
import org.toop.app.canvas.ReversiBitCanvas;
|
|
||||||
import org.toop.app.canvas.TicTacToeBitCanvas;
|
|
||||||
import org.toop.app.gameControllers.GenericGameController;
|
|
||||||
import org.toop.app.gameControllers.ReversiBitController;
|
import org.toop.app.gameControllers.ReversiBitController;
|
||||||
import org.toop.app.gameControllers.TicTacToeBitController;
|
import org.toop.app.gameControllers.TicTacToeBitController;
|
||||||
import org.toop.framework.gameFramework.controller.GameController;
|
import org.toop.framework.gameFramework.controller.GameController;
|
||||||
@@ -18,8 +15,8 @@ import org.toop.app.widget.complex.PlayerInfoWidget;
|
|||||||
import org.toop.app.widget.complex.ViewWidget;
|
import org.toop.app.widget.complex.ViewWidget;
|
||||||
import org.toop.app.widget.popup.ErrorPopup;
|
import org.toop.app.widget.popup.ErrorPopup;
|
||||||
import org.toop.app.widget.tutorial.*;
|
import org.toop.app.widget.tutorial.*;
|
||||||
import org.toop.game.players.MiniMaxAI;
|
import org.toop.game.players.ai.MiniMaxAI;
|
||||||
import org.toop.game.players.RandomAI;
|
import org.toop.game.players.ai.RandomAI;
|
||||||
import org.toop.local.AppContext;
|
import org.toop.local.AppContext;
|
||||||
|
|
||||||
import javafx.geometry.Pos;
|
import javafx.geometry.Pos;
|
||||||
@@ -27,9 +24,6 @@ import javafx.scene.control.ScrollPane;
|
|||||||
import javafx.scene.layout.VBox;
|
import javafx.scene.layout.VBox;
|
||||||
import org.toop.local.AppSettings;
|
import org.toop.local.AppSettings;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
public class LocalMultiplayerView extends ViewWidget {
|
public class LocalMultiplayerView extends ViewWidget {
|
||||||
private final GameInformation information;
|
private final GameInformation information;
|
||||||
|
|
||||||
@@ -85,6 +79,7 @@ public class LocalMultiplayerView extends ViewWidget {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case REVERSI:
|
case REVERSI:
|
||||||
|
boolean swap = AppSettings.getSettings().getSwitchReversi();
|
||||||
if (information.players[0].isHuman) {
|
if (information.players[0].isHuman) {
|
||||||
players[0] = new LocalPlayer<>(information.players[0].name);
|
players[0] = new LocalPlayer<>(information.players[0].name);
|
||||||
} else {
|
} else {
|
||||||
@@ -98,17 +93,17 @@ public class LocalMultiplayerView extends ViewWidget {
|
|||||||
if (AppSettings.getSettings().getTutorialFlag() && AppSettings.getSettings().getFirstReversi()) {
|
if (AppSettings.getSettings().getTutorialFlag() && AppSettings.getSettings().getFirstReversi()) {
|
||||||
new ShowEnableTutorialWidget(
|
new ShowEnableTutorialWidget(
|
||||||
() -> new ReversiTutorialWidget(() -> {
|
() -> new ReversiTutorialWidget(() -> {
|
||||||
gameController = new ReversiBitController(players);
|
gameController = new ReversiBitController(players, swap);
|
||||||
gameController.start();
|
gameController.start();
|
||||||
}),
|
}),
|
||||||
() -> Platform.runLater(() -> {
|
() -> Platform.runLater(() -> {
|
||||||
gameController = new ReversiBitController(players);
|
gameController = new ReversiBitController(players, swap);
|
||||||
gameController.start();
|
gameController.start();
|
||||||
}),
|
}),
|
||||||
() -> AppSettings.getSettings().setFirstReversi(false)
|
() -> AppSettings.getSettings().setFirstReversi(false)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
gameController = new ReversiBitController(players);
|
gameController = new ReversiBitController(players, swap);
|
||||||
gameController.start();
|
gameController.start();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -149,13 +149,22 @@ public class OptionsView extends ViewWidget {
|
|||||||
"small", "medium", "large"
|
"small", "medium", "large"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
var swapReversiColors = new ToggleWidget(
|
||||||
|
"reversinotswapped", "reversiswapped",
|
||||||
|
AppSettings.getSettings().getSwitchReversi(),
|
||||||
|
swap -> {
|
||||||
|
AppSettings.getSettings().setSwitchReversi(swap);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
return Primitive.vbox(
|
return Primitive.vbox(
|
||||||
Primitive.header("style"),
|
Primitive.header("style"),
|
||||||
Primitive.separator(),
|
Primitive.separator(),
|
||||||
|
|
||||||
themeWidget.getNode(),
|
themeWidget.getNode(),
|
||||||
layoutWidget.getNode()
|
layoutWidget.getNode(),
|
||||||
|
Primitive.text("reversiswap"),
|
||||||
|
swapReversiColors.getNode()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,18 +5,16 @@ import org.toop.framework.audio.VolumeControl;
|
|||||||
import org.toop.framework.audio.events.AudioEvents;
|
import org.toop.framework.audio.events.AudioEvents;
|
||||||
import org.toop.framework.eventbus.EventFlow;
|
import org.toop.framework.eventbus.EventFlow;
|
||||||
import org.toop.framework.resource.ResourceManager;
|
import org.toop.framework.resource.ResourceManager;
|
||||||
import org.toop.framework.resource.ResourceMeta;
|
|
||||||
import org.toop.framework.resource.resources.SettingsAsset;
|
import org.toop.framework.resource.resources.SettingsAsset;
|
||||||
import org.toop.framework.settings.Settings;
|
import org.toop.framework.settings.Settings;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
public class AppSettings {
|
public class AppSettings {
|
||||||
private static SettingsAsset settingsAsset;
|
private static SettingsAsset settingsAsset;
|
||||||
|
|
||||||
public static void applySettings() {
|
public static void applySettings() {
|
||||||
settingsAsset = getPath();
|
settingsAsset = getSettingsAsset();
|
||||||
if (!settingsAsset.isLoaded()) {
|
if (!settingsAsset.isLoaded()) {
|
||||||
settingsAsset.load();
|
settingsAsset.load();
|
||||||
}
|
}
|
||||||
@@ -45,26 +43,9 @@ public class AppSettings {
|
|||||||
.postEvent();
|
.postEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SettingsAsset getPath() {
|
public static SettingsAsset getSettingsAsset() {
|
||||||
if (settingsAsset == null) {
|
if (settingsAsset == null) {
|
||||||
String os = System.getProperty("os.name").toLowerCase();
|
settingsAsset = SettingsAsset.getPath();
|
||||||
String basePath;
|
|
||||||
|
|
||||||
if (os.contains("win")) {
|
|
||||||
basePath = System.getenv("APPDATA");
|
|
||||||
if (basePath == null) {
|
|
||||||
basePath = System.getProperty("user.home");
|
|
||||||
}
|
|
||||||
} else if (os.contains("mac")) {
|
|
||||||
basePath = System.getProperty("user.home") + "/Library/Application Support";
|
|
||||||
} else {
|
|
||||||
basePath = System.getProperty("user.home") + "/.config";
|
|
||||||
}
|
|
||||||
|
|
||||||
File settingsFile =
|
|
||||||
new File(basePath + File.separator + "ISY1" + File.separator + "settings.json");
|
|
||||||
// this.settingsAsset = new SettingsAsset(settingsFile);
|
|
||||||
ResourceManager.addAsset(new ResourceMeta<>("settings.json", new SettingsAsset(settingsFile)));
|
|
||||||
}
|
}
|
||||||
return ResourceManager.get("settings.json");
|
return ResourceManager.get("settings.json");
|
||||||
}
|
}
|
||||||
@@ -110,5 +91,6 @@ public class AppSettings {
|
|||||||
settingsAsset.setMusicVolume(15);
|
settingsAsset.setMusicVolume(15);
|
||||||
settingsAsset.setTutorialFlag(true);
|
settingsAsset.setTutorialFlag(true);
|
||||||
settingsAsset.setLayoutSize("medium");
|
settingsAsset.setLayoutSize("medium");
|
||||||
|
settingsAsset.setSwitchReversi(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -89,6 +89,9 @@ turnof=\u062F\u0648\u0631\u0647
|
|||||||
zwartepiet=\u0633\u0647\u0644: Zwarte Piet
|
zwartepiet=\u0633\u0647\u0644: Zwarte Piet
|
||||||
sinterklaas=\u0645\u062a\u0648\u0633\u0637: Sint R. Klaas
|
sinterklaas=\u0645\u062a\u0648\u0633\u0637: Sint R. Klaas
|
||||||
santa=\u0635\u0639\u0628: Santa
|
santa=\u0635\u0639\u0628: Santa
|
||||||
|
reversiswapped=\u0645\u0628\u062F\u0651\u064E\u0644
|
||||||
|
reversinotswapped=\u063A\u064A\u0631\u0020\u0645\u0628\u062F\u0651\u064E\u0644
|
||||||
|
reversiswap=\u0647\u0644\u0020\u062A\u0631\u064A\u062F\u0020\u062A\u0628\u062F\u064A\u0644\u0020\u0623\u0644\u0648\u0627\u0646\u0020\u0627\u0644\u0631\u064A\u0641\u064E\u0631\u0633\u064A\u061F\u0020\u0645\u062D\u0644\u064A\u0020\u0641\u0642\u0637\u002E
|
||||||
|
|
||||||
|
|
||||||
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629
|
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629
|
||||||
|
|||||||
@@ -91,6 +91,9 @@ turnof=ist dran
|
|||||||
zwartepiet=Leicht: Zwarte Piet
|
zwartepiet=Leicht: Zwarte Piet
|
||||||
sinterklaas=Mittel: Sint R. Klaas
|
sinterklaas=Mittel: Sint R. Klaas
|
||||||
santa=Schwer: Santa
|
santa=Schwer: Santa
|
||||||
|
reversiswapped=Getauscht
|
||||||
|
reversinotswapped=Nicht getauscht
|
||||||
|
reversiswap=M\u00F6chten Sie die Reversi-Farben tauschen? Nur lokal.
|
||||||
|
|
||||||
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (Arabisch)
|
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (Arabisch)
|
||||||
chinese=\u4e2d\u6587 (Chinesisch)
|
chinese=\u4e2d\u6587 (Chinesisch)
|
||||||
|
|||||||
@@ -93,6 +93,9 @@ turnof='s turn
|
|||||||
zwartepiet=Easy: Zwarte Piet
|
zwartepiet=Easy: Zwarte Piet
|
||||||
sinterklaas=Medium: Sint R. Klaas
|
sinterklaas=Medium: Sint R. Klaas
|
||||||
santa=Hard:Santa
|
santa=Hard:Santa
|
||||||
|
reversiswapped=Swapped
|
||||||
|
reversinotswapped=Not Swapped
|
||||||
|
reversiswap=Do you want to swap the Reversi colors? Local only.
|
||||||
|
|
||||||
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (Arabic)
|
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (Arabic)
|
||||||
chinese=\u4e2d\u6587 (Chinese)
|
chinese=\u4e2d\u6587 (Chinese)
|
||||||
|
|||||||
@@ -90,6 +90,9 @@ turnof=le toca
|
|||||||
zwartepiet=F\u00e1cil: Zwarte Piet
|
zwartepiet=F\u00e1cil: Zwarte Piet
|
||||||
sinterklaas=Medio: Sint R. Klaas
|
sinterklaas=Medio: Sint R. Klaas
|
||||||
santa=Dif\u00edcil: Santa
|
santa=Dif\u00edcil: Santa
|
||||||
|
reversiswapped=Cambiado
|
||||||
|
reversinotswapped=No cambiado
|
||||||
|
reversiswap=\u00BFDeseas intercambiar los colores de Reversi? Solo local.
|
||||||
|
|
||||||
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (Ar\u00e1bigo)
|
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (Ar\u00e1bigo)
|
||||||
chinese=\u4e2d\u6587 (Chino)
|
chinese=\u4e2d\u6587 (Chino)
|
||||||
|
|||||||
@@ -90,6 +90,9 @@ turnof=\u00E0 son tour
|
|||||||
zwartepiet=Facile: Zwarte Piet
|
zwartepiet=Facile: Zwarte Piet
|
||||||
sinterklaas=Moyen : Sint R. Klaas
|
sinterklaas=Moyen : Sint R. Klaas
|
||||||
santa=Difficile: Santa
|
santa=Difficile: Santa
|
||||||
|
reversiswapped=\u00C9chang\u00E9
|
||||||
|
reversinotswapped=Non \u00E9chang\u00E9
|
||||||
|
reversiswap=Voulez-vous \u00E9changer les couleurs de Reversi ? Local uniquement.
|
||||||
|
|
||||||
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (Arabe)
|
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (Arabe)
|
||||||
chinese=\u4e2d\u6587 (Chinois)
|
chinese=\u4e2d\u6587 (Chinois)
|
||||||
|
|||||||
@@ -90,6 +90,9 @@ turnof=\u0915\u0940 \u092C\u093E\u0930\u0940
|
|||||||
zwartepiet=\u0905\u0938\u093e\u0928: Zwarte Piet
|
zwartepiet=\u0905\u0938\u093e\u0928: Zwarte Piet
|
||||||
sinterklaas=\u092e\u0927\u094d\u092f\u092e: Sint R. Klaas
|
sinterklaas=\u092e\u0927\u094d\u092f\u092e: Sint R. Klaas
|
||||||
santa=\u0915\u0924\u093f\u0928: Santa
|
santa=\u0915\u0924\u093f\u0928: Santa
|
||||||
|
reversiswapped=\u092C\u0926\u0932\u093E\u0020\u0939\u0941\u0906
|
||||||
|
reversinotswapped=\u0928\u0939\u0940\u0902\u0020\u092C\u0926\u0932\u093E\u0020\u0939\u0941\u0906
|
||||||
|
reversiswap=\u0915\u094D\u092F\u093E\u0020\u0906\u092A\u0020\u0930\u093F\u0935\u0930\u094D\u0938\u0940\u0020\u0915\u0947\u0020\u0930\u0902\u0917\u0020\u092C\u0926\u0932\u0928\u093E\u0020\u091A\u093E\u0939\u0924\u0947\u0020\u0939\u0948\u0902?\u0020\u0915\u0947\u0935\u0932\u0020\u0938\u094D\u0925\u093E\u0928\u0940\u092F\u002E
|
||||||
|
|
||||||
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (\u0905\u0930\u092c\u0940)
|
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (\u0905\u0930\u092c\u0940)
|
||||||
chinese=\u4e2d\u6587 (\u091a\u0940\u0928\u0940)
|
chinese=\u4e2d\u6587 (\u091a\u0940\u0928\u0940)
|
||||||
|
|||||||
@@ -89,6 +89,9 @@ turnof=\u00E8 il suo turno
|
|||||||
zwartepiet=Facile: Zwarte Piet
|
zwartepiet=Facile: Zwarte Piet
|
||||||
sinterklaas=Medio: Sint R. Klaas
|
sinterklaas=Medio: Sint R. Klaas
|
||||||
santa=Difficile: Santa
|
santa=Difficile: Santa
|
||||||
|
reversiswapped=Scambiato
|
||||||
|
reversinotswapped=Non scambiato
|
||||||
|
reversiswap=Vuoi scambiare i colori di Reversi? Solo locale.
|
||||||
|
|
||||||
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (Arabo)
|
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (Arabo)
|
||||||
chinese=\u4e2d\u6587 (Cinese)
|
chinese=\u4e2d\u6587 (Cinese)
|
||||||
|
|||||||
@@ -89,6 +89,10 @@ turnof=\u306E\u756A
|
|||||||
zwartepiet=\u7c21\u5358: Zwarte Piet
|
zwartepiet=\u7c21\u5358: Zwarte Piet
|
||||||
sinterklaas=\u4e2d\u7d1a: Sint R. Klaas
|
sinterklaas=\u4e2d\u7d1a: Sint R. Klaas
|
||||||
santa=\u96e3\u3057\u3044: Santa
|
santa=\u96e3\u3057\u3044: Santa
|
||||||
|
reversiswapped=\u5165\u308C\u66FF\u3048\u6E08\u307F
|
||||||
|
reversinotswapped=\u672A\u5165\u308C\u66FF\u3048
|
||||||
|
reversiswap=\u30EA\u30D0\u30FC\u30B7\u306E\u8272\u3092\u5165\u308C\u66FF\u3048\u307E\u3059\u304B?\u0020\u30ED\u30FC\u30AB\u30EB\u306E\u307F\u3067\u3059\u002E
|
||||||
|
|
||||||
|
|
||||||
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (\u30a2\u30e9\u30d3\u30a2\u8a9e)
|
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (\u30a2\u30e9\u30d3\u30a2\u8a9e)
|
||||||
chinese=\u4e2d\u6587 (\u4e2d\u6587)
|
chinese=\u4e2d\u6587 (\u4e2d\u6587)
|
||||||
|
|||||||
@@ -89,6 +89,9 @@ turnof=\uC758 \uCC28\uB840
|
|||||||
zwartepiet=\uc218\uc601: Zwarte Piet
|
zwartepiet=\uc218\uc601: Zwarte Piet
|
||||||
sinterklaas=\ubcf4\ud1b5: Sint R. Klaas
|
sinterklaas=\ubcf4\ud1b5: Sint R. Klaas
|
||||||
santa=\uc5d0\uc18c: Santa
|
santa=\uc5d0\uc18c: Santa
|
||||||
|
reversiswapped=\uAD50\uCCB4\uB428
|
||||||
|
reversinotswapped=\uAD50\uCCB4\uB418\uC9C0 \uC54A\uC74C
|
||||||
|
reversiswap=\uB9AC\uBC84\uC2DC \uC0C9\uC0C1\uC744 \uBC14\uAFB8\uC2DC\uACA0\uC2B5\uB2C8\uAE4C?\u0020\uB85C\uCEEC \uC804\uC6A9\u0020\uC785\uB2C8\uB2E4\u002E
|
||||||
|
|
||||||
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (\u0639\u0631\u0628\u064a\u0629)
|
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (\u0639\u0631\u0628\u064a\u0629)
|
||||||
chinese=\u4e2d\u6587 (\u4e2d\u6587)
|
chinese=\u4e2d\u6587 (\u4e2d\u6587)
|
||||||
|
|||||||
@@ -89,6 +89,9 @@ turnof=is aan de beurt
|
|||||||
zwartepiet=Makkelijk: Zwarte Piet
|
zwartepiet=Makkelijk: Zwarte Piet
|
||||||
sinterklaas=Gemiddeld: Sint R. Klaas
|
sinterklaas=Gemiddeld: Sint R. Klaas
|
||||||
santa=Moeilijk: Santa
|
santa=Moeilijk: Santa
|
||||||
|
reversiswapped=Gewisseld
|
||||||
|
reversinotswapped=Niet gewisseld
|
||||||
|
reversiswap=Wil je de Reversi-kleuren wisselen? Alleen lokaal.
|
||||||
|
|
||||||
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (Arabisch)
|
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (Arabisch)
|
||||||
chinese=\u4e2d\u6587 (Chinees)
|
chinese=\u4e2d\u6587 (Chinees)
|
||||||
|
|||||||
@@ -89,6 +89,9 @@ turnof=\u0445\u043E\u0434\u0438\u0442
|
|||||||
zwartepiet=\u041b\u0435\u0433\u043a\u043e: Zwarte Piet
|
zwartepiet=\u041b\u0435\u0433\u043a\u043e: Zwarte Piet
|
||||||
sinterklaas=\u0421\u0440\u0435\u0434\u043d\u0438\u0439: Sint R. Klaas
|
sinterklaas=\u0421\u0440\u0435\u0434\u043d\u0438\u0439: Sint R. Klaas
|
||||||
santa=\u0421\u043b\u043e\u0436\u043d\u043e: Santa
|
santa=\u0421\u043b\u043e\u0436\u043d\u043e: Santa
|
||||||
|
reversiswapped=\u041F\u043E\u043C\u0435\u043D\u044F\u043D\u043E
|
||||||
|
reversinotswapped=\u041D\u0435 \u043F\u043E\u043C\u0435\u043D\u044F\u043D\u043E
|
||||||
|
reversiswap=\u0425\u043E\u0442\u0438\u0442\u0435 \u043F\u043E\u043C\u0435\u043D\u044F\u0442\u044C \u0446\u0432\u0435\u0442\u0430 \u0420\u0435\u0432\u0435\u0440\u0441\u0438?\u0020\u0422\u043E\u043B\u044C\u043A\u043E \u043B\u043E\u043A\u0430\u043B\u044C\u043D\u043E\u002E
|
||||||
|
|
||||||
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (\u0410\u0440\u0430\u0431\u0441\u043a\u0438\u0439)
|
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (\u0410\u0440\u0430\u0431\u0441\u043a\u0438\u0439)
|
||||||
chinese=\u4e2d\u6587 (\u041a\u0438\u0442\u0430\u0439\u0441\u043a\u0438\u0439)
|
chinese=\u4e2d\u6587 (\u041a\u0438\u0442\u0430\u0439\u0441\u043a\u0438\u0439)
|
||||||
|
|||||||
@@ -89,6 +89,9 @@ turnof=\u7684\u56DE\u5408
|
|||||||
zwartepiet=\u7b80\u5355: Zwarte Piet
|
zwartepiet=\u7b80\u5355: Zwarte Piet
|
||||||
sinterklaas=\u4e2d\u7b49: Sint R. Klaas
|
sinterklaas=\u4e2d\u7b49: Sint R. Klaas
|
||||||
santa=\u56f0\u96be: Santa
|
santa=\u56f0\u96be: Santa
|
||||||
|
reversiswapped=\u5DF2\u4EA4\u6362
|
||||||
|
reversinotswapped=\u672A\u4EA4\u6362
|
||||||
|
reversiswap=\u662F\u5426\u8981\u4EA4\u6362\u9ED1\u767D\u68CB\u7684\u989C\u8272\uFF1F\u4EC5\u9650\u672C\u5730\u002E
|
||||||
|
|
||||||
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (\u963f\u62c9\u4f2f\u8bed)
|
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (\u963f\u62c9\u4f2f\u8bed)
|
||||||
chinese=\u4e2d\u6587
|
chinese=\u4e2d\u6587
|
||||||
|
|||||||
@@ -5,45 +5,65 @@ import org.apache.logging.log4j.Logger;
|
|||||||
import org.toop.framework.gameFramework.model.game.TurnBasedGame;
|
import org.toop.framework.gameFramework.model.game.TurnBasedGame;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract class representing a player in a game.
|
* Base class for players in a turn-based game.
|
||||||
* <p>
|
*
|
||||||
* Players are entities that can make moves based on the current state of a game.
|
* @param <T> the game type
|
||||||
* player types, such as human players or AI players.
|
|
||||||
* </p>
|
|
||||||
* <p>
|
|
||||||
* Subclasses should override the {@link #getMove(GameR)} method to provide
|
|
||||||
* specific move logic.
|
|
||||||
* </p>
|
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractPlayer<T extends TurnBasedGame<T>> implements Player<T> {
|
public abstract class AbstractPlayer<T extends TurnBasedGame<T>> implements Player<T> {
|
||||||
private final Logger logger = LogManager.getLogger(this.getClass());
|
|
||||||
|
|
||||||
|
private final Logger logger = LogManager.getLogger(this.getClass());
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new player with the given name.
|
||||||
|
*
|
||||||
|
* @param name the player name
|
||||||
|
*/
|
||||||
protected AbstractPlayer(String name) {
|
protected AbstractPlayer(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a copy of another player.
|
||||||
|
*
|
||||||
|
* @param other the player to copy
|
||||||
|
*/
|
||||||
protected AbstractPlayer(AbstractPlayer<T> other) {
|
protected AbstractPlayer(AbstractPlayer<T> other) {
|
||||||
this.name = other.name;
|
this.name = other.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines the next move based on the provided game state.
|
* Gets the player's move for the given game state.
|
||||||
|
* A deep copy is provided so the player cannot modify the real state.
|
||||||
* <p>
|
* <p>
|
||||||
* The default implementation throws an {@link UnsupportedOperationException},
|
* This method uses the Template Method Pattern: it defines the fixed
|
||||||
* indicating that concrete subclasses must override this method to provide
|
* algorithm and delegates the variable part to {@link #determineMove(T)}.
|
||||||
* actual move logic.
|
|
||||||
* </p>
|
|
||||||
*
|
*
|
||||||
* @param gameCopy a snapshot of the current game state
|
* @param game the current game
|
||||||
* @return an integer representing the chosen move
|
* @return the chosen move
|
||||||
* @throws UnsupportedOperationException if the method is not overridden
|
|
||||||
*/
|
*/
|
||||||
public long getMove(T gameCopy) {
|
public final long getMove(T game) {
|
||||||
logger.error("Method getMove not implemented.");
|
return determineMove(game.deepCopy());
|
||||||
throw new UnsupportedOperationException("Not supported yet.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines the player's move using a safe copy of the game.
|
||||||
|
* <p>
|
||||||
|
* This method is called by {@link #getMove(T)} and should contain
|
||||||
|
* the player's strategy for choosing a move.
|
||||||
|
*
|
||||||
|
* @param gameCopy a deep copy of the game
|
||||||
|
* @return the chosen move
|
||||||
|
*/
|
||||||
|
protected abstract long determineMove(T gameCopy);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the player's name.
|
||||||
|
*
|
||||||
|
* @return the name
|
||||||
|
*/
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,9 @@ package org.toop.framework.resource.resources;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import org.toop.framework.resource.ResourceManager;
|
||||||
|
import org.toop.framework.resource.ResourceMeta;
|
||||||
import org.toop.framework.settings.Settings;
|
import org.toop.framework.settings.Settings;
|
||||||
|
|
||||||
public class SettingsAsset extends JsonAsset<Settings> {
|
public class SettingsAsset extends JsonAsset<Settings> {
|
||||||
@@ -54,6 +57,10 @@ public class SettingsAsset extends JsonAsset<Settings> {
|
|||||||
return getContent().firstReversi;
|
return getContent().firstReversi;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getSwitchReversi() {
|
||||||
|
return getContent().switchReversi;
|
||||||
|
}
|
||||||
|
|
||||||
public void setVolume(int volume) {
|
public void setVolume(int volume) {
|
||||||
getContent().volume = volume;
|
getContent().volume = volume;
|
||||||
save();
|
save();
|
||||||
@@ -108,4 +115,51 @@ public class SettingsAsset extends JsonAsset<Settings> {
|
|||||||
getContent().firstReversi = firstReversi;
|
getContent().firstReversi = firstReversi;
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSwitchReversi(boolean switchReversi) {
|
||||||
|
getContent().switchReversi = switchReversi;
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setContent(Settings settings) {
|
||||||
|
setVolume(settings.volume);
|
||||||
|
setFxVolume(settings.fxVolume);
|
||||||
|
setMusicVolume(settings.musicVolume);
|
||||||
|
setLocale(settings.locale);
|
||||||
|
setFullscreen(settings.fullScreen);
|
||||||
|
setTheme(settings.theme);
|
||||||
|
setLayoutSize(settings.layoutSize);
|
||||||
|
setTutorialFlag(settings.showTutorials);
|
||||||
|
setFirstTTT(settings.firstTTT);
|
||||||
|
setFirstConnect4(settings.firstConnect4);
|
||||||
|
setFirstReversi(settings.firstReversi);
|
||||||
|
setSwitchReversi(settings.switchReversi);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SettingsAsset getPath() {
|
||||||
|
SettingsAsset settingsAsset;
|
||||||
|
try {
|
||||||
|
settingsAsset = ResourceManager.get("settings.json");
|
||||||
|
} catch (Exception e) {
|
||||||
|
String os = System.getProperty("os.name").toLowerCase();
|
||||||
|
String basePath;
|
||||||
|
|
||||||
|
if (os.contains("win")) {
|
||||||
|
basePath = System.getenv("APPDATA");
|
||||||
|
if (basePath == null) {
|
||||||
|
basePath = System.getProperty("user.home");
|
||||||
|
}
|
||||||
|
} else if (os.contains("mac")) {
|
||||||
|
basePath = System.getProperty("user.home") + "/Library/Application Support";
|
||||||
|
} else {
|
||||||
|
basePath = System.getProperty("user.home") + "/.config";
|
||||||
|
}
|
||||||
|
|
||||||
|
File settingsFile =
|
||||||
|
new File(basePath + File.separator + "ISY1" + File.separator + "settings.json");
|
||||||
|
settingsAsset = new SettingsAsset(settingsFile);
|
||||||
|
ResourceManager.addAsset(new ResourceMeta<>("settings.json", settingsAsset));
|
||||||
|
}
|
||||||
|
return settingsAsset;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,5 +12,5 @@ public class Settings {
|
|||||||
public Boolean firstReversi;
|
public Boolean firstReversi;
|
||||||
public Boolean firstTTT;
|
public Boolean firstTTT;
|
||||||
public Boolean firstConnect4;
|
public Boolean firstConnect4;
|
||||||
|
public boolean switchReversi = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,135 @@
|
|||||||
|
package org.toop.framework.settings;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.AfterEach;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.toop.framework.resource.resources.SettingsAsset;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
public class SettingsAssetTest {
|
||||||
|
|
||||||
|
private Settings copySettings;
|
||||||
|
private SettingsAsset settingsAsset;
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void setup() {
|
||||||
|
this.settingsAsset = SettingsAsset.getPath();
|
||||||
|
Settings original = settingsAsset.getContent();
|
||||||
|
this.copySettings = new Settings();
|
||||||
|
this.copySettings.volume = original.volume;
|
||||||
|
this.copySettings.fxVolume = original.fxVolume;
|
||||||
|
this.copySettings.musicVolume = original.musicVolume;
|
||||||
|
this.copySettings.locale = original.locale;
|
||||||
|
this.copySettings.fullScreen = original.fullScreen;
|
||||||
|
this.copySettings.theme = original.theme;
|
||||||
|
this.copySettings.layoutSize = original.layoutSize;
|
||||||
|
this.copySettings.showTutorials = original.showTutorials;
|
||||||
|
this.copySettings.firstTTT = original.firstTTT;
|
||||||
|
this.copySettings.firstConnect4 = original.firstConnect4;
|
||||||
|
this.copySettings.firstReversi = original.firstReversi;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@AfterEach
|
||||||
|
void teardown() {
|
||||||
|
settingsAsset.setContent(copySettings);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testVolume() {
|
||||||
|
settingsAsset.setVolume(55);
|
||||||
|
assertEquals(55, settingsAsset.getVolume());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testFxVolume() {
|
||||||
|
settingsAsset.setFxVolume(33);
|
||||||
|
assertEquals(33, settingsAsset.getFxVolume());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testMusicVolume() {
|
||||||
|
settingsAsset.setMusicVolume(77);
|
||||||
|
assertEquals(77, settingsAsset.getMusicVolume());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testLocale() {
|
||||||
|
settingsAsset.setLocale("es-ES");
|
||||||
|
assertEquals(Locale.forLanguageTag("es-ES"), settingsAsset.getLocale());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testFullscreen() {
|
||||||
|
settingsAsset.setFullscreen(true);
|
||||||
|
assertTrue(settingsAsset.getFullscreen());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testTheme() {
|
||||||
|
settingsAsset.setTheme("dark");
|
||||||
|
assertEquals("dark", settingsAsset.getTheme());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testLayoutsize() {
|
||||||
|
settingsAsset.setLayoutSize("large");
|
||||||
|
assertEquals("large", settingsAsset.getLayoutSize());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testTutorialflag() {
|
||||||
|
settingsAsset.setTutorialFlag(false);
|
||||||
|
assertFalse(settingsAsset.getTutorialFlag());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testTTT() {
|
||||||
|
settingsAsset.setFirstTTT(true);
|
||||||
|
assertTrue(settingsAsset.getFirstTTT());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testConnect4() {
|
||||||
|
settingsAsset.setFirstConnect4(false);
|
||||||
|
assertFalse(settingsAsset.getFirstConnect4());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testReversi() {
|
||||||
|
settingsAsset.setFirstReversi(true);
|
||||||
|
assertTrue(settingsAsset.getFirstReversi());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testReplaceFields() {
|
||||||
|
Settings newSettings = new Settings();
|
||||||
|
newSettings.volume = 10;
|
||||||
|
newSettings.fxVolume = 20;
|
||||||
|
newSettings.musicVolume = 30;
|
||||||
|
newSettings.locale = "fr-FR";
|
||||||
|
newSettings.fullScreen = true;
|
||||||
|
newSettings.theme = "light";
|
||||||
|
newSettings.layoutSize = "medium";
|
||||||
|
newSettings.showTutorials = false;
|
||||||
|
newSettings.firstTTT = false;
|
||||||
|
newSettings.firstConnect4 = true;
|
||||||
|
newSettings.firstReversi = false;
|
||||||
|
settingsAsset.setContent(newSettings);
|
||||||
|
assertEquals(10, settingsAsset.getVolume());
|
||||||
|
assertEquals(20, settingsAsset.getFxVolume());
|
||||||
|
assertEquals(30, settingsAsset.getMusicVolume());
|
||||||
|
assertEquals(Locale.forLanguageTag("fr-FR"), settingsAsset.getLocale());
|
||||||
|
assertTrue(settingsAsset.getFullscreen());
|
||||||
|
assertEquals("light", settingsAsset.getTheme());
|
||||||
|
assertEquals("medium", settingsAsset.getLayoutSize());
|
||||||
|
assertFalse(settingsAsset.getTutorialFlag());
|
||||||
|
assertFalse(settingsAsset.getFirstTTT());
|
||||||
|
assertTrue(settingsAsset.getFirstConnect4());
|
||||||
|
assertFalse(settingsAsset.getFirstReversi());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -4,52 +4,52 @@ import org.toop.framework.gameFramework.model.player.*;
|
|||||||
import org.toop.framework.gameFramework.model.game.TurnBasedGame;
|
import org.toop.framework.gameFramework.model.game.TurnBasedGame;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a player controlled by an AI in a game.
|
* Represents a player controlled by an AI.
|
||||||
* <p>
|
|
||||||
* This player uses an {@link AbstractAI} instance to determine its moves. The generic
|
|
||||||
* parameter {@code T} specifies the type of {@link GameR} the AI can handle.
|
|
||||||
* </p>
|
|
||||||
*
|
*
|
||||||
* @param <T> the specific type of game this AI player can play
|
* @param <T> the type of turn-based game
|
||||||
*/
|
*/
|
||||||
public class ArtificialPlayer<T extends TurnBasedGame<T>> extends AbstractPlayer<T> {
|
public class ArtificialPlayer<T extends TurnBasedGame<T>> extends AbstractPlayer<T> {
|
||||||
|
|
||||||
/** The AI instance used to calculate moves. */
|
|
||||||
private final AI<T> ai;
|
private final AI<T> ai;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new ArtificialPlayer using the specified AI.
|
* Creates a new AI-controlled player.
|
||||||
*
|
*
|
||||||
* @param ai the AI instance that determines moves for this player
|
* @param ai the AI controlling this player
|
||||||
|
* @param name the player's name
|
||||||
*/
|
*/
|
||||||
public ArtificialPlayer(AI<T> ai, String name) {
|
public ArtificialPlayer(AI<T> ai, String name) {
|
||||||
super(name);
|
super(name);
|
||||||
this.ai = ai;
|
this.ai = ai;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a copy of another AI-controlled player.
|
||||||
|
*
|
||||||
|
* @param other the player to copy
|
||||||
|
*/
|
||||||
public ArtificialPlayer(ArtificialPlayer<T> other) {
|
public ArtificialPlayer(ArtificialPlayer<T> other) {
|
||||||
super(other);
|
super(other);
|
||||||
this.ai = other.ai.deepCopy();
|
this.ai = other.ai.deepCopy();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines the next move for this player using its AI.
|
* Determines the player's move using the AI.
|
||||||
* <p>
|
|
||||||
* This method overrides {@link AbstractPlayer#getMove(GameR)}. Because the AI is
|
|
||||||
* typed to {@code T}, a runtime cast is required. It is the caller's
|
|
||||||
* responsibility to ensure that {@code gameCopy} is of type {@code T}.
|
|
||||||
* </p>
|
|
||||||
*
|
*
|
||||||
* @param gameCopy a copy of the current game state
|
* @param gameCopy a copy of the current game
|
||||||
* @return the integer representing the chosen move
|
* @return the move chosen by the AI
|
||||||
* @throws ClassCastException if {@code gameCopy} is not of type {@code T}
|
|
||||||
*/
|
*/
|
||||||
public long getMove(T gameCopy) {
|
protected long determineMove(T gameCopy) {
|
||||||
return ai.getMove(gameCopy);
|
return ai.getMove(gameCopy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a deep copy of this AI player.
|
||||||
|
*
|
||||||
|
* @return a copy of this player
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ArtificialPlayer<T> deepCopy() {
|
public ArtificialPlayer<T> deepCopy() {
|
||||||
return new ArtificialPlayer<T>(this);
|
return new ArtificialPlayer<>(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,85 +2,86 @@ package org.toop.game.players;
|
|||||||
|
|
||||||
import org.toop.framework.gameFramework.model.game.TurnBasedGame;
|
import org.toop.framework.gameFramework.model.game.TurnBasedGame;
|
||||||
import org.toop.framework.gameFramework.model.player.AbstractPlayer;
|
import org.toop.framework.gameFramework.model.player.AbstractPlayer;
|
||||||
import org.toop.framework.gameFramework.model.player.Player;
|
|
||||||
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a local player who provides moves manually.
|
||||||
|
*
|
||||||
|
* @param <T> the type of turn-based game
|
||||||
|
*/
|
||||||
public class LocalPlayer<T extends TurnBasedGame<T>> extends AbstractPlayer<T> {
|
public class LocalPlayer<T extends TurnBasedGame<T>> extends AbstractPlayer<T> {
|
||||||
// Future can be used with event system, IF unsubscribeAfterSuccess works...
|
|
||||||
// private CompletableFuture<Integer> LastMove = new CompletableFuture<>();
|
|
||||||
|
|
||||||
private CompletableFuture<Long> LastMove;
|
private CompletableFuture<Long> LastMove = new CompletableFuture<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new local player with the given name.
|
||||||
|
*
|
||||||
|
* @param name the player's name
|
||||||
|
*/
|
||||||
public LocalPlayer(String name) {
|
public LocalPlayer(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a copy of another local player.
|
||||||
|
*
|
||||||
|
* @param other the player to copy
|
||||||
|
*/
|
||||||
public LocalPlayer(LocalPlayer<T> other) {
|
public LocalPlayer(LocalPlayer<T> other) {
|
||||||
super(other);
|
super(other);
|
||||||
|
this.LastMove = other.LastMove;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Waits for and returns the player's next legal move.
|
||||||
|
*
|
||||||
|
* @param gameCopy a copy of the current game
|
||||||
|
* @return the chosen move
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public long getMove(T gameCopy) {
|
protected long determineMove(T gameCopy) {
|
||||||
return getValidMove(gameCopy);
|
long legalMoves = gameCopy.getLegalMoves();
|
||||||
|
long move;
|
||||||
|
|
||||||
|
do {
|
||||||
|
move = getLastMove();
|
||||||
|
} while ((legalMoves & move) == 0);
|
||||||
|
|
||||||
|
return move;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMove(long move) {
|
/**
|
||||||
|
* Sets the player's last move.
|
||||||
|
*
|
||||||
|
* @param move the move to set
|
||||||
|
*/
|
||||||
|
public void setLastMove(long move) {
|
||||||
LastMove.complete(move);
|
LastMove.complete(move);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: helper function, would like to replace to get rid of this method
|
/**
|
||||||
public static boolean contains(int[] array, int value){
|
* Waits for the next move from the player.
|
||||||
for (int i : array) if (i == value) return true;
|
*
|
||||||
return false;
|
* @return the chosen move or 0 if interrupted
|
||||||
}
|
*/
|
||||||
|
private long getLastMove() {
|
||||||
private long getMove2(T gameCopy) {
|
LastMove = new CompletableFuture<>(); // Reset the future
|
||||||
LastMove = new CompletableFuture<>();
|
|
||||||
long move = 0;
|
|
||||||
try {
|
try {
|
||||||
move = LastMove.get();
|
return LastMove.get();
|
||||||
System.out.println(Long.toBinaryString(move));
|
} catch (ExecutionException | InterruptedException e) {
|
||||||
} catch (InterruptedException | ExecutionException e) {
|
return 0;
|
||||||
// TODO: Add proper logging.
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
return move;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected long getValidMove(T gameCopy){
|
|
||||||
// Get this player's valid moves
|
|
||||||
long validMoves = gameCopy.getLegalMoves();
|
|
||||||
// Make sure provided move is valid
|
|
||||||
// TODO: Limit amount of retries?
|
|
||||||
// TODO: Stop copying game so many times
|
|
||||||
long move = getMove2(gameCopy.deepCopy());
|
|
||||||
while ((validMoves & move) == 0) {
|
|
||||||
System.out.println("Not a valid move, try again");
|
|
||||||
move = getMove2(gameCopy.deepCopy());
|
|
||||||
}
|
|
||||||
return move;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a deep copy of this local player.
|
||||||
|
*
|
||||||
|
* @return a copy of this player
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public LocalPlayer<T> deepCopy() {
|
public LocalPlayer<T> deepCopy() {
|
||||||
return new LocalPlayer<T>(this.getName());
|
return new LocalPlayer<>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*public void register() {
|
|
||||||
// Listening to PlayerAttemptedMove
|
|
||||||
new EventFlow().listen(GUIEvents.PlayerAttemptedMove.class, event -> {
|
|
||||||
if (!LastMove.isDone()) {
|
|
||||||
LastMove.complete(event.move()); // complete the future
|
|
||||||
}
|
|
||||||
}, true); // auto-unsubscribe
|
|
||||||
}
|
|
||||||
|
|
||||||
// This blocks until the next move arrives
|
|
||||||
public int take() throws ExecutionException, InterruptedException {
|
|
||||||
int move = LastMove.get(); // blocking
|
|
||||||
LastMove = new CompletableFuture<>(); // reset for next move
|
|
||||||
return move;
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,30 +5,45 @@ import org.toop.framework.gameFramework.model.player.AbstractPlayer;
|
|||||||
import org.toop.framework.gameFramework.model.player.Player;
|
import org.toop.framework.gameFramework.model.player.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a player controlled remotely or over a network.
|
* Represents a player that participates online.
|
||||||
* <p>
|
*
|
||||||
* This class extends {@link AbstractPlayer} and can be used to implement game logic
|
* @param <T> the type of turn-based game
|
||||||
* where moves are provided by an external source (e.g., another user or a server).
|
|
||||||
* Currently, this class is a placeholder and does not implement move logic.
|
|
||||||
* </p>
|
|
||||||
*/
|
*/
|
||||||
public class OnlinePlayer<T extends TurnBasedGame<T>> extends AbstractPlayer<T> {
|
public class OnlinePlayer<T extends TurnBasedGame<T>> extends AbstractPlayer<T> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new OnlinePlayer.
|
* Creates a new online player with the given name.
|
||||||
* <p>
|
*
|
||||||
* Currently, no additional initialization is performed. Subclasses or
|
* @param name the name of the player
|
||||||
* future implementations should provide mechanisms to receive moves from
|
|
||||||
* an external source.
|
|
||||||
*/
|
*/
|
||||||
public OnlinePlayer(String name) {
|
public OnlinePlayer(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a copy of another online player.
|
||||||
|
*
|
||||||
|
* @param other the player to copy
|
||||||
|
*/
|
||||||
public OnlinePlayer(OnlinePlayer<T> other) {
|
public OnlinePlayer(OnlinePlayer<T> other) {
|
||||||
super(other);
|
super(other);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* <p>
|
||||||
|
* This method is not supported for online players.
|
||||||
|
*
|
||||||
|
* @throws UnsupportedOperationException always
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected long determineMove(T gameCopy) {
|
||||||
|
throw new UnsupportedOperationException("An online player does not support determining move");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Player<T> deepCopy() {
|
public Player<T> deepCopy() {
|
||||||
return new OnlinePlayer<>(this);
|
return new OnlinePlayer<>(this);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.toop.game.players;
|
package org.toop.game.players.ai;
|
||||||
|
|
||||||
import org.toop.framework.gameFramework.GameState;
|
import org.toop.framework.gameFramework.GameState;
|
||||||
import org.toop.framework.gameFramework.model.game.PlayResult;
|
import org.toop.framework.gameFramework.model.game.PlayResult;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.toop.game.players;
|
package org.toop.game.players.ai;
|
||||||
|
|
||||||
import org.toop.framework.gameFramework.model.game.TurnBasedGame;
|
import org.toop.framework.gameFramework.model.game.TurnBasedGame;
|
||||||
import org.toop.framework.gameFramework.model.player.AbstractAI;
|
import org.toop.framework.gameFramework.model.player.AbstractAI;
|
||||||
Reference in New Issue
Block a user