Merge dev/client_beck

This commit is contained in:
Felix Koppe
2024-12-01 21:51:01 +01:00
18 changed files with 160 additions and 79 deletions

View File

@@ -18,8 +18,12 @@
import pp.mdga.client.board.PieceControl; import pp.mdga.client.board.PieceControl;
import pp.mdga.client.gui.CardControl; import pp.mdga.client.gui.CardControl;
import pp.mdga.client.view.GameView; import pp.mdga.client.view.GameView;
import pp.mdga.game.BonusCard;
import pp.mdga.game.Color; import pp.mdga.game.Color;
import pp.mdga.game.Piece; import pp.mdga.game.Piece;
import pp.mdga.notification.SelectableCardsNotification;
import java.util.List;
public class InputSynchronizer { public class InputSynchronizer {
@@ -112,6 +116,7 @@ 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){
app.getNotificationSynchronizer().addTestNotification(new SelectableCardsNotification(List.of(BonusCard.SHIELD)));
} }
} }
} }

View File

@@ -66,7 +66,6 @@ private void handleLobby(Notification notification) {
//lobbyView.setReady(lobbyReadyNotification.getColor(), lobbyReadyNotification.isReady()): //lobbyView.setReady(lobbyReadyNotification.getColor(), lobbyReadyNotification.isReady()):
} else if (notification instanceof GameNotification n) { } else if (notification instanceof GameNotification n) {
app.enter(MdgaState.GAME); app.enter(MdgaState.GAME);
((GameView) app.getView()).setOwnColor(n.getOwnColor());
} else { } else {
throw new RuntimeException("notification not expected: " + notification.toString()); throw new RuntimeException("notification not expected: " + notification.toString());
} }
@@ -77,8 +76,8 @@ 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) { if (notification instanceof AcquireCardNotification n) {
// Handle AcquireCardNotification guiHandler.addCard(n.getBonusCard());
} 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) {
@@ -146,11 +145,11 @@ private void handleGame(Notification notification) {
//TODO //TODO
} else if (notification instanceof RollDiceNotification n) { } else if (notification instanceof RollDiceNotification n) {
if(n.getColor() == gameView.getOwnColor()){ if(n.getColor() == gameView.getOwnColor()){
//guiHandler.rollDice(n.getEyes(), n.isTurbo() ? n.getMultiplier() : -1); guiHandler.rollDice(n.getEyes(), n.isTurbo() ? n.getMultiplier() : -1);
} }
else { else {
//if (n.isTurbo()) guiHandler.showRolledDiceMult(n.getEyes(), n.getMultiplier(), n.getColor()); if (n.isTurbo()) guiHandler.showRolledDiceMult(n.getEyes(), n.getMultiplier(), n.getColor());
//else guiHandler.showRolledDice(n.getEyes(), 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());
@@ -169,10 +168,10 @@ private void handleGame(Notification notification) {
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) { } else if (notification instanceof SelectableShieldNotification n) {
// boardHandler.outlineShield(n.getOwnPieces()); boardHandler.outlineShield(n.getPieces());
//} else if (notification instanceof TurboActiveNotification){ } else if (notification instanceof TurboActiveNotification){
// guiHandler.turbo(); guiHandler.turbo();
} else { } else {
throw new RuntimeException("notification not expected: " + notification.toString()); throw new RuntimeException("notification not expected: " + notification.toString());
} }

View File

@@ -68,7 +68,6 @@ public void init() {
public void shutdown(){ public void shutdown(){
clearSelectable(); clearSelectable();
isInitialised = false; isInitialised = false;
initMap();
rootNode.detachChild(rootNodeBoard); rootNode.detachChild(rootNodeBoard);
} }

View File

@@ -7,6 +7,7 @@
import com.jme3.renderer.RenderManager; import com.jme3.renderer.RenderManager;
import com.jme3.renderer.ViewPort; import com.jme3.renderer.ViewPort;
import com.jme3.scene.Spatial; import com.jme3.scene.Spatial;
import pp.mdga.client.MdgaApp;
public class SelectObjectOutliner { public class SelectObjectOutliner {
@@ -19,14 +20,16 @@ public class SelectObjectOutliner {
private ViewPort outlineViewport = null; private ViewPort outlineViewport = null;
// private OutlineFilter outlineFilter = null; // private OutlineFilter outlineFilter = null;
private OutlineProFilter outlineFilter = null; private OutlineProFilter outlineFilter = null;
private final MdgaApp app;
public SelectObjectOutliner(int width, FilterPostProcessor fpp, RenderManager renderManager, AssetManager assetManager, Camera cam) { public SelectObjectOutliner(int width, FilterPostProcessor fpp, RenderManager renderManager, AssetManager assetManager, Camera cam, MdgaApp app) {
this.selected = false; this.selected = false;
this.fpp = fpp; this.fpp = fpp;
this.renderManager = renderManager; this.renderManager = renderManager;
this.assetManager = assetManager; this.assetManager = assetManager;
this.cam = cam; this.cam = cam;
this.width = width; this.width = width;
this.app = app;
} }
public void deselect(Spatial model) { public void deselect(Spatial model) {
@@ -51,30 +54,35 @@ public void select(Spatial model, ColorRGBA color, int width) {
} }
private void hideOutlineFilterEffect(Spatial model) { private void hideOutlineFilterEffect(Spatial model) {
outlineFilter.setEnabled(false); // app.enqueue(() -> {
outlineFilter.getOutlinePreFilter().setEnabled(false); outlineFilter.setEnabled(false);
fpp.removeFilter(outlineFilter); outlineFilter.getOutlinePreFilter().setEnabled(false);
outlineViewport.detachScene(model); fpp.removeFilter(outlineFilter);
outlineViewport.clearProcessors(); outlineViewport.detachScene(model);
renderManager.removePreView(outlineViewport); outlineViewport.clearProcessors();
outlineViewport = null; renderManager.removePreView(outlineViewport);
outlineViewport = null;
// return null;
// });
} }
private void showOutlineFilterEffect(Spatial model, int width, ColorRGBA color) { private void showOutlineFilterEffect(Spatial model, int width, ColorRGBA color) {
outlineViewport = renderManager.createPreView("outlineViewport", cam); // app.enqueue(() -> {
FilterPostProcessor outlineFpp = new FilterPostProcessor(assetManager); outlineViewport = renderManager.createPreView("outlineViewport", cam);
FilterPostProcessor outlineFpp = new FilterPostProcessor(assetManager);
OutlinePreFilter outlinePreFilter = new OutlinePreFilter(); OutlinePreFilter outlinePreFilter = new OutlinePreFilter();
outlineFpp.addFilter(outlinePreFilter); outlineFpp.addFilter(outlinePreFilter);
outlineViewport.attachScene(model); outlineViewport.attachScene(model);
outlineViewport.addProcessor(outlineFpp); outlineViewport.addProcessor(outlineFpp);
// outlineFilter = new OutlineFilter(outlinePreFilter); outlineFilter = new OutlineProFilter(outlinePreFilter);
outlineFilter = new OutlineProFilter(outlinePreFilter); outlineFilter.setOutlineColor(color);
outlineFilter.setOutlineColor(color); outlineFilter.setOutlineWidth(width);
outlineFilter.setOutlineWidth(width);
fpp.addFilter(outlineFilter); fpp.addFilter(outlineFilter);
// return null;
// });
} }
} }

View File

@@ -18,17 +18,17 @@ public class OutlineControl extends AbstractControl {
public OutlineControl(MdgaApp app, FilterPostProcessor fpp){ public OutlineControl(MdgaApp app, FilterPostProcessor fpp){
this.app = app; this.app = app;
outlineOwn = new SelectObjectOutliner(THICKNESS_DEFAULT, fpp, app.getRenderManager(), app.getAssetManager(), app.getCamera()); outlineOwn = new SelectObjectOutliner(THICKNESS_DEFAULT, fpp, app.getRenderManager(), app.getAssetManager(), app.getCamera(), app);
} }
public OutlineControl(MdgaApp app, FilterPostProcessor fpp, Camera cam){ public OutlineControl(MdgaApp app, FilterPostProcessor fpp, Camera cam){
this.app = app; this.app = app;
outlineOwn = new SelectObjectOutliner(THICKNESS_DEFAULT, fpp, app.getRenderManager(), app.getAssetManager(), cam); outlineOwn = new SelectObjectOutliner(THICKNESS_DEFAULT, fpp, app.getRenderManager(), app.getAssetManager(), cam, app);
} }
public OutlineControl(MdgaApp app, FilterPostProcessor fpp, Camera cam, int thickness){ public OutlineControl(MdgaApp app, FilterPostProcessor fpp, Camera cam, int thickness){
this.app = app; this.app = app;
outlineOwn = new SelectObjectOutliner(thickness, fpp, app.getRenderManager(), app.getAssetManager(), cam); outlineOwn = new SelectObjectOutliner(thickness, fpp, app.getRenderManager(), app.getAssetManager(), cam, app);
} }
public void outline(ColorRGBA color){ public void outline(ColorRGBA color){

View File

@@ -84,9 +84,6 @@ public Node getRoot() {
public void initSpatial(){ public void initSpatial(){
} }
public void outline(){ public void outline(){
super.outline(OUTLINE_COLOR); super.outline(OUTLINE_COLOR);
} }

View File

@@ -88,8 +88,6 @@ public void render(RenderManager rm) {
@Override @Override
public void update( float tpf ) { public void update( float tpf ) {
if (init && !cardBuffer.isEmpty()) { if (init && !cardBuffer.isEmpty()) {
for(Spatial spatial : cardBuffer){ for(Spatial spatial : cardBuffer){
root.attachChild(spatial); root.attachChild(spatial);
@@ -114,4 +112,4 @@ public Camera getOverlayCam(){
public Node getRootNode(){ public Node getRootNode(){
return root; return root;
} }
} }

View File

@@ -43,6 +43,7 @@ public void init() {
cardLayerCamera = createOverlayCam(); cardLayerCamera = createOverlayCam();
cardLayer = new CardLayer(fpp, cardLayerCamera, backTexture); cardLayer = new CardLayer(fpp, cardLayerCamera, backTexture);
app.getStateManager().attach(cardLayer); app.getStateManager().attach(cardLayer);
diceControl = new DiceControl(app.getAssetManager()); diceControl = new DiceControl(app.getAssetManager());
diceControl.create(new Vector3f(0, 0, 0), 1f, false); diceControl.create(new Vector3f(0, 0, 0), 1f, false);
} }
@@ -50,6 +51,7 @@ public void init() {
public void shutdown() { public void shutdown() {
if (cardLayer != null) { if (cardLayer != null) {
cardLayer.shutdown(); cardLayer.shutdown();
clearSelectableCards();
} }
cardLayer = null; cardLayer = null;
} }

View File

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

View File

@@ -9,9 +9,18 @@
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.gui.GuiHandler; import pp.mdga.client.gui.GuiHandler;
import pp.mdga.game.BonusCard;
import pp.mdga.game.Color; import pp.mdga.game.Color;
import pp.mdga.notification.AcquireCardNotification;
import pp.mdga.notification.ActivePlayerNotification;
import pp.mdga.notification.DiceNowNotification;
import pp.mdga.notification.GameNotification; import pp.mdga.notification.GameNotification;
import pp.mdga.notification.MovePieceNotification;
import pp.mdga.notification.PlayerInGameNotification; import pp.mdga.notification.PlayerInGameNotification;
import pp.mdga.notification.RollDiceNotification;
import pp.mdga.notification.SelectableCardsNotification;
import pp.mdga.notification.SelectableMoveNotification;
import pp.mdga.notification.ShieldActiveNotification;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -43,26 +52,66 @@ public GameView(MdgaApp app) {
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, ownColor); guiHandler = new GuiHandler(app, guiNode);
} }
@Override @Override
public void onEnter() { public void onEnter() {
camera.init(); camera.init();
boardHandler.init(); boardHandler.init();
guiHandler.init(); setOwnColor(Color.AIRFORCE);
guiHandler.init(ownColor);
app.getViewPort().addProcessor(fpp); app.getViewPort().addProcessor(fpp);
app.getAcousticHandler().playSound(MdgaSound.START); app.getAcousticHandler().playSound(MdgaSound.START);
//Test
List<UUID> uuid1 = new ArrayList<>();
UUID p1 = UUID.randomUUID();
UUID p2 = UUID.randomUUID();
uuid1.add(p1);
uuid1.add(p2);
uuid1.add(UUID.randomUUID());
uuid1.add(UUID.randomUUID());
List<UUID> uuid2 = new ArrayList<>();
UUID p1_2 = UUID.randomUUID();
UUID p2_2 = UUID.randomUUID();
uuid2.add(p1_2);
uuid2.add(p2_2);
uuid2.add(UUID.randomUUID());
uuid2.add(UUID.randomUUID());
app.getNotificationSynchronizer().addTestNotification(new PlayerInGameNotification(Color.AIRFORCE, uuid1, "Cedric"));
app.getNotificationSynchronizer().addTestNotification(new PlayerInGameNotification(Color.NAVY, uuid2, "Test"));
app.getNotificationSynchronizer().addTestNotification(new MovePieceNotification(p1, 0, true));
app.getNotificationSynchronizer().addTestNotification(new MovePieceNotification(p1_2, 30, true));
// app.getNotificationSynchronizer().addTestNotification(new SelectableMoveNotification(List.of(p1), List.of(4), List.of(false)));
app.getNotificationSynchronizer().addTestNotification(new AcquireCardNotification(BonusCard.SHIELD));
// app.getNotificationSynchronizer().addTestNotification(new SelectableCardsNotification(List.of(BonusCard.SHIELD)));
// app.getNotificationSynchronizer().addTestNotification(new ShieldActiveNotification(p1));
// app.getNotificationSynchronizer().addTestNotification(new ActivePlayerNotification(Color.NAVY));
// app.getNotificationSynchronizer().addTestNotification(new DiceNowNotification());
// app.getNotificationSynchronizer().addTestNotification(new RollDiceNotification(Color.AIRFORCE, 5, true, 2));
p1 = p1;
} }
@Override @Override
public void onLeave() { public void onLeave() {
camera.shutdown();
boardHandler.shutdown(); boardHandler.shutdown();
guiHandler.shutdown(); guiHandler.shutdown();
camera.shutdown();
confirmButton.hide(); confirmButton.hide();

View File

@@ -51,8 +51,8 @@ public void enter() {
} }
public void leave() { public void leave() {
app.getRootNode().detachChild(rootNode); onLeave();
app.getGuiNode().detachChild(guiNode);
settingsButton.hide(); settingsButton.hide();
@@ -60,7 +60,8 @@ public void leave() {
pressEscape(); pressEscape();
} }
onLeave(); app.getRootNode().detachChild(rootNode);
app.getGuiNode().detachChild(guiNode);
} }
public void enterOverlay(Overlay overlay) { public void enterOverlay(Overlay overlay) {

View File

@@ -46,17 +46,21 @@ cir 5,4 0
cir 5,5 0 cir 5,5 0
#Assets #Assets
jet -10,-1 45 jet -12,0 45
ship 11,0 169 jet -17,-2 55
big_tent -9,-7 130
big_tent 7,-10 225
small_tent -9,7 45 small_tent -9,7 45
small_tent -10,5 60 small_tent -10,5 60
small_tent -7,8 30
ship 11,0 169
small_tent 6,8 340
small_tent 8,7 320
big_tent -10,-9 130
big_tent 9,-10 225
radar 0,10 -20 radar 0,10 -20
small_tent 6,8 190
small_tent 8,7 160
tank -1,-10 135 tank -1,-10 135
tank 0,-18 180
tank 3,-18 180
tank -3,-18 180
#Yellow (CIR) wait Node #Yellow (CIR) wait Node
node_wait_yellow 4,5 0 node_wait_yellow 4,5 0

View File

@@ -34,7 +34,7 @@ public void received(CeremonyMessage msg){
@Override @Override
public void received(DieMessage msg){ public void received(DieMessage msg){
logic.getGame().setDiceEyes(msg.getDiceEye()); logic.getGame().setDiceEyes(msg.getDiceEye());
logic.addNotification(new RollDiceNotification(logic.getGame().getActiveColor(), logic.getGame().getDiceEyes(), logic.getGame().getDiceEyes() * logic.getGame().getDiceModifier())); // logic.addNotification(new RollDiceNotification(logic.getGame().getActiveColor(), logic.getGame().getDiceEyes(), logic.getGame().getDiceEyes() * logic.getGame().getDiceModifier()));
if(msg.getDiceEye() == 6){ if(msg.getDiceEye() == 6){
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseDiced6(); logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseDiced6();
logic.getGame().getGameStatistics().increaseDiced6(); logic.getGame().getGameStatistics().increaseDiced6();

View File

@@ -40,7 +40,7 @@ public void received(DiceNowMessage msg){
@Override @Override
public void received(DieMessage msg){ public void received(DieMessage msg){
logic.getGame().setDiceEyes(msg.getDiceEye()); logic.getGame().setDiceEyes(msg.getDiceEye());
logic.addNotification(new RollDiceNotification(logic.getGame().getActiveColor(), logic.getGame().getDiceEyes(), logic.getGame().getDiceEyes() * logic.getGame().getDiceModifier())); // logic.addNotification(new RollDiceNotification(logic.getGame().getActiveColor(), logic.getGame().getDiceEyes(), logic.getGame().getDiceEyes() * logic.getGame().getDiceModifier()));
if(msg.getDiceEye() == 6){ if(msg.getDiceEye() == 6){
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseDiced6(); logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseDiced6();
logic.getGame().getGameStatistics().increaseDiced6(); logic.getGame().getGameStatistics().increaseDiced6();

View File

@@ -9,24 +9,13 @@
*/ */
public class AcquireCardNotification extends Notification{ public class AcquireCardNotification extends Notification{
private UUID cardId;
private BonusCard bonusCard; private BonusCard bonusCard;
/** /**
* Constructor. * Constructor.
* @param cardId The id of the card that was acquired.
*/ */
public AcquireCardNotification(BonusCard bonusCard, UUID cardId) { public AcquireCardNotification(BonusCard bonusCard) {
this.bonusCard = bonusCard; this.bonusCard = bonusCard;
this.cardId = cardId;
}
/**
* Get the id of the card that was acquired.
* @return The id of the card that was acquired.
*/
public UUID getCardId() {
return cardId;
} }
public BonusCard getBonusCard() { public BonusCard getBonusCard() {

View File

@@ -9,18 +9,26 @@ public class RollDiceNotification extends Notification{
private Color color; private Color color;
private int eyes; private int eyes;
private int moveNumber; private boolean turbo;
private int multiplier;
/** /**
* Constructor. * Constructor.
* @param color the color of the player that rolled the die. * @param color the color of the player that rolled the die.
* @param eyes the number of eyes that were rolled. * @param eyes the number of eyes that were rolled.
* @param moveNumber the number of the move that was made.
*/ */
public RollDiceNotification(Color color, int eyes, int moveNumber) { public RollDiceNotification(Color color, int eyes) {
this.color = color; this.color = color;
this.eyes = eyes; this.eyes = eyes;
this.moveNumber = moveNumber; this.turbo = false;
this.multiplier = -1;
}
public RollDiceNotification(Color color, int eyes, boolean turbo, int multiplier) {
this.color = color;
this.eyes = eyes;
this.turbo = turbo;
this.multiplier = multiplier;
} }
/** /**
@@ -39,11 +47,11 @@ public int getEyes() {
return eyes; return eyes;
} }
/** public int getMultiplier() {
* Get the number of the move that was made. return multiplier;
* @return the number of the move that was made. }
*/
public int getMoveNumber() { public boolean isTurbo() {
return moveNumber; return turbo;
} }
} }

View File

@@ -0,0 +1,16 @@
package pp.mdga.notification;
import java.util.List;
import java.util.UUID;
public class SelectableShieldNotification extends Notification{
private List<UUID> pieces;
public SelectableShieldNotification(List<UUID> pieces){
this.pieces = pieces;
}
public List<UUID> getPieces() {
return pieces;
}
}

View File

@@ -0,0 +1,4 @@
package pp.mdga.notification;
public class TurboActiveNotification extends Notification{
}