Prepare for model

This commit is contained in:
Felix Koppe
2024-12-01 17:44:37 +01:00
parent 21f98de3e6
commit 5b8032bed9
2 changed files with 21 additions and 60 deletions

View File

@@ -12,11 +12,15 @@
import pp.mdga.notification.TskSelectNotification; import pp.mdga.notification.TskSelectNotification;
import java.util.UUID; import java.util.UUID;
import java.util.logging.ConsoleHandler;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
public class ModelSynchronizer { public class ModelSynchronizer {
private static final Logger LOGGER = Logger.getLogger(ModelSynchronizer.class.getName()); private static final Logger LOGGER = Logger.getLogger(ModelSynchronizer.class.getName());
ConsoleHandler handler = new ConsoleHandler();
private MdgaApp app; private MdgaApp app;
private UUID a; private UUID a;
@@ -25,6 +29,13 @@ public class ModelSynchronizer {
ModelSynchronizer(MdgaApp app) { ModelSynchronizer(MdgaApp app) {
this.app = app; this.app = app;
LOGGER.setLevel(Level.INFO);
handler.setLevel(Level.ALL);
LOGGER.addHandler(handler);
LOGGER.setUseParentHandlers(false);
} }
private Color testColor; private Color testColor;
@@ -35,7 +46,6 @@ public void animationEnd() {
} }
public void selectSwap(UUID a, UUID b) { public void selectSwap(UUID a, UUID b) {
// TODO call from somewhere
LOGGER.log(Level.INFO, "selectPiece"); LOGGER.log(Level.INFO, "selectPiece");
this.a = a; this.a = a;
this.b = b; this.b = b;
@@ -49,7 +59,6 @@ public void selectSwap(UUID a, UUID b) {
} }
public void selectPiece(UUID piece) { public void selectPiece(UUID piece) {
// TODO call from somewhere
LOGGER.log(Level.INFO, "selectPiece"); LOGGER.log(Level.INFO, "selectPiece");
this.a = piece; this.a = piece;
@@ -63,7 +72,6 @@ public void selectPiece(UUID piece) {
} }
public void selectCard(BonusCard card) { public void selectCard(BonusCard card) {
// TODO call from somewhere
LOGGER.log(Level.INFO, "selectCard"); LOGGER.log(Level.INFO, "selectCard");
this.card = card; this.card = card;
@@ -98,90 +106,43 @@ public void confirm() {
} }
public void selectTsk(Color color) { public void selectTsk(Color color) {
// TODO call from somewhere LOGGER.log(Level.INFO, "selectTsk: " + color);
LOGGER.log(Level.INFO, "selectTsk: {0}", color);
LobbyView view = (LobbyView) app.getView();
view.setTaken(color, true, true, "OwnPlayerName");
testColor = color;
} }
public void unselectTsk() { public void unselectTsk() {
// TODO call from somewhere
LOGGER.log(Level.INFO, "unselectTsk"); LOGGER.log(Level.INFO, "unselectTsk");
} }
public void rolledDice() { public void rolledDice() {
// TODO call from somewhere
LOGGER.log(Level.INFO, "rolledDice"); LOGGER.log(Level.INFO, "rolledDice");
} }
public void setName(String name) { public void setName(String name) {
// TODO call from somewhere LOGGER.log(Level.INFO, "setName: " + name);
LOGGER.log(Level.INFO, "setName: {0}", name);
} }
public void setReady(boolean ready) { public void setReady(boolean ready) {
LOGGER.log(Level.INFO, "setReady"); LOGGER.log(Level.INFO, "setReady");
LobbyView view = (LobbyView) app.getView();
view.setReady(testColor, ready);
test++;
if(test > 2) {
testColor = null;
test = 0;
enter(MdgaState.GAME);
}
} }
public void setHost(int port) { public void setHost(int port) {
// TODO call from somewhere LOGGER.log(Level.INFO, "setHost: " + port);
LOGGER.log(Level.INFO, "setHost: {0}", port);
enter(MdgaState.LOBBY);
} }
public void setJoin(String ip, int port) { public void setJoin(String ip, int port) {
// TODO call from somewhere LOGGER.log(Level.INFO, "setJoin with IP: " + ip + "\nPort: " + port);
LOGGER.log(Level.INFO, "setJoin with IP: {0}, Port: {1}", new Object[]{ip, port});
enter(MdgaState.LOBBY);
} }
public void leave() { public void leave() {
LOGGER.log(Level.INFO, "leave"); LOGGER.log(Level.INFO, "leave");
app.getAcousticHandler().playSound(MdgaSound.LEAVE);
enter(MdgaState.MAIN);
} }
public void enter(MdgaState state) { public void enter(MdgaState state) {
LOGGER.log(Level.INFO, "enter: {0}", state); LOGGER.log(Level.INFO, "enter: " + state);
app.enter(state);
if (state == MdgaState.CEREMONY) {
CeremonyView ceremonyView = (CeremonyView) app.getView();
ceremonyView.addCeremonyParticipant(Color.AIRFORCE, 1, "ugidffdg");
ceremonyView.addCeremonyParticipant(Color.ARMY, 2, "ugidffdg");
ceremonyView.addCeremonyParticipant(Color.NAVY, 3, "ugidffdg");
ceremonyView.addCeremonyParticipant(Color.CYBER, 4, "ugidffdg");
ceremonyView.addStatisticsRow("player sdgsd", 1, 2, 3, 4, 5, 6);
ceremonyView.addStatisticsRow("player sdgsd", 1, 2, 3, 4, 5, 6);
ceremonyView.addStatisticsRow("player sdgsd", 1, 2, 3, 4, 5, 6);
ceremonyView.addStatisticsRow("player sdgsd", 1, 2, 3, 4, 5, 6);
ceremonyView.addStatisticsRow("Gesamt", 1, 2, 3, 4, 5, 6);
}
if (state == MdgaState.GAME) {
GameView gameView = (GameView) app.getView();
//app.getNotificationSynchronizer().addTestNotification(new DrawCardNotification(Color.AIRFORCE, BonusCard.SHIELD));
selectPiece(UUID.randomUUID());
}
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));
lobbyView.setReady(Color.ARMY, true);
}
} }
} }

View File

@@ -143,7 +143,7 @@ private void handleGame(Notification notification) {
boardHandler.addPlayer(n.getColor(),n.getPiecesList()); boardHandler.addPlayer(n.getColor(),n.getPiecesList());
guiHandler.addPlayer(n.getColor(),n.getName()); guiHandler.addPlayer(n.getColor(),n.getName());
} else if (notification instanceof ResumeNotification) { } else if (notification instanceof ResumeNotification) {
//TODO //ignore
} else if (notification instanceof RollDiceNotification n) { } else if (notification instanceof RollDiceNotification n) {
if(n.getColor() == gameView.getOwnColor()){ if(n.getColor() == gameView.getOwnColor()){
//guiHandler.rollDice(n.getEyes(), n.isTurbo() ? n.getMultiplier() : -1); //guiHandler.rollDice(n.getEyes(), n.isTurbo() ? n.getMultiplier() : -1);