merge development into test #26
32
Projekte/mdga/client/hs_err_pid112363.log
Normal file
32
Projekte/mdga/client/hs_err_pid112363.log
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
#
|
||||||
|
# A fatal error has been detected by the Java Runtime Environment:
|
||||||
|
#
|
||||||
|
# SIGSEGV (0xb) at pc=0x000076fb04e70b48, pid=112363, tid=112397
|
||||||
|
#
|
||||||
|
# JRE version: OpenJDK Runtime Environment Temurin-20.0.2+9 (20.0.2+9) (build 20.0.2+9)
|
||||||
|
# Java VM: OpenJDK 64-Bit Server VM Temurin-20.0.2+9 (20.0.2+9, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
|
||||||
|
# Problematic frame:
|
||||||
|
# C [libLLVM.so.18.1+0x1070b48] llvm::EVT::isExtendedVector() const+0x8
|
||||||
|
#
|
||||||
|
# Core dump will be written. Default location: Core dumps may be processed with "/usr/lib/systemd/systemd-coredump %P %u %g %s %t %c %h" (or dumping to /home/cedric/ProgProjekt/Gruppe-01/Projekte/mdga/client/core.112363)
|
||||||
|
#
|
||||||
|
# If you would like to submit a bug report, please visit:
|
||||||
|
# https://github.com/adoptium/adoptium-support/issues
|
||||||
|
# The crash happened outside the Java Virtual Machine in native code.
|
||||||
|
# See problematic frame for where to report the bug.
|
||||||
|
#
|
||||||
|
|
||||||
|
--------------- S U M M A R Y ------------
|
||||||
|
|
||||||
|
Command Line: -Ddebugger.agent.enable.coroutines=true -Djava.util.logging.config.file=logging.properties -Dkotlinx.coroutines.debug.enable.creation.stack.trace=false -agentlib:jdwp=transport=dt_socket,server=n,suspend=y,address=127.0.0.1:37129 -javaagent:/usr/share/idea/plugins/java/lib/rt/debugger-agent.jar -Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant -ea pp.mdga.client.MdgaApp
|
||||||
|
|
||||||
|
Host: AMD Ryzen 5 8640HS w/ Radeon 760M Graphics, 12 cores, 14G, Manjaro Linux
|
||||||
|
Time: Fri Nov 29 22:02:46 2024 CET elapsed time: 26.893420 seconds (0d 0h 0m 26s)
|
||||||
|
|
||||||
|
--------------- T H R E A D ---------------
|
||||||
|
|
||||||
|
Current thread (0x000076fbec5e6dd0): JavaThread "jME3 Main" [_thread_in_native, id=112397, stack(0x000076fbd00fe000,0x000076fbd01fe000)]
|
||||||
|
|
||||||
|
Stack: [0x000076fbd00fe000,0x000076fbd01fe000], sp=0x000076fbd01f4ef8, free space=987k
|
||||||
|
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
|
||||||
|
C [libLLVM.so.18.1+0x1070b48] llvm::EVT::isExtendedVector() const+0x8
|
||||||
@@ -75,7 +75,7 @@ public void onAction(String name, boolean isPressed, float tpf) {
|
|||||||
}
|
}
|
||||||
if(name.equals("Click") && isPressed) {
|
if(name.equals("Click") && isPressed) {
|
||||||
if (app.getView() instanceof GameView gameView) {
|
if (app.getView() instanceof GameView gameView) {
|
||||||
CardControl cardLayerSelect = checkHover(gameView.getGuiHandler().getCardLayerCamera(), gameView.getGuiHandler().getCardLayer().getRootNode(), CardControl.class);
|
CardControl cardLayerSelect = checkHover(gameView.getGuiHandler().getCardLayerCamera(), gameView.getGuiHandler().getCardLayerRootNode(), CardControl.class);
|
||||||
OutlineControl boardSelect = checkHover(app.getCamera(), app.getRootNode(), OutlineControl.class);
|
OutlineControl boardSelect = checkHover(app.getCamera(), app.getRootNode(), OutlineControl.class);
|
||||||
|
|
||||||
if(cardLayerSelect != null) {
|
if(cardLayerSelect != null) {
|
||||||
@@ -100,9 +100,6 @@ else if(boardSelect != null) {
|
|||||||
}
|
}
|
||||||
if(name.equals("Test") &&isPressed){
|
if(name.equals("Test") &&isPressed){
|
||||||
if(app.getView() instanceof GameView gameView){
|
if(app.getView() instanceof GameView gameView){
|
||||||
|
|
||||||
gameView.getGuiHandler().showDice();
|
|
||||||
// gameView.getBoardHandler().showDice(Color.AIRFORCE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -134,8 +131,8 @@ private <T extends AbstractControl> T checkHover(Camera cam, Node root, Class<T>
|
|||||||
CollisionResults results = new CollisionResults();
|
CollisionResults results = new CollisionResults();
|
||||||
Ray ray = new Ray(cam.getLocation(), getMousePos(cam).subtract(cam.getLocation()).normalize());
|
Ray ray = new Ray(cam.getLocation(), getMousePos(cam).subtract(cam.getLocation()).normalize());
|
||||||
root.collideWith(ray, results);
|
root.collideWith(ray, results);
|
||||||
if (results.size() > 0) {
|
for(CollisionResult collisionResult : results){
|
||||||
return results.getClosestCollision().getGeometry().getControl(controlType);
|
if(collisionResult.getGeometry().getControl(controlType) != null) return collisionResult.getGeometry().getControl(controlType);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -188,7 +185,7 @@ private PieceControl checkPiece(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
private CardControl checkCard(GameView gameView){
|
private CardControl checkCard(GameView gameView){
|
||||||
return checkHoverOrtho(gameView.getGuiHandler().getCardLayerCamera(), gameView.getGuiHandler().getCardLayer().getRootNode(), CardControl.class);
|
return checkHoverOrtho(gameView.getGuiHandler().getCardLayerCamera(), gameView.getGuiHandler().getCardLayerRootNode(), CardControl.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void pieceOff(){
|
private void pieceOff(){
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ public class MdgaApp extends SimpleApplication {
|
|||||||
private AcousticHandler acousticHandler;
|
private AcousticHandler acousticHandler;
|
||||||
private NotificationSynchronizer notificationSynchronizer;
|
private NotificationSynchronizer notificationSynchronizer;
|
||||||
private InputSynchronizer inputSynchronizer;
|
private InputSynchronizer inputSynchronizer;
|
||||||
private ModelSyncronizer modelSyncronizer;
|
private ModelSynchronizer modelSynchronizer;
|
||||||
|
|
||||||
MdgaView view = null;
|
MdgaView view = null;
|
||||||
private MdgaState state = null;
|
private MdgaState state = null;
|
||||||
@@ -50,7 +50,7 @@ public void simpleInitApp() {
|
|||||||
acousticHandler = new AcousticHandler(this);
|
acousticHandler = new AcousticHandler(this);
|
||||||
notificationSynchronizer = new NotificationSynchronizer(this);
|
notificationSynchronizer = new NotificationSynchronizer(this);
|
||||||
inputSynchronizer = new InputSynchronizer(this);
|
inputSynchronizer = new InputSynchronizer(this);
|
||||||
modelSyncronizer = new ModelSyncronizer(this);
|
modelSynchronizer = new ModelSynchronizer(this);
|
||||||
|
|
||||||
mainView = new MainView(this);
|
mainView = new MainView(this);
|
||||||
lobbyView = new LobbyView(this);
|
lobbyView = new LobbyView(this);
|
||||||
@@ -114,11 +114,11 @@ public MdgaView getView() {
|
|||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ModelSyncronizer getModelSyncronizer() {
|
public ModelSynchronizer getModelSynchronize() {
|
||||||
return modelSyncronizer;
|
return modelSynchronizer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public InputSynchronizer getInputSyncronizer() { return inputSynchronizer; }
|
public InputSynchronizer getInputSynchronize() { return inputSynchronizer; }
|
||||||
|
|
||||||
public NotificationSynchronizer getNotificationSynchronizer() { return notificationSynchronizer; }
|
public NotificationSynchronizer getNotificationSynchronizer() { return notificationSynchronizer; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,15 +14,15 @@
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public class ModelSyncronizer {
|
public class ModelSynchronizer {
|
||||||
private static final Logger LOGGER = Logger.getLogger(ModelSyncronizer.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(ModelSynchronizer.class.getName());
|
||||||
private MdgaApp app;
|
private MdgaApp app;
|
||||||
|
|
||||||
private UUID a;
|
private UUID a;
|
||||||
private UUID b;
|
private UUID b;
|
||||||
private BonusCard card;
|
private BonusCard card;
|
||||||
|
|
||||||
ModelSyncronizer(MdgaApp app) {
|
ModelSynchronizer(MdgaApp app) {
|
||||||
this.app = app;
|
this.app = app;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,6 +31,7 @@ public void animationEnd() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void selectSwap(UUID a, UUID b) {
|
public void selectSwap(UUID a, UUID b) {
|
||||||
|
// TODO call from somewhere
|
||||||
LOGGER.log(Level.INFO, "selectPiece");
|
LOGGER.log(Level.INFO, "selectPiece");
|
||||||
this.a = a;
|
this.a = a;
|
||||||
this.b = b;
|
this.b = b;
|
||||||
@@ -44,6 +45,7 @@ public void selectSwap(UUID a, UUID b) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void selectPiece(UUID piece) {
|
public void selectPiece(UUID piece) {
|
||||||
|
// TODO call from somewhere
|
||||||
LOGGER.log(Level.INFO, "selectPiece");
|
LOGGER.log(Level.INFO, "selectPiece");
|
||||||
|
|
||||||
this.a = piece;
|
this.a = piece;
|
||||||
@@ -57,6 +59,7 @@ public void selectPiece(UUID piece) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void selectCard(BonusCard card) {
|
public void selectCard(BonusCard card) {
|
||||||
|
// TODO call from somewhere
|
||||||
LOGGER.log(Level.INFO, "selectCard");
|
LOGGER.log(Level.INFO, "selectCard");
|
||||||
|
|
||||||
this.card = card;
|
this.card = card;
|
||||||
@@ -91,20 +94,24 @@ public void confirm() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void selectTsk(Color color) {
|
public void selectTsk(Color color) {
|
||||||
|
// TODO call from somewhere
|
||||||
LOGGER.log(Level.INFO, "selectTsk: {0}", color);
|
LOGGER.log(Level.INFO, "selectTsk: {0}", color);
|
||||||
LobbyView view = (LobbyView) app.getView();
|
LobbyView view = (LobbyView) app.getView();
|
||||||
view.setTaken(color, true, true, "OwnPlayerName");
|
view.setTaken(color, true, true, "OwnPlayerName");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unselectTsk() {
|
public void unselectTsk() {
|
||||||
|
// TODO call from somewhere
|
||||||
LOGGER.log(Level.INFO, "unselectTsk");
|
LOGGER.log(Level.INFO, "unselectTsk");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void rolledDice() {
|
public void rolledDice() {
|
||||||
|
// TODO call from somewhere
|
||||||
LOGGER.log(Level.INFO, "rolledDice");
|
LOGGER.log(Level.INFO, "rolledDice");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
|
// TODO call from somewhere
|
||||||
LOGGER.log(Level.INFO, "setName: {0}", name);
|
LOGGER.log(Level.INFO, "setName: {0}", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,11 +121,13 @@ public void setReady() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setHost(int port) {
|
public void setHost(int port) {
|
||||||
|
// TODO call from somewhere
|
||||||
LOGGER.log(Level.INFO, "setHost: {0}", port);
|
LOGGER.log(Level.INFO, "setHost: {0}", port);
|
||||||
enter(MdgaState.LOBBY);
|
enter(MdgaState.LOBBY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setJoin(String ip, int port) {
|
public void setJoin(String ip, int port) {
|
||||||
|
// TODO call from somewhere
|
||||||
LOGGER.log(Level.INFO, "setJoin with IP: {0}, Port: {1}", new Object[]{ip, port});
|
LOGGER.log(Level.INFO, "setJoin with IP: {0}, Port: {1}", new Object[]{ip, port});
|
||||||
enter(MdgaState.LOBBY);
|
enter(MdgaState.LOBBY);
|
||||||
}
|
}
|
||||||
@@ -57,11 +57,12 @@ private void handleMain(Notification notification) {
|
|||||||
private void handleLobby(Notification notification) {
|
private void handleLobby(Notification notification) {
|
||||||
LobbyView lobbyView = (LobbyView) app.getView();
|
LobbyView lobbyView = (LobbyView) app.getView();
|
||||||
|
|
||||||
if (notification instanceof TskSelectNotification tskSelectNotification) {
|
if (notification instanceof TskSelectNotification n) {
|
||||||
lobbyView.setTaken(tskSelectNotification.getColor(), true, tskSelectNotification.isSelf(), tskSelectNotification.getName());
|
//lobbyView.setTaken(n.getColor(), true, n.isSelf(), n.getName());
|
||||||
} else if (notification instanceof TskUnselectNotification tskUnselectNotification) {
|
lobbyView.setTaken(n.getColor(), true, true, n.getName());
|
||||||
lobbyView.setTaken(tskUnselectNotification.getColor(), false, false, null);
|
} else if (notification instanceof TskUnselectNotification n) {
|
||||||
//} else if(notification instanceof LobbyReadyNotification lobbyReadyNotification) {
|
lobbyView.setTaken(n.getColor(), false, false, null);
|
||||||
|
//} else if(notification instanceof LobbyReadyNotification lobbyReadyNotification) {
|
||||||
// lobbyView.setReady(lobbyReadyNotification.getColor(), lobbyReadyNotification.isReady()):
|
// lobbyView.setReady(lobbyReadyNotification.getColor(), lobbyReadyNotification.isReady()):
|
||||||
} else if (notification instanceof GameNotification) {
|
} else if (notification instanceof GameNotification) {
|
||||||
app.enter(MdgaState.GAME);
|
app.enter(MdgaState.GAME);
|
||||||
@@ -75,12 +76,12 @@ private void handleGame(Notification notification) {
|
|||||||
GuiHandler guiHandler = gameView.getGuiHandler();
|
GuiHandler guiHandler = gameView.getGuiHandler();
|
||||||
BoardHandler boardHandler = gameView.getBoardHandler();
|
BoardHandler boardHandler = gameView.getBoardHandler();
|
||||||
|
|
||||||
if (notification instanceof AcquireCardNotification n) {
|
if (notification instanceof AcquireCardNotification) {
|
||||||
guiHandler.addCard(n.getBonusCard(), n.getCardId());
|
// Handle AcquireCardNotification
|
||||||
} else if (notification instanceof ActivePlayerNotification n) {
|
} else if (notification instanceof ActivePlayerNotification n) {
|
||||||
gameView.getGuiHandler().setActivePlayer(n.getColor());
|
gameView.getGuiHandler().setActivePlayer(n.getColor());
|
||||||
} else if (notification instanceof CeremonyNotification ceremonyNotification) {
|
} else if (notification instanceof CeremonyNotification ceremonyNotification) {
|
||||||
app.enter(MdgaState.CEREMONY);
|
/*app.enter(MdgaState.CEREMONY);
|
||||||
CeremonyView ceremonyView = (CeremonyView) app.getView();
|
CeremonyView ceremonyView = (CeremonyView) app.getView();
|
||||||
int size = ceremonyNotification.getNames().size();
|
int size = ceremonyNotification.getNames().size();
|
||||||
|
|
||||||
@@ -105,17 +106,18 @@ private void handleGame(Notification notification) {
|
|||||||
|
|
||||||
ceremonyView.addCeremonyParticipant(color, i, name);
|
ceremonyView.addCeremonyParticipant(color, i, name);
|
||||||
ceremonyView.addStatisticsRow(name, v1, v2, v3, v4, v5, v6);
|
ceremonyView.addStatisticsRow(name, v1, v2, v3, v4, v5, v6);
|
||||||
}
|
}*/
|
||||||
} else if (notification instanceof DiceNowNotification) {
|
} else if (notification instanceof DiceNowNotification) {
|
||||||
guiHandler.showDice();
|
guiHandler.showDice();
|
||||||
} else if (notification instanceof DicingNotification n) {
|
} else if (notification instanceof DicingNotification n) {
|
||||||
//TODO
|
|
||||||
} else if (notification instanceof DrawCardNotification n) {
|
|
||||||
//TODO ???
|
//TODO ???
|
||||||
|
} else if (notification instanceof DrawCardNotification n) {
|
||||||
|
guiHandler.drawCard(n.getColor());
|
||||||
} else if (notification instanceof HomeMoveNotification home) {
|
} else if (notification instanceof HomeMoveNotification home) {
|
||||||
boardHandler.moveHomePiece(home.getPieceId(), home.getHomeIndex());
|
boardHandler.moveHomePiece(home.getPieceId(), home.getHomeIndex());
|
||||||
|
guiHandler.hideText();
|
||||||
} else if (notification instanceof InterruptNotification) {
|
} else if (notification instanceof InterruptNotification) {
|
||||||
//TODO
|
//TODO ???
|
||||||
} else if (notification instanceof MovePieceNotification n) {
|
} else if (notification instanceof MovePieceNotification n) {
|
||||||
if(n.isMoveStart()) {
|
if(n.isMoveStart()) {
|
||||||
//StartMove
|
//StartMove
|
||||||
@@ -138,11 +140,17 @@ private void handleGame(Notification notification) {
|
|||||||
}
|
}
|
||||||
} else if (notification instanceof PlayerInGameNotification n) {
|
} else if (notification instanceof PlayerInGameNotification n) {
|
||||||
boardHandler.addPlayer(n.getColor(),n.getPiecesList());
|
boardHandler.addPlayer(n.getColor(),n.getPiecesList());
|
||||||
guiHandler.addPlayer(n.getColor(),n.getName(), gameView.getOwnColor() == n.getColor());
|
guiHandler.addPlayer(n.getColor(),n.getName());
|
||||||
} else if (notification instanceof ResumeNotification) {
|
} else if (notification instanceof ResumeNotification) {
|
||||||
|
//TODO
|
||||||
} else if (notification instanceof RollDiceNotification n) {
|
} else if (notification instanceof RollDiceNotification n) {
|
||||||
guiHandler.rollDice(n.getEyes());
|
if(n.getColor() == gameView.getOwnColor()){
|
||||||
//TODO multiplicator
|
//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());
|
||||||
|
}
|
||||||
} else if (notification instanceof SelectableCardsNotification n) {
|
} else if (notification instanceof SelectableCardsNotification n) {
|
||||||
guiHandler.setSelectableCards(n.getCards());
|
guiHandler.setSelectableCards(n.getCards());
|
||||||
} else if (notification instanceof ShieldActiveNotification n) {
|
} else if (notification instanceof ShieldActiveNotification n) {
|
||||||
@@ -153,12 +161,17 @@ private void handleGame(Notification notification) {
|
|||||||
app.enter(MdgaState.MAIN);
|
app.enter(MdgaState.MAIN);
|
||||||
} else if (notification instanceof SwapPieceNotification n) {
|
} else if (notification instanceof SwapPieceNotification n) {
|
||||||
boardHandler.swapPieces(n.getFirstPiece(), n.getSecondPiece());
|
boardHandler.swapPieces(n.getFirstPiece(), n.getSecondPiece());
|
||||||
|
guiHandler.swap();
|
||||||
} else if (notification instanceof WaitMoveNotification) {
|
} else if (notification instanceof WaitMoveNotification) {
|
||||||
//TODO disable all hover, highlight, etc
|
//TODO ???
|
||||||
} else if (notification instanceof SelectableMoveNotification n) {
|
} else if (notification instanceof SelectableMoveNotification n) {
|
||||||
boardHandler.outlineMove(n.getPieces(), n.getMoveIndexe(), n.getHomeMoves());
|
boardHandler.outlineMove(n.getPieces(), n.getMoveIndexe(), n.getHomeMoves());
|
||||||
} else if (notification instanceof SelectableSwapNotification n) {
|
} else if (notification instanceof SelectableSwapNotification n) {
|
||||||
boardHandler.outlineSwap(n.getOwnPieces(), n.getEnemyPieces());
|
boardHandler.outlineSwap(n.getOwnPieces(), n.getEnemyPieces());
|
||||||
|
// } //else if (notification instanceof SelectableShieldNotification n) {
|
||||||
|
// boardHandler.outlineShield(n.getOwnPieces());
|
||||||
|
//} else if (notification instanceof TurboActiveNotification){
|
||||||
|
// guiHandler.turbo();
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException("notification not expected: " + notification.toString());
|
throw new RuntimeException("notification not expected: " + notification.toString());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,9 +21,6 @@ public class BoardHandler {
|
|||||||
|
|
||||||
private final MdgaApp app;
|
private final MdgaApp app;
|
||||||
|
|
||||||
private final PileControl drawPile = null;
|
|
||||||
private final PileControl discardPile = null;
|
|
||||||
|
|
||||||
private ArrayList<NodeControl> infield;
|
private ArrayList<NodeControl> infield;
|
||||||
private Map<UUID, PieceControl> pieces;
|
private Map<UUID, PieceControl> pieces;
|
||||||
|
|
||||||
@@ -32,32 +29,46 @@ public class BoardHandler {
|
|||||||
private Map<Color, List<NodeControl>> waitingNodesMap;
|
private Map<Color, List<NodeControl>> waitingNodesMap;
|
||||||
private Map<Color, List<PieceControl>> waitingPiecesMap;
|
private Map<Color, List<PieceControl>> waitingPiecesMap;
|
||||||
private Map<UUID, Color> pieceColor;
|
private Map<UUID, Color> pieceColor;
|
||||||
private Set<OutlineControl> outlineControls;
|
|
||||||
|
|
||||||
private Node node = new Node();
|
private Node node = new Node();
|
||||||
private Node rootNode;
|
private final Node rootNode;
|
||||||
|
|
||||||
private FilterPostProcessor fpp;
|
private final FilterPostProcessor fpp;
|
||||||
|
|
||||||
private boolean isInitialised;
|
private boolean isInitialised;
|
||||||
|
|
||||||
private List<PieceControl> selectableOwnPieces = new ArrayList<>();
|
private List<PieceControl> selectableOwnPieces;
|
||||||
private List<PieceControl> selectableEnemyPieces = new ArrayList<>();
|
private List<PieceControl> selectableEnemyPieces;
|
||||||
|
private List<NodeControl> outlineNodes;
|
||||||
private PieceControl selectedOwnPiece;
|
private PieceControl selectedOwnPiece;
|
||||||
private PieceControl selectedEnemyPiece;
|
private PieceControl selectedEnemyPiece;
|
||||||
private DiceControl diceControl;
|
private DiceControl diceControl;
|
||||||
|
|
||||||
public BoardHandler(MdgaApp app, Node node3d, FilterPostProcessor fpp) {
|
public BoardHandler(MdgaApp app, Node rootNode, FilterPostProcessor fpp) {
|
||||||
if(app == null) throw new RuntimeException("app is null");
|
if(app == null) throw new RuntimeException("app is null");
|
||||||
|
|
||||||
this.isInitialised = false;
|
|
||||||
this.app = app;
|
this.app = app;
|
||||||
this.rootNode = node3d;
|
|
||||||
this.fpp = fpp;
|
this.fpp = fpp;
|
||||||
selectedEnemyPiece = null;
|
this.rootNode = rootNode;
|
||||||
selectedOwnPiece = null;
|
isInitialised = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init() {
|
||||||
|
isInitialised = true;
|
||||||
|
selectableOwnPieces = new ArrayList<>();
|
||||||
|
selectableEnemyPieces = new ArrayList<>();
|
||||||
|
outlineNodes = new ArrayList<>();
|
||||||
|
selectedOwnPiece = null;
|
||||||
|
selectedEnemyPiece = null;
|
||||||
initMap();
|
initMap();
|
||||||
|
rootNode.attachChild(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void shutdown(){
|
||||||
|
clearSelectable();
|
||||||
|
isInitialised = false;
|
||||||
|
initMap();
|
||||||
|
rootNode.detachChild(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addFigureToPlayerMap(Color col, AssetOnMap assetOnMap) {
|
private void addFigureToPlayerMap(Color col, AssetOnMap assetOnMap) {
|
||||||
@@ -66,21 +77,16 @@ private void addFigureToPlayerMap(Color col, AssetOnMap assetOnMap) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initMap() {
|
private void initMap() {
|
||||||
this.node = new Node("Asset Node");
|
pieces = new HashMap<>();
|
||||||
this.pieces = new HashMap<>();
|
colorAssetsMap = new HashMap<>();
|
||||||
this.colorAssetsMap = new HashMap<>();
|
infield = new ArrayList<>(40);
|
||||||
this.infield = new ArrayList<>(40);
|
homeNodesMap = new HashMap<>();
|
||||||
this.homeNodesMap = new HashMap<>();
|
waitingNodesMap = new HashMap<>();
|
||||||
this.waitingNodesMap = new HashMap<>();
|
waitingPiecesMap = new HashMap<>();
|
||||||
this.waitingPiecesMap = new HashMap<>();
|
pieceColor = new HashMap<>();
|
||||||
this.pieceColor = new HashMap<>();
|
|
||||||
this.outlineControls = new HashSet<>();
|
|
||||||
|
|
||||||
// Initialize dice
|
|
||||||
diceControl = new DiceControl(app.getAssetManager());
|
diceControl = new DiceControl(app.getAssetManager());
|
||||||
diceControl.create(new Vector3f(0, 0, 0), 0.7f, true);
|
diceControl.create(new Vector3f(0,0,0), 0.7f, true);
|
||||||
|
|
||||||
// Load assets and populate the node
|
|
||||||
List<AssetOnMap> assetOnMaps = MapLoader.loadMap(MAP_NAME);
|
List<AssetOnMap> assetOnMaps = MapLoader.loadMap(MAP_NAME);
|
||||||
|
|
||||||
for (AssetOnMap assetOnMap : assetOnMaps) {
|
for (AssetOnMap assetOnMap : assetOnMaps) {
|
||||||
@@ -99,6 +105,7 @@ private void initMap() {
|
|||||||
case node_wait_blue -> addHomeNode(waitingNodesMap, Color.NAVY, assetOnMap);
|
case node_wait_blue -> addHomeNode(waitingNodesMap, Color.NAVY, assetOnMap);
|
||||||
case node_wait_green -> addHomeNode(waitingNodesMap, Color.ARMY, assetOnMap);
|
case node_wait_green -> addHomeNode(waitingNodesMap, Color.ARMY, assetOnMap);
|
||||||
case node_wait_yellow -> addHomeNode(waitingNodesMap, Color.CYBER, assetOnMap);
|
case node_wait_yellow -> addHomeNode(waitingNodesMap, Color.CYBER, assetOnMap);
|
||||||
|
|
||||||
default -> displayAsset(assetOnMap);
|
default -> displayAsset(assetOnMap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -117,20 +124,14 @@ private Color assetToColor(Asset asset) {
|
|||||||
private Spatial createModel(Asset asset, Vector3f pos, float rot) {
|
private Spatial createModel(Asset asset, Vector3f pos, float rot) {
|
||||||
String modelName = asset.getModelPath();
|
String modelName = asset.getModelPath();
|
||||||
String texName = asset.getDiffPath();
|
String texName = asset.getDiffPath();
|
||||||
|
|
||||||
// Load the model
|
|
||||||
Spatial model = app.getAssetManager().loadModel(modelName);
|
Spatial model = app.getAssetManager().loadModel(modelName);
|
||||||
model.scale(asset.getSize());
|
model.scale(asset.getSize());
|
||||||
model.rotate((float) Math.toRadians(0), 0, (float) Math.toRadians(rot));
|
model.rotate((float) Math.toRadians(0), 0, (float) Math.toRadians(rot));
|
||||||
model.setLocalTranslation(pos);
|
model.setLocalTranslation(pos);
|
||||||
model.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
|
model.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
|
||||||
|
|
||||||
// Set material
|
|
||||||
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md");
|
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md");
|
||||||
mat.setTexture("DiffuseMap", app.getAssetManager().loadTexture(texName));
|
mat.setTexture("DiffuseMap", app.getAssetManager().loadTexture(texName));
|
||||||
model.setMaterial(mat);
|
model.setMaterial(mat);
|
||||||
|
|
||||||
// Attach to the asset node
|
|
||||||
node.attachChild(model);
|
node.attachChild(model);
|
||||||
|
|
||||||
return model;
|
return model;
|
||||||
@@ -169,7 +170,7 @@ private float getRotationMove(Vector3f prev, Vector3f next) {
|
|||||||
return newRot;
|
return newRot;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void movePiece_rek(UUID uuid, int curIndex, int moveIndex){
|
private void movePieceRek(UUID uuid, int curIndex, int moveIndex){
|
||||||
if (curIndex == moveIndex) return;
|
if (curIndex == moveIndex) return;
|
||||||
|
|
||||||
curIndex = (curIndex + 1) % infield.size();
|
curIndex = (curIndex + 1) % infield.size();
|
||||||
@@ -181,7 +182,7 @@ private void movePiece_rek(UUID uuid, int curIndex, int moveIndex){
|
|||||||
|
|
||||||
movePieceToNode(pieceControl, nodeControl);
|
movePieceToNode(pieceControl, nodeControl);
|
||||||
|
|
||||||
movePiece_rek(uuid, curIndex, moveIndex);
|
movePieceRek(uuid, curIndex, moveIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T, E> List<T> addItemToMapList(Map<E,List<T>> map, E key, T item){
|
private <T, E> List<T> addItemToMapList(Map<E,List<T>> map, E key, T item){
|
||||||
@@ -191,11 +192,10 @@ private <T, E> List<T> addItemToMapList(Map<E,List<T>> map, E key, T item){
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T, E> List<T> removeItemFromMapList(Map<E,List<T>> map, E key, T item){
|
private <T, E> void removeItemFromMapList(Map<E,List<T>> map, E key, T item){
|
||||||
List<T> list = map.getOrDefault(key, new ArrayList<>());
|
List<T> list = map.getOrDefault(key, new ArrayList<>());
|
||||||
list.remove(item);
|
list.remove(item);
|
||||||
map.put(key, list);
|
map.put(key, list);
|
||||||
return list;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Vector3f getWaitingPos(Color color){
|
private Vector3f getWaitingPos(Color color){
|
||||||
@@ -274,7 +274,7 @@ public void movePieceStart(UUID uuid, int nodeIndex){
|
|||||||
public void movePiece(UUID uuid, int curIndex, int moveIndex){
|
public void movePiece(UUID uuid, int curIndex, int moveIndex){
|
||||||
if (!isInitialised) throw new RuntimeException("BoardHandler is not initialized");
|
if (!isInitialised) throw new RuntimeException("BoardHandler is not initialized");
|
||||||
|
|
||||||
movePiece_rek(uuid, curIndex, moveIndex);
|
movePieceRek(uuid, curIndex, moveIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void throwPiece(UUID uuid){
|
public void throwPiece(UUID uuid){
|
||||||
@@ -313,70 +313,25 @@ public void suppressShield(UUID uuid){
|
|||||||
public void swapPieces(UUID piece1, UUID piece2){
|
public void swapPieces(UUID piece1, UUID piece2){
|
||||||
if (!isInitialised) throw new RuntimeException("BoardHandler is not initialized");
|
if (!isInitialised) throw new RuntimeException("BoardHandler is not initialized");
|
||||||
|
|
||||||
PieceControl piece1_control = pieces.get(piece1);
|
PieceControl piece1Control = pieces.get(piece1);
|
||||||
PieceControl piece2_control = pieces.get(piece2);
|
PieceControl piece2Control = pieces.get(piece2);
|
||||||
|
|
||||||
if(piece1_control == null) throw new RuntimeException("piece1 UUID is not valid");
|
if(piece1Control == null) throw new RuntimeException("piece1 UUID is not valid");
|
||||||
if(piece2_control == null) throw new RuntimeException("piece2 UUID is not valid");
|
if(piece2Control == null) throw new RuntimeException("piece2 UUID is not valid");
|
||||||
|
|
||||||
float rot1 = piece1_control.getRotation();
|
float rot1 = piece1Control.getRotation();
|
||||||
float rot2 = piece2_control.getRotation();
|
float rot2 = piece2Control.getRotation();
|
||||||
|
|
||||||
piece1_control.setRotation(rot2);
|
piece1Control.setRotation(rot2);
|
||||||
piece2_control.setRotation(rot1);
|
piece2Control.setRotation(rot1);
|
||||||
|
|
||||||
Vector3f pos1 = piece1_control.getLocation().clone();
|
Vector3f pos1 = piece1Control.getLocation().clone();
|
||||||
Vector3f pos2 = piece2_control.getLocation().clone();
|
Vector3f pos2 = piece2Control.getLocation().clone();
|
||||||
|
|
||||||
piece1_control.setLocation(pos2);
|
piece1Control.setLocation(pos2);
|
||||||
piece2_control.setLocation(pos1);
|
piece2Control.setLocation(pos1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init() {
|
|
||||||
if (isInitialised) return;
|
|
||||||
|
|
||||||
rootNode.attachChild(node);
|
|
||||||
|
|
||||||
app.getViewPort().addProcessor(fpp);
|
|
||||||
|
|
||||||
isInitialised = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void shutdown() {
|
|
||||||
if (!isInitialised) return;
|
|
||||||
|
|
||||||
outlineControls.forEach(OutlineControl::deOutline);
|
|
||||||
outlineControls.clear();
|
|
||||||
|
|
||||||
rootNode.detachChild(node);
|
|
||||||
|
|
||||||
if (fpp != null) {
|
|
||||||
app.getViewPort().removeProcessor(fpp);
|
|
||||||
}
|
|
||||||
|
|
||||||
pieces.clear();
|
|
||||||
colorAssetsMap.clear();
|
|
||||||
homeNodesMap.clear();
|
|
||||||
waitingNodesMap.clear();
|
|
||||||
waitingPiecesMap.clear();
|
|
||||||
pieceColor.clear();
|
|
||||||
|
|
||||||
selectableOwnPieces.clear();
|
|
||||||
selectableEnemyPieces.clear();
|
|
||||||
selectedEnemyPiece = null;
|
|
||||||
selectedOwnPiece = null;
|
|
||||||
|
|
||||||
if (diceControl != null) {
|
|
||||||
diceControl.hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
isInitialised = false;
|
|
||||||
|
|
||||||
System.gc();
|
|
||||||
}
|
|
||||||
|
|
||||||
//List<Pieces>
|
|
||||||
//List<NodesIndexe>
|
|
||||||
public void highlight(UUID uuid, boolean bool){
|
public void highlight(UUID uuid, boolean bool){
|
||||||
if (!isInitialised) throw new RuntimeException("BoardHandler is not initialized");
|
if (!isInitialised) throw new RuntimeException("BoardHandler is not initialized");
|
||||||
|
|
||||||
@@ -385,20 +340,6 @@ public void highlight(UUID uuid, boolean bool){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deOutline(UUID uuid){
|
|
||||||
if (!isInitialised) throw new RuntimeException("BoardHandler is not initialized");
|
|
||||||
|
|
||||||
pieces.get(uuid).deOutline();
|
|
||||||
|
|
||||||
outlineControls.remove(pieces.get(uuid));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void outline(int index){
|
|
||||||
// infield.get(index).outline();
|
|
||||||
|
|
||||||
outlineControls.add(infield.get(index));
|
|
||||||
}
|
|
||||||
|
|
||||||
//called when (dice) moveNum is received from server to display the movable pieces and corresponding moveNodes
|
//called when (dice) moveNum is received from server to display the movable pieces and corresponding moveNodes
|
||||||
public void outlineMove(List<UUID> pieces, List<Integer> moveIndexe, List<Boolean> homeMoves) {
|
public void outlineMove(List<UUID> pieces, List<Integer> moveIndexe, List<Boolean> homeMoves) {
|
||||||
if(pieces.size() != moveIndexe.size() || pieces.size() != homeMoves.size()) throw new RuntimeException("arrays are not the same size");
|
if(pieces.size() != moveIndexe.size() || pieces.size() != homeMoves.size()) throw new RuntimeException("arrays are not the same size");
|
||||||
@@ -424,6 +365,7 @@ public void outlineMove(List<UUID> pieces, List<Integer> moveIndexe, List<Boolea
|
|||||||
pieceControl.highlight(false);
|
pieceControl.highlight(false);
|
||||||
pieceControl.setHoverable(true);
|
pieceControl.setHoverable(true);
|
||||||
pieceControl.setSelectable(true);
|
pieceControl.setSelectable(true);
|
||||||
|
outlineNodes.add(nodeControl);
|
||||||
selectableOwnPieces.add(pieceControl);
|
selectableOwnPieces.add(pieceControl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -452,6 +394,21 @@ public void outlineSwap(List<UUID> ownPieces, List<UUID> enemyPieces){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void outlineShield(List<UUID> pieces){
|
||||||
|
selectableOwnPieces.clear();
|
||||||
|
selectableEnemyPieces.clear();
|
||||||
|
selectedOwnPiece = null;
|
||||||
|
selectedEnemyPiece = null;
|
||||||
|
|
||||||
|
for (UUID uuid : pieces){
|
||||||
|
PieceControl p = this.pieces.get(uuid);
|
||||||
|
p.highlight(false);
|
||||||
|
p.setHoverable(true);
|
||||||
|
p.setSelectable(true);
|
||||||
|
selectableOwnPieces.add(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//called from inputSynchronizer when a piece is selectable
|
//called from inputSynchronizer when a piece is selectable
|
||||||
public void pieceSelect(PieceControl pieceSelected) {
|
public void pieceSelect(PieceControl pieceSelected) {
|
||||||
boolean isSelected = pieceSelected.isSelected();
|
boolean isSelected = pieceSelected.isSelected();
|
||||||
@@ -496,18 +453,16 @@ public void clearSelectable(){
|
|||||||
p.unHighlight();
|
p.unHighlight();
|
||||||
p.setSelectable(false);
|
p.setSelectable(false);
|
||||||
}
|
}
|
||||||
|
for(NodeControl n : outlineNodes){
|
||||||
|
n.deOutline();
|
||||||
|
}
|
||||||
|
outlineNodes.clear();
|
||||||
selectableEnemyPieces.clear();
|
selectableEnemyPieces.clear();
|
||||||
selectableOwnPieces.clear();
|
selectableOwnPieces.clear();
|
||||||
selectedEnemyPiece = null;
|
selectedEnemyPiece = null;
|
||||||
selectedOwnPiece = null;
|
selectedOwnPiece = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deOutline(int index){
|
|
||||||
infield.get(index).deOutline();
|
|
||||||
|
|
||||||
outlineControls.remove(infield.get(index));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void enableHover(UUID uuid){
|
public void enableHover(UUID uuid){
|
||||||
pieces.get(uuid).setHoverable(true);
|
pieces.get(uuid).setHoverable(true);
|
||||||
}
|
}
|
||||||
@@ -521,4 +476,6 @@ public void showDice(Color color){
|
|||||||
public void hideDice(){
|
public void hideDice(){
|
||||||
diceControl.hide();
|
diceControl.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,11 @@
|
|||||||
import com.jme3.math.Quaternion;
|
import com.jme3.math.Quaternion;
|
||||||
import com.jme3.math.Vector3f;
|
import com.jme3.math.Vector3f;
|
||||||
import com.jme3.post.FilterPostProcessor;
|
import com.jme3.post.FilterPostProcessor;
|
||||||
|
import com.jme3.scene.Spatial;
|
||||||
import com.jme3.shadow.DirectionalLightShadowFilter;
|
import com.jme3.shadow.DirectionalLightShadowFilter;
|
||||||
import com.jme3.shadow.EdgeFilteringMode;
|
import com.jme3.shadow.EdgeFilteringMode;
|
||||||
|
import com.jme3.util.SkyFactory;
|
||||||
|
import com.jme3.util.SkyFactory.EnvMapType;
|
||||||
import pp.mdga.client.MdgaApp;
|
import pp.mdga.client.MdgaApp;
|
||||||
|
|
||||||
public class CameraHandler {
|
public class CameraHandler {
|
||||||
@@ -25,6 +28,8 @@ public class CameraHandler {
|
|||||||
FilterPostProcessor fpp;
|
FilterPostProcessor fpp;
|
||||||
DirectionalLightShadowFilter dlsf;
|
DirectionalLightShadowFilter dlsf;
|
||||||
|
|
||||||
|
Spatial sky;
|
||||||
|
|
||||||
public CameraHandler(MdgaApp app, FilterPostProcessor fpp) {
|
public CameraHandler(MdgaApp app, FilterPostProcessor fpp) {
|
||||||
this.app = app;
|
this.app = app;
|
||||||
this.fpp = fpp;
|
this.fpp = fpp;
|
||||||
@@ -45,18 +50,24 @@ public CameraHandler(MdgaApp app, FilterPostProcessor fpp) {
|
|||||||
dlsf.setEnabled(true);
|
dlsf.setEnabled(true);
|
||||||
dlsf.setEdgeFilteringMode(EdgeFilteringMode.PCFPOISSON);
|
dlsf.setEdgeFilteringMode(EdgeFilteringMode.PCFPOISSON);
|
||||||
dlsf.setShadowIntensity(0.7f);
|
dlsf.setShadowIntensity(0.7f);
|
||||||
|
fpp.addFilter(dlsf);
|
||||||
|
|
||||||
|
sky = SkyFactory.createSky(app.getAssetManager(), "Images/sky/sky.dds", EnvMapType.EquirectMap).rotate(FastMath.HALF_PI*1,0,FastMath.HALF_PI*0.2f);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init() {
|
public void init() {
|
||||||
app.getRootNode().addLight(sun);
|
app.getRootNode().addLight(sun);
|
||||||
app.getRootNode().addLight(ambient);
|
app.getRootNode().addLight(ambient);
|
||||||
|
app.getRootNode().attachChild(sky);
|
||||||
fpp.addFilter(dlsf);
|
fpp.addFilter(dlsf);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void shutdown() {
|
public void shutdown() {
|
||||||
app.getRootNode().removeLight(sun);
|
app.getRootNode().removeLight(sun);
|
||||||
app.getRootNode().removeLight(ambient);
|
app.getRootNode().removeLight(ambient);
|
||||||
|
app.getRootNode().detachChild(sky);
|
||||||
|
|
||||||
// Reset the camera to its default state
|
// Reset the camera to its default state
|
||||||
app.getCamera().setLocation(defaultCameraPosition);
|
app.getCamera().setLocation(defaultCameraPosition);
|
||||||
@@ -96,4 +107,5 @@ public void update(float scroll, float rotation) {
|
|||||||
|
|
||||||
app.getCamera().lookAt(Vector3f.ZERO, Vector3f.UNIT_Z);
|
app.getCamera().lookAt(Vector3f.ZERO, Vector3f.UNIT_Z);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,12 @@
|
|||||||
package pp.mdga.client.board.Outline;
|
package pp.mdga.client.board.Outline;
|
||||||
|
|
||||||
import com.jme3.asset.AssetManager;
|
import com.jme3.asset.AssetManager;
|
||||||
import com.jme3.material.Material;
|
|
||||||
import com.jme3.material.RenderState;
|
|
||||||
import com.jme3.material.RenderState.BlendMode;
|
|
||||||
import com.jme3.math.ColorRGBA;
|
import com.jme3.math.ColorRGBA;
|
||||||
import com.jme3.post.Filter;
|
|
||||||
import com.jme3.post.FilterPostProcessor;
|
import com.jme3.post.FilterPostProcessor;
|
||||||
import com.jme3.renderer.Camera;
|
import com.jme3.renderer.Camera;
|
||||||
import com.jme3.renderer.RenderManager;
|
import com.jme3.renderer.RenderManager;
|
||||||
import com.jme3.renderer.ViewPort;
|
import com.jme3.renderer.ViewPort;
|
||||||
import com.jme3.scene.Node;
|
|
||||||
import com.jme3.scene.Spatial;
|
import com.jme3.scene.Spatial;
|
||||||
import pp.mdga.game.Color;
|
|
||||||
|
|
||||||
public class SelectObjectOutliner {
|
public class SelectObjectOutliner {
|
||||||
|
|
||||||
|
|||||||
@@ -214,5 +214,6 @@ public void setTaken(Taken taken, String name) {
|
|||||||
|
|
||||||
public void setReady(boolean isReady) {
|
public void setReady(boolean isReady) {
|
||||||
this.isReady = isReady;
|
this.isReady = isReady;
|
||||||
|
onUnHover();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,43 +5,20 @@
|
|||||||
import com.jme3.scene.Node;
|
import com.jme3.scene.Node;
|
||||||
import pp.mdga.client.MdgaApp;
|
import pp.mdga.client.MdgaApp;
|
||||||
import pp.mdga.client.button.AbstractButton;
|
import pp.mdga.client.button.AbstractButton;
|
||||||
import pp.mdga.client.button.InputButton;
|
|
||||||
import pp.mdga.client.button.LabelButton;
|
import pp.mdga.client.button.LabelButton;
|
||||||
import pp.mdga.client.button.MenuButton;
|
import pp.mdga.client.button.MenuButton;
|
||||||
import pp.mdga.client.view.MainView;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class CeremonyDialog extends Dialog {
|
public class CeremonyDialog extends Dialog {
|
||||||
private ArrayList<ArrayList<LabelButton>> labels;
|
private ArrayList<ArrayList<LabelButton>> labels;
|
||||||
|
|
||||||
float offsetX = 0.5f;
|
float offsetX;
|
||||||
|
|
||||||
public CeremonyDialog(MdgaApp app, Node node) {
|
public CeremonyDialog(MdgaApp app, Node node) {
|
||||||
super(app, node);
|
super(app, node);
|
||||||
|
|
||||||
labels = new ArrayList<>();
|
prepare();
|
||||||
|
|
||||||
ArrayList<LabelButton> first = new ArrayList<>();
|
|
||||||
Vector2f size = new Vector2f(4, 1.2f);
|
|
||||||
first.add(new LabelButton(app, node, "", size, new Vector2f()));
|
|
||||||
first.add(new LabelButton(app, node, "Figuren geworfen", size, new Vector2f()));
|
|
||||||
first.add(new LabelButton(app, node, "Figuren verloren", size, new Vector2f()));
|
|
||||||
first.add(new LabelButton(app, node, "Verwendete Bonuskarten", size, new Vector2f()));
|
|
||||||
first.add(new LabelButton(app, node, "Gewürfelte 6en", size, new Vector2f()));
|
|
||||||
first.add(new LabelButton(app, node, "Gelaufene Felder", size, new Vector2f()));
|
|
||||||
first.add(new LabelButton(app, node, "Bonusfeldern erreicht", size, new Vector2f()));
|
|
||||||
|
|
||||||
float offsetY = 0.5f;
|
|
||||||
|
|
||||||
for (LabelButton b : first) {
|
|
||||||
b.setPos(new Vector2f(offsetX, MenuButton.VERTICAL - offsetY));
|
|
||||||
offsetY += 0.8f;
|
|
||||||
}
|
|
||||||
|
|
||||||
offsetX += 2.3f;
|
|
||||||
|
|
||||||
labels.add(first);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -98,4 +75,31 @@ public void addStatisticsRow(String name, int v1, int v2, int v3, int v4, int v5
|
|||||||
|
|
||||||
labels.add(row);
|
labels.add(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void prepare() {
|
||||||
|
offsetX = 0.5f;
|
||||||
|
|
||||||
|
labels = new ArrayList<>();
|
||||||
|
|
||||||
|
ArrayList<LabelButton> first = new ArrayList<>();
|
||||||
|
Vector2f size = new Vector2f(4, 1.2f);
|
||||||
|
first.add(new LabelButton(app, node, "", size, new Vector2f()));
|
||||||
|
first.add(new LabelButton(app, node, "Figuren geworfen", size, new Vector2f()));
|
||||||
|
first.add(new LabelButton(app, node, "Figuren verloren", size, new Vector2f()));
|
||||||
|
first.add(new LabelButton(app, node, "Verwendete Bonuskarten", size, new Vector2f()));
|
||||||
|
first.add(new LabelButton(app, node, "Gewürfelte 6en", size, new Vector2f()));
|
||||||
|
first.add(new LabelButton(app, node, "Gelaufene Felder", size, new Vector2f()));
|
||||||
|
first.add(new LabelButton(app, node, "Bonusfeldern erreicht", size, new Vector2f()));
|
||||||
|
|
||||||
|
float offsetY = 0.5f;
|
||||||
|
|
||||||
|
for (LabelButton b : first) {
|
||||||
|
b.setPos(new Vector2f(offsetX, MenuButton.VERTICAL - offsetY));
|
||||||
|
offsetY += 0.8f;
|
||||||
|
}
|
||||||
|
|
||||||
|
offsetX += 2.3f;
|
||||||
|
|
||||||
|
labels.add(first);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,54 +8,121 @@
|
|||||||
import com.jme3.scene.Node;
|
import com.jme3.scene.Node;
|
||||||
import com.jme3.system.AppSettings;
|
import com.jme3.system.AppSettings;
|
||||||
import pp.mdga.client.Asset;
|
import pp.mdga.client.Asset;
|
||||||
|
import pp.mdga.game.Color;
|
||||||
|
|
||||||
public class ActionTextHandler {
|
public class ActionTextHandler {
|
||||||
private Node node;
|
private Node root;
|
||||||
|
private BitmapFont font;
|
||||||
|
private AppSettings appSettings;
|
||||||
|
|
||||||
private Node textWithSpacing;
|
public ActionTextHandler(Node guiNode, AssetManager assetManager, AppSettings appSettings){
|
||||||
|
root = new Node("actionTextRoot");
|
||||||
|
guiNode.attachChild(root);
|
||||||
|
|
||||||
public ActionTextHandler(AppSettings appSettings, AssetManager assetManager, Node node){
|
root.setLocalTranslation(center(appSettings.getWidth(), appSettings.getHeight(), Vector3f.ZERO));
|
||||||
BitmapFont playerFont = assetManager.loadFont("Fonts/Gunplay.fnt");
|
font = assetManager.loadFont("Fonts/Gunplay.fnt");
|
||||||
|
this.appSettings = appSettings;
|
||||||
|
|
||||||
textWithSpacing = createTextWithSpacing(playerFont, "TEST", 20f, 250);
|
|
||||||
|
|
||||||
textWithSpacing.setLocalTranslation(center(appSettings.getWidth(), appSettings.getHeight(), Vector3f.ZERO));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void show () {
|
private Node createTextWithSpacing(String[] textArr, float spacing, float size, ColorRGBA[] colorArr) {
|
||||||
node.attachChild(textWithSpacing);
|
if(textArr.length != colorArr.length) throw new RuntimeException("text and color are not the same length");
|
||||||
}
|
|
||||||
|
|
||||||
public void hide() {
|
|
||||||
node.detachChild(textWithSpacing);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Node createTextWithSpacing(BitmapFont font, String text, float spacing, float size) {
|
|
||||||
Node textNode = new Node("TextWithSpacing");
|
Node textNode = new Node("TextWithSpacing");
|
||||||
Node center = new Node();
|
Node center = new Node();
|
||||||
float xOffset = 0;
|
float xOffset = 0;
|
||||||
|
for(int i = 0; i < textArr.length; i++){
|
||||||
|
String text = textArr[i];
|
||||||
|
ColorRGBA color = colorArr[i];
|
||||||
|
for (char c : text.toCharArray()) {
|
||||||
|
BitmapText letter = new BitmapText(font);
|
||||||
|
letter.setColor(color);
|
||||||
|
letter.setSize(size);
|
||||||
|
letter.setText(Character.toString(c));
|
||||||
|
letter.setLocalTranslation(xOffset, letter.getHeight()/2, 0);
|
||||||
|
center.attachChild(letter);
|
||||||
|
|
||||||
for (char c : text.toCharArray()) {
|
xOffset += letter.getLineWidth() + spacing;
|
||||||
BitmapText letter = new BitmapText(font);
|
}
|
||||||
letter.setSize(size);
|
|
||||||
letter.setText(Character.toString(c));
|
|
||||||
letter.setLocalTranslation(xOffset, letter.getHeight()/2, 0);
|
|
||||||
center.attachChild(letter);
|
|
||||||
|
|
||||||
xOffset += letter.getLineWidth() + spacing;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
center.setLocalTranslation(new Vector3f(-xOffset/2,0,0));
|
center.setLocalTranslation(new Vector3f(-xOffset/2,0,0));
|
||||||
textNode.attachChild(center);
|
textNode.attachChild(center);
|
||||||
|
|
||||||
return textNode;
|
return textNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Node createTextWithSpacing(String text, float spacing, float size, ColorRGBA color) {
|
||||||
|
return createTextWithSpacing(new String[]{text}, spacing, size, new ColorRGBA[]{color});
|
||||||
|
}
|
||||||
|
|
||||||
private Vector3f center(float width, float height, Vector3f pos){
|
private Vector3f center(float width, float height, Vector3f pos){
|
||||||
return new Vector3f(pos.x+width/2, pos.y+height/2,0);
|
return new Vector3f(pos.x+width/2, pos.y+height/2,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Node createTopText(String name, float spacing, float size, ColorRGBA color, float top){
|
||||||
|
return createTopText(new String[]{name}, spacing, size, new ColorRGBA[]{color}, top);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Node createTopText(String[] name, float spacing, float size, ColorRGBA color[], float top){
|
||||||
|
Node text = createTextWithSpacing(name, spacing, size, color);
|
||||||
|
text.setLocalTranslation(0, (appSettings.getHeight()/2f)*0.8f-top,0);
|
||||||
|
root.attachChild(text);
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
private Vector3f centerText(float width, float height, Vector3f pos){
|
private Vector3f centerText(float width, float height, Vector3f pos){
|
||||||
return center(-width, height, pos);
|
return center(-width, height, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void activePlayer(String name, Color color){
|
||||||
|
createTopText(new String[]{name," ist dran"}, 10,90,new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0).addControl(new ZoomControl());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ownActive(Color color){
|
||||||
|
createTopText(new String[]{"Du"," bist dran"}, 10,90,new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0).addControl(new ZoomControl());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void diceNum(int diceNum, String name, Color color){
|
||||||
|
createTopText(new String[]{name," würfelt:"}, 10,90,new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0);
|
||||||
|
|
||||||
|
createTopText(String.valueOf(diceNum), 10, 100, ColorRGBA.White, 100);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void diceNumMult(int diceNum,int mult, String name, Color color){
|
||||||
|
createTopText(new String[]{name," würfelt:"}, 10,90,new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0);
|
||||||
|
|
||||||
|
createTopText(new String[]{String.valueOf(diceNum), " x" + mult + " = " + (diceNum*mult)}, 20, 100, new ColorRGBA[]{ColorRGBA.White,ColorRGBA.Red}, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ownDice(int diceNum){
|
||||||
|
createTopText(String.valueOf(diceNum), 10, 100, ColorRGBA.White, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ownDiceMult(int diceNum, int mult){
|
||||||
|
createTopText(new String[]{String.valueOf(diceNum), " x" + mult + " = " + (diceNum*mult)}, 20, 100, new ColorRGBA[]{ColorRGBA.White,ColorRGBA.Red}, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawCard(String name, Color color){
|
||||||
|
createTopText(new String[]{name," erhält eine Bonuskarte"}, 7,70, new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0).addControl(new ZoomControl());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawCardOwn(Color color){
|
||||||
|
createTopText(new String[]{"Du"," erhälst eine Bonuskarte"}, 5,70, new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0).addControl(new ZoomControl());
|
||||||
|
}
|
||||||
|
|
||||||
|
private ColorRGBA playerColorToColorRGBA(Color color){
|
||||||
|
return switch (color){
|
||||||
|
case ARMY -> ColorRGBA.Green;
|
||||||
|
case NAVY -> ColorRGBA.Blue;
|
||||||
|
case CYBER -> ColorRGBA.Orange;
|
||||||
|
case AIRFORCE -> ColorRGBA.Black;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void hide(){
|
||||||
|
root.detachAllChildren();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,214 @@
|
|||||||
|
package pp.mdga.client.gui;
|
||||||
|
|
||||||
|
import com.jme3.material.Material;
|
||||||
|
import com.jme3.math.Vector3f;
|
||||||
|
import com.jme3.post.FilterPostProcessor;
|
||||||
|
import com.jme3.renderer.Camera;
|
||||||
|
import com.jme3.renderer.queue.RenderQueue;
|
||||||
|
import com.jme3.scene.Node;
|
||||||
|
import com.jme3.scene.Spatial;
|
||||||
|
import com.jme3.texture.Texture2D;
|
||||||
|
import pp.mdga.client.Asset;
|
||||||
|
import pp.mdga.client.MdgaApp;
|
||||||
|
import pp.mdga.game.BonusCard;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class CardLayerHandler {
|
||||||
|
private static final Vector3f START = new Vector3f(-1.8f, -3.5f, 0);
|
||||||
|
private static final Vector3f MARGIN = new Vector3f(1.8f, 0, 0);
|
||||||
|
private static final float CARDLAYER_CAMERA_ZOOM = 4;
|
||||||
|
|
||||||
|
private final MdgaApp app;
|
||||||
|
private final FilterPostProcessor fpp;
|
||||||
|
private final Texture2D backTexture;
|
||||||
|
|
||||||
|
private Camera cardLayerCamera;
|
||||||
|
private CardLayer cardLayer;
|
||||||
|
private DiceControl diceControl;
|
||||||
|
|
||||||
|
private final Map<BonusCard, CardControl> bonusCardControlMap = new HashMap<>();
|
||||||
|
private final Map<BonusCard, Integer> bonusCardIntegerMap = new HashMap<>();
|
||||||
|
private final Set<CardControl> selectableCards = new HashSet<>();
|
||||||
|
|
||||||
|
private BonusCard cardSelect = null;
|
||||||
|
|
||||||
|
public CardLayerHandler(MdgaApp app, Texture2D backTexture) {
|
||||||
|
this.app = app;
|
||||||
|
this.fpp = new FilterPostProcessor(app.getAssetManager());
|
||||||
|
this.backTexture = backTexture;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init() {
|
||||||
|
cardLayerCamera = createOverlayCam();
|
||||||
|
cardLayer = new CardLayer(fpp, cardLayerCamera, backTexture);
|
||||||
|
app.getStateManager().attach(cardLayer);
|
||||||
|
diceControl = new DiceControl(app.getAssetManager());
|
||||||
|
diceControl.create(new Vector3f(0, 0, 0), 1f, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void shutdown() {
|
||||||
|
if (cardLayer != null) {
|
||||||
|
cardLayer.shutdown();
|
||||||
|
}
|
||||||
|
cardLayer = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void rollDice(int rollNum, Runnable actionAfter) {
|
||||||
|
if (!(1 <= rollNum && rollNum <= 6)) throw new RuntimeException("rollNum is not in the range [1,6]");
|
||||||
|
diceControl.rollDice(rollNum, actionAfter);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showDice() {
|
||||||
|
cardLayer.addSpatial(diceControl.getSpatial());
|
||||||
|
diceControl.spin();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void hideDice() {
|
||||||
|
diceControl.hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addCard(BonusCard card) {
|
||||||
|
if (card == BonusCard.HIDDEN) throw new RuntimeException("Can't add hidden card to GUI");
|
||||||
|
|
||||||
|
if (!bonusCardControlMap.containsKey(card)) {
|
||||||
|
CardControl control = createCard(bonusToAsset(card), nextPos());
|
||||||
|
bonusCardControlMap.put(card, control);
|
||||||
|
cardLayer.addSpatial(control.getRoot());
|
||||||
|
}
|
||||||
|
|
||||||
|
int newNum = bonusCardIntegerMap.getOrDefault(card, 0) + 1;
|
||||||
|
bonusCardIntegerMap.put(card, newNum);
|
||||||
|
bonusCardControlMap.get(card).setNumCard(newNum);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearSelectableCards() {
|
||||||
|
for (CardControl control : selectableCards) {
|
||||||
|
control.setSelectable(false);
|
||||||
|
control.setHoverable(false);
|
||||||
|
control.unHighlight();
|
||||||
|
control.unSelect();
|
||||||
|
}
|
||||||
|
selectableCards.clear();
|
||||||
|
cardSelect = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSelectableCards(List<BonusCard> select) {
|
||||||
|
for (BonusCard card : select) {
|
||||||
|
selectableCards.add(bonusCardControlMap.get(card));
|
||||||
|
}
|
||||||
|
for (CardControl control : selectableCards) {
|
||||||
|
control.setSelectable(true);
|
||||||
|
control.setHoverable(true);
|
||||||
|
control.setHighlight();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void selectCard(CardControl cardControl) {
|
||||||
|
if (cardControl.isSelected()) {
|
||||||
|
cardControl.unSelect();
|
||||||
|
cardSelect = null;
|
||||||
|
} else {
|
||||||
|
for (CardControl control : selectableCards) {
|
||||||
|
control.unSelect();
|
||||||
|
}
|
||||||
|
cardControl.select();
|
||||||
|
cardSelect = getKeyByValue(bonusCardControlMap, cardControl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Camera getCardLayerCamera() {
|
||||||
|
return cardLayerCamera;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void shield(){
|
||||||
|
SymbolControl control = createSymbol(Asset.shieldSymbol);
|
||||||
|
cardLayer.addSpatial(control.getSpatial());
|
||||||
|
control.shield();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void swap(){
|
||||||
|
SymbolControl control = createSymbol(Asset.swapSymbol);
|
||||||
|
cardLayer.addSpatial(control.getSpatial());
|
||||||
|
control.swap();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void turbo(){
|
||||||
|
SymbolControl control = createSymbol(Asset.turboSymbol);
|
||||||
|
cardLayer.addSpatial(control.getSpatial());
|
||||||
|
control.turbo();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Asset bonusToAsset(BonusCard card) {
|
||||||
|
return switch (card) {
|
||||||
|
case TURBO -> Asset.turboCard;
|
||||||
|
case SHIELD -> Asset.shieldCard;
|
||||||
|
case SWAP -> Asset.swapCard;
|
||||||
|
case HIDDEN -> throw new RuntimeException("HIDDEN is not allowed in GUI");
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private Vector3f nextPos() {
|
||||||
|
return START.add(MARGIN.mult(bonusCardControlMap.size()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private Camera createOverlayCam() {
|
||||||
|
Camera originalCam = app.getCamera();
|
||||||
|
Camera overlayCam = new Camera(originalCam.getWidth(), originalCam.getHeight());
|
||||||
|
overlayCam.setParallelProjection(true);
|
||||||
|
float aspect = (float) originalCam.getWidth() / originalCam.getHeight();
|
||||||
|
float size = CARDLAYER_CAMERA_ZOOM;
|
||||||
|
overlayCam.setFrustum(-1000, 1000, -aspect * size, aspect * size, size, -size);
|
||||||
|
overlayCam.setLocation(new Vector3f(0, 0, 10));
|
||||||
|
overlayCam.lookAt(new Vector3f(0, 0, 0), Vector3f.UNIT_Y);
|
||||||
|
return overlayCam;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void test() {
|
||||||
|
addCard(BonusCard.SHIELD);
|
||||||
|
addCard(BonusCard.SHIELD);
|
||||||
|
addCard(BonusCard.TURBO);
|
||||||
|
addCard(BonusCard.SWAP);
|
||||||
|
}
|
||||||
|
|
||||||
|
private CardControl createCard(Asset card, Vector3f pos){
|
||||||
|
Node rootCard = new Node("Root Card");
|
||||||
|
Spatial spatial = app.getAssetManager().loadModel(card.getModelPath());
|
||||||
|
rootCard.attachChild(spatial);
|
||||||
|
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md");
|
||||||
|
mat.setTexture("DiffuseMap", app.getAssetManager().loadTexture(card.getDiffPath()));
|
||||||
|
spatial.setMaterial(mat);
|
||||||
|
spatial.setLocalScale(1f);
|
||||||
|
rootCard.setLocalTranslation(pos);
|
||||||
|
spatial.rotate((float)Math.toRadians(90), (float)Math.toRadians(180), (float)Math.toRadians(180));
|
||||||
|
spatial.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
|
||||||
|
CardControl control = new CardControl(app, fpp, cardLayer.getOverlayCam(), rootCard);
|
||||||
|
spatial.addControl(control);
|
||||||
|
return control;
|
||||||
|
}
|
||||||
|
|
||||||
|
private SymbolControl createSymbol(Asset asset){
|
||||||
|
Spatial spatial = app.getAssetManager().loadModel(asset.getModelPath());
|
||||||
|
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
|
||||||
|
mat.setTexture("ColorMap", app.getAssetManager().loadTexture(asset.getDiffPath()));
|
||||||
|
spatial.setMaterial(mat);
|
||||||
|
spatial.setLocalScale(1f);
|
||||||
|
spatial.rotate((float)Math.toRadians(90), (float)Math.toRadians(180), (float)Math.toRadians(180));
|
||||||
|
SymbolControl control = new SymbolControl();
|
||||||
|
spatial.addControl(control);
|
||||||
|
return control;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CardLayer getCardLayer(){
|
||||||
|
return cardLayer;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,7 +11,6 @@
|
|||||||
import com.jme3.scene.Spatial;
|
import com.jme3.scene.Spatial;
|
||||||
import com.jme3.scene.control.AbstractControl;
|
import com.jme3.scene.control.AbstractControl;
|
||||||
import pp.mdga.client.Asset;
|
import pp.mdga.client.Asset;
|
||||||
import pp.mdga.message.server.Dice;
|
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
@@ -23,7 +22,7 @@ public class DiceControl extends AbstractControl {
|
|||||||
private final Vector3f angularVelocity = new Vector3f();
|
private final Vector3f angularVelocity = new Vector3f();
|
||||||
private float deceleration = 0.5f;
|
private float deceleration = 0.5f;
|
||||||
private float timeElapsed = 0.0f;
|
private float timeElapsed = 0.0f;
|
||||||
private float rollDuration = 0.0001f;
|
private float rollDuration = 1f;
|
||||||
private static final int ANGULAR_MIN = 5;
|
private static final int ANGULAR_MIN = 5;
|
||||||
private static final int ANGULAR_MAX = 15;
|
private static final int ANGULAR_MAX = 15;
|
||||||
private static final int ANGULAR_SPIN = 10;
|
private static final int ANGULAR_SPIN = 10;
|
||||||
@@ -31,6 +30,7 @@ public class DiceControl extends AbstractControl {
|
|||||||
private boolean slerp = false;
|
private boolean slerp = false;
|
||||||
private boolean spin = false;
|
private boolean spin = false;
|
||||||
private final AssetManager assetManager;
|
private final AssetManager assetManager;
|
||||||
|
private Runnable actionAfter;
|
||||||
|
|
||||||
public DiceControl(AssetManager assetManager){
|
public DiceControl(AssetManager assetManager){
|
||||||
this.assetManager = assetManager;
|
this.assetManager = assetManager;
|
||||||
@@ -60,13 +60,14 @@ protected void controlUpdate(float tpf) {
|
|||||||
|
|
||||||
if (timeElapsed > 1.0f) timeElapsed = 1.0f;
|
if (timeElapsed > 1.0f) timeElapsed = 1.0f;
|
||||||
Quaternion interpolated = spatial.getLocalRotation().clone();
|
Quaternion interpolated = spatial.getLocalRotation().clone();
|
||||||
interpolated.nlerp(targetRotation, lerp(timeElapsed));
|
interpolated.slerp(targetRotation, timeElapsed);
|
||||||
spatial.setLocalRotation(interpolated);
|
spatial.setLocalRotation(interpolated);
|
||||||
|
|
||||||
// Stop rolling once duration is complete
|
// Stop rolling once duration is complete
|
||||||
if (timeElapsed >= 1.0f) {
|
if (timeElapsed >= 1.0f) {
|
||||||
isRolling = false;
|
isRolling = false;
|
||||||
slerp = false;
|
slerp = false;
|
||||||
|
actionAfter.run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else if(spin){
|
}else if(spin){
|
||||||
@@ -90,11 +91,11 @@ protected void controlRender(RenderManager rm, ViewPort vp) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void rollDice(int diceNum) {
|
public void rollDice(int diceNum, Runnable actionAfter) {
|
||||||
if (isRolling) return;
|
if (isRolling) return;
|
||||||
spin = false;
|
spin = false;
|
||||||
slerp = false;
|
slerp = false;
|
||||||
|
this.actionAfter = actionAfter;
|
||||||
angularVelocity.set(
|
angularVelocity.set(
|
||||||
FastMath.nextRandomInt(ANGULAR_MIN,ANGULAR_MAX),
|
FastMath.nextRandomInt(ANGULAR_MIN,ANGULAR_MAX),
|
||||||
FastMath.nextRandomInt(ANGULAR_MIN,ANGULAR_MAX),
|
FastMath.nextRandomInt(ANGULAR_MIN,ANGULAR_MAX),
|
||||||
@@ -166,4 +167,5 @@ public void create(Vector3f pos, float scale, boolean shadow){
|
|||||||
public void setPos(Vector3f pos){
|
public void setPos(Vector3f pos){
|
||||||
spatial.setLocalTranslation(pos);
|
spatial.setLocalTranslation(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,262 +1,130 @@
|
|||||||
package pp.mdga.client.gui;
|
package pp.mdga.client.gui;
|
||||||
|
|
||||||
import com.jme3.font.BitmapFont;
|
|
||||||
import com.jme3.font.BitmapText;
|
|
||||||
import com.jme3.material.Material;
|
|
||||||
import com.jme3.math.ColorRGBA;
|
|
||||||
import com.jme3.math.Vector3f;
|
|
||||||
import com.jme3.post.FilterPostProcessor;
|
|
||||||
import com.jme3.renderer.Camera;
|
import com.jme3.renderer.Camera;
|
||||||
import com.jme3.renderer.queue.RenderQueue;
|
|
||||||
import com.jme3.scene.Node;
|
import com.jme3.scene.Node;
|
||||||
import com.jme3.scene.Spatial;
|
|
||||||
import com.jme3.texture.FrameBuffer;
|
import com.jme3.texture.FrameBuffer;
|
||||||
import com.jme3.texture.Image;
|
import com.jme3.texture.Image;
|
||||||
import com.jme3.texture.Texture2D;
|
import com.jme3.texture.Texture2D;
|
||||||
import pp.mdga.client.Asset;
|
|
||||||
import pp.mdga.client.MdgaApp;
|
import pp.mdga.client.MdgaApp;
|
||||||
import pp.mdga.game.BonusCard;
|
|
||||||
import pp.mdga.game.Color;
|
import pp.mdga.game.Color;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.List;
|
||||||
|
|
||||||
import static com.jme3.material.Materials.UNSHADED;
|
|
||||||
|
|
||||||
|
|
||||||
public class GuiHandler {
|
public class GuiHandler {
|
||||||
|
private final MdgaApp app;
|
||||||
|
private final CardLayerHandler cardLayerHandler;
|
||||||
|
private final PlayerNameHandler playerNameHandler;
|
||||||
|
private final ActionTextHandler actionTextHandler;
|
||||||
|
private final Color ownColor;
|
||||||
|
|
||||||
private MdgaApp app;
|
private FrameBuffer backFrameBuffer;
|
||||||
private CardLayer cardLayer;
|
|
||||||
private Map<UUID, BonusCard> uuidBonusCardMap;
|
|
||||||
private Map<BonusCard, CardControl> bonusCardControlMap;
|
|
||||||
private Map<BonusCard, Integer> bonusCardIntegerMap;
|
|
||||||
|
|
||||||
private static final Vector3f START = new Vector3f(-1.8f,-3.5f,0);
|
public GuiHandler(MdgaApp app, Node guiNode, Color ownColor) {
|
||||||
private static final Vector3f MARGIN = new Vector3f(1.8f,0,0);
|
|
||||||
|
|
||||||
private final FilterPostProcessor fpp;
|
|
||||||
private Camera cardLayerCamera;
|
|
||||||
private DiceControl diceControl;
|
|
||||||
|
|
||||||
private Set<CardControl> selectableCards = new HashSet<>();
|
|
||||||
private BonusCard cardSelect = null;
|
|
||||||
private PlayerNameHandler playerNameHandler;
|
|
||||||
|
|
||||||
private Node rootNode;
|
|
||||||
|
|
||||||
public GuiHandler(MdgaApp app, Node node) {
|
|
||||||
this.app = app;
|
this.app = app;
|
||||||
this.fpp = new FilterPostProcessor(app.getAssetManager());
|
this.ownColor = ownColor;
|
||||||
this.rootNode = node;
|
|
||||||
|
|
||||||
cardLayerCamera = createOverlayCam();
|
backFrameBuffer = new FrameBuffer(app.getCamera().getWidth(), app.getCamera().getHeight(), 1);
|
||||||
uuidBonusCardMap = new HashMap<>();
|
|
||||||
bonusCardIntegerMap = new HashMap<>();
|
|
||||||
bonusCardControlMap = new HashMap<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void init(){
|
|
||||||
FrameBuffer backFrameBuffer = new FrameBuffer(app.getCamera().getWidth(), app.getCamera().getHeight(), 1);
|
|
||||||
Texture2D backTexture = new Texture2D(app.getCamera().getWidth(), app.getCamera().getHeight(), Image.Format.RGBA8);
|
Texture2D backTexture = new Texture2D(app.getCamera().getWidth(), app.getCamera().getHeight(), Image.Format.RGBA8);
|
||||||
backFrameBuffer.setDepthTarget(FrameBuffer.FrameBufferTarget.newTarget(Image.Format.Depth));
|
backFrameBuffer.setDepthTarget(FrameBuffer.FrameBufferTarget.newTarget(Image.Format.Depth));
|
||||||
backFrameBuffer.addColorTarget(FrameBuffer.FrameBufferTarget.newTarget(backTexture));
|
backFrameBuffer.addColorTarget(FrameBuffer.FrameBufferTarget.newTarget(backTexture));
|
||||||
|
|
||||||
|
cardLayerHandler = new CardLayerHandler(app, backTexture);
|
||||||
|
playerNameHandler = new PlayerNameHandler(guiNode, app.getAssetManager(), app.getContext().getSettings());
|
||||||
|
actionTextHandler = new ActionTextHandler(guiNode, app.getAssetManager(), app.getContext().getSettings());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init() {
|
||||||
|
cardLayerHandler.init();
|
||||||
app.getViewPort().setOutputFrameBuffer(backFrameBuffer);
|
app.getViewPort().setOutputFrameBuffer(backFrameBuffer);
|
||||||
|
|
||||||
cardLayer = new CardLayer(fpp, cardLayerCamera, backTexture);
|
|
||||||
app.getStateManager().attach(cardLayer);
|
|
||||||
diceControl = new DiceControl(app.getAssetManager());
|
|
||||||
diceControl.create(new Vector3f(0,0,0), 1f, false);
|
|
||||||
|
|
||||||
playerNameHandler = new PlayerNameHandler(rootNode, app.getAssetManager(), app.getContext().getSettings());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void shutdown(){
|
public void shutdown() {
|
||||||
if(cardLayer != null){
|
cardLayerHandler.shutdown();
|
||||||
cardLayer.shutdown();
|
app.getViewPort().setOutputFrameBuffer(null);
|
||||||
}
|
|
||||||
|
|
||||||
cardLayer = null;
|
|
||||||
|
|
||||||
//app.getViewPort().setOutputFrameBuffer(null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Asset bonusToAsset(BonusCard card){
|
public void rollDice(int rollNum, int mult) {
|
||||||
return switch (card){
|
cardLayerHandler.rollDice(rollNum, ()->{
|
||||||
case TURBO -> Asset.turboCard;
|
if(mult == -1) actionTextHandler.ownDice(rollNum);
|
||||||
case SHIELD -> Asset.shieldCard;
|
else actionTextHandler.ownDiceMult(rollNum, mult);
|
||||||
case SWAP -> Asset.swapCard;
|
hideDice();
|
||||||
case HIDDEN -> throw new RuntimeException("HIDDEN is not allowed in GUI");
|
//TODO send Model finished
|
||||||
};
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addCard(BonusCard card, UUID uuid) {
|
public void showRolledDiceMult(int rollNum, int mult, Color color) {
|
||||||
if(card == BonusCard.HIDDEN) throw new RuntimeException("cant add hidden card to gui");
|
String name = playerNameHandler.getName(color);
|
||||||
|
if(mult == -1) actionTextHandler.diceNum(rollNum, name, color);
|
||||||
uuidBonusCardMap.put(uuid, card);
|
else actionTextHandler.diceNumMult(rollNum, mult, name, color);
|
||||||
if(!bonusCardControlMap.containsKey(card)) {
|
|
||||||
CardControl control = createCard(bonusToAsset(card), nextPos());
|
|
||||||
bonusCardControlMap.put(card, control);
|
|
||||||
cardLayer.addSpatial(control.getRoot());
|
|
||||||
}
|
|
||||||
|
|
||||||
int newNum = bonusCardIntegerMap.getOrDefault(card,0) + 1;
|
|
||||||
bonusCardIntegerMap.put(card, newNum);
|
|
||||||
bonusCardControlMap.get(card).setNumCard(newNum);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void rollDice(int rollNum){
|
public void showRolledDice(int rollNum, Color color) {
|
||||||
if(!(1 <= rollNum && rollNum <= 6)) throw new RuntimeException("rollNum is not in the range [1,6]");
|
actionTextHandler.diceNum(rollNum, playerNameHandler.getName(color), color);
|
||||||
diceControl.rollDice(rollNum);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showDice(){
|
public void showDice() {
|
||||||
cardLayer.addSpatial(diceControl.getSpatial());
|
cardLayerHandler.showDice();
|
||||||
diceControl.spin();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hideDice(){
|
public void hideDice() {
|
||||||
diceControl.hide();
|
cardLayerHandler.hideDice();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Vector3f nextPos() {
|
public void addCard(pp.mdga.game.BonusCard card) {
|
||||||
return START.add(MARGIN.mult(bonusCardControlMap.size()));
|
cardLayerHandler.addCard(card);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPlayer(Color color, String name, boolean own){
|
public void clearSelectableCards() {
|
||||||
playerNameHandler.addPlayer(color, name, own);
|
cardLayerHandler.clearSelectableCards();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setActivePlayer(Color color){
|
public void setSelectableCards(List<pp.mdga.game.BonusCard> select) {
|
||||||
playerNameHandler.setActivePlayer(color);
|
cardLayerHandler.setSelectableCards(select);
|
||||||
}
|
|
||||||
|
|
||||||
public Camera getCardLayerCamera() {
|
|
||||||
return cardLayerCamera;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CardLayer getCardLayer(){
|
|
||||||
return cardLayer;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSelectableCards_UUID(List<UUID> selectUuids) {
|
|
||||||
for(UUID uuid : selectUuids) {
|
|
||||||
selectableCards.add(bonusCardControlMap.get(uuidBonusCardMap.get(uuid)));
|
|
||||||
}
|
|
||||||
for(CardControl control : selectableCards){
|
|
||||||
control.setSelectable(true);
|
|
||||||
control.setHoverable(true);
|
|
||||||
control.setHighlight();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSelectableCards(List<BonusCard> select) {
|
|
||||||
for(BonusCard uuid : select) {
|
|
||||||
selectableCards.add(bonusCardControlMap.get(uuid));
|
|
||||||
}
|
|
||||||
for(CardControl control : selectableCards){
|
|
||||||
control.setSelectable(true);
|
|
||||||
control.setHoverable(true);
|
|
||||||
control.setHighlight();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void clearSelectableCards(){
|
|
||||||
for(CardControl control : selectableCards){
|
|
||||||
control.setSelectable(false);
|
|
||||||
control.setHoverable(false);
|
|
||||||
control.unHighlight();
|
|
||||||
control.unSelect();
|
|
||||||
}
|
|
||||||
selectableCards.clear();
|
|
||||||
cardSelect = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void selectCard(CardControl cardControl) {
|
public void selectCard(CardControl cardControl) {
|
||||||
if(cardControl.isSelected()) {
|
cardLayerHandler.selectCard(cardControl);
|
||||||
cardControl.unSelect();
|
}
|
||||||
cardSelect = null;
|
|
||||||
}
|
public Camera getCardLayerCamera() {
|
||||||
else {
|
return cardLayerHandler.getCardLayerCamera();
|
||||||
for (CardControl control : selectableCards){
|
}
|
||||||
control.unSelect();
|
|
||||||
}
|
public Node getCardLayerRootNode(){
|
||||||
cardControl.select();
|
return cardLayerHandler.getCardLayer().getRootNode();
|
||||||
cardSelect = getKeyByValue(bonusCardControlMap, cardControl);
|
}
|
||||||
}
|
|
||||||
|
public void addPlayer(Color color, String name) {
|
||||||
|
playerNameHandler.addPlayer(color, name, color == ownColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActivePlayer(Color color) {
|
||||||
|
playerNameHandler.setActivePlayer(color);
|
||||||
|
|
||||||
|
if (ownColor == color) actionTextHandler.ownActive(color);
|
||||||
|
else actionTextHandler.activePlayer(playerNameHandler.getName(color), color);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void shield(){
|
public void shield(){
|
||||||
SymbolControl control = createSymbol(Asset.shieldSymbol);
|
cardLayerHandler.shield();
|
||||||
cardLayer.addSpatial(control.getSpatial());
|
|
||||||
control.shield();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void swap(){
|
public void swap(){
|
||||||
SymbolControl control = createSymbol(Asset.swapSymbol);
|
cardLayerHandler.swap();
|
||||||
cardLayer.addSpatial(control.getSpatial());
|
|
||||||
control.swap();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void turbo(){
|
public void turbo(){
|
||||||
SymbolControl control = createSymbol(Asset.turboSymbol);
|
cardLayerHandler.turbo();
|
||||||
cardLayer.addSpatial(control.getSpatial());
|
|
||||||
control.turbo();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <K, V> K getKeyByValue(Map<K, V> map, V value) {
|
public void hideText(){
|
||||||
for (Map.Entry<K, V> entry : map.entrySet()) {
|
actionTextHandler.hide();
|
||||||
if (entry.getValue().equals(value)) {
|
|
||||||
return entry.getKey();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null; // Key not found
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private SymbolControl createSymbol(Asset asset){
|
public void drawCard(Color color) {
|
||||||
Spatial spatial = app.getAssetManager().loadModel(asset.getModelPath());
|
if (ownColor == color) actionTextHandler.drawCardOwn(color);
|
||||||
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
|
else actionTextHandler.drawCard(playerNameHandler.getName(color), color);
|
||||||
mat.setTexture("ColorMap", app.getAssetManager().loadTexture(asset.getDiffPath()));
|
|
||||||
spatial.setMaterial(mat);
|
|
||||||
spatial.setLocalScale(1f);
|
|
||||||
spatial.rotate((float)Math.toRadians(90), (float)Math.toRadians(180), (float)Math.toRadians(180));
|
|
||||||
SymbolControl control = new SymbolControl();
|
|
||||||
spatial.addControl(control);
|
|
||||||
return control;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Camera createOverlayCam(){
|
|
||||||
Camera originalCam = app.getCamera();
|
|
||||||
Camera overlayCam = new Camera(originalCam.getWidth(), originalCam.getHeight());
|
|
||||||
overlayCam.setParallelProjection(true);
|
|
||||||
// overlayCam.setFrustum(originalCam.getFrustumNear(), originalCam.getFrustumFar(), originalCam.getFrustumLeft(), originalCam.getFrustumRight(),originalCam.getFrustumTop(), originalCam.getFrustumBottom());
|
|
||||||
float CAMERA_ZOOM = 4;
|
|
||||||
float aspect = (float) originalCam.getWidth() / originalCam.getHeight();
|
|
||||||
float size = CAMERA_ZOOM;
|
|
||||||
overlayCam.setFrustum(-1000, 1000, -aspect * size, aspect * size, size, -size);
|
|
||||||
// overlayCam.setFov(originalCam.getFov());
|
|
||||||
overlayCam.setLocation(new Vector3f(0, 0, 10));
|
|
||||||
overlayCam.lookAt(new Vector3f(0,0,0), Vector3f.UNIT_Y);
|
|
||||||
return overlayCam;
|
|
||||||
}
|
|
||||||
|
|
||||||
private CardControl createCard(Asset card, Vector3f pos){
|
|
||||||
Node rootCard = new Node("Root Card");
|
|
||||||
Spatial spatial = app.getAssetManager().loadModel(card.getModelPath());
|
|
||||||
rootCard.attachChild(spatial);
|
|
||||||
// Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
|
|
||||||
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md");
|
|
||||||
// mat.setTexture("ColorMap", app.getAssetManager().loadTexture(card.getDiffPath()));
|
|
||||||
mat.setTexture("DiffuseMap", app.getAssetManager().loadTexture(card.getDiffPath()));
|
|
||||||
spatial.setMaterial(mat);
|
|
||||||
spatial.setLocalScale(1f);
|
|
||||||
rootCard.setLocalTranslation(pos);
|
|
||||||
// spatial.setLocalTranslation(pos);
|
|
||||||
spatial.rotate((float)Math.toRadians(90), (float)Math.toRadians(180), (float)Math.toRadians(180));
|
|
||||||
spatial.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
|
|
||||||
CardControl control = new CardControl(app, fpp, cardLayer.getOverlayCam(), rootCard);
|
|
||||||
spatial.addControl(control);
|
|
||||||
return control;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,8 +25,7 @@ public class PlayerNameHandler {
|
|||||||
private final AssetManager assetManager;
|
private final AssetManager assetManager;
|
||||||
private Color ownColor;
|
private Color ownColor;
|
||||||
|
|
||||||
|
private static final float PADDING_TOP = 35;
|
||||||
private static final float PADDING_TOP = 50;
|
|
||||||
private static final float PADDING_LEFT = 50;
|
private static final float PADDING_LEFT = 50;
|
||||||
private static final float MARGIN_NAMES = 50;
|
private static final float MARGIN_NAMES = 50;
|
||||||
private static final float IMAGE_SIZE = 50;
|
private static final float IMAGE_SIZE = 50;
|
||||||
@@ -91,14 +90,7 @@ private Spatial createColor(Color color) {
|
|||||||
return pic;
|
return pic;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ColorRGBA playerColorToColorRGBA(Color color){
|
|
||||||
return switch (color){
|
|
||||||
case ARMY -> ColorRGBA.Green;
|
|
||||||
case NAVY -> ColorRGBA.Blue;
|
|
||||||
case CYBER -> ColorRGBA.Orange;
|
|
||||||
case AIRFORCE -> ColorRGBA.Black;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
private Spatial createName(String name, boolean first, boolean own){
|
private Spatial createName(String name, boolean first, boolean own){
|
||||||
BitmapText hudText = new BitmapText(playerFont);
|
BitmapText hudText = new BitmapText(playerFont);
|
||||||
@@ -126,5 +118,9 @@ public void setActivePlayer(Color color) {
|
|||||||
drawPlayers();
|
drawPlayers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getName(Color color){
|
||||||
|
return colorNameMap.get(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,82 @@
|
|||||||
|
package pp.mdga.client.gui;
|
||||||
|
|
||||||
|
import com.jme3.renderer.RenderManager;
|
||||||
|
import com.jme3.renderer.ViewPort;
|
||||||
|
import com.jme3.scene.Spatial;
|
||||||
|
import com.jme3.scene.control.AbstractControl;
|
||||||
|
|
||||||
|
public class ZoomControl extends AbstractControl {
|
||||||
|
private boolean zoomingIn = false;
|
||||||
|
private boolean zoomingOut = false;
|
||||||
|
private float progress = 0;
|
||||||
|
private float zoomSpeed = 1f;
|
||||||
|
private float zoomFactor = 1f;
|
||||||
|
|
||||||
|
public ZoomControl(){}
|
||||||
|
|
||||||
|
public ZoomControl(float speed) {
|
||||||
|
zoomSpeed = speed;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setSpatial(Spatial spatial){
|
||||||
|
if(this.spatial == null && spatial != null){
|
||||||
|
super.setSpatial(spatial);
|
||||||
|
initSpatial();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initSpatial() {
|
||||||
|
zoomingIn = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void controlUpdate(float tpf) {
|
||||||
|
if (zoomingIn) {
|
||||||
|
progress += tpf * zoomSpeed;
|
||||||
|
if (progress > 1) progress = 1;
|
||||||
|
spatial.setLocalScale(lerp(0, zoomFactor, easeOut(progress)));
|
||||||
|
if (progress >= 1) {
|
||||||
|
zoomingIn = false;
|
||||||
|
zoomingOut = true;
|
||||||
|
progress = 0;
|
||||||
|
}
|
||||||
|
} else if (zoomingOut) {
|
||||||
|
progress += tpf * zoomSpeed;
|
||||||
|
spatial.setLocalScale(lerp(zoomFactor, 0, easeIn(progress)));
|
||||||
|
if (progress > 1) {
|
||||||
|
zoomingOut = false;
|
||||||
|
end();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void end(){
|
||||||
|
spatial.removeFromParent();
|
||||||
|
spatial.removeControl(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void controlRender(RenderManager rm, ViewPort vp) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static float lerp(float start, float end, float t) {
|
||||||
|
return (1 - t) * start + t * end;
|
||||||
|
}
|
||||||
|
|
||||||
|
// private static float easeOut(float t) {
|
||||||
|
// return (float) Math.sqrt(1 - Math.pow(t - 1, 2));
|
||||||
|
// }
|
||||||
|
private float easeOut(float x) {
|
||||||
|
return x == 1 ? 1 : (float) (1 - Math.pow(2, -10 * x));
|
||||||
|
|
||||||
|
}
|
||||||
|
// private float easeIn(float t) {
|
||||||
|
// return t * t * t * t;
|
||||||
|
// }
|
||||||
|
private float easeIn(float x) {
|
||||||
|
return x == 0 ? 0 : (float) Math.pow(2, 10 * x - 10);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,235 @@
|
|||||||
|
package pp.mdga.client.server;
|
||||||
|
|
||||||
|
import com.jme3.network.*;
|
||||||
|
import com.jme3.network.serializing.Serializer;
|
||||||
|
import pp.mdga.game.Game;
|
||||||
|
import pp.mdga.game.Player;
|
||||||
|
import pp.mdga.message.client.*;
|
||||||
|
import pp.mdga.message.server.*;
|
||||||
|
import pp.mdga.server.ServerGameLogic;
|
||||||
|
import pp.mdga.server.ServerSender;
|
||||||
|
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.lang.System.Logger;
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.BlockingQueue;
|
||||||
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
|
import java.util.logging.LogManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Server implementing the visitor pattern as MessageReceiver for ClientMessages
|
||||||
|
*/
|
||||||
|
public class MdgaServer implements MessageListener<HostedConnection>, ConnectionListener, ServerSender {
|
||||||
|
private static final Logger LOGGER = System.getLogger(MdgaServer.class.getName());
|
||||||
|
|
||||||
|
private Server myServer;
|
||||||
|
private final ServerGameLogic logic;
|
||||||
|
private final BlockingQueue<ReceivedMessage> pendingMessages = new LinkedBlockingQueue<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
// Configure logging
|
||||||
|
LogManager manager = LogManager.getLogManager();
|
||||||
|
try {
|
||||||
|
manager.readConfiguration(new FileInputStream("logging.properties"));
|
||||||
|
LOGGER.log(Level.INFO, "Successfully read logging properties"); //NON-NLS
|
||||||
|
} catch (IOException e) {
|
||||||
|
LOGGER.log(Level.INFO, e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts the Battleships server.
|
||||||
|
*/
|
||||||
|
public static void main(String[] args) {
|
||||||
|
new MdgaServer().run();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new MdgaServer.
|
||||||
|
*/
|
||||||
|
public MdgaServer() {
|
||||||
|
LOGGER.log(Level.INFO, "Creating MdgaServer"); //NON-NLS
|
||||||
|
logic = new ServerGameLogic(this, new Game());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
startServer();
|
||||||
|
this.connectionAdded(myServer, myServer.getConnection(0));
|
||||||
|
while (true)
|
||||||
|
processNextMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void startServer() {
|
||||||
|
try {
|
||||||
|
LOGGER.log(Level.INFO, "Starting server..."); //NON-NLS
|
||||||
|
myServer = Network.createServer(1234);
|
||||||
|
|
||||||
|
initializeSerializables();
|
||||||
|
myServer.start();
|
||||||
|
registerListeners();
|
||||||
|
LOGGER.log(Level.INFO, "Server started: {0}", myServer.isRunning()); //NON-NLS
|
||||||
|
} catch (IOException e) {
|
||||||
|
LOGGER.log(Level.ERROR, "Couldn't start server: {0}", e.getMessage()); //NON-NLS
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void processNextMessage() {
|
||||||
|
try {
|
||||||
|
pendingMessages.take().process(logic);
|
||||||
|
} catch (InterruptedException ex) {
|
||||||
|
LOGGER.log(Level.INFO, "Interrupted while waiting for messages"); //NON-NLS
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initializeSerializables() {
|
||||||
|
Serializer.registerClass(AnimationEndMessage.class);
|
||||||
|
Serializer.registerClass(ClientStartGameMessage.class);
|
||||||
|
Serializer.registerClass(DeselectTSKMessage.class);
|
||||||
|
Serializer.registerClass(ForceContinueGameMessage.class);
|
||||||
|
Serializer.registerClass(StartGameMessage.class);
|
||||||
|
Serializer.registerClass(JoinServerMessage.class);
|
||||||
|
Serializer.registerClass(LeaveGameMessage.class);
|
||||||
|
Serializer.registerClass(LobbyNotReadyMessage.class);
|
||||||
|
Serializer.registerClass(LobbyReadyMessage.class);
|
||||||
|
Serializer.registerClass(NoPowerCardMessage.class);
|
||||||
|
Serializer.registerClass(RequestBriefingMessage.class);
|
||||||
|
Serializer.registerClass(RequestDieMessage.class);
|
||||||
|
Serializer.registerClass(RequestMoveMessage.class);
|
||||||
|
Serializer.registerClass(RequestPlayCardMessage.class);
|
||||||
|
Serializer.registerClass(SelectCardMessage.class);
|
||||||
|
Serializer.registerClass(SelectedPiecesMessage.class);
|
||||||
|
Serializer.registerClass(SelectTSKMessage.class);
|
||||||
|
|
||||||
|
Serializer.registerClass(ActivePlayerMessage.class);
|
||||||
|
Serializer.registerClass(AnyPieceMessage.class);
|
||||||
|
Serializer.registerClass(BriefingMessage.class);
|
||||||
|
Serializer.registerClass(CeremonyMessage.class);
|
||||||
|
Serializer.registerClass(DieMessage.class);
|
||||||
|
Serializer.registerClass(DiceAgainMessage.class);
|
||||||
|
Serializer.registerClass(DiceNowMessage.class);
|
||||||
|
Serializer.registerClass(EndOfTurnMessage.class);
|
||||||
|
Serializer.registerClass(LobbyAcceptMessage.class);
|
||||||
|
Serializer.registerClass(LobbyDenyMessage.class);
|
||||||
|
Serializer.registerClass(LobbyPlayerJoinMessage.class);
|
||||||
|
Serializer.registerClass(LobbyPlayerLeaveMessage.class);
|
||||||
|
Serializer.registerClass(MoveMessage.class);
|
||||||
|
Serializer.registerClass(NoTurnMessage.class);
|
||||||
|
Serializer.registerClass(PauseGameMessage.class);
|
||||||
|
Serializer.registerClass(PlayCardMessage.class);
|
||||||
|
Serializer.registerClass(PossibleCardMessage.class);
|
||||||
|
Serializer.registerClass(PossiblePieceMessage.class);
|
||||||
|
Serializer.registerClass(RankingResponseMessage.class);
|
||||||
|
Serializer.registerClass(RankingRollAgainMessage.class);
|
||||||
|
Serializer.registerClass(ReconnectBriefingMessage.class);
|
||||||
|
Serializer.registerClass(ResumeGameMessage.class);
|
||||||
|
Serializer.registerClass(ServerStartGameMessage.class);
|
||||||
|
Serializer.registerClass(StartPieceMessage.class);
|
||||||
|
Serializer.registerClass(UpdateReadyMessage.class);
|
||||||
|
Serializer.registerClass(UpdateTSKMessage.class);
|
||||||
|
Serializer.registerClass(WaitPieceMessage.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void registerListeners() {
|
||||||
|
myServer.addMessageListener(this, AnimationEndMessage.class);
|
||||||
|
myServer.addMessageListener(this, ClientStartGameMessage.class);
|
||||||
|
myServer.addMessageListener(this, DeselectTSKMessage.class);
|
||||||
|
myServer.addMessageListener(this, ForceContinueGameMessage.class);
|
||||||
|
myServer.addMessageListener(this, StartGameMessage.class);
|
||||||
|
myServer.addMessageListener(this, JoinServerMessage.class);
|
||||||
|
myServer.addMessageListener(this, LeaveGameMessage.class);
|
||||||
|
myServer.addMessageListener(this, LobbyNotReadyMessage.class);
|
||||||
|
myServer.addMessageListener(this, LobbyReadyMessage.class);
|
||||||
|
myServer.addMessageListener(this, NoPowerCardMessage.class);
|
||||||
|
myServer.addMessageListener(this, RequestBriefingMessage.class);
|
||||||
|
myServer.addMessageListener(this, RequestDieMessage.class);
|
||||||
|
myServer.addMessageListener(this, RequestMoveMessage.class);
|
||||||
|
myServer.addMessageListener(this, RequestPlayCardMessage.class);
|
||||||
|
myServer.addMessageListener(this, SelectCardMessage.class);
|
||||||
|
myServer.addMessageListener(this, SelectedPiecesMessage.class);
|
||||||
|
myServer.addMessageListener(this, SelectTSKMessage.class);
|
||||||
|
myServer.addConnectionListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void messageReceived(HostedConnection source, ClientMessage message) {
|
||||||
|
LOGGER.log(Level.INFO, "message received from {0}: {1}", source.getId(), message); //NON-NLS
|
||||||
|
pendingMessages.add(new ReceivedMessage(message, source.getId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void connectionAdded(Server server, HostedConnection hostedConnection) {
|
||||||
|
LOGGER.log(Level.INFO, "new connection {0}", hostedConnection); //NON-NLS
|
||||||
|
// ToDo: Synchronize data between server and client.
|
||||||
|
logic.getGame().addPlayer(hostedConnection.getId(), new Player());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void connectionRemoved(Server server, HostedConnection hostedConnection) {
|
||||||
|
LOGGER.log(Level.INFO, "connection closed: {0}", hostedConnection); //NON-NLS
|
||||||
|
final Player player = logic.getGame().getPlayerById(hostedConnection.getId());
|
||||||
|
if (player == null)
|
||||||
|
LOGGER.log(Level.INFO, "closed connection does not belong to an active player"); //NON-NLS
|
||||||
|
else { //NON-NLS
|
||||||
|
LOGGER.log(Level.INFO, "closed connection belongs to {0}", player); //NON-NLS
|
||||||
|
// exit(0);
|
||||||
|
this.handleDisconnect(hostedConnection.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method will be used to handle unintentional disconnections from players.
|
||||||
|
*
|
||||||
|
* @param id as the id of the disconnected player.
|
||||||
|
*/
|
||||||
|
public void handleDisconnect(int id) {
|
||||||
|
this.logic.received(new DisconnectedMessage(), id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void exit(int exitValue) { //NON-NLS
|
||||||
|
LOGGER.log(Level.INFO, "close request"); //NON-NLS
|
||||||
|
if (myServer != null)
|
||||||
|
for (HostedConnection client : myServer.getConnections()) //NON-NLS
|
||||||
|
if (client != null) client.close("Game over"); //NON-NLS
|
||||||
|
System.exit(exitValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send the specified message to the specified connection.
|
||||||
|
*
|
||||||
|
* @param id the connection id
|
||||||
|
* @param message the message
|
||||||
|
*/
|
||||||
|
public void send(int id, ServerMessage message) {
|
||||||
|
if (myServer == null || !myServer.isRunning()) {
|
||||||
|
LOGGER.log(Level.ERROR, "no server running when trying to send {0}", message); //NON-NLS
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final HostedConnection connection = myServer.getConnection(id);
|
||||||
|
if (connection != null)
|
||||||
|
connection.send(message);
|
||||||
|
else
|
||||||
|
LOGGER.log(Level.ERROR, "there is no connection with id={0}", id); //NON-NLS
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method will be used to send the given message parameter to all connected players which are saved inside the
|
||||||
|
* players attribute of Game class.
|
||||||
|
*
|
||||||
|
* @param message as the message which will be sent to all players as a ServerMessage.
|
||||||
|
*/
|
||||||
|
public void broadcast(ServerMessage message) {
|
||||||
|
for (Map.Entry<Integer, Player> entry: this.logic.getGame().getPlayers().entrySet()) {
|
||||||
|
this.send(entry.getKey(), message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO:
|
||||||
|
@Override
|
||||||
|
public void messageReceived(HostedConnection source, Message m) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package pp.mdga.client.server;
|
||||||
|
|
||||||
|
import pp.mdga.message.client.ClientInterpreter;
|
||||||
|
import pp.mdga.message.client.ClientMessage;
|
||||||
|
|
||||||
|
public record ReceivedMessage(ClientMessage msg, int from) {
|
||||||
|
void process(ClientInterpreter interpreter) {
|
||||||
|
msg.accept(interpreter, from);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,7 +9,6 @@
|
|||||||
import pp.mdga.client.button.ButtonLeft;
|
import pp.mdga.client.button.ButtonLeft;
|
||||||
import pp.mdga.client.button.ButtonRight;
|
import pp.mdga.client.button.ButtonRight;
|
||||||
import pp.mdga.client.button.CeremonyButton;
|
import pp.mdga.client.button.CeremonyButton;
|
||||||
import pp.mdga.client.button.LobbyButton;
|
|
||||||
import pp.mdga.client.dialog.CeremonyDialog;
|
import pp.mdga.client.dialog.CeremonyDialog;
|
||||||
import pp.mdga.game.Color;
|
import pp.mdga.game.Color;
|
||||||
|
|
||||||
@@ -68,6 +67,8 @@ public void onLeave() {
|
|||||||
ceremonyButtons.clear();
|
ceremonyButtons.clear();
|
||||||
|
|
||||||
rootNode.removeLight(ambient);
|
rootNode.removeLight(ambient);
|
||||||
|
|
||||||
|
ceremonyDialog.prepare();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -132,7 +133,7 @@ public void forward() {
|
|||||||
enterSub(SubState.STATISTICS);
|
enterSub(SubState.STATISTICS);
|
||||||
break;
|
break;
|
||||||
case STATISTICS:
|
case STATISTICS:
|
||||||
app.getModelSyncronizer().enter(MdgaState.MAIN);
|
app.getModelSynchronize().enter(MdgaState.MAIN);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,16 +45,16 @@ public class GameView extends MdgaView {
|
|||||||
public GameView(MdgaApp app) {
|
public GameView(MdgaApp app) {
|
||||||
super(app);
|
super(app);
|
||||||
|
|
||||||
cheatButton = new ButtonRight(app, settingsNode, () -> app.getModelSyncronizer().enter(MdgaState.CEREMONY), "CHEAT", 1);
|
cheatButton = new ButtonRight(app, settingsNode, () -> app.getModelSynchronize().enter(MdgaState.CEREMONY), "CHEAT", 1);
|
||||||
leaveButton = new ButtonLeft(app, settingsNode, () -> app.getModelSyncronizer().leave(), "Spiel verlassen", 1);
|
|
||||||
|
|
||||||
confirmButton = new ButtonRight(app, guiNode, () -> app.getModelSyncronizer().confirm(), "Bestätigen", 1);
|
leaveButton = new ButtonLeft(app, settingsNode, () -> app.getModelSynchronize().leave(), "Spiel verlassen", 1);
|
||||||
|
confirmButton = new ButtonRight(app, settingsNode, () -> app.getModelSynchronize().confirm(), "Bestätigen", 1);
|
||||||
|
|
||||||
fpp = new FilterPostProcessor(app.getAssetManager());
|
fpp = new FilterPostProcessor(app.getAssetManager());
|
||||||
this.camera = new CameraHandler(app, fpp);
|
this.camera = new CameraHandler(app, fpp);
|
||||||
this.boardHandler = new BoardHandler(app, rootNode, fpp);
|
this.boardHandler = new BoardHandler(app, rootNode, fpp);
|
||||||
|
|
||||||
guiHandler = new GuiHandler(app, guiNode);
|
guiHandler = new GuiHandler(app, guiNode, ownColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -79,7 +79,7 @@ public void onLeave() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUpdate(float tpf) {
|
public void onUpdate(float tpf) {
|
||||||
camera.update(app.getInputSyncronizer().getScroll(), app.getInputSyncronizer().getRotation());
|
camera.update(app.getInputSynchronize().getScroll(), app.getInputSynchronize().getRotation());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -99,7 +99,7 @@ protected void onLeaveOverlay(Overlay overlay) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void leaveGame() {
|
private void leaveGame() {
|
||||||
app.getModelSyncronizer().leave();
|
app.getModelSynchronize().leave();
|
||||||
}
|
}
|
||||||
|
|
||||||
public BoardHandler getBoardHandler() {
|
public BoardHandler getBoardHandler() {
|
||||||
|
|||||||
@@ -179,10 +179,10 @@ private void toggleTsk(Color color) {
|
|||||||
|
|
||||||
switch (taken) {
|
switch (taken) {
|
||||||
case NOT:
|
case NOT:
|
||||||
app.getModelSyncronizer().selectTsk(color);
|
app.getModelSynchronize().selectTsk(color);
|
||||||
break;
|
break;
|
||||||
case SELF:
|
case SELF:
|
||||||
app.getModelSyncronizer().unselectTsk();
|
app.getModelSynchronize().unselectTsk();
|
||||||
break;
|
break;
|
||||||
case OTHER:
|
case OTHER:
|
||||||
//nothing
|
//nothing
|
||||||
@@ -191,11 +191,11 @@ private void toggleTsk(Color color) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void ready() {
|
private void ready() {
|
||||||
app.getModelSyncronizer().setReady();
|
app.getModelSynchronize().setReady();
|
||||||
app.getAcousticHandler().playSound(MdgaSound.SELF_READY);
|
app.getAcousticHandler().playSound(MdgaSound.SELF_READY);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void leaveLobby() {
|
private void leaveLobby() {
|
||||||
app.getModelSyncronizer().leave();
|
app.getModelSynchronize().leave();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,11 +2,7 @@
|
|||||||
|
|
||||||
import com.jme3.scene.Geometry;
|
import com.jme3.scene.Geometry;
|
||||||
import pp.mdga.client.MdgaApp;
|
import pp.mdga.client.MdgaApp;
|
||||||
import pp.mdga.client.MdgaState;
|
|
||||||
import pp.mdga.client.acoustic.MdgaSound;
|
import pp.mdga.client.acoustic.MdgaSound;
|
||||||
import pp.mdga.client.button.ButtonRight;
|
|
||||||
import pp.mdga.client.button.MenuButton;
|
|
||||||
import pp.mdga.client.button.SettingsButton;
|
|
||||||
import pp.mdga.client.dialog.HostDialog;
|
import pp.mdga.client.dialog.HostDialog;
|
||||||
import pp.mdga.client.dialog.JoinDialog;
|
import pp.mdga.client.dialog.JoinDialog;
|
||||||
import pp.mdga.client.dialog.StartDialog;
|
import pp.mdga.client.dialog.StartDialog;
|
||||||
@@ -98,8 +94,8 @@ private void tryHost() {
|
|||||||
port = Integer.parseInt(text);
|
port = Integer.parseInt(text);
|
||||||
|
|
||||||
if(port >= 1 && port <= 65535) {
|
if(port >= 1 && port <= 65535) {
|
||||||
app.getModelSyncronizer().setName(startDialog.getName());
|
app.getModelSynchronize().setName(startDialog.getName());
|
||||||
app.getModelSyncronizer().setHost(port);
|
app.getModelSynchronize().setHost(port);
|
||||||
//app.getAcousticHandler().playSound(MdgaSound.WRONG_INPUT);
|
//app.getAcousticHandler().playSound(MdgaSound.WRONG_INPUT);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -125,8 +121,8 @@ private void tryJoin() {
|
|||||||
|
|
||||||
// Validate the IP address
|
// Validate the IP address
|
||||||
if (isValidIpAddress(ip)) {
|
if (isValidIpAddress(ip)) {
|
||||||
app.getModelSyncronizer().setName(startDialog.getName());
|
app.getModelSynchronize().setName(startDialog.getName());
|
||||||
app.getModelSyncronizer().setJoin(ip, port);
|
app.getModelSynchronize().setJoin(ip, port);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
|
|||||||
BIN
Projekte/mdga/client/src/main/resources/Images/sky/sky.dds
Normal file
BIN
Projekte/mdga/client/src/main/resources/Images/sky/sky.dds
Normal file
Binary file not shown.
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class Animation extends ClientState {
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class AudioSettings extends ClientState {
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class Ceremony extends ClientState {
|
|
||||||
private final CeremonyStateMachine ceremonyStateMachine = new CeremonyStateMachine();
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class CeremonyStateMachine extends ClientStateMachine {
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class ChoosePiece extends ClientState {
|
|
||||||
private final ChoosePieceStateMachine choosePieceStateMachine = new ChoosePieceStateMachine();
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class ChoosePieceStateMachine extends ClientStateMachine{
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class ChoosePowerCard extends ClientState {
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class ClientAutomaton extends ClientStateMachine {
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class ClientGameLogic {
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public abstract class ClientState {
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public abstract class ClientStateMachine extends ClientState {
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class DetermineStartPlayer extends ClientState {
|
|
||||||
private final DetermineStartPlayerStateMachine determineStartPlayerStateMachine = new DetermineStartPlayerStateMachine();
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class DetermineStartPlayerStateMachine extends ClientStateMachine{
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class Dialogs extends ClientState {
|
|
||||||
private final DialogsStateMachine dialogsStateMachine = new DialogsStateMachine();
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class DialogsStateMachine extends ClientStateMachine {
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class GameState extends ClientState {
|
|
||||||
private final GameStateMachine gameStateMachine = new GameStateMachine();
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class GameStateMachine extends ClientStateMachine {
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class Interrupt extends ClientState {
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class Lobby extends ClientState {
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class MainSettings extends ClientState {
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class MovePiece extends ClientState {
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class NetworkDialog extends ClientState {
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class NoPiece extends ClientState {
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class PlayPowerCard extends ClientState {
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class Podium extends ClientState {
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class PowerCard extends ClientState {
|
|
||||||
private final PowerCardStateMachine powerCardStateMachine = new PowerCardStateMachine();
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class PowerCardStateMachine extends ClientStateMachine {
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class RollDice extends ClientState {
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class RollRankingDice extends ClientState {
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class SelectPiece extends ClientState {
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class Settings extends ClientState {
|
|
||||||
private final SettingsStateMachine settingsStateMachine = new SettingsStateMachine();
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class SettingsStateMachine extends ClientStateMachine {
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class Shield extends ClientState {
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class Spectator extends ClientState {
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class StartDialog extends ClientState {
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class StartPiece extends ClientState {
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class Statistics extends ClientState {
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class Swap extends ClientState {
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class Turn extends ClientState {
|
|
||||||
private final TurnStateMachine turnStateMachine = new TurnStateMachine();
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class TurnStateMachine extends ClientStateMachine {
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class VideoSettings extends ClientState {
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class WaitRanking extends ClientState {
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class Waiting extends ClientState {
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package pp.mdga.client;
|
|
||||||
|
|
||||||
public class WaitingPiece extends ClientState {
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
package pp.mdga.game;
|
|
||||||
|
|
||||||
public enum Color {
|
|
||||||
ARMY,
|
|
||||||
NAVY,
|
|
||||||
CYBER,
|
|
||||||
AIRFORCE
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package pp.mdga.message.client;
|
|
||||||
|
|
||||||
public class AnimationEnd extends ClientMessage {
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "null";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void accept(ClientInterpreter interpreter, int from) {
|
|
||||||
interpreter.received(this, from);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
package pp.mdga.message.client;
|
|
||||||
|
|
||||||
public interface ClientInterpreter {
|
|
||||||
void received(AnimationEnd animationEnd, int from);
|
|
||||||
|
|
||||||
void received(DeselectTSK deselectTSK , int from);
|
|
||||||
|
|
||||||
void received(ForceStartGame forceStartGame, int from);
|
|
||||||
|
|
||||||
void received(JoinServer joinServer , int from);
|
|
||||||
|
|
||||||
void received(LeaveGame leaveGame , int from);
|
|
||||||
|
|
||||||
void received(LobbyNotReady lobbyNotReady , int from);
|
|
||||||
|
|
||||||
void received(LobbyReady lobbyReady , int from);
|
|
||||||
|
|
||||||
void received(RequestBriefing requestBriefing , int from);
|
|
||||||
|
|
||||||
void received(RequestDice requestDice , int from);
|
|
||||||
|
|
||||||
void received(RequestMove requestMove , int from);
|
|
||||||
|
|
||||||
void received(RequestPlayCard requestPlayCard , int from);
|
|
||||||
|
|
||||||
void received(SelectCard selectCard , int from);
|
|
||||||
|
|
||||||
void received(SelectTSK selectTSK , int from);
|
|
||||||
|
|
||||||
void received(ForceContinueGame forceContinueGame, int from);
|
|
||||||
|
|
||||||
void received(ClientStartGame clientStartGame, int from);
|
|
||||||
|
|
||||||
void received(NoPowerCard noPowerCard, int from);
|
|
||||||
|
|
||||||
void received(SelectedPieces selectedPieces, int from);
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
package pp.mdga.message.client;
|
|
||||||
|
|
||||||
import com.jme3.network.AbstractMessage;
|
|
||||||
|
|
||||||
public abstract class ClientMessage extends AbstractMessage {
|
|
||||||
protected ClientMessage() {
|
|
||||||
super(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract void accept(ClientInterpreter interpreter, int from);
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package pp.mdga.message.client;
|
|
||||||
|
|
||||||
public class ClientStartGame extends ClientMessage {
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "null";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void accept(ClientInterpreter interpreter, int from) {
|
|
||||||
interpreter.received(this, from);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package pp.mdga.message.client;
|
|
||||||
|
|
||||||
public class DeselectTSK extends ClientMessage {
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "null";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void accept(ClientInterpreter interpreter, int from) {
|
|
||||||
interpreter.received(this, from);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package pp.mdga.message.client;
|
|
||||||
|
|
||||||
public class ForceContinueGame extends ClientMessage {
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "null";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void accept(ClientInterpreter interpreter, int from) {
|
|
||||||
interpreter.received(this, from);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
package pp.mdga.message.client;
|
|
||||||
|
|
||||||
public class ForceStartGame extends ClientMessage {
|
|
||||||
public ForceStartGame() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "null";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void accept(ClientInterpreter interpreter, int from) {
|
|
||||||
interpreter.received(this, from);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package pp.mdga.message.client;
|
|
||||||
|
|
||||||
public class JoinServer extends ClientMessage {
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "null";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void accept(ClientInterpreter interpreter, int from) {
|
|
||||||
interpreter.received(this, from);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package pp.mdga.message.client;
|
|
||||||
|
|
||||||
public class LeaveGame extends ClientMessage {
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "null";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void accept(ClientInterpreter interpreter, int from) {
|
|
||||||
interpreter.received(this, from);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package pp.mdga.message.client;
|
|
||||||
|
|
||||||
public class LobbyNotReady extends ClientMessage {
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "null";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void accept(ClientInterpreter interpreter, int from) {
|
|
||||||
interpreter.received(this, from);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package pp.mdga.message.client;
|
|
||||||
|
|
||||||
public class LobbyReady extends ClientMessage {
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "null";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void accept(ClientInterpreter interpreter, int from) {
|
|
||||||
interpreter.received(this, from);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package pp.mdga.message.client;
|
|
||||||
|
|
||||||
public class NoPowerCard extends ClientMessage {
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "null";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void accept(ClientInterpreter interpreter, int from) {
|
|
||||||
interpreter.received(this, from);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package pp.mdga.message.client;
|
|
||||||
|
|
||||||
public class RequestBriefing extends ClientMessage {
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "null";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void accept(ClientInterpreter interpreter, int from) {
|
|
||||||
interpreter.received(this, from);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package pp.mdga.message.client;
|
|
||||||
|
|
||||||
public class RequestDice extends ClientMessage {
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "null";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void accept(ClientInterpreter interpreter, int from) {
|
|
||||||
interpreter.received(this, from);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
package pp.mdga.message.client;
|
|
||||||
|
|
||||||
import pp.mdga.game.Color;
|
|
||||||
|
|
||||||
public class RequestMove extends ClientMessage {
|
|
||||||
|
|
||||||
private final String pieceIdentifier;
|
|
||||||
|
|
||||||
/** Constructor for RequestMove
|
|
||||||
* @param pieceIdentifier the piece identifier
|
|
||||||
*/
|
|
||||||
public RequestMove(String pieceIdentifier) {
|
|
||||||
this.pieceIdentifier = pieceIdentifier;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Getter for the piece identifier
|
|
||||||
* @return the piece identifier
|
|
||||||
*/
|
|
||||||
public String getPieceIdentifier() {
|
|
||||||
return pieceIdentifier;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return pieceIdentifier;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void accept(ClientInterpreter interpreter, int from) {
|
|
||||||
interpreter.received(this, from);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
package pp.mdga.message.client;
|
|
||||||
|
|
||||||
import pp.mdga.game.BonusCard;
|
|
||||||
|
|
||||||
public class RequestPlayCard extends ClientMessage {
|
|
||||||
|
|
||||||
private final BonusCard card;
|
|
||||||
private final String pieceIdentifier;
|
|
||||||
|
|
||||||
public RequestPlayCard(BonusCard card, String pieceIdentifier) {
|
|
||||||
this.pieceIdentifier = pieceIdentifier;
|
|
||||||
this.card = card;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BonusCard getCard() {
|
|
||||||
return card;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPieceIdentifier() {
|
|
||||||
return pieceIdentifier;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return card.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void accept(ClientInterpreter interpreter, int from) {
|
|
||||||
interpreter.received(this, from);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
package pp.mdga.message.client;
|
|
||||||
|
|
||||||
import pp.mdga.game.BonusCard;
|
|
||||||
|
|
||||||
public class SelectCard extends ClientMessage {
|
|
||||||
|
|
||||||
private final BonusCard card;
|
|
||||||
|
|
||||||
public SelectCard(BonusCard card) {
|
|
||||||
this.card = card;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BonusCard getCard() {
|
|
||||||
return card;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "null";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void accept(ClientInterpreter interpreter, int from) {
|
|
||||||
interpreter.received(this, from);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
package pp.mdga.message.client;
|
|
||||||
|
|
||||||
import pp.mdga.game.Color;
|
|
||||||
|
|
||||||
public class SelectTSK extends ClientMessage {
|
|
||||||
|
|
||||||
private final Color color;
|
|
||||||
|
|
||||||
public SelectTSK(Color color) {
|
|
||||||
this.color = color;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Color getColor() {
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "null";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void accept(ClientInterpreter interpreter, int from) {
|
|
||||||
interpreter.received(this, from);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
package pp.mdga.message.client;
|
|
||||||
|
|
||||||
import pp.mdga.game.Color;
|
|
||||||
|
|
||||||
public class SelectedPieces extends ClientMessage {
|
|
||||||
|
|
||||||
private String pieceIdentifier;
|
|
||||||
|
|
||||||
/** Constructor for SelectedPieces
|
|
||||||
* @param pieceIdentifier the piece identifier
|
|
||||||
*/
|
|
||||||
public SelectedPieces(String pieceIdentifier) {
|
|
||||||
this.pieceIdentifier = pieceIdentifier;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Getter for the piece identifier
|
|
||||||
* @return the piece identifier
|
|
||||||
*/
|
|
||||||
public String getPieceIdentifier() {
|
|
||||||
return pieceIdentifier;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "null";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void accept(ClientInterpreter interpreter, int from) {
|
|
||||||
interpreter.received(this, from);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
package pp.mdga.message.server;
|
|
||||||
|
|
||||||
import pp.mdga.game.Color;
|
|
||||||
|
|
||||||
public class ActivePlayer extends ServerMessage {
|
|
||||||
|
|
||||||
private Color color;
|
|
||||||
|
|
||||||
/** Constructor for ActivePlayer
|
|
||||||
* @param color the color of the active player
|
|
||||||
*/
|
|
||||||
public ActivePlayer(Color color) {
|
|
||||||
this.color = color;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Getter for the color of the active player
|
|
||||||
* @return the color of the active player
|
|
||||||
*/
|
|
||||||
public Color getColor() {
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void accept(ServerInterpreter interpreter) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getInfoTextKey() {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
package pp.mdga.message.server;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
public class AnyPiece extends ServerMessage {
|
|
||||||
|
|
||||||
private ArrayList<String> piece;
|
|
||||||
|
|
||||||
/** Constructor for AnyPiece
|
|
||||||
*/
|
|
||||||
public AnyPiece() {
|
|
||||||
piece = new ArrayList<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Add a piece to the list of pieces
|
|
||||||
* @param piece the piece to add
|
|
||||||
*/
|
|
||||||
public void addPiece(String piece) {
|
|
||||||
this.piece.add(piece);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Getter for the list of pieces
|
|
||||||
* @return the list of pieces
|
|
||||||
*/
|
|
||||||
public ArrayList<String> getPiece() {
|
|
||||||
return piece;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void accept(ServerInterpreter interpreter) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getInfoTextKey() {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package pp.mdga.message.server;
|
|
||||||
|
|
||||||
public class Briefing extends ServerMessage {
|
|
||||||
@Override
|
|
||||||
public void accept(ServerInterpreter interpreter) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getInfoTextKey() {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package pp.mdga.message.server;
|
|
||||||
|
|
||||||
public class Ceremony extends ServerMessage {
|
|
||||||
@Override
|
|
||||||
public void accept(ServerInterpreter interpreter) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getInfoTextKey() {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
package pp.mdga.message.server;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
public class Dice extends ServerMessage {
|
|
||||||
|
|
||||||
private final int diceEye;
|
|
||||||
private final ArrayList<String> moveablePieces;
|
|
||||||
|
|
||||||
/** Constructor for Dice
|
|
||||||
* @param diceEye the eye of the dice
|
|
||||||
* @param moveablePieces the pieces that can be moved
|
|
||||||
*/
|
|
||||||
public Dice(int diceEye, ArrayList<String> moveablePieces) {
|
|
||||||
this.diceEye = diceEye;
|
|
||||||
this.moveablePieces = moveablePieces;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Constructor for inactivePlayer
|
|
||||||
* @param diceEye the eye of the dice
|
|
||||||
* @return a new Dice object
|
|
||||||
*/
|
|
||||||
public static Dice inactivePlayer(int diceEye) {
|
|
||||||
return new Dice(diceEye, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Constructor for activePlayer
|
|
||||||
* @param diceEye the eye of the dice
|
|
||||||
* @param moveablePieces the pieces that can be moved
|
|
||||||
* @return a new Dice object
|
|
||||||
*/
|
|
||||||
public static Dice activePlayer(int diceEye, ArrayList<String> moveablePieces) {
|
|
||||||
return new Dice(diceEye, moveablePieces);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Getter for the eye of the dice
|
|
||||||
* @return the eye of the dice
|
|
||||||
*/
|
|
||||||
public int getDiceEye() {
|
|
||||||
return diceEye;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Getter for the pieces that can be moved
|
|
||||||
* @return the pieces that can be moved
|
|
||||||
*/
|
|
||||||
public ArrayList<String> getMoveablePieces() {
|
|
||||||
return moveablePieces;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void accept(ServerInterpreter interpreter) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getInfoTextKey() {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package pp.mdga.message.server;
|
|
||||||
|
|
||||||
public class DiceAgain extends ServerMessage {
|
|
||||||
@Override
|
|
||||||
public void accept(ServerInterpreter interpreter) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getInfoTextKey() {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package pp.mdga.message.server;
|
|
||||||
|
|
||||||
public class DiceNow extends ServerMessage {
|
|
||||||
@Override
|
|
||||||
public void accept(ServerInterpreter interpreter) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getInfoTextKey() {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package pp.mdga.message.server;
|
|
||||||
|
|
||||||
public class EndOfTurn extends ServerMessage {
|
|
||||||
@Override
|
|
||||||
public void accept(ServerInterpreter interpreter) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getInfoTextKey() {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package pp.mdga.message.server;
|
|
||||||
|
|
||||||
public class LobbyAccept extends ServerMessage {
|
|
||||||
@Override
|
|
||||||
public void accept(ServerInterpreter interpreter) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getInfoTextKey() {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package pp.mdga.message.server;
|
|
||||||
|
|
||||||
public class LobbyDeny extends ServerMessage {
|
|
||||||
@Override
|
|
||||||
public void accept(ServerInterpreter interpreter) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getInfoTextKey() {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
package pp.mdga.message.server;
|
|
||||||
|
|
||||||
public class LobbyPlayerJoin extends ServerMessage {
|
|
||||||
|
|
||||||
private final String name;
|
|
||||||
|
|
||||||
public LobbyPlayerJoin(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void accept(ServerInterpreter interpreter) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getInfoTextKey() {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
package pp.mdga.message.server;
|
|
||||||
|
|
||||||
import pp.mdga.game.Color;
|
|
||||||
|
|
||||||
public class LobbyPlayerLeave extends ServerMessage {
|
|
||||||
|
|
||||||
private final String name;
|
|
||||||
private final Color color;
|
|
||||||
|
|
||||||
public LobbyPlayerLeave(String name, Color color) {
|
|
||||||
this.name = name;
|
|
||||||
this.color = color;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Color getColor() {
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void accept(ServerInterpreter interpreter) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getInfoTextKey() {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
package pp.mdga.message.server;
|
|
||||||
|
|
||||||
public class MoveMessage extends ServerMessage {
|
|
||||||
|
|
||||||
private final String pieceIdentifier;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param identifier the identifier of the piece that should be moved
|
|
||||||
*/
|
|
||||||
public MoveMessage(String identifier) {
|
|
||||||
this.pieceIdentifier = identifier;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the identifier of the piece that should be moved
|
|
||||||
*/
|
|
||||||
public String getIdentifier() {
|
|
||||||
return pieceIdentifier;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the identifier of the piece that should be moved
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void accept(ServerInterpreter interpreter) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getInfoTextKey() {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user