mirror of
https://github.com/2OOP/pism.git
synced 2026-02-04 19:04:49 +00:00
Merge remote-tracking branch 'origin/Development' into Development
# Conflicts: # app/src/main/java/org/toop/app/App.java # app/src/main/java/org/toop/app/canvas/ReversiCanvas.java # app/src/main/java/org/toop/app/game/ReversiGame.java # app/src/main/java/org/toop/app/game/TicTacToeGame.java # app/src/main/java/org/toop/app/view/displays/SongDisplay.java # app/src/main/java/org/toop/local/AppContext.java
This commit is contained in:
@@ -41,6 +41,8 @@ public final class App extends Application {
|
|||||||
stage.setWidth(1080);
|
stage.setWidth(1080);
|
||||||
stage.setHeight(720);
|
stage.setHeight(720);
|
||||||
|
|
||||||
|
scene.getRoot();
|
||||||
|
|
||||||
stage.setMinWidth(1080);
|
stage.setMinWidth(1080);
|
||||||
stage.setMinHeight(720);
|
stage.setMinHeight(720);
|
||||||
stage.setOnCloseRequest(event -> {
|
stage.setOnCloseRequest(event -> {
|
||||||
|
|||||||
@@ -80,7 +80,5 @@ public final class ReversiCanvas extends GameCanvas {
|
|||||||
innerColor = new Color(1.0f, 1.0f, 1.0f, 0.75f);
|
innerColor = new Color(1.0f, 1.0f, 1.0f, 0.75f);
|
||||||
}
|
}
|
||||||
drawInnerDot(innerColor, cell,false);
|
drawInnerDot(innerColor, cell,false);
|
||||||
public void drawLegalPosition(Color color, int cell) {
|
|
||||||
drawDot(new Color(color.getRed(), color.getGreen(), color.getBlue(), 0.25), cell);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -28,8 +28,6 @@ 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<Game.Move> moveQueue;
|
||||||
private Runnable onGameOver;
|
|
||||||
private final BlockingQueue<Move> moveQueue;
|
|
||||||
|
|
||||||
private final Reversi game;
|
private final Reversi game;
|
||||||
private final ReversiAI ai;
|
private final ReversiAI ai;
|
||||||
@@ -167,16 +165,15 @@ public final class ReversiGame {
|
|||||||
final GameState state = game.play(move);
|
final GameState state = game.play(move);
|
||||||
updateCanvas(true);
|
updateCanvas(true);
|
||||||
|
|
||||||
if (state != Game.State.NORMAL) {
|
|
||||||
if (state == Game.State.WIN) {
|
|
||||||
primary.gameOver(true, information.players[currentTurn].name);
|
|
||||||
} else if (state == Game.State.DRAW) {
|
|
||||||
primary.gameOver(false, "");
|
|
||||||
if (state != GameState.NORMAL) {
|
if (state != GameState.NORMAL) {
|
||||||
if (state == GameState.WIN) {
|
if (state == GameState.TURN_SKIPPED){
|
||||||
view.gameOver(true, information.players[currentTurn].name);
|
continue;
|
||||||
} else if (state == GameState.DRAW) {
|
}
|
||||||
view.gameOver(false, "");
|
int winningPLayerNumber = getPlayerNumberWithHighestScore();
|
||||||
|
if (state == GameState.WIN && winningPLayerNumber > -1) {
|
||||||
|
primary.gameOver(true, information.players[winningPLayerNumber].name);
|
||||||
|
} else if (state == GameState.DRAW || winningPLayerNumber == -1) {
|
||||||
|
primary.gameOver(false, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
isRunning.set(false);
|
isRunning.set(false);
|
||||||
@@ -184,6 +181,13 @@ public final class ReversiGame {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int getPlayerNumberWithHighestScore(){
|
||||||
|
Reversi.Score score = game.getScore();
|
||||||
|
if (score.player1Score() > score.player2Score()) return 0;
|
||||||
|
if (score.player1Score() < score.player2Score()) return 1;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
private void onMoveResponse(NetworkEvents.GameMoveResponse response) {
|
private void onMoveResponse(NetworkEvents.GameMoveResponse response) {
|
||||||
if (!isRunning.get()) {
|
if (!isRunning.get()) {
|
||||||
return;
|
return;
|
||||||
@@ -209,8 +213,8 @@ public final class ReversiGame {
|
|||||||
primary.gameOver(false, information.players[1].name);
|
primary.gameOver(false, information.players[1].name);
|
||||||
gameOver();
|
gameOver();
|
||||||
}
|
}
|
||||||
} else if (state == GameState.DRAW) {
|
} else if (state == Game.State.DRAW) {
|
||||||
view.gameOver(false, "");
|
primary.gameOver(false, "");
|
||||||
game.play(move);
|
game.play(move);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -282,12 +286,12 @@ public final class ReversiGame {
|
|||||||
animation.setOnFinished(_ -> {
|
animation.setOnFinished(_ -> {
|
||||||
isPaused.set(false);
|
isPaused.set(false);
|
||||||
|
|
||||||
|
if (information.players[game.getCurrentTurn()].isHuman) {
|
||||||
final Move[] legalMoves = game.getLegalMoves();
|
final Move[] legalMoves = game.getLegalMoves();
|
||||||
|
|
||||||
for (final Move legalMove : legalMoves) {
|
|
||||||
canvas.drawLegalPosition(legalMove.position(), game.getCurrentPlayer());
|
|
||||||
for (final Game.Move legalMove : legalMoves) {
|
for (final Game.Move legalMove : legalMoves) {
|
||||||
canvas.drawLegalPosition(fromColor, legalMove.position());
|
canvas.drawLegalPosition(legalMove.position(), game.getCurrentPlayer());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -305,6 +309,7 @@ public final class ReversiGame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void highlightCells(int cellEntered) {
|
private void highlightCells(int cellEntered) {
|
||||||
|
if (information.players[game.getCurrentTurn()].isHuman) {
|
||||||
Move[] legalMoves = game.getLegalMoves();
|
Move[] legalMoves = game.getLegalMoves();
|
||||||
boolean isLegalMove = false;
|
boolean isLegalMove = false;
|
||||||
for (Move move : legalMoves) {
|
for (Move move : legalMoves) {
|
||||||
@@ -325,3 +330,4 @@ public final class ReversiGame {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@@ -24,8 +24,8 @@ public final class TicTacToeGame {
|
|||||||
private final GameInformation information;
|
private final GameInformation information;
|
||||||
|
|
||||||
private final int myTurn;
|
private final int myTurn;
|
||||||
private Runnable onGameOver;
|
private final Runnable onGameOver;
|
||||||
private final BlockingQueue<Move> moveQueue;
|
private final BlockingQueue<Game.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 != GameState.NORMAL) {
|
if (state != Game.State.NORMAL) {
|
||||||
if (state == GameState.WIN) {
|
if (state == Game.State.WIN) {
|
||||||
primary.gameOver(true, information.players[currentTurn].name);
|
primary.gameOver(true, information.players[currentTurn].name);
|
||||||
} else if (state == GameState.DRAW) {
|
} else if (state == Game.State.DRAW) {
|
||||||
primary.gameOver(false, "");
|
primary.gameOver(false, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -108,6 +108,10 @@ public class SongDisplay extends VBox implements Widget {
|
|||||||
return time;
|
return time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Node getNode() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
private String getPlayString(boolean paused) {
|
private String getPlayString(boolean paused) {
|
||||||
if (paused) {
|
if (paused) {
|
||||||
return "▶";
|
return "▶";
|
||||||
@@ -116,11 +120,6 @@ public class SongDisplay extends VBox implements Widget {
|
|||||||
return "⏸";
|
return "⏸";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Node getNode() {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
package org.toop.local;
|
package org.toop.local;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.MissingResourceException;
|
||||||
|
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.toop.framework.resource.ResourceManager;
|
import org.toop.framework.resource.ResourceManager;
|
||||||
import org.toop.framework.resource.resources.LocalizationAsset;
|
import org.toop.framework.resource.resources.LocalizationAsset;
|
||||||
|
|
||||||
@@ -14,9 +19,8 @@ public class AppContext {
|
|||||||
private static final LocalizationAsset localization = ResourceManager.get("localization");
|
private static final LocalizationAsset localization = ResourceManager.get("localization");
|
||||||
private static Locale locale = Locale.forLanguageTag("en");
|
private static Locale locale = Locale.forLanguageTag("en");
|
||||||
|
|
||||||
private static final Logger logger = LogManager.getLogger(AppContext.class);
|
|
||||||
|
|
||||||
private static final ObjectProperty<Locale> localeProperty = new SimpleObjectProperty<>(locale);
|
private static final ObjectProperty<Locale> localeProperty = new SimpleObjectProperty<>(locale);
|
||||||
|
private static final Logger logger = LogManager.getLogger(AppContext.class);
|
||||||
|
|
||||||
public static LocalizationAsset getLocalization() {
|
public static LocalizationAsset getLocalization() {
|
||||||
return localization;
|
return localization;
|
||||||
|
|||||||
Reference in New Issue
Block a user