Remove state classes

This commit is contained in:
Felix
2024-11-14 22:13:57 +01:00
parent ee59807395
commit a68ad80402
10 changed files with 66 additions and 32 deletions

View File

@@ -0,0 +1,4 @@
package Acoustic;
public class AcousticHandler {
}

View File

@@ -23,7 +23,7 @@ public void update() {
if(animation.isOver()) {
animation = null;
//trigger next state
//trigger next state in model
}
}
}

View File

@@ -0,0 +1,42 @@
package pp.mdga.client;
import pp.mdga.notification.Notification;
import pp.mdga.notification.PieceInGameNotification;
import pp.mdga.notification.PlayerInGameNotification;
public enum MdgaState {
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,5 +1,23 @@
package pp.mdga.client;
public class NotificationSynchronizer {
import pp.mdga.notification.Notification;
import java.util.ArrayList;
public class NotificationSynchronizer {
private final MdgaApp app;
private MdgaState state = MdgaState.MAIN;
NotificationSynchronizer(MdgaApp app) {
this.app = app;
}
void update() {
ArrayList<Notification> notifications = new ArrayList<>();
//TODO fetch model notifications
for (Notification n : notifications) {
state.handleNotification(app, n);
}
}
}

View File

@@ -1,5 +0,0 @@
package pp.mdga.client.State;
public class CeremonyState {
}

View File

@@ -1,5 +0,0 @@
package pp.mdga.client.State;
public class GameState {
}

View File

@@ -1,5 +0,0 @@
package pp.mdga.client.State;
public class LobbyState {
}

View File

@@ -1,5 +0,0 @@
package pp.mdga.client.State;
public class MdgaState {
}

View File

@@ -1,5 +0,0 @@
package pp.mdga.client.State;
public class MusicState {
}

View File

@@ -1,5 +0,0 @@
package pp.mdga.client.State;
public class SoundState {
}