Prepare for model
This commit is contained in:
@@ -12,11 +12,15 @@
|
||||
import pp.mdga.notification.TskSelectNotification;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.logging.ConsoleHandler;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class ModelSynchronizer {
|
||||
private static final Logger LOGGER = Logger.getLogger(ModelSynchronizer.class.getName());
|
||||
|
||||
ConsoleHandler handler = new ConsoleHandler();
|
||||
|
||||
private MdgaApp app;
|
||||
|
||||
private UUID a;
|
||||
@@ -25,6 +29,13 @@ public class ModelSynchronizer {
|
||||
|
||||
ModelSynchronizer(MdgaApp app) {
|
||||
this.app = app;
|
||||
|
||||
LOGGER.setLevel(Level.INFO);
|
||||
|
||||
handler.setLevel(Level.ALL);
|
||||
LOGGER.addHandler(handler);
|
||||
|
||||
LOGGER.setUseParentHandlers(false);
|
||||
}
|
||||
|
||||
private Color testColor;
|
||||
@@ -35,7 +46,6 @@ 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;
|
||||
@@ -49,7 +59,6 @@ public void selectSwap(UUID a, UUID b) {
|
||||
}
|
||||
|
||||
public void selectPiece(UUID piece) {
|
||||
// TODO call from somewhere
|
||||
LOGGER.log(Level.INFO, "selectPiece");
|
||||
|
||||
this.a = piece;
|
||||
@@ -63,7 +72,6 @@ public void selectPiece(UUID piece) {
|
||||
}
|
||||
|
||||
public void selectCard(BonusCard card) {
|
||||
// TODO call from somewhere
|
||||
LOGGER.log(Level.INFO, "selectCard");
|
||||
|
||||
this.card = card;
|
||||
@@ -98,90 +106,43 @@ public void 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");
|
||||
testColor = color;
|
||||
LOGGER.log(Level.INFO, "selectTsk: " + color);
|
||||
|
||||
}
|
||||
|
||||
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);
|
||||
LOGGER.log(Level.INFO, "setName: " + name);
|
||||
}
|
||||
|
||||
public void setReady(boolean ready) {
|
||||
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) {
|
||||
// TODO call from somewhere
|
||||
LOGGER.log(Level.INFO, "setHost: {0}", port);
|
||||
enter(MdgaState.LOBBY);
|
||||
LOGGER.log(Level.INFO, "setHost: " + port);
|
||||
|
||||
}
|
||||
|
||||
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);
|
||||
LOGGER.log(Level.INFO, "setJoin with IP: " + ip + "\nPort: " + port);
|
||||
|
||||
}
|
||||
|
||||
public void leave() {
|
||||
LOGGER.log(Level.INFO, "leave");
|
||||
app.getAcousticHandler().playSound(MdgaSound.LEAVE);
|
||||
enter(MdgaState.MAIN);
|
||||
|
||||
}
|
||||
|
||||
public void enter(MdgaState state) {
|
||||
LOGGER.log(Level.INFO, "enter: {0}", 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);
|
||||
}
|
||||
LOGGER.log(Level.INFO, "enter: " + state);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ private void handleGame(Notification notification) {
|
||||
boardHandler.addPlayer(n.getColor(),n.getPiecesList());
|
||||
guiHandler.addPlayer(n.getColor(),n.getName());
|
||||
} else if (notification instanceof ResumeNotification) {
|
||||
//TODO
|
||||
//ignore
|
||||
} else if (notification instanceof RollDiceNotification n) {
|
||||
if(n.getColor() == gameView.getOwnColor()){
|
||||
//guiHandler.rollDice(n.getEyes(), n.isTurbo() ? n.getMultiplier() : -1);
|
||||
|
||||
Reference in New Issue
Block a user