Add confirm button

This commit is contained in:
Felix Koppe
2024-11-30 11:17:42 +01:00
parent be15b3bd63
commit 28a2c9a448
2 changed files with 52 additions and 12 deletions

View File

@@ -17,6 +17,10 @@ public class ModelSyncronizer {
private static final Logger LOGGER = Logger.getLogger(ModelSyncronizer.class.getName());
private MdgaApp app;
private UUID a;
private UUID b;
private BonusCard card;
ModelSyncronizer(MdgaApp app) {
this.app = app;
}
@@ -26,43 +30,73 @@ public void animationEnd() {
}
public void selectSwap(UUID a, UUID b) {
// TODO call from somewhere
LOGGER.log(Level.INFO, "selectPiece");
this.a = a;
this.b = b;
GameView gameView = (GameView) app.getView();
if(a != null && b != null) {
gameView.needConfirm();
} else {
gameView.noConfirm();
}
}
public void selectPiece(UUID piece) {
// TODO call from somewhere
LOGGER.log(Level.INFO, "selectPiece");
this.a = piece;
GameView gameView = (GameView) app.getView();
if(piece != null) {
gameView.needConfirm();
} else {
gameView.noConfirm();
}
}
public void selectCard(BonusCard card) {
// TODO call from somewhere
LOGGER.log(Level.INFO, "selectCard");
this.card = card;
GameView gameView = (GameView) app.getView();
if(card != null) {
gameView.needConfirm();
} else {
gameView.noConfirm();
}
}
public void confirm() {
LOGGER.log(Level.INFO, "confirm");
if(a != null && b != null) {
//swap
} else if (a != null) {
//piece
} else if (card != null){
//card
} else {
throw new RuntimeException("nothing to confirm");
}
}
public void selectTsk(Color color) {
// TODO call from somewhere
LOGGER.log(Level.INFO, "selectTsk: {0}", color);
LobbyView view = (LobbyView) app.getView();
view.setTaken(color, true, true, "OwnPlayerName");
}
public void unselectTsk() {
// TODO call from somewhere
LOGGER.log(Level.INFO, "unselectTsk");
}
public void rolledDice() {
// TODO call from somewhere
LOGGER.log(Level.INFO, "rolledDice");
}
public void setName(String name) {
// TODO call from somewhere
LOGGER.log(Level.INFO, "setName: {0}", name);
}
@@ -72,13 +106,11 @@ public void setReady() {
}
public void setHost(int port) {
// TODO call from somewhere
LOGGER.log(Level.INFO, "setHost: {0}", port);
enter(MdgaState.LOBBY);
}
public void setJoin(String ip, int port) {
// TODO call from somewhere
LOGGER.log(Level.INFO, "setJoin with IP: {0}, Port: {1}", new Object[]{ip, port});
enter(MdgaState.LOBBY);
}
@@ -109,14 +141,14 @@ public void enter(MdgaState state) {
if (state == MdgaState.GAME) {
GameView gameView = (GameView) app.getView();
app.getNotificationSynchronizer().addTestNotification(new DrawCardNotification(Color.AIRFORCE, BonusCard.SHIELD));
//app.getNotificationSynchronizer().addTestNotification(new DrawCardNotification(Color.AIRFORCE, BonusCard.SHIELD));
}
if (state == MdgaState.LOBBY) {
LobbyView lobbyView = (LobbyView) app.getView();
app.getNotificationSynchronizer().addTestNotification(new TskSelectNotification(Color.CYBER, "blablabupp", false));
app.getNotificationSynchronizer().addTestNotification(new TskSelectNotification(Color.ARMY, "Spieler 2", false));
//app.getNotificationSynchronizer().addTestNotification(new TskSelectNotification(Color.CYBER, "blablabupp", false));
//app.getNotificationSynchronizer().addTestNotification(new TskSelectNotification(Color.ARMY, "Spieler 2", false));
lobbyView.setReady(Color.ARMY, true);
}
}

View File

@@ -117,4 +117,12 @@ public void setOwnColor(Color ownColor) {
public Color getOwnColor() {
return ownColor;
}
public void needConfirm() {
confirmButton.show();
}
public void noConfirm() {
confirmButton.hide();
}
}