Merge dev/client

This commit is contained in:
Felix Koppe
2024-11-30 14:03:54 +01:00
316 changed files with 10192 additions and 3467 deletions

View 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

View File

@@ -75,7 +75,7 @@ public void onAction(String name, boolean isPressed, float tpf) {
}
if(name.equals("Click") && isPressed) {
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);
if(cardLayerSelect != null) {
@@ -100,9 +100,6 @@ else if(boardSelect != null) {
}
if(name.equals("Test") &&isPressed){
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();
Ray ray = new Ray(cam.getLocation(), getMousePos(cam).subtract(cam.getLocation()).normalize());
root.collideWith(ray, results);
if (results.size() > 0) {
return results.getClosestCollision().getGeometry().getControl(controlType);
for(CollisionResult collisionResult : results){
if(collisionResult.getGeometry().getControl(controlType) != null) return collisionResult.getGeometry().getControl(controlType);
}
return null;
}
@@ -188,7 +185,7 @@ private PieceControl checkPiece(){
}
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(){

View File

@@ -12,7 +12,7 @@ public class MdgaApp extends SimpleApplication {
private AcousticHandler acousticHandler;
private NotificationSynchronizer notificationSynchronizer;
private InputSynchronizer inputSynchronizer;
private ModelSyncronizer modelSyncronizer;
private ModelSynchronizer modelSynchronizer;
MdgaView view = null;
private MdgaState state = null;
@@ -50,7 +50,7 @@ public void simpleInitApp() {
acousticHandler = new AcousticHandler(this);
notificationSynchronizer = new NotificationSynchronizer(this);
inputSynchronizer = new InputSynchronizer(this);
modelSyncronizer = new ModelSyncronizer(this);
modelSynchronizer = new ModelSynchronizer(this);
mainView = new MainView(this);
lobbyView = new LobbyView(this);
@@ -114,11 +114,11 @@ public MdgaView getView() {
return view;
}
public ModelSyncronizer getModelSyncronizer() {
return modelSyncronizer;
public ModelSynchronizer getModelSynchronize() {
return modelSynchronizer;
}
public InputSynchronizer getInputSyncronizer() { return inputSynchronizer; }
public InputSynchronizer getInputSynchronize() { return inputSynchronizer; }
public NotificationSynchronizer getNotificationSynchronizer() { return notificationSynchronizer; }
}

View File

@@ -14,15 +14,15 @@
import java.util.logging.Level;
import java.util.logging.Logger;
public class ModelSyncronizer {
private static final Logger LOGGER = Logger.getLogger(ModelSyncronizer.class.getName());
public class ModelSynchronizer {
private static final Logger LOGGER = Logger.getLogger(ModelSynchronizer.class.getName());
private MdgaApp app;
private UUID a;
private UUID b;
private BonusCard card;
ModelSyncronizer(MdgaApp app) {
ModelSynchronizer(MdgaApp app) {
this.app = app;
}
@@ -31,6 +31,7 @@ public void animationEnd() {
}
public void selectSwap(UUID a, UUID b) {
// TODO call from somewhere
LOGGER.log(Level.INFO, "selectPiece");
this.a = a;
this.b = b;
@@ -44,6 +45,7 @@ public void selectSwap(UUID a, UUID b) {
}
public void selectPiece(UUID piece) {
// TODO call from somewhere
LOGGER.log(Level.INFO, "selectPiece");
this.a = piece;
@@ -57,6 +59,7 @@ public void selectPiece(UUID piece) {
}
public void selectCard(BonusCard card) {
// TODO call from somewhere
LOGGER.log(Level.INFO, "selectCard");
this.card = card;
@@ -91,20 +94,24 @@ public void confirm() {
}
public void selectTsk(Color color) {
// TODO call from somewhere
LOGGER.log(Level.INFO, "selectTsk: {0}", color);
LobbyView view = (LobbyView) app.getView();
view.setTaken(color, true, true, "OwnPlayerName");
}
public void unselectTsk() {
// TODO call from somewhere
LOGGER.log(Level.INFO, "unselectTsk");
}
public void rolledDice() {
// TODO call from somewhere
LOGGER.log(Level.INFO, "rolledDice");
}
public void setName(String name) {
// TODO call from somewhere
LOGGER.log(Level.INFO, "setName: {0}", name);
}
@@ -114,11 +121,13 @@ public void setReady() {
}
public void setHost(int port) {
// TODO call from somewhere
LOGGER.log(Level.INFO, "setHost: {0}", port);
enter(MdgaState.LOBBY);
}
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});
enter(MdgaState.LOBBY);
}

View File

@@ -57,10 +57,11 @@ private void handleMain(Notification notification) {
private void handleLobby(Notification notification) {
LobbyView lobbyView = (LobbyView) app.getView();
if (notification instanceof TskSelectNotification tskSelectNotification) {
lobbyView.setTaken(tskSelectNotification.getColor(), true, tskSelectNotification.isSelf(), tskSelectNotification.getName());
} else if (notification instanceof TskUnselectNotification tskUnselectNotification) {
lobbyView.setTaken(tskUnselectNotification.getColor(), false, false, null);
if (notification instanceof TskSelectNotification n) {
//lobbyView.setTaken(n.getColor(), true, n.isSelf(), n.getName());
lobbyView.setTaken(n.getColor(), true, true, n.getName());
} else if (notification instanceof TskUnselectNotification n) {
lobbyView.setTaken(n.getColor(), false, false, null);
//} else if(notification instanceof LobbyReadyNotification lobbyReadyNotification) {
// lobbyView.setReady(lobbyReadyNotification.getColor(), lobbyReadyNotification.isReady()):
} else if (notification instanceof GameNotification) {
@@ -75,12 +76,12 @@ private void handleGame(Notification notification) {
GuiHandler guiHandler = gameView.getGuiHandler();
BoardHandler boardHandler = gameView.getBoardHandler();
if (notification instanceof AcquireCardNotification n) {
guiHandler.addCard(n.getBonusCard(), n.getCardId());
if (notification instanceof AcquireCardNotification) {
// Handle AcquireCardNotification
} else if (notification instanceof ActivePlayerNotification n) {
gameView.getGuiHandler().setActivePlayer(n.getColor());
} else if (notification instanceof CeremonyNotification ceremonyNotification) {
app.enter(MdgaState.CEREMONY);
/*app.enter(MdgaState.CEREMONY);
CeremonyView ceremonyView = (CeremonyView) app.getView();
int size = ceremonyNotification.getNames().size();
@@ -105,17 +106,18 @@ private void handleGame(Notification notification) {
ceremonyView.addCeremonyParticipant(color, i, name);
ceremonyView.addStatisticsRow(name, v1, v2, v3, v4, v5, v6);
}
}*/
} else if (notification instanceof DiceNowNotification) {
guiHandler.showDice();
} else if (notification instanceof DicingNotification n) {
//TODO
} else if (notification instanceof DrawCardNotification n) {
//TODO ???
} else if (notification instanceof DrawCardNotification n) {
guiHandler.drawCard(n.getColor());
} else if (notification instanceof HomeMoveNotification home) {
boardHandler.moveHomePiece(home.getPieceId(), home.getHomeIndex());
guiHandler.hideText();
} else if (notification instanceof InterruptNotification) {
//TODO
//TODO ???
} else if (notification instanceof MovePieceNotification n) {
if(n.isMoveStart()) {
//StartMove
@@ -138,11 +140,17 @@ private void handleGame(Notification notification) {
}
} else if (notification instanceof PlayerInGameNotification n) {
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) {
//TODO
} else if (notification instanceof RollDiceNotification n) {
guiHandler.rollDice(n.getEyes());
//TODO multiplicator
if(n.getColor() == gameView.getOwnColor()){
//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) {
guiHandler.setSelectableCards(n.getCards());
} else if (notification instanceof ShieldActiveNotification n) {
@@ -153,12 +161,17 @@ private void handleGame(Notification notification) {
app.enter(MdgaState.MAIN);
} else if (notification instanceof SwapPieceNotification n) {
boardHandler.swapPieces(n.getFirstPiece(), n.getSecondPiece());
guiHandler.swap();
} else if (notification instanceof WaitMoveNotification) {
//TODO disable all hover, highlight, etc
//TODO ???
} else if (notification instanceof SelectableMoveNotification n) {
boardHandler.outlineMove(n.getPieces(), n.getMoveIndexe(), n.getHomeMoves());
} else if (notification instanceof SelectableSwapNotification n) {
boardHandler.outlineSwap(n.getOwnPieces(), n.getEnemyPieces());
// } //else if (notification instanceof SelectableShieldNotification n) {
// boardHandler.outlineShield(n.getOwnPieces());
//} else if (notification instanceof TurboActiveNotification){
// guiHandler.turbo();
} else {
throw new RuntimeException("notification not expected: " + notification.toString());
}

View File

@@ -21,9 +21,6 @@ public class BoardHandler {
private final MdgaApp app;
private final PileControl drawPile = null;
private final PileControl discardPile = null;
private ArrayList<NodeControl> infield;
private Map<UUID, PieceControl> pieces;
@@ -32,32 +29,46 @@ public class BoardHandler {
private Map<Color, List<NodeControl>> waitingNodesMap;
private Map<Color, List<PieceControl>> waitingPiecesMap;
private Map<UUID, Color> pieceColor;
private Set<OutlineControl> outlineControls;
private Node node = new Node();
private Node rootNode;
private final Node rootNode;
private FilterPostProcessor fpp;
private final FilterPostProcessor fpp;
private boolean isInitialised;
private List<PieceControl> selectableOwnPieces = new ArrayList<>();
private List<PieceControl> selectableEnemyPieces = new ArrayList<>();
private List<PieceControl> selectableOwnPieces;
private List<PieceControl> selectableEnemyPieces;
private List<NodeControl> outlineNodes;
private PieceControl selectedOwnPiece;
private PieceControl selectedEnemyPiece;
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");
this.isInitialised = false;
this.app = app;
this.rootNode = node3d;
this.fpp = fpp;
selectedEnemyPiece = null;
selectedOwnPiece = null;
this.rootNode = rootNode;
isInitialised = false;
}
public void init() {
isInitialised = true;
selectableOwnPieces = new ArrayList<>();
selectableEnemyPieces = new ArrayList<>();
outlineNodes = new ArrayList<>();
selectedOwnPiece = null;
selectedEnemyPiece = null;
initMap();
rootNode.attachChild(node);
}
public void shutdown(){
clearSelectable();
isInitialised = false;
initMap();
rootNode.detachChild(node);
}
private void addFigureToPlayerMap(Color col, AssetOnMap assetOnMap) {
@@ -66,21 +77,16 @@ private void addFigureToPlayerMap(Color col, AssetOnMap assetOnMap) {
}
private void initMap() {
this.node = new Node("Asset Node");
this.pieces = new HashMap<>();
this.colorAssetsMap = new HashMap<>();
this.infield = new ArrayList<>(40);
this.homeNodesMap = new HashMap<>();
this.waitingNodesMap = new HashMap<>();
this.waitingPiecesMap = new HashMap<>();
this.pieceColor = new HashMap<>();
this.outlineControls = new HashSet<>();
// Initialize dice
pieces = new HashMap<>();
colorAssetsMap = new HashMap<>();
infield = new ArrayList<>(40);
homeNodesMap = new HashMap<>();
waitingNodesMap = new HashMap<>();
waitingPiecesMap = new HashMap<>();
pieceColor = new HashMap<>();
diceControl = new DiceControl(app.getAssetManager());
diceControl.create(new Vector3f(0,0,0), 0.7f, true);
// Load assets and populate the node
List<AssetOnMap> assetOnMaps = MapLoader.loadMap(MAP_NAME);
for (AssetOnMap assetOnMap : assetOnMaps) {
@@ -99,6 +105,7 @@ private void initMap() {
case node_wait_blue -> addHomeNode(waitingNodesMap, Color.NAVY, assetOnMap);
case node_wait_green -> addHomeNode(waitingNodesMap, Color.ARMY, assetOnMap);
case node_wait_yellow -> addHomeNode(waitingNodesMap, Color.CYBER, assetOnMap);
default -> displayAsset(assetOnMap);
}
}
@@ -117,20 +124,14 @@ private Color assetToColor(Asset asset) {
private Spatial createModel(Asset asset, Vector3f pos, float rot) {
String modelName = asset.getModelPath();
String texName = asset.getDiffPath();
// Load the model
Spatial model = app.getAssetManager().loadModel(modelName);
model.scale(asset.getSize());
model.rotate((float) Math.toRadians(0), 0, (float) Math.toRadians(rot));
model.setLocalTranslation(pos);
model.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
// Set material
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md");
mat.setTexture("DiffuseMap", app.getAssetManager().loadTexture(texName));
model.setMaterial(mat);
// Attach to the asset node
node.attachChild(model);
return model;
@@ -169,7 +170,7 @@ private float getRotationMove(Vector3f prev, Vector3f next) {
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;
curIndex = (curIndex + 1) % infield.size();
@@ -181,7 +182,7 @@ private void movePiece_rek(UUID uuid, int curIndex, int moveIndex){
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){
@@ -191,11 +192,10 @@ private <T, E> List<T> addItemToMapList(Map<E,List<T>> map, E key, T item){
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.remove(item);
map.put(key, list);
return list;
}
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){
if (!isInitialised) throw new RuntimeException("BoardHandler is not initialized");
movePiece_rek(uuid, curIndex, moveIndex);
movePieceRek(uuid, curIndex, moveIndex);
}
public void throwPiece(UUID uuid){
@@ -313,70 +313,25 @@ public void suppressShield(UUID uuid){
public void swapPieces(UUID piece1, UUID piece2){
if (!isInitialised) throw new RuntimeException("BoardHandler is not initialized");
PieceControl piece1_control = pieces.get(piece1);
PieceControl piece2_control = pieces.get(piece2);
PieceControl piece1Control = pieces.get(piece1);
PieceControl piece2Control = pieces.get(piece2);
if(piece1_control == null) throw new RuntimeException("piece1 UUID is not valid");
if(piece2_control == null) throw new RuntimeException("piece2 UUID is not valid");
if(piece1Control == null) throw new RuntimeException("piece1 UUID is not valid");
if(piece2Control == null) throw new RuntimeException("piece2 UUID is not valid");
float rot1 = piece1_control.getRotation();
float rot2 = piece2_control.getRotation();
float rot1 = piece1Control.getRotation();
float rot2 = piece2Control.getRotation();
piece1_control.setRotation(rot2);
piece2_control.setRotation(rot1);
piece1Control.setRotation(rot2);
piece2Control.setRotation(rot1);
Vector3f pos1 = piece1_control.getLocation().clone();
Vector3f pos2 = piece2_control.getLocation().clone();
Vector3f pos1 = piece1Control.getLocation().clone();
Vector3f pos2 = piece2Control.getLocation().clone();
piece1_control.setLocation(pos2);
piece2_control.setLocation(pos1);
piece1Control.setLocation(pos2);
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){
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
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");
@@ -424,6 +365,7 @@ public void outlineMove(List<UUID> pieces, List<Integer> moveIndexe, List<Boolea
pieceControl.highlight(false);
pieceControl.setHoverable(true);
pieceControl.setSelectable(true);
outlineNodes.add(nodeControl);
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
public void pieceSelect(PieceControl pieceSelected) {
boolean isSelected = pieceSelected.isSelected();
@@ -496,18 +453,16 @@ public void clearSelectable(){
p.unHighlight();
p.setSelectable(false);
}
for(NodeControl n : outlineNodes){
n.deOutline();
}
outlineNodes.clear();
selectableEnemyPieces.clear();
selectableOwnPieces.clear();
selectedEnemyPiece = null;
selectedOwnPiece = null;
}
public void deOutline(int index){
infield.get(index).deOutline();
outlineControls.remove(infield.get(index));
}
public void enableHover(UUID uuid){
pieces.get(uuid).setHoverable(true);
}
@@ -521,4 +476,6 @@ public void showDice(Color color){
public void hideDice(){
diceControl.hide();
}
}

View File

@@ -7,8 +7,11 @@
import com.jme3.math.Quaternion;
import com.jme3.math.Vector3f;
import com.jme3.post.FilterPostProcessor;
import com.jme3.scene.Spatial;
import com.jme3.shadow.DirectionalLightShadowFilter;
import com.jme3.shadow.EdgeFilteringMode;
import com.jme3.util.SkyFactory;
import com.jme3.util.SkyFactory.EnvMapType;
import pp.mdga.client.MdgaApp;
public class CameraHandler {
@@ -25,6 +28,8 @@ public class CameraHandler {
FilterPostProcessor fpp;
DirectionalLightShadowFilter dlsf;
Spatial sky;
public CameraHandler(MdgaApp app, FilterPostProcessor fpp) {
this.app = app;
this.fpp = fpp;
@@ -45,18 +50,24 @@ public CameraHandler(MdgaApp app, FilterPostProcessor fpp) {
dlsf.setEnabled(true);
dlsf.setEdgeFilteringMode(EdgeFilteringMode.PCFPOISSON);
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() {
app.getRootNode().addLight(sun);
app.getRootNode().addLight(ambient);
app.getRootNode().attachChild(sky);
fpp.addFilter(dlsf);
}
public void shutdown() {
app.getRootNode().removeLight(sun);
app.getRootNode().removeLight(ambient);
app.getRootNode().detachChild(sky);
// Reset the camera to its default state
app.getCamera().setLocation(defaultCameraPosition);
@@ -96,4 +107,5 @@ public void update(float scroll, float rotation) {
app.getCamera().lookAt(Vector3f.ZERO, Vector3f.UNIT_Z);
}
}

View File

@@ -1,18 +1,12 @@
package pp.mdga.client.board.Outline;
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.post.Filter;
import com.jme3.post.FilterPostProcessor;
import com.jme3.renderer.Camera;
import com.jme3.renderer.RenderManager;
import com.jme3.renderer.ViewPort;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import pp.mdga.game.Color;
public class SelectObjectOutliner {

View File

@@ -214,5 +214,6 @@ public void setTaken(Taken taken, String name) {
public void setReady(boolean isReady) {
this.isReady = isReady;
onUnHover();
}
}

View File

@@ -5,43 +5,20 @@
import com.jme3.scene.Node;
import pp.mdga.client.MdgaApp;
import pp.mdga.client.button.AbstractButton;
import pp.mdga.client.button.InputButton;
import pp.mdga.client.button.LabelButton;
import pp.mdga.client.button.MenuButton;
import pp.mdga.client.view.MainView;
import java.util.ArrayList;
public class CeremonyDialog extends Dialog {
private ArrayList<ArrayList<LabelButton>> labels;
float offsetX = 0.5f;
float offsetX;
public CeremonyDialog(MdgaApp app, Node node) {
super(app, node);
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);
prepare();
}
@Override
@@ -98,4 +75,31 @@ public void addStatisticsRow(String name, int v1, int v2, int v3, int v4, int v5
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);
}
}

View File

@@ -8,35 +8,35 @@
import com.jme3.scene.Node;
import com.jme3.system.AppSettings;
import pp.mdga.client.Asset;
import pp.mdga.game.Color;
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){
BitmapFont playerFont = assetManager.loadFont("Fonts/Gunplay.fnt");
root.setLocalTranslation(center(appSettings.getWidth(), appSettings.getHeight(), Vector3f.ZERO));
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 () {
node.attachChild(textWithSpacing);
}
private Node createTextWithSpacing(String[] textArr, float spacing, float size, ColorRGBA[] colorArr) {
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 center = new Node();
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);
@@ -44,18 +44,85 @@ private static Node createTextWithSpacing(BitmapFont font, String text, float sp
xOffset += letter.getLineWidth() + spacing;
}
}
center.setLocalTranslation(new Vector3f(-xOffset/2,0,0));
textNode.attachChild(center);
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){
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){
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();
}
}

View File

@@ -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;
}
}

View File

@@ -11,7 +11,6 @@
import com.jme3.scene.Spatial;
import com.jme3.scene.control.AbstractControl;
import pp.mdga.client.Asset;
import pp.mdga.message.server.Dice;
import java.util.Random;
@@ -23,7 +22,7 @@ public class DiceControl extends AbstractControl {
private final Vector3f angularVelocity = new Vector3f();
private float deceleration = 0.5f;
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_MAX = 15;
private static final int ANGULAR_SPIN = 10;
@@ -31,6 +30,7 @@ public class DiceControl extends AbstractControl {
private boolean slerp = false;
private boolean spin = false;
private final AssetManager assetManager;
private Runnable actionAfter;
public DiceControl(AssetManager assetManager){
this.assetManager = assetManager;
@@ -60,13 +60,14 @@ protected void controlUpdate(float tpf) {
if (timeElapsed > 1.0f) timeElapsed = 1.0f;
Quaternion interpolated = spatial.getLocalRotation().clone();
interpolated.nlerp(targetRotation, lerp(timeElapsed));
interpolated.slerp(targetRotation, timeElapsed);
spatial.setLocalRotation(interpolated);
// Stop rolling once duration is complete
if (timeElapsed >= 1.0f) {
isRolling = false;
slerp = false;
actionAfter.run();
}
}
}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;
spin = false;
slerp = false;
this.actionAfter = actionAfter;
angularVelocity.set(
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){
spatial.setLocalTranslation(pos);
}
}

View File

@@ -1,262 +1,130 @@
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.queue.RenderQueue;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import com.jme3.texture.FrameBuffer;
import com.jme3.texture.Image;
import com.jme3.texture.Texture2D;
import pp.mdga.client.Asset;
import pp.mdga.client.MdgaApp;
import pp.mdga.game.BonusCard;
import pp.mdga.game.Color;
import java.util.*;
import static com.jme3.material.Materials.UNSHADED;
import java.util.List;
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 CardLayer cardLayer;
private Map<UUID, BonusCard> uuidBonusCardMap;
private Map<BonusCard, CardControl> bonusCardControlMap;
private Map<BonusCard, Integer> bonusCardIntegerMap;
private FrameBuffer backFrameBuffer;
private static final Vector3f START = new Vector3f(-1.8f,-3.5f,0);
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) {
public GuiHandler(MdgaApp app, Node guiNode, Color ownColor) {
this.app = app;
this.fpp = new FilterPostProcessor(app.getAssetManager());
this.rootNode = node;
this.ownColor = ownColor;
cardLayerCamera = createOverlayCam();
uuidBonusCardMap = new HashMap<>();
bonusCardIntegerMap = new HashMap<>();
bonusCardControlMap = new HashMap<>();
}
public void init(){
FrameBuffer backFrameBuffer = new FrameBuffer(app.getCamera().getWidth(), app.getCamera().getHeight(), 1);
backFrameBuffer = new FrameBuffer(app.getCamera().getWidth(), app.getCamera().getHeight(), 1);
Texture2D backTexture = new Texture2D(app.getCamera().getWidth(), app.getCamera().getHeight(), Image.Format.RGBA8);
backFrameBuffer.setDepthTarget(FrameBuffer.FrameBufferTarget.newTarget(Image.Format.Depth));
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);
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() {
if(cardLayer != null){
cardLayer.shutdown();
cardLayerHandler.shutdown();
app.getViewPort().setOutputFrameBuffer(null);
}
cardLayer = null;
//app.getViewPort().setOutputFrameBuffer(null);
public void rollDice(int rollNum, int mult) {
cardLayerHandler.rollDice(rollNum, ()->{
if(mult == -1) actionTextHandler.ownDice(rollNum);
else actionTextHandler.ownDiceMult(rollNum, mult);
hideDice();
//TODO send Model finished
});
}
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");
};
public void showRolledDiceMult(int rollNum, int mult, Color color) {
String name = playerNameHandler.getName(color);
if(mult == -1) actionTextHandler.diceNum(rollNum, name, color);
else actionTextHandler.diceNumMult(rollNum, mult, name, color);
}
public void addCard(BonusCard card, UUID uuid) {
if(card == BonusCard.HIDDEN) throw new RuntimeException("cant add hidden card to gui");
uuidBonusCardMap.put(uuid, card);
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){
if(!(1 <= rollNum && rollNum <= 6)) throw new RuntimeException("rollNum is not in the range [1,6]");
diceControl.rollDice(rollNum);
public void showRolledDice(int rollNum, Color color) {
actionTextHandler.diceNum(rollNum, playerNameHandler.getName(color), color);
}
public void showDice() {
cardLayer.addSpatial(diceControl.getSpatial());
diceControl.spin();
cardLayerHandler.showDice();
}
public void hideDice() {
diceControl.hide();
cardLayerHandler.hideDice();
}
private Vector3f nextPos() {
return START.add(MARGIN.mult(bonusCardControlMap.size()));
public void addCard(pp.mdga.game.BonusCard card) {
cardLayerHandler.addCard(card);
}
public void addPlayer(Color color, String name, boolean own){
playerNameHandler.addPlayer(color, name, own);
public void clearSelectableCards() {
cardLayerHandler.clearSelectableCards();
}
public void setSelectableCards(List<pp.mdga.game.BonusCard> select) {
cardLayerHandler.setSelectableCards(select);
}
public void selectCard(CardControl cardControl) {
cardLayerHandler.selectCard(cardControl);
}
public Camera getCardLayerCamera() {
return cardLayerHandler.getCardLayerCamera();
}
public Node getCardLayerRootNode(){
return cardLayerHandler.getCardLayer().getRootNode();
}
public void addPlayer(Color color, String name) {
playerNameHandler.addPlayer(color, name, color == ownColor);
}
public void setActivePlayer(Color color) {
playerNameHandler.setActivePlayer(color);
}
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) {
if(cardControl.isSelected()) {
cardControl.unSelect();
cardSelect = null;
}
else {
for (CardControl control : selectableCards){
control.unSelect();
}
cardControl.select();
cardSelect = getKeyByValue(bonusCardControlMap, cardControl);
}
if (ownColor == color) actionTextHandler.ownActive(color);
else actionTextHandler.activePlayer(playerNameHandler.getName(color), color);
}
public void shield(){
SymbolControl control = createSymbol(Asset.shieldSymbol);
cardLayer.addSpatial(control.getSpatial());
control.shield();
cardLayerHandler.shield();
}
public void swap(){
SymbolControl control = createSymbol(Asset.swapSymbol);
cardLayer.addSpatial(control.getSpatial());
control.swap();
cardLayerHandler.swap();
}
public void turbo(){
SymbolControl control = createSymbol(Asset.turboSymbol);
cardLayer.addSpatial(control.getSpatial());
control.turbo();
cardLayerHandler.turbo();
}
private static <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; // Key not found
public void hideText(){
actionTextHandler.hide();
}
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 void drawCard(Color color) {
if (ownColor == color) actionTextHandler.drawCardOwn(color);
else actionTextHandler.drawCard(playerNameHandler.getName(color), color);
}
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;
}
}

View File

@@ -25,8 +25,7 @@ public class PlayerNameHandler {
private final AssetManager assetManager;
private Color ownColor;
private static final float PADDING_TOP = 50;
private static final float PADDING_TOP = 35;
private static final float PADDING_LEFT = 50;
private static final float MARGIN_NAMES = 50;
private static final float IMAGE_SIZE = 50;
@@ -91,14 +90,7 @@ private Spatial createColor(Color color) {
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){
BitmapText hudText = new BitmapText(playerFont);
@@ -126,5 +118,9 @@ public void setActivePlayer(Color color) {
drawPlayers();
}
public String getName(Color color){
return colorNameMap.get(color);
}
}

View File

@@ -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);
}
}

View File

@@ -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) {
}
}

View File

@@ -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);
}
}

View File

@@ -9,7 +9,6 @@
import pp.mdga.client.button.ButtonLeft;
import pp.mdga.client.button.ButtonRight;
import pp.mdga.client.button.CeremonyButton;
import pp.mdga.client.button.LobbyButton;
import pp.mdga.client.dialog.CeremonyDialog;
import pp.mdga.game.Color;
@@ -68,6 +67,8 @@ public void onLeave() {
ceremonyButtons.clear();
rootNode.removeLight(ambient);
ceremonyDialog.prepare();
}
@Override
@@ -132,7 +133,7 @@ public void forward() {
enterSub(SubState.STATISTICS);
break;
case STATISTICS:
app.getModelSyncronizer().enter(MdgaState.MAIN);
app.getModelSynchronize().enter(MdgaState.MAIN);
break;
}
}

View File

@@ -45,16 +45,16 @@ public class GameView extends MdgaView {
public GameView(MdgaApp app) {
super(app);
cheatButton = new ButtonRight(app, settingsNode, () -> app.getModelSyncronizer().enter(MdgaState.CEREMONY), "CHEAT", 1);
leaveButton = new ButtonLeft(app, settingsNode, () -> app.getModelSyncronizer().leave(), "Spiel verlassen", 1);
cheatButton = new ButtonRight(app, settingsNode, () -> app.getModelSynchronize().enter(MdgaState.CEREMONY), "CHEAT", 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());
this.camera = new CameraHandler(app, fpp);
this.boardHandler = new BoardHandler(app, rootNode, fpp);
guiHandler = new GuiHandler(app, guiNode);
guiHandler = new GuiHandler(app, guiNode, ownColor);
}
@Override
@@ -79,7 +79,7 @@ public void onLeave() {
@Override
public void onUpdate(float tpf) {
camera.update(app.getInputSyncronizer().getScroll(), app.getInputSyncronizer().getRotation());
camera.update(app.getInputSynchronize().getScroll(), app.getInputSynchronize().getRotation());
}
@Override
@@ -99,7 +99,7 @@ protected void onLeaveOverlay(Overlay overlay) {
}
private void leaveGame() {
app.getModelSyncronizer().leave();
app.getModelSynchronize().leave();
}
public BoardHandler getBoardHandler() {

View File

@@ -179,10 +179,10 @@ private void toggleTsk(Color color) {
switch (taken) {
case NOT:
app.getModelSyncronizer().selectTsk(color);
app.getModelSynchronize().selectTsk(color);
break;
case SELF:
app.getModelSyncronizer().unselectTsk();
app.getModelSynchronize().unselectTsk();
break;
case OTHER:
//nothing
@@ -191,11 +191,11 @@ private void toggleTsk(Color color) {
}
private void ready() {
app.getModelSyncronizer().setReady();
app.getModelSynchronize().setReady();
app.getAcousticHandler().playSound(MdgaSound.SELF_READY);
}
private void leaveLobby() {
app.getModelSyncronizer().leave();
app.getModelSynchronize().leave();
}
}

View File

@@ -2,11 +2,7 @@
import com.jme3.scene.Geometry;
import pp.mdga.client.MdgaApp;
import pp.mdga.client.MdgaState;
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.JoinDialog;
import pp.mdga.client.dialog.StartDialog;
@@ -98,8 +94,8 @@ private void tryHost() {
port = Integer.parseInt(text);
if(port >= 1 && port <= 65535) {
app.getModelSyncronizer().setName(startDialog.getName());
app.getModelSyncronizer().setHost(port);
app.getModelSynchronize().setName(startDialog.getName());
app.getModelSynchronize().setHost(port);
//app.getAcousticHandler().playSound(MdgaSound.WRONG_INPUT);
return;
}
@@ -125,8 +121,8 @@ private void tryJoin() {
// Validate the IP address
if (isValidIpAddress(ip)) {
app.getModelSyncronizer().setName(startDialog.getName());
app.getModelSyncronizer().setJoin(ip, port);
app.getModelSynchronize().setName(startDialog.getName());
app.getModelSynchronize().setJoin(ip, port);
return;
}
} catch (IllegalArgumentException e) {

View File

@@ -1,4 +0,0 @@
package pp.mdga.client;
public class Animation extends ClientState {
}

View File

@@ -1,4 +0,0 @@
package pp.mdga.client;
public class AudioSettings extends ClientState {
}

View File

@@ -1,5 +0,0 @@
package pp.mdga.client;
public class Ceremony extends ClientState {
private final CeremonyStateMachine ceremonyStateMachine = new CeremonyStateMachine();
}

View File

@@ -1,4 +0,0 @@
package pp.mdga.client;
public class CeremonyStateMachine extends ClientStateMachine {
}

View File

@@ -1,5 +0,0 @@
package pp.mdga.client;
public class ChoosePiece extends ClientState {
private final ChoosePieceStateMachine choosePieceStateMachine = new ChoosePieceStateMachine();
}

View File

@@ -1,4 +0,0 @@
package pp.mdga.client;
public class ChoosePieceStateMachine extends ClientStateMachine{
}

View File

@@ -1,4 +0,0 @@
package pp.mdga.client;
public class ChoosePowerCard extends ClientState {
}

View File

@@ -1,4 +0,0 @@
package pp.mdga.client;
public class ClientAutomaton extends ClientStateMachine {
}

View File

@@ -1,4 +0,0 @@
package pp.mdga.client;
public class ClientGameLogic {
}

View File

@@ -1,4 +0,0 @@
package pp.mdga.client;
public abstract class ClientState {
}

View File

@@ -1,4 +0,0 @@
package pp.mdga.client;
public abstract class ClientStateMachine extends ClientState {
}

View File

@@ -1,5 +0,0 @@
package pp.mdga.client;
public class DetermineStartPlayer extends ClientState {
private final DetermineStartPlayerStateMachine determineStartPlayerStateMachine = new DetermineStartPlayerStateMachine();
}

View File

@@ -1,4 +0,0 @@
package pp.mdga.client;
public class DetermineStartPlayerStateMachine extends ClientStateMachine{
}

View File

@@ -1,5 +0,0 @@
package pp.mdga.client;
public class Dialogs extends ClientState {
private final DialogsStateMachine dialogsStateMachine = new DialogsStateMachine();
}

View File

@@ -1,4 +0,0 @@
package pp.mdga.client;
public class DialogsStateMachine extends ClientStateMachine {
}

View File

@@ -1,5 +0,0 @@
package pp.mdga.client;
public class GameState extends ClientState {
private final GameStateMachine gameStateMachine = new GameStateMachine();
}

View File

@@ -1,4 +0,0 @@
package pp.mdga.client;
public class GameStateMachine extends ClientStateMachine {
}

View File

@@ -1,4 +0,0 @@
package pp.mdga.client;
public class Interrupt extends ClientState {
}

View File

@@ -1,4 +0,0 @@
package pp.mdga.client;
public class Lobby extends ClientState {
}

View File

@@ -1,4 +0,0 @@
package pp.mdga.client;
public class MainSettings extends ClientState {
}

View File

@@ -1,4 +0,0 @@
package pp.mdga.client;
public class MovePiece extends ClientState {
}

View File

@@ -1,4 +0,0 @@
package pp.mdga.client;
public class NetworkDialog extends ClientState {
}

View File

@@ -1,4 +0,0 @@
package pp.mdga.client;
public class NoPiece extends ClientState {
}

View File

@@ -1,4 +0,0 @@
package pp.mdga.client;
public class PlayPowerCard extends ClientState {
}

View File

@@ -1,4 +0,0 @@
package pp.mdga.client;
public class Podium extends ClientState {
}

View File

@@ -1,5 +0,0 @@
package pp.mdga.client;
public class PowerCard extends ClientState {
private final PowerCardStateMachine powerCardStateMachine = new PowerCardStateMachine();
}

View File

@@ -1,4 +0,0 @@
package pp.mdga.client;
public class PowerCardStateMachine extends ClientStateMachine {
}

View File

@@ -1,4 +0,0 @@
package pp.mdga.client;
public class RollDice extends ClientState {
}

View File

@@ -1,4 +0,0 @@
package pp.mdga.client;
public class RollRankingDice extends ClientState {
}

View File

@@ -1,4 +0,0 @@
package pp.mdga.client;
public class SelectPiece extends ClientState {
}

View File

@@ -1,5 +0,0 @@
package pp.mdga.client;
public class Settings extends ClientState {
private final SettingsStateMachine settingsStateMachine = new SettingsStateMachine();
}

View File

@@ -1,4 +0,0 @@
package pp.mdga.client;
public class SettingsStateMachine extends ClientStateMachine {
}

View File

@@ -1,4 +0,0 @@
package pp.mdga.client;
public class Shield extends ClientState {
}

View File

@@ -1,4 +0,0 @@
package pp.mdga.client;
public class Spectator extends ClientState {
}

View File

@@ -1,4 +0,0 @@
package pp.mdga.client;
public class StartDialog extends ClientState {
}

View File

@@ -1,4 +0,0 @@
package pp.mdga.client;
public class StartPiece extends ClientState {
}

View File

@@ -1,4 +0,0 @@
package pp.mdga.client;
public class Statistics extends ClientState {
}

View File

@@ -1,4 +0,0 @@
package pp.mdga.client;
public class Swap extends ClientState {
}

View File

@@ -1,5 +0,0 @@
package pp.mdga.client;
public class Turn extends ClientState {
private final TurnStateMachine turnStateMachine = new TurnStateMachine();
}

View File

@@ -1,4 +0,0 @@
package pp.mdga.client;
public class TurnStateMachine extends ClientStateMachine {
}

View File

@@ -1,4 +0,0 @@
package pp.mdga.client;
public class VideoSettings extends ClientState {
}

View File

@@ -1,4 +0,0 @@
package pp.mdga.client;
public class WaitRanking extends ClientState {
}

View File

@@ -1,4 +0,0 @@
package pp.mdga.client;
public class Waiting extends ClientState {
}

View File

@@ -1,4 +0,0 @@
package pp.mdga.client;
public class WaitingPiece extends ClientState {
}

View File

@@ -1,9 +0,0 @@
package pp.mdga.game;
public enum Color {
ARMY,
NAVY,
CYBER,
AIRFORCE
}

View File

@@ -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);
}
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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 "";
}
}

View File

@@ -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 "";
}
}

View File

@@ -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 "";
}
}

View File

@@ -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 "";
}
}

View File

@@ -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 "";
}
}

View File

@@ -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 "";
}
}

View File

@@ -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 "";
}
}

View File

@@ -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 "";
}
}

View File

@@ -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 "";
}
}

View File

@@ -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 "";
}
}

View File

@@ -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 "";
}
}

View File

@@ -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 "";
}
}

View File

@@ -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