fixed missing messages

This commit is contained in:
Cedric Beck
2024-12-01 18:12:31 +01:00
parent 2732a89da6
commit 453aacfe1a
8 changed files with 86 additions and 35 deletions

View File

@@ -145,11 +145,11 @@ private void handleGame(Notification notification) {
//TODO
} else if (notification instanceof RollDiceNotification n) {
if(n.getColor() == gameView.getOwnColor()){
//guiHandler.rollDice(n.getEyes(), n.isTurbo() ? n.getMultiplier() : -1);
guiHandler.rollDice(n.getEyes(), n.isTurbo() ? n.getMultiplier() : -1);
}
else {
//if (n.isTurbo()) guiHandler.showRolledDiceMult(n.getEyes(), n.getMultiplier(), n.getColor());
//else guiHandler.showRolledDice(n.getEyes(), n.getColor());
if (n.isTurbo()) guiHandler.showRolledDiceMult(n.getEyes(), n.getMultiplier(), n.getColor());
else guiHandler.showRolledDice(n.getEyes(), n.getColor());
}
} else if (notification instanceof SelectableCardsNotification n) {
guiHandler.setSelectableCards(n.getCards());
@@ -168,10 +168,10 @@ private void handleGame(Notification notification) {
boardHandler.outlineMove(n.getPieces(), n.getMoveIndexe(), n.getHomeMoves());
} else if (notification instanceof SelectableSwapNotification n) {
boardHandler.outlineSwap(n.getOwnPieces(), n.getEnemyPieces());
// } //else if (notification instanceof SelectableShieldNotification n) {
// boardHandler.outlineShield(n.getOwnPieces());
//} else if (notification instanceof TurboActiveNotification){
// guiHandler.turbo();
} else if (notification instanceof SelectableShieldNotification n) {
boardHandler.outlineShield(n.getPieces());
} else if (notification instanceof TurboActiveNotification){
guiHandler.turbo();
} else {
throw new RuntimeException("notification not expected: " + notification.toString());
}

View File

@@ -15,11 +15,11 @@ public class GuiHandler {
private final CardLayerHandler cardLayerHandler;
private final PlayerNameHandler playerNameHandler;
private final ActionTextHandler actionTextHandler;
private final Color ownColor;
private Color ownColor;
private FrameBuffer backFrameBuffer;
public GuiHandler(MdgaApp app, Node guiNode, Color ownColor) {
public GuiHandler(MdgaApp app, Node guiNode) {
this.app = app;
this.ownColor = ownColor;
@@ -33,8 +33,10 @@ public GuiHandler(MdgaApp app, Node guiNode, Color ownColor) {
actionTextHandler = new ActionTextHandler(guiNode, app.getAssetManager(), app.getContext().getSettings());
}
public void init() {
public void init(Color ownColor) {
cardLayerHandler.init();
playerNameHandler.show();
this.ownColor = ownColor;
app.getViewPort().setOutputFrameBuffer(backFrameBuffer);
}

View File

@@ -12,11 +12,15 @@
import pp.mdga.game.BonusCard;
import pp.mdga.game.Color;
import pp.mdga.notification.AcquireCardNotification;
import pp.mdga.notification.ActivePlayerNotification;
import pp.mdga.notification.DiceNowNotification;
import pp.mdga.notification.GameNotification;
import pp.mdga.notification.MovePieceNotification;
import pp.mdga.notification.PlayerInGameNotification;
import pp.mdga.notification.RollDiceNotification;
import pp.mdga.notification.SelectableCardsNotification;
import pp.mdga.notification.SelectableMoveNotification;
import pp.mdga.notification.ShieldActiveNotification;
import java.util.ArrayList;
import java.util.List;
@@ -48,10 +52,23 @@ public GameView(MdgaApp app) {
this.camera = new CameraHandler(app, fpp);
this.boardHandler = new BoardHandler(app, rootNode, fpp);
guiHandler = new GuiHandler(app, guiNode, ownColor);
guiHandler = new GuiHandler(app, guiNode);
}
@Override
public void onEnter() {
camera.init();
boardHandler.init();
setOwnColor(Color.AIRFORCE);
guiHandler.init(ownColor);
app.getViewPort().addProcessor(fpp);
app.getAcousticHandler().playSound(MdgaSound.START);
//Test
setOwnColor(Color.AIRFORCE);
List<UUID> uuid1 = new ArrayList<>();
UUID p1 = UUID.randomUUID();
@@ -60,27 +77,31 @@ public GameView(MdgaApp app) {
uuid1.add(p2);
uuid1.add(UUID.randomUUID());
uuid1.add(UUID.randomUUID());
List<UUID> uuid2 = new ArrayList<>();
UUID p1_2 = UUID.randomUUID();
UUID p2_2 = UUID.randomUUID();
uuid2.add(p1_2);
uuid2.add(p2_2);
uuid2.add(UUID.randomUUID());
uuid2.add(UUID.randomUUID());
app.getNotificationSynchronizer().addTestNotification(new PlayerInGameNotification(Color.AIRFORCE, uuid1, "Cedric"));
app.getNotificationSynchronizer().addTestNotification(new PlayerInGameNotification(Color.NAVY, uuid2, "Test"));
app.getNotificationSynchronizer().addTestNotification(new MovePieceNotification(p1, 0, true));
app.getNotificationSynchronizer().addTestNotification(new MovePieceNotification(p1_2, 30, true));
app.getNotificationSynchronizer().addTestNotification(new SelectableMoveNotification(List.of(p1), List.of(4), List.of(false)));
app.getNotificationSynchronizer().addTestNotification(new AcquireCardNotification(BonusCard.SHIELD));
app.getNotificationSynchronizer().addTestNotification(new SelectableCardsNotification(List.of(BonusCard.SHIELD)));
app.getNotificationSynchronizer().addTestNotification(new ShieldActiveNotification(p1));
app.getNotificationSynchronizer().addTestNotification(new ActivePlayerNotification(Color.NAVY));
// app.getNotificationSynchronizer().addTestNotification(new DiceNowNotification());
// app.getNotificationSynchronizer().addTestNotification(new RollDiceNotification(Color.AIRFORCE, 5, true, 2));
}
@Override
public void onEnter() {
camera.init();
boardHandler.init();
guiHandler.init();
app.getViewPort().addProcessor(fpp);
app.getAcousticHandler().playSound(MdgaSound.START);
p1 = p1;
}