Merge work #7
@@ -80,4 +80,6 @@ public AnimationHandler getAnimationHandler() {
|
|||||||
public AcousticHandler getAcousticHandler() {
|
public AcousticHandler getAcousticHandler() {
|
||||||
return acousticHandler;
|
return acousticHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MdgaState getState() {return state; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 ) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user