merge dev into test #30
@@ -107,7 +107,7 @@ public void simpleInitApp() {
|
|||||||
gameView = new GameView(this);
|
gameView = new GameView(this);
|
||||||
ceremonyView = new CeremonyView(this);
|
ceremonyView = new CeremonyView(this);
|
||||||
|
|
||||||
enter(MdgaState.MAIN);
|
enter(MdgaState.GAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -23,15 +23,22 @@ public class ModelSynchronizer {
|
|||||||
private UUID a;
|
private UUID a;
|
||||||
private UUID b;
|
private UUID b;
|
||||||
private BonusCard card;
|
private BonusCard card;
|
||||||
|
private boolean swap;
|
||||||
|
|
||||||
ModelSynchronizer(MdgaApp app) {
|
ModelSynchronizer(MdgaApp app) {
|
||||||
this.app = app;
|
this.app = app;
|
||||||
|
swap = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void animationEnd() {
|
public void animationEnd() {
|
||||||
app.getGameLogic().selectAnimationEnd();
|
app.getGameLogic().selectAnimationEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void select(UUID a, UUID b){
|
||||||
|
if(swap) selectSwap(a,b);
|
||||||
|
else selectPiece(a);
|
||||||
|
}
|
||||||
|
|
||||||
public void selectSwap(UUID a, UUID b) {
|
public void selectSwap(UUID a, UUID b) {
|
||||||
// TODO call from somewhere
|
// TODO call from somewhere
|
||||||
LOGGER.log(Level.INFO, "selectPiece");
|
LOGGER.log(Level.INFO, "selectPiece");
|
||||||
@@ -134,4 +141,8 @@ public void enter(MdgaState state) {
|
|||||||
LOGGER.log(Level.INFO, "enter: {0}", state);
|
LOGGER.log(Level.INFO, "enter: {0}", state);
|
||||||
//app.enter(state);
|
//app.enter(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSwap(boolean swap){
|
||||||
|
this.swap = swap;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,10 +21,12 @@ public class NotificationSynchronizer {
|
|||||||
|
|
||||||
public void addTestNotification(Notification n) {
|
public void addTestNotification(Notification n) {
|
||||||
notifications.add(n);
|
notifications.add(n);
|
||||||
|
handleGame(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update() {
|
public void update() {
|
||||||
Notification n = app.getGameLogic().getNotification();
|
Notification n = app.getGameLogic().getNotification();
|
||||||
|
|
||||||
if(n != null) {
|
if(n != null) {
|
||||||
switch (app.getState()) {
|
switch (app.getState()) {
|
||||||
case MAIN:
|
case MAIN:
|
||||||
@@ -43,7 +45,6 @@ public void update() {
|
|||||||
throw new RuntimeException("no notification expected: " + n.toString());
|
throw new RuntimeException("no notification expected: " + n.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
notifications.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleMain(Notification notification) {
|
private void handleMain(Notification notification) {
|
||||||
@@ -75,6 +76,7 @@ private void handleGame(Notification notification) {
|
|||||||
GameView gameView = (GameView) app.getView();
|
GameView gameView = (GameView) app.getView();
|
||||||
GuiHandler guiHandler = gameView.getGuiHandler();
|
GuiHandler guiHandler = gameView.getGuiHandler();
|
||||||
BoardHandler boardHandler = gameView.getBoardHandler();
|
BoardHandler boardHandler = gameView.getBoardHandler();
|
||||||
|
ModelSynchronizer modelSynchronizer = app.getModelSynchronize();
|
||||||
|
|
||||||
if (notification instanceof AcquireCardNotification n) {
|
if (notification instanceof AcquireCardNotification n) {
|
||||||
guiHandler.addCard(n.getBonusCard());
|
guiHandler.addCard(n.getBonusCard());
|
||||||
@@ -166,10 +168,13 @@ private void handleGame(Notification notification) {
|
|||||||
//TODO ???
|
//TODO ???
|
||||||
} else if (notification instanceof SelectableMoveNotification n) {
|
} else if (notification instanceof SelectableMoveNotification n) {
|
||||||
boardHandler.outlineMove(n.getPieces(), n.getMoveIndices(), n.getHomeMoves());
|
boardHandler.outlineMove(n.getPieces(), n.getMoveIndices(), n.getHomeMoves());
|
||||||
|
modelSynchronizer.setSwap(false);
|
||||||
} else if (notification instanceof SelectableSwapNotification n) {
|
} else if (notification instanceof SelectableSwapNotification n) {
|
||||||
boardHandler.outlineSwap(n.getOwnPieces(), n.getEnemyPieces());
|
boardHandler.outlineSwap(n.getOwnPieces(), n.getEnemyPieces());
|
||||||
|
modelSynchronizer.setSwap(true);
|
||||||
} else if (notification instanceof SelectableShieldNotification n) {
|
} else if (notification instanceof SelectableShieldNotification n) {
|
||||||
boardHandler.outlineShield(n.getPieces());
|
boardHandler.outlineShield(n.getPieces());
|
||||||
|
modelSynchronizer.setSwap(false);
|
||||||
} else if (notification instanceof TurboActiveNotification){
|
} else if (notification instanceof TurboActiveNotification){
|
||||||
guiHandler.turbo();
|
guiHandler.turbo();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -439,6 +439,8 @@ else if(selectableEnemyPieces.contains(pieceSelected)) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else throw new RuntimeException("pieceSelected is not in own/enemySelectablePieces");
|
else throw new RuntimeException("pieceSelected is not in own/enemySelectablePieces");
|
||||||
|
|
||||||
|
app.getModelSynchronize().select(getKeyByValue(pieces, selectedOwnPiece), getKeyByValue(pieces, selectedEnemyPiece));
|
||||||
}
|
}
|
||||||
|
|
||||||
//called when view is no longer needed to select pieces
|
//called when view is no longer needed to select pieces
|
||||||
@@ -477,5 +479,13 @@ public void hideDice(){
|
|||||||
diceControl.hide();
|
diceControl.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private <K, V> K getKeyByValue(Map<K, V> map, V value) {
|
||||||
|
for (Map.Entry<K, V> entry : map.entrySet()) {
|
||||||
|
if (entry.getValue().equals(value)) {
|
||||||
|
return entry.getKey();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
import pp.mdga.notification.RollDiceNotification;
|
import pp.mdga.notification.RollDiceNotification;
|
||||||
import pp.mdga.notification.SelectableCardsNotification;
|
import pp.mdga.notification.SelectableCardsNotification;
|
||||||
import pp.mdga.notification.SelectableMoveNotification;
|
import pp.mdga.notification.SelectableMoveNotification;
|
||||||
|
import pp.mdga.notification.SelectableSwapNotification;
|
||||||
import pp.mdga.notification.ShieldActiveNotification;
|
import pp.mdga.notification.ShieldActiveNotification;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -69,27 +70,28 @@ public void onEnter() {
|
|||||||
|
|
||||||
|
|
||||||
//Test
|
//Test
|
||||||
// List<UUID> uuid1 = new ArrayList<>();
|
List<UUID> uuid1 = new ArrayList<>();
|
||||||
// UUID p1 = UUID.randomUUID();
|
UUID p1 = UUID.randomUUID();
|
||||||
// UUID p2 = UUID.randomUUID();
|
UUID p2 = UUID.randomUUID();
|
||||||
// uuid1.add(p1);
|
uuid1.add(p1);
|
||||||
// uuid1.add(p2);
|
uuid1.add(p2);
|
||||||
// uuid1.add(UUID.randomUUID());
|
uuid1.add(UUID.randomUUID());
|
||||||
// uuid1.add(UUID.randomUUID());
|
uuid1.add(UUID.randomUUID());
|
||||||
// List<UUID> uuid2 = new ArrayList<>();
|
List<UUID> uuid2 = new ArrayList<>();
|
||||||
// UUID p1_2 = UUID.randomUUID();
|
UUID p1_2 = UUID.randomUUID();
|
||||||
// UUID p2_2 = UUID.randomUUID();
|
UUID p2_2 = UUID.randomUUID();
|
||||||
// uuid2.add(p1_2);
|
uuid2.add(p1_2);
|
||||||
// uuid2.add(p2_2);
|
uuid2.add(p2_2);
|
||||||
// uuid2.add(UUID.randomUUID());
|
uuid2.add(UUID.randomUUID());
|
||||||
// uuid2.add(UUID.randomUUID());
|
uuid2.add(UUID.randomUUID());
|
||||||
|
|
||||||
// app.getNotificationSynchronizer().addTestNotification(new PlayerInGameNotification(Color.AIRFORCE, uuid1, "Cedric"));
|
app.getNotificationSynchronizer().addTestNotification(new PlayerInGameNotification(Color.AIRFORCE, uuid1, "Cedric"));
|
||||||
// app.getNotificationSynchronizer().addTestNotification(new PlayerInGameNotification(Color.NAVY, uuid2, "Test"));
|
app.getNotificationSynchronizer().addTestNotification(new PlayerInGameNotification(Color.NAVY, uuid2, "Test"));
|
||||||
// app.getNotificationSynchronizer().addTestNotification(new MovePieceNotification(p1, 0, true));
|
app.getNotificationSynchronizer().addTestNotification(new MovePieceNotification(p1, 0, true));
|
||||||
// app.getNotificationSynchronizer().addTestNotification(new MovePieceNotification(p1_2, 30, true));
|
app.getNotificationSynchronizer().addTestNotification(new MovePieceNotification(p1_2, 20, true));
|
||||||
// app.getNotificationSynchronizer().addTestNotification(new SelectableMoveNotification(List.of(p1), List.of(4), List.of(false)));
|
// 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 AcquireCardNotification(BonusCard.SHIELD));
|
||||||
|
app.getNotificationSynchronizer().addTestNotification(new SelectableSwapNotification(List.of(p1), List.of(p1_2)));
|
||||||
|
|
||||||
// app.getNotificationSynchronizer().addTestNotification(new SelectableCardsNotification(List.of(BonusCard.SHIELD)));
|
// app.getNotificationSynchronizer().addTestNotification(new SelectableCardsNotification(List.of(BonusCard.SHIELD)));
|
||||||
// app.getNotificationSynchronizer().addTestNotification(new ShieldActiveNotification(p1));
|
// app.getNotificationSynchronizer().addTestNotification(new ShieldActiveNotification(p1));
|
||||||
|
|||||||
Reference in New Issue
Block a user