mirror of
https://github.com/2OOP/pism.git
synced 2026-02-04 19:04:49 +00:00
turn updates
This commit is contained in:
@@ -99,7 +99,7 @@ public class ReversiController extends AbstractGameController<ReversiR> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
animation.play();
|
animation.play();
|
||||||
primary.nextPlayer(true, getCurrentPlayer().getName(), game.getCurrentTurn() == 0 ? "X" : "O", getPlayer((game.getCurrentTurn() + 1) % 2).getName());
|
primary.nextPlayer(true, getCurrentPlayer().getName(), game.getCurrentTurn() == 0 ? "X" : "O", getPlayer((game.getCurrentTurn() + 1) % 2).getName(), 'R');
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ public class TicTacToeController extends AbstractGameController<TicTacToeR> {
|
|||||||
public void updateUI() {
|
public void updateUI() {
|
||||||
canvas.clearAll();
|
canvas.clearAll();
|
||||||
// TODO: wtf is even this pile of poop temp fix
|
// TODO: wtf is even this pile of poop temp fix
|
||||||
primary.nextPlayer(true, getCurrentPlayer().getName(), game.getCurrentTurn() == 0 ? "X" : "O", getPlayer((game.getCurrentTurn() + 1) % 2).getName());
|
primary.nextPlayer(true, getCurrentPlayer().getName(), game.getCurrentTurn() == 0 ? "X" : "O", getPlayer((game.getCurrentTurn() + 1) % 2).getName(), 'T');
|
||||||
drawMoves();
|
drawMoves();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,34 +1,44 @@
|
|||||||
package org.toop.app.widget.view;
|
package org.toop.app.widget.view;
|
||||||
|
|
||||||
|
import javafx.scene.paint.Color;
|
||||||
|
import javafx.scene.shape.Circle;
|
||||||
|
import javafx.scene.text.Font;
|
||||||
import org.toop.app.widget.Primitive;
|
import org.toop.app.widget.Primitive;
|
||||||
import org.toop.app.widget.complex.ViewWidget;
|
import org.toop.app.widget.complex.ViewWidget;
|
||||||
import org.toop.app.widget.popup.GameOverPopup;
|
import org.toop.app.widget.popup.GameOverPopup;
|
||||||
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.geometry.Pos;
|
import javafx.geometry.Pos;
|
||||||
import javafx.scene.control.Button;
|
import javafx.scene.control.Button;
|
||||||
import javafx.scene.control.TextField;
|
import javafx.scene.control.TextField;
|
||||||
import javafx.scene.text.Text;
|
import javafx.scene.text.Text;
|
||||||
import org.toop.app.widget.tutorial.BaseTutorialWidget;
|
|
||||||
import org.toop.app.widget.tutorial.Connect4TutorialWidget;
|
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;
|
||||||
|
|
||||||
public final class GameView extends ViewWidget {
|
public final class GameView extends ViewWidget {
|
||||||
private final Text currentPlayerHeader;
|
private final Text playerHeader;
|
||||||
private final Text currentMoveHeader;
|
private final Text turnHeader;
|
||||||
private final Text nextPlayerHeader;
|
private final Text player1Header;
|
||||||
|
private final Text player2Header;
|
||||||
|
private Circle player1Icon;
|
||||||
|
private Circle player2Icon;
|
||||||
private final Button forfeitButton;
|
private final Button forfeitButton;
|
||||||
private final Button exitButton;
|
private final Button exitButton;
|
||||||
private final Button tutorialButton;
|
private final Button tutorialButton;
|
||||||
private final TextField chatInput;
|
private final TextField chatInput;
|
||||||
|
private final Text keyThingy;
|
||||||
|
private boolean hasSet = false;
|
||||||
|
|
||||||
public GameView(Runnable onForfeit, Runnable onExit, Consumer<String> onMessage, String gameType) {
|
public GameView(Runnable onForfeit, Runnable onExit, Consumer<String> onMessage, String gameType) {
|
||||||
currentPlayerHeader = Primitive.header("");
|
playerHeader = Primitive.header("");
|
||||||
currentMoveHeader = Primitive.header("");
|
turnHeader = Primitive.header("");
|
||||||
nextPlayerHeader = Primitive.header("");
|
keyThingy = Primitive.text("turnof");
|
||||||
|
player1Header = Primitive.header("");
|
||||||
|
player2Header = Primitive.header("");
|
||||||
|
player1Icon = new Circle();
|
||||||
|
player2Icon = new Circle();
|
||||||
|
|
||||||
if (onForfeit != null) {
|
if (onForfeit != null) {
|
||||||
forfeitButton = Primitive.button("forfeit", () -> onForfeit.run());
|
forfeitButton = Primitive.button("forfeit", () -> onForfeit.run());
|
||||||
@@ -66,17 +76,11 @@ public final class GameView extends ViewWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setupLayout() {
|
private void setupLayout() {
|
||||||
var playerInfo = Primitive.vbox(
|
var turnInfo = Primitive.vbox(
|
||||||
currentPlayerHeader,
|
turnHeader
|
||||||
Primitive.hbox(
|
);
|
||||||
Primitive.separator(),
|
|
||||||
currentMoveHeader,
|
|
||||||
Primitive.separator()
|
|
||||||
),
|
|
||||||
nextPlayerHeader
|
|
||||||
);
|
|
||||||
|
|
||||||
add(Pos.TOP_RIGHT, playerInfo);
|
add(Pos.TOP_CENTER, turnInfo);
|
||||||
|
|
||||||
var buttons = Primitive.vbox(
|
var buttons = Primitive.vbox(
|
||||||
forfeitButton,
|
forfeitButton,
|
||||||
@@ -94,21 +98,92 @@ public final class GameView extends ViewWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void nextPlayer(boolean isMe, String currentPlayer, String currentMove, String nextPlayer) {
|
public void nextPlayer(boolean isMe, String currentPlayer, String currentMove, String nextPlayer, char GameType) {
|
||||||
Platform.runLater(() -> {
|
Platform.runLater(() -> {
|
||||||
currentPlayerHeader.setText(currentPlayer);
|
if (!(hasSet)) {
|
||||||
currentMoveHeader.setText(currentMove);
|
playerHeader.setText(currentPlayer + " vs. " + nextPlayer);
|
||||||
nextPlayerHeader.setText(nextPlayer);
|
hasSet = true;
|
||||||
|
setPlayerHeaders(isMe, currentPlayer, nextPlayer, GameType);
|
||||||
|
}
|
||||||
|
//TODO idk if theres any way to check this? only EN uses 's and the rest doesnt. if theres a better way to do this pls let me know
|
||||||
|
if (AppContext.getLocale().toLanguageTag().equals("en")) {
|
||||||
|
turnHeader.setText(currentPlayer + keyThingy.getText());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
turnHeader.setText(currentPlayer + " " + keyThingy.getText());
|
||||||
|
}
|
||||||
|
|
||||||
if (isMe) {
|
if (isMe) {
|
||||||
currentPlayerHeader.getStyleClass().add("my-turn");
|
turnHeader.getStyleClass().add("my-turn");
|
||||||
} else {
|
}
|
||||||
currentPlayerHeader.getStyleClass().remove("my-turn");
|
else {
|
||||||
}
|
turnHeader.getStyleClass().remove("my-turn");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void gameOver(boolean iWon, String winner) {
|
public void gameOver(boolean iWon, String winner) {
|
||||||
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) {
|
||||||
|
if (GameType == 'T') {
|
||||||
|
if (isMe) {
|
||||||
|
player1Header.setText("X: " + currentPlayer);
|
||||||
|
player2Header.setText("O: " + nextPlayer);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
player1Header.setText("X: " + nextPlayer);
|
||||||
|
player2Header.setText("O: " + currentPlayer);
|
||||||
|
}
|
||||||
|
setPlayerInfoTTT();
|
||||||
|
}
|
||||||
|
else if (GameType == 'R') {
|
||||||
|
if (isMe) {
|
||||||
|
player1Header.setText(currentPlayer);
|
||||||
|
player2Header.setText(nextPlayer);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
player1Header.setText(nextPlayer);
|
||||||
|
player2Header.setText(currentPlayer);
|
||||||
|
}
|
||||||
|
setPlayerInfoReversi();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setPlayerInfoTTT() {
|
||||||
|
var playerInfo = Primitive.vbox(
|
||||||
|
playerHeader,
|
||||||
|
Primitive.separator(),
|
||||||
|
player1Header,
|
||||||
|
player2Header
|
||||||
|
);
|
||||||
|
|
||||||
|
add(Pos.TOP_RIGHT, playerInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setPlayerInfoReversi() {
|
||||||
|
var player1box = Primitive.hbox(
|
||||||
|
player1Icon,
|
||||||
|
player1Header
|
||||||
|
);
|
||||||
|
|
||||||
|
var player2box = Primitive.hbox(
|
||||||
|
player2Icon,
|
||||||
|
player2Header
|
||||||
|
);
|
||||||
|
|
||||||
|
var playerInfo = Primitive.vbox(
|
||||||
|
playerHeader,
|
||||||
|
Primitive.separator(),
|
||||||
|
player1box,
|
||||||
|
player2box
|
||||||
|
);
|
||||||
|
|
||||||
|
player1Icon.setRadius(player1Header.fontProperty().map(Font::getSize).getValue());
|
||||||
|
player2Icon.setRadius(player2Header.fontProperty().map(Font::getSize).getValue());
|
||||||
|
player1Icon.setFill(Color.BLACK);
|
||||||
|
player2Icon.setFill(Color.WHITE);
|
||||||
|
add(Pos.TOP_RIGHT, playerInfo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -85,6 +85,8 @@ reversi4=\u0627\u0644\u0644\u0627\u0639\u0628 \u0627\u0644\u0630\u064a \u064a\u0
|
|||||||
tutorialstring=\u0627\u0644\u062f\u0631\u0633 \u0627\u0644\u062a\u0648\u0636\u064a\u062d\u064a
|
tutorialstring=\u0627\u0644\u062f\u0631\u0633 \u0627\u0644\u062a\u0648\u0636\u064a\u062d\u064a
|
||||||
startgame=\u0627\u0628\u062f\u0623 \u0627\u0644\u0644\u0639\u0628\u0629!
|
startgame=\u0627\u0628\u062f\u0623 \u0627\u0644\u0644\u0639\u0628\u0629!
|
||||||
goback=\u0627\u0631\u062c\u0639
|
goback=\u0627\u0631\u062c\u0639
|
||||||
|
turnof=\u062F\u0648\u0631\u0647
|
||||||
|
|
||||||
|
|
||||||
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629
|
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629
|
||||||
chinese=\u4e2d\u6587 (\u0627\u0644\u0635\u064a\u0646\u064a\u0629)
|
chinese=\u4e2d\u6587 (\u0627\u0644\u0635\u064a\u0646\u064a\u0629)
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ reversi4=Der Spieler, der am Ende die meisten Steine auf dem Brett hat, gewinnt.
|
|||||||
tutorialstring=Tutorial
|
tutorialstring=Tutorial
|
||||||
startgame=Spiel starten!
|
startgame=Spiel starten!
|
||||||
goback=Zur<EFBFBD>ck
|
goback=Zur<EFBFBD>ck
|
||||||
|
turnof=ist dran
|
||||||
|
|
||||||
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)
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ reversi4=The player who wins at the end of the game is the one who has the most
|
|||||||
tutorialstring=Tutorial
|
tutorialstring=Tutorial
|
||||||
startgame=Start game!
|
startgame=Start game!
|
||||||
goback=Go back
|
goback=Go back
|
||||||
|
turnof='s turn
|
||||||
|
|
||||||
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)
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ reversi4=El jugador que gane al final del juego es quien tenga m
|
|||||||
tutorialstring=Tutorial
|
tutorialstring=Tutorial
|
||||||
startgame=\u00a1Iniciar juego!
|
startgame=\u00a1Iniciar juego!
|
||||||
goback=Volver
|
goback=Volver
|
||||||
|
turnof=le toca
|
||||||
|
|
||||||
|
|
||||||
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (Ar\u00e1bigo)
|
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (Ar\u00e1bigo)
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ reversi4=Le joueur qui a le plus de pions
|
|||||||
tutorialstring=Tutoriel
|
tutorialstring=Tutoriel
|
||||||
startgame=D\u00e9marrer le jeu!
|
startgame=D\u00e9marrer le jeu!
|
||||||
goback=Retour
|
goback=Retour
|
||||||
|
turnof=\u00E0 son tour
|
||||||
|
|
||||||
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)
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ reversi4=\u0916\u0941\u092f \u0915\u093f \u0915\u0940 \u0928\u093f\u092e\u0940 \
|
|||||||
tutorialstring=\u0924\u0942\u091f\u0949\u0930\u093f\u092f\u0932
|
tutorialstring=\u0924\u0942\u091f\u0949\u0930\u093f\u092f\u0932
|
||||||
startgame=\u0916\u0947\u0932 \u0936\u0941\u0930\u0942 \u0915\u0930\u0947\u0902!
|
startgame=\u0916\u0947\u0932 \u0936\u0941\u0930\u0942 \u0915\u0930\u0947\u0902!
|
||||||
goback=\u0935\u093e\u092a\u0938 \u091c\u093e\u090f\u0901
|
goback=\u0935\u093e\u092a\u0938 \u091c\u093e\u090f\u0901
|
||||||
|
turnof=\u0915\u0940 \u092C\u093E\u0930\u0940
|
||||||
|
|
||||||
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)
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ reversi4=Il giocatore che alla fine del gioco ha pi
|
|||||||
tutorialstring=Tutorial
|
tutorialstring=Tutorial
|
||||||
startgame=Avvia il gioco!
|
startgame=Avvia il gioco!
|
||||||
goback=Indietro
|
goback=Indietro
|
||||||
|
turnof=\u00E8 il suo turno
|
||||||
|
|
||||||
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)
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ reversi4=\u672c\u6b21\u306b\u30dc\u30fc\u30c9\u4e0a\u3067\u6700\u591a\u306e\u8ca
|
|||||||
tutorialstring=\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb
|
tutorialstring=\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb
|
||||||
startgame=\u30b2\u30fc\u30e0\u3092\u958b\u59cb\uff01
|
startgame=\u30b2\u30fc\u30e0\u3092\u958b\u59cb\uff01
|
||||||
goback=\u623b\u308b
|
goback=\u623b\u308b
|
||||||
|
turnof=\u306E\u756A
|
||||||
|
|
||||||
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)
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ reversi4=\uacbd\uc6b0 \uc5d0\uc11c \ucd5c\ub300 \ud648\uc744 \uac00\uc838\ub294
|
|||||||
tutorialstring=\ud14c\ud2b8\ub9ad
|
tutorialstring=\ud14c\ud2b8\ub9ad
|
||||||
startgame=\uac8c\uc784 \uc2dc\uc791!
|
startgame=\uac8c\uc784 \uc2dc\uc791!
|
||||||
goback=\ub4a4\ub85c \uac00\uae30
|
goback=\ub4a4\ub85c \uac00\uae30
|
||||||
|
turnof=\uC758 \uCC28\uB840
|
||||||
|
|
||||||
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)
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ reversi4=De speler die aan het einde van het spel de meeste stukken op het bord
|
|||||||
tutorialstring=Tutorial
|
tutorialstring=Tutorial
|
||||||
startgame=Spel starten!
|
startgame=Spel starten!
|
||||||
goback=Ga terug
|
goback=Ga terug
|
||||||
|
turnof=is aan de beurt
|
||||||
|
|
||||||
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)
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ reversi4=\u0418043 \u0433043 \u0440043 \u043e043 \u043a043 \u043e043 \u0442043 \
|
|||||||
tutorialstring=\u0423\u0447\u0435\u0431\u043d\u0438\u043a
|
tutorialstring=\u0423\u0447\u0435\u0431\u043d\u0438\u043a
|
||||||
startgame=\u041d\u0430\u0447\u0430\u0442\u044c \u0438\u0433\u0440\u0443!
|
startgame=\u041d\u0430\u0447\u0430\u0442\u044c \u0438\u0433\u0440\u0443!
|
||||||
goback=\u041d\u0430\u0437\u0430\u0434
|
goback=\u041d\u0430\u0437\u0430\u0434
|
||||||
|
turnof=\u0445\u043E\u0434\u0438\u0442
|
||||||
|
|
||||||
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)
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ reversi4=\u672c\u6e38\u620f\u7ed3\u675f\u65f6\u8d62\u5f97\u6ee1\u8fc7\u76d8\u976
|
|||||||
tutorialstring=\u6559\u7a0b
|
tutorialstring=\u6559\u7a0b
|
||||||
startgame=\u5f00\u59cb\u6e38\u620f\uff01
|
startgame=\u5f00\u59cb\u6e38\u620f\uff01
|
||||||
goback=\u8fd4\u56de
|
goback=\u8fd4\u56de
|
||||||
|
turnof=\u7684\u56DE\u5408
|
||||||
|
|
||||||
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
|
||||||
|
|||||||
Reference in New Issue
Block a user