Begin work on actionHandler

This commit is contained in:
Felix
2024-11-19 18:36:49 +01:00
parent 03eef66332
commit 80fab1ffdc
3 changed files with 34 additions and 42 deletions

View File

@@ -80,4 +80,6 @@ public AnimationHandler getAnimationHandler() {
public AcousticHandler getAcousticHandler() { public AcousticHandler getAcousticHandler() {
return acousticHandler; return acousticHandler;
} }
public MdgaState getState() {return state; }
} }

View File

@@ -5,44 +5,9 @@
import pp.mdga.notification.PlayerInGameNotification; import pp.mdga.notification.PlayerInGameNotification;
public enum MdgaState { public enum MdgaState {
NONE { NONE,
@Override MAIN,
void handleNotification(MdgaApp app, Notification notification) { LOBBY,
throw new RuntimeException("unexpected notification"); GAME,
} CEREMONY;
},
MAIN {
@Override
void handleNotification(MdgaApp app, Notification notification) {
throw new RuntimeException("unexpected notification");
}
},
LOBBY {
@Override
void handleNotification(MdgaApp app, Notification notification) {
throw new RuntimeException("unexpected notification");
}
},
GAME {
@Override
void handleNotification(MdgaApp app, Notification notification) {
if (notification instanceof PlayerInGameNotification) {
//TODO
}
else if (notification instanceof PieceInGameNotification) {
//TODO
}
else {
throw new RuntimeException("unexpected notification");
}
}
},
CEREMONY {
@Override
void handleNotification(MdgaApp app, Notification notification) {
throw new RuntimeException("unexpected notification");
}
};
abstract void handleNotification(MdgaApp app, Notification notification);
} }

View File

@@ -1,12 +1,12 @@
package pp.mdga.client; package pp.mdga.client;
import pp.mdga.client.Acoustic.MusicAsset;
import pp.mdga.notification.Notification; import pp.mdga.notification.Notification;
import java.util.ArrayList; import java.util.ArrayList;
public class NotificationSynchronizer { public class NotificationSynchronizer {
private final MdgaApp app; private final MdgaApp app;
private MdgaState state = MdgaState.MAIN;
NotificationSynchronizer(MdgaApp app) { NotificationSynchronizer(MdgaApp app) {
this.app = app; this.app = app;
@@ -17,7 +17,32 @@ void update() {
//TODO fetch model notifications //TODO fetch model notifications
for (Notification n : notifications) { for (Notification n : notifications) {
state.handleNotification(app, n); switch (app.getState()) {
case MAIN:
break;
case LOBBY:
break;
case GAME:
break;
case CEREMONY:
break;
case NONE:
throw new RuntimeException("no notification expected");
}
}
}
private void handleMain(Notification notification) {
throw new RuntimeException("no notification expected in state: MAIN");
}
private void handleGame(Notification notification) {
if(notification instanceof ) {
} }
} }
} }