Merge branch 'development2' of https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-01 into development2
# Conflicts: # Projekte/mdga/model/src/main/java/pp/mdga/game/Game.java # Projekte/mdga/model/src/main/java/pp/mdga/server/automaton/game/turn/choosepiece/ChoosePieceAutomatonState.java # Projekte/mdga/model/src/main/java/pp/mdga/server/automaton/game/turn/choosepiece/SelectPieceState.java
This commit is contained in:
		@@ -11,6 +11,7 @@ public enum Asset {
 | 
			
		||||
    cir,
 | 
			
		||||
    heer,
 | 
			
		||||
    jet,
 | 
			
		||||
    jet_noGear("Models/jet/jet_noGear.j3o", "Models/jet/jet_diff.png"),
 | 
			
		||||
    lw,
 | 
			
		||||
    marine,
 | 
			
		||||
    node_home_blue("Models/node_home/node_home.j3o", "Models/node_home/node_home_blue_diff.png"),
 | 
			
		||||
 
 | 
			
		||||
@@ -250,12 +250,13 @@ private void hoverPiece() {
 | 
			
		||||
            PieceControl control = checkPiece();
 | 
			
		||||
            if (control != null) {
 | 
			
		||||
                if (control != hoverPiece) {
 | 
			
		||||
                    pieceOff();
 | 
			
		||||
                    pieceOff(gameView);
 | 
			
		||||
                    hoverPiece = control;
 | 
			
		||||
                    hoverPiece.hover();
 | 
			
		||||
//                    hoverPiece.hover();
 | 
			
		||||
                    gameView.getBoardHandler().pieceHoverOn(hoverPiece);
 | 
			
		||||
                }
 | 
			
		||||
            } else {
 | 
			
		||||
                pieceOff();
 | 
			
		||||
                pieceOff(gameView);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
@@ -305,8 +306,11 @@ private CardControl checkCard(GameView gameView) {
 | 
			
		||||
    /**
 | 
			
		||||
     * Disables the hover effect on the currently hovered piece, if any.
 | 
			
		||||
     */
 | 
			
		||||
    private void pieceOff() {
 | 
			
		||||
        if (hoverPiece != null) hoverPiece.hoverOff();
 | 
			
		||||
    private void pieceOff(GameView gameView) {
 | 
			
		||||
        if (hoverPiece != null) {
 | 
			
		||||
            gameView.getBoardHandler().pieceHoverOff(hoverPiece);
 | 
			
		||||
//            hoverPiece.hoverOff();
 | 
			
		||||
        }
 | 
			
		||||
        hoverPiece = null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -66,6 +66,8 @@ public class MdgaApp extends SimpleApplication {
 | 
			
		||||
 | 
			
		||||
    private ServerConnection networkConnection;
 | 
			
		||||
 | 
			
		||||
    public static final int DEBUG_MULTIPLIER = 0;
 | 
			
		||||
 | 
			
		||||
    public MdgaApp() {
 | 
			
		||||
        networkConnection = new NetworkSupport(this);
 | 
			
		||||
        this.clientGameLogic = new ClientGameLogic(networkConnection);
 | 
			
		||||
 
 | 
			
		||||
@@ -23,7 +23,11 @@ public class ModelSynchronizer {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void animationEnd() {
 | 
			
		||||
        app.getGameLogic().selectAnimationEnd();
 | 
			
		||||
        if(app.getNotificationSynchronizer().waitForAnimation) {
 | 
			
		||||
            app.getNotificationSynchronizer().waitForAnimation = false;
 | 
			
		||||
        } else {
 | 
			
		||||
            app.getGameLogic().selectAnimationEnd();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void select(UUID a, UUID b){
 | 
			
		||||
@@ -79,6 +83,8 @@ public void confirm() {
 | 
			
		||||
 | 
			
		||||
        GameView gameView = (GameView) app.getView();
 | 
			
		||||
 | 
			
		||||
        gameView.getGuiHandler().hideText();
 | 
			
		||||
 | 
			
		||||
        if(a != null && b != null) {
 | 
			
		||||
            app.getGameLogic().selectPiece(a);
 | 
			
		||||
            app.getGameLogic().selectPiece(b);
 | 
			
		||||
 
 | 
			
		||||
@@ -7,10 +7,13 @@
 | 
			
		||||
import pp.mdga.client.view.CeremonyView;
 | 
			
		||||
import pp.mdga.client.view.GameView;
 | 
			
		||||
import pp.mdga.client.view.LobbyView;
 | 
			
		||||
import pp.mdga.game.BonusCard;
 | 
			
		||||
import pp.mdga.game.Color;
 | 
			
		||||
import pp.mdga.notification.*;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.Timer;
 | 
			
		||||
import java.util.TimerTask;
 | 
			
		||||
 | 
			
		||||
public class NotificationSynchronizer {
 | 
			
		||||
    private final MdgaApp app;
 | 
			
		||||
@@ -22,12 +25,18 @@ public class NotificationSynchronizer {
 | 
			
		||||
 | 
			
		||||
    private static final float STANDARD_DELAY = 2.5f;
 | 
			
		||||
 | 
			
		||||
    public boolean waitForAnimation = false;
 | 
			
		||||
 | 
			
		||||
    NotificationSynchronizer(MdgaApp app) {
 | 
			
		||||
        this.app = app;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void update() {
 | 
			
		||||
        while (timer.getTimeInSeconds() >= delay) {
 | 
			
		||||
            if(waitForAnimation) {
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            Notification n = app.getGameLogic().getNotification();
 | 
			
		||||
 | 
			
		||||
            if(n == null) {
 | 
			
		||||
@@ -62,7 +71,9 @@ public void update() {
 | 
			
		||||
                        throw new RuntimeException("no notification expected: " + n.getClass().getName());
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                delay = 0;
 | 
			
		||||
                if(0 == MdgaApp.DEBUG_MULTIPLIER) {
 | 
			
		||||
                    delay = 0;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
@@ -144,9 +155,11 @@ private void handleGame(Notification notification) {
 | 
			
		||||
            guiHandler.showDice();
 | 
			
		||||
        } else if (notification instanceof DrawCardNotification n) {
 | 
			
		||||
            guiHandler.drawCard(n.getColor());
 | 
			
		||||
            delay = STANDARD_DELAY;
 | 
			
		||||
        } else if (notification instanceof HomeMoveNotification home) {
 | 
			
		||||
            boardHandler.movePieceHomeAnim(home.getPieceId(), home.getHomeIndex());
 | 
			
		||||
            guiHandler.hideText();
 | 
			
		||||
            app.getGameLogic().selectAnimationEnd();
 | 
			
		||||
        } else if (notification instanceof InterruptNotification notification1) {
 | 
			
		||||
            gameView.enterInterrupt(notification1.getColor());
 | 
			
		||||
        } else if (notification instanceof MovePieceNotification n) {
 | 
			
		||||
@@ -161,11 +174,27 @@ private void handleGame(Notification notification) {
 | 
			
		||||
            guiHandler.hideText();
 | 
			
		||||
        } else if (notification instanceof ThrowPieceNotification n) {
 | 
			
		||||
            boardHandler.throwPiece(n.getPieceId(), n.getThrowColor());
 | 
			
		||||
        } else if (notification instanceof NoShieldNotification n) {
 | 
			
		||||
            boardHandler.unshieldPiece(n.getPieceId());
 | 
			
		||||
            waitForAnimation = true;
 | 
			
		||||
        } else if (notification instanceof RemoveShieldNotification n) {
 | 
			
		||||
            boardHandler.unshieldPiece(n.getPieceUuid());
 | 
			
		||||
        } else if (notification instanceof PlayCardNotification n) {
 | 
			
		||||
            if(n.getCard() == BonusCard.TURBO) {
 | 
			
		||||
                app.getAcousticHandler().playSound(MdgaSound.TURBO);
 | 
			
		||||
                guiHandler.turbo();
 | 
			
		||||
            } else if(n.getCard() == BonusCard.SHIELD) {
 | 
			
		||||
                app.getAcousticHandler().playSound(MdgaSound.SHIELD);
 | 
			
		||||
            } else if(n.getCard() == BonusCard.SWAP) {
 | 
			
		||||
                app.getAcousticHandler().playSound(MdgaSound.SWAP);
 | 
			
		||||
            }
 | 
			
		||||
            if(n.getColor() == ownColor) guiHandler.playCardOwn(n.getCard());
 | 
			
		||||
            else guiHandler.playCardEnemy(n.getColor(), n.getCard());
 | 
			
		||||
 | 
			
		||||
            new Timer().schedule(new TimerTask() {
 | 
			
		||||
                @Override
 | 
			
		||||
                public void run() {
 | 
			
		||||
                    app.getModelSynchronize().animationEnd();
 | 
			
		||||
                }
 | 
			
		||||
            }, 2200 * MdgaApp.DEBUG_MULTIPLIER);
 | 
			
		||||
        } else if (notification instanceof PlayerInGameNotification n) {
 | 
			
		||||
            boardHandler.addPlayer(n.getColor(),n.getPiecesList());
 | 
			
		||||
            guiHandler.addPlayer(n.getColor(),n.getName());
 | 
			
		||||
@@ -175,13 +204,13 @@ private void handleGame(Notification notification) {
 | 
			
		||||
            gameView.getGuiHandler().hideText();
 | 
			
		||||
            if(n.getColor() == ownColor){
 | 
			
		||||
                guiHandler.rollDice(n.getEyes(), n.isTurbo() ? n.getMultiplier() : -1);
 | 
			
		||||
                waitForAnimation = true;
 | 
			
		||||
            }
 | 
			
		||||
            else {
 | 
			
		||||
                boardHandler.hideDice();
 | 
			
		||||
                if (n.isTurbo()) guiHandler.showRolledDiceMult(n.getEyes(), n.getMultiplier(), n.getColor());
 | 
			
		||||
                else guiHandler.showRolledDice(n.getEyes(), n.getColor());
 | 
			
		||||
            }
 | 
			
		||||
            delay = 7;
 | 
			
		||||
        } else if (notification instanceof SelectableCardsNotification n) {
 | 
			
		||||
            guiHandler.setSelectableCards(n.getCards());
 | 
			
		||||
            gameView.showNoPower();
 | 
			
		||||
@@ -196,7 +225,7 @@ private void handleGame(Notification notification) {
 | 
			
		||||
            boardHandler.swapPieceAnim(n.getFirstPiece(), n.getSecondPiece());
 | 
			
		||||
            guiHandler.swap();
 | 
			
		||||
        } else if (notification instanceof WaitMoveNotification) {
 | 
			
		||||
            //TODO ???
 | 
			
		||||
            //nothing
 | 
			
		||||
        } else if (notification instanceof SelectableMoveNotification n) {
 | 
			
		||||
            boardHandler.outlineMove(n.getPieces(), n.getMoveIndices(), n.getHomeMoves());
 | 
			
		||||
            modelSynchronizer.setSwap(false);
 | 
			
		||||
@@ -207,7 +236,7 @@ private void handleGame(Notification notification) {
 | 
			
		||||
            boardHandler.outlineShield(n.getPieces());
 | 
			
		||||
            modelSynchronizer.setSwap(false);
 | 
			
		||||
        } else if (notification instanceof TurboActiveNotification){
 | 
			
		||||
            guiHandler.turbo();
 | 
			
		||||
            //nothing
 | 
			
		||||
        } else if (notification instanceof FinishNotification n){
 | 
			
		||||
            guiHandler.finish(n.getColorFinished());
 | 
			
		||||
        } else {
 | 
			
		||||
 
 | 
			
		||||
@@ -147,6 +147,16 @@ public void playSound(MdgaSound sound) {
 | 
			
		||||
            case TANK_EXPLOSION:
 | 
			
		||||
                assets.add(new SoundAssetDelayVolume(SoundAsset.EXPLOSION_1, 1.0f, 0f));
 | 
			
		||||
                break;
 | 
			
		||||
            case SHIELD:
 | 
			
		||||
                assets.add(new SoundAssetDelayVolume(SoundAsset.SHIELD, 1.0f, 0f));
 | 
			
		||||
                break;
 | 
			
		||||
            case TURBO:
 | 
			
		||||
                assets.add(new SoundAssetDelayVolume(SoundAsset.SPEED, 1.0f, 0.1f));
 | 
			
		||||
                assets.add(new SoundAssetDelayVolume(SoundAsset.SPEED, 1.0f, 1.3f));
 | 
			
		||||
                break;
 | 
			
		||||
            case SWAP:
 | 
			
		||||
                assets.add(new SoundAssetDelayVolume(SoundAsset.SWAP, 1.0f, 0f));
 | 
			
		||||
                break;
 | 
			
		||||
            default:
 | 
			
		||||
                break;
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -40,5 +40,8 @@ public enum MdgaSound {
 | 
			
		||||
    MATRIX,
 | 
			
		||||
    TURRET_ROTATE,
 | 
			
		||||
    TANK_SHOOT,
 | 
			
		||||
    TANK_EXPLOSION
 | 
			
		||||
    TANK_EXPLOSION,
 | 
			
		||||
    SHIELD,
 | 
			
		||||
    TURBO,
 | 
			
		||||
    SWAP,
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -39,7 +39,10 @@ enum SoundAsset {
 | 
			
		||||
    MATRIX("matrix.wav"),
 | 
			
		||||
    CONNECTED("connected.wav"),
 | 
			
		||||
    TURRET_ROTATE("turret_rotate.ogg"),
 | 
			
		||||
    TANK_SHOOT("tank_shoot.ogg")
 | 
			
		||||
    TANK_SHOOT("tank_shoot.ogg"),
 | 
			
		||||
    SHIELD("shield.ogg"),
 | 
			
		||||
    SPEED("speed.ogg"),
 | 
			
		||||
    SWAP("swap.ogg"),
 | 
			
		||||
    ;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -76,13 +76,13 @@ public void start() {
 | 
			
		||||
     * Spawns the jet model at the designated spawn point, applying material, scaling, and rotation.
 | 
			
		||||
     */
 | 
			
		||||
    private void spawnJet() {
 | 
			
		||||
        jetModel = app.getAssetManager().loadModel(Asset.jet.getModelPath());
 | 
			
		||||
        jetModel = app.getAssetManager().loadModel(Asset.jet_noGear.getModelPath());
 | 
			
		||||
        jetModel.setLocalTranslation(spawnPoint);
 | 
			
		||||
        jetModel.scale(Asset.jet.getSize());
 | 
			
		||||
        jetModel.scale(Asset.jet_noGear.getSize());
 | 
			
		||||
        jetModel.rotate(FastMath.HALF_PI, 0, 0);
 | 
			
		||||
        jetModel.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
 | 
			
		||||
        Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md");
 | 
			
		||||
        mat.setTexture("DiffuseMap", app.getAssetManager().loadTexture(Asset.jet.getDiffPath()));
 | 
			
		||||
        mat.setTexture("DiffuseMap", app.getAssetManager().loadTexture(Asset.jet_noGear.getDiffPath()));
 | 
			
		||||
        jetModel.setMaterial(mat);
 | 
			
		||||
 | 
			
		||||
        rootNode.attachChild(jetModel);
 | 
			
		||||
 
 | 
			
		||||
@@ -529,7 +529,6 @@ private void throwPiece(UUID uuid){
 | 
			
		||||
     * @param uuid the UUID of the piece to shield
 | 
			
		||||
     */
 | 
			
		||||
    public void shieldPiece(UUID uuid){
 | 
			
		||||
 | 
			
		||||
        pieces.get(uuid).activateShield();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -670,6 +669,7 @@ public void pieceSelect(PieceControl pieceSelected) {
 | 
			
		||||
        if(selectableOwnPieces.contains(pieceSelected)){
 | 
			
		||||
            for(PieceControl p : selectableOwnPieces) {
 | 
			
		||||
                p.unSelect();
 | 
			
		||||
                if(selectedPieceNodeMap.get(p) != null) selectedPieceNodeMap.get(p).unSelect();
 | 
			
		||||
            }
 | 
			
		||||
            if (!isSelected) {
 | 
			
		||||
                pieceSelected.select();
 | 
			
		||||
@@ -678,7 +678,7 @@ public void pieceSelect(PieceControl pieceSelected) {
 | 
			
		||||
            }
 | 
			
		||||
            else {
 | 
			
		||||
                pieceSelected.unSelect();
 | 
			
		||||
                if(selectedPieceNodeMap.get(pieceSelected) != null) selectedPieceNodeMap.get(pieceSelected).highlight();
 | 
			
		||||
                if(selectedPieceNodeMap.get(pieceSelected) != null) selectedPieceNodeMap.get(pieceSelected).unSelect();
 | 
			
		||||
                selectedOwnPiece = null;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
@@ -700,6 +700,16 @@ else if(selectableEnemyPieces.contains(pieceSelected)) {
 | 
			
		||||
        app.getModelSynchronize().select(getKeyByValue(pieces, selectedOwnPiece), getKeyByValue(pieces, selectedEnemyPiece));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void pieceHoverOn(PieceControl hoverPiece){
 | 
			
		||||
        hoverPiece.hover();
 | 
			
		||||
        if(selectedPieceNodeMap.get(hoverPiece) != null) selectedPieceNodeMap.get(hoverPiece).hover();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void pieceHoverOff(PieceControl hoverPiece){
 | 
			
		||||
        hoverPiece.hoverOff();
 | 
			
		||||
        if(selectedPieceNodeMap.get(hoverPiece) != null) selectedPieceNodeMap.get(hoverPiece).hoverOff();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Clears all highlighted, selectable, and selected pieces and nodes.
 | 
			
		||||
     */
 | 
			
		||||
 
 | 
			
		||||
@@ -17,7 +17,11 @@ public class NodeControl extends OutlineControl {
 | 
			
		||||
    private static final ColorRGBA OUTLINE_HIGHLIGHT_COLOR = ColorRGBA.White;
 | 
			
		||||
    private static final int OUTLINE_HIGHLIGHT_WIDTH = 6;
 | 
			
		||||
    private static final ColorRGBA OUTLINE_SELECT_COLOR = ColorRGBA.Cyan;
 | 
			
		||||
    private static final int OUTLINE_SELECT_WIDTH = 6;
 | 
			
		||||
    private static final int OUTLINE_SELECT_WIDTH = 8;
 | 
			
		||||
    private static final ColorRGBA OUTLINE_HOVER_COLOR = ColorRGBA.Yellow;
 | 
			
		||||
    private static final int OUTLINE_HOVER_WIDTH = 6;
 | 
			
		||||
    private boolean select = false;
 | 
			
		||||
    private boolean highlight = false;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Constructs a {@link NodeControl} with the specified application and post processor.
 | 
			
		||||
@@ -40,15 +44,34 @@ public Vector3f getLocation(){
 | 
			
		||||
        return this.getSpatial().getLocalTranslation();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Highlights the node by applying an outline effect.
 | 
			
		||||
     * The outline color and width are predefined as white and 6, respectively.
 | 
			
		||||
     */
 | 
			
		||||
    public void highlight() {
 | 
			
		||||
    public void highlight(){
 | 
			
		||||
        highlight = true;
 | 
			
		||||
        super.outline(OUTLINE_HIGHLIGHT_COLOR, OUTLINE_HIGHLIGHT_WIDTH);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void select() {
 | 
			
		||||
    public void unHighlight(){
 | 
			
		||||
        highlight = false;
 | 
			
		||||
        deOutline();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void select(){
 | 
			
		||||
        select = true;
 | 
			
		||||
        super.outline(OUTLINE_SELECT_COLOR, OUTLINE_SELECT_WIDTH);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void unSelect(){
 | 
			
		||||
        select = false;
 | 
			
		||||
        if(highlight) highlight();
 | 
			
		||||
        else deOutline();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void hover(){
 | 
			
		||||
        super.outline(OUTLINE_HOVER_COLOR, OUTLINE_HOVER_WIDTH);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void hoverOff(){
 | 
			
		||||
        if(select) select();
 | 
			
		||||
        else if(highlight) highlight();
 | 
			
		||||
        else deOutline();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -113,6 +113,7 @@ public Vector3f getLocation(){
 | 
			
		||||
    protected void controlUpdate(float delta) {
 | 
			
		||||
        if(shieldRing != null){
 | 
			
		||||
            shieldRing.rotate(0, 0, delta * SHIELD_SPEED);
 | 
			
		||||
            shieldRing.setLocalTranslation(spatial.getLocalTranslation().add(new Vector3f(0,0,SHIELD_Z)));
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -33,6 +33,7 @@ public class CardLayerHandler {
 | 
			
		||||
    private final Set<CardControl> selectableCards = new HashSet<>();
 | 
			
		||||
 | 
			
		||||
    private BonusCard cardSelect = null;
 | 
			
		||||
    private boolean show = false;
 | 
			
		||||
 | 
			
		||||
    public CardLayerHandler(MdgaApp app, Texture2D backTexture) {
 | 
			
		||||
        this.app = app;
 | 
			
		||||
@@ -64,11 +65,14 @@ public void rollDice(int rollNum, Runnable actionAfter) {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void showDice() {
 | 
			
		||||
        if(show) return;
 | 
			
		||||
        show = true;
 | 
			
		||||
        cardLayer.addSpatial(diceControl.getSpatial());
 | 
			
		||||
        diceControl.spin();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void hideDice() {
 | 
			
		||||
        show = false;
 | 
			
		||||
        diceControl.hide();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -11,6 +11,7 @@
 | 
			
		||||
import com.jme3.scene.Spatial;
 | 
			
		||||
import com.jme3.scene.control.AbstractControl;
 | 
			
		||||
import pp.mdga.client.Asset;
 | 
			
		||||
import pp.mdga.client.MdgaApp;
 | 
			
		||||
 | 
			
		||||
import java.util.Random;
 | 
			
		||||
 | 
			
		||||
@@ -51,8 +52,7 @@ protected void controlUpdate(float tpf) {
 | 
			
		||||
                );
 | 
			
		||||
 | 
			
		||||
                // Stop rolling when angular velocity is close to zero
 | 
			
		||||
//                if (angularVelocity.lengthSquared() < 3f) {
 | 
			
		||||
                if(true){
 | 
			
		||||
                if (angularVelocity.lengthSquared() <= 3f || MdgaApp.DEBUG_MULTIPLIER == 0) {
 | 
			
		||||
                    slerp = true;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
@@ -66,14 +66,13 @@ protected void controlUpdate(float tpf) {
 | 
			
		||||
                spatial.setLocalRotation(interpolated);
 | 
			
		||||
 | 
			
		||||
                // Stop rolling once duration is complete
 | 
			
		||||
//                if (timeElapsed >= 1.0f) {
 | 
			
		||||
                if(true){
 | 
			
		||||
              if (timeElapsed >= 1.0f * MdgaApp.DEBUG_MULTIPLIER) {
 | 
			
		||||
                    isRolling = false;
 | 
			
		||||
                    slerp = false;
 | 
			
		||||
                    actionAfter.run();
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }else if(spin){
 | 
			
		||||
        } else if(spin){
 | 
			
		||||
            spinWithAngularVelocity(clampedTpf);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -52,6 +52,7 @@ public void rollDice(int rollNum, int mult) {
 | 
			
		||||
            else actionTextHandler.ownDiceMult(rollNum, mult);
 | 
			
		||||
            hideDice();
 | 
			
		||||
            app.getModelSynchronize().animationEnd();
 | 
			
		||||
            app.getModelSynchronize().animationEnd();
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -153,6 +153,7 @@ private void initializeSerializables() {
 | 
			
		||||
        Serializer.registerClass(ShieldCard.class);
 | 
			
		||||
        Serializer.registerClass(HiddenCard.class);
 | 
			
		||||
        Serializer.registerClass(ChoosePieceStateMessage.class);
 | 
			
		||||
        Serializer.registerClass(DrawCardMessage.class);
 | 
			
		||||
 | 
			
		||||
        Serializer.registerClass(Color.class, new EnumSerializer());
 | 
			
		||||
        Serializer.registerClass(PieceState.class, new EnumSerializer());
 | 
			
		||||
 
 | 
			
		||||
@@ -14,13 +14,22 @@ public <T> T readObject(ByteBuffer data, Class<T> c) throws IOException
 | 
			
		||||
    byte[] uuid = new byte[36];
 | 
			
		||||
    data.get(uuid);
 | 
			
		||||
 | 
			
		||||
    return (T) UUID.fromString(new String(uuid));
 | 
			
		||||
    if(uuid.equals(new UUID(1, 1))) {
 | 
			
		||||
        return null;
 | 
			
		||||
    } else {
 | 
			
		||||
        return (T) UUID.fromString(new String(uuid));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void writeObject(ByteBuffer buffer, Object object) throws IOException
 | 
			
		||||
    {
 | 
			
		||||
        UUID uuid = (UUID) object;
 | 
			
		||||
        buffer.put(uuid.toString().getBytes());
 | 
			
		||||
 | 
			
		||||
        if(uuid != null) {
 | 
			
		||||
            buffer.put(uuid.toString().getBytes());
 | 
			
		||||
        } else {
 | 
			
		||||
            buffer.put(new UUID(1, 1).toString().getBytes());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								Projekte/mdga/client/src/main/resources/Sounds/shield.ogg
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Projekte/mdga/client/src/main/resources/Sounds/shield.ogg
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								Projekte/mdga/client/src/main/resources/Sounds/speed.ogg
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Projekte/mdga/client/src/main/resources/Sounds/speed.ogg
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								Projekte/mdga/client/src/main/resources/Sounds/swap.ogg
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Projekte/mdga/client/src/main/resources/Sounds/swap.ogg
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							@@ -424,6 +424,14 @@ public void received(ChoosePieceStateMessage choosePieceStateMessage) {
 | 
			
		||||
        state.received(choosePieceStateMessage);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param drawCardMessage
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(DrawCardMessage drawCardMessage) {
 | 
			
		||||
        state.received(drawCardMessage);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method calls the method received of the state
 | 
			
		||||
     *
 | 
			
		||||
 
 | 
			
		||||
@@ -100,6 +100,11 @@ public void received(ChoosePieceStateMessage msg) {
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(DrawCardMessage msg){
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(MoveMessage msg) {
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
 | 
			
		||||
 
 | 
			
		||||
@@ -3,8 +3,14 @@
 | 
			
		||||
import pp.mdga.client.gamestate.*;
 | 
			
		||||
import pp.mdga.game.BonusCard;
 | 
			
		||||
import pp.mdga.game.Piece;
 | 
			
		||||
import pp.mdga.game.card.HiddenCard;
 | 
			
		||||
import pp.mdga.game.card.ShieldCard;
 | 
			
		||||
import pp.mdga.game.card.SwapCard;
 | 
			
		||||
import pp.mdga.game.card.TurboCard;
 | 
			
		||||
import pp.mdga.message.client.LeaveGameMessage;
 | 
			
		||||
import pp.mdga.message.server.*;
 | 
			
		||||
import pp.mdga.notification.AcquireCardNotification;
 | 
			
		||||
import pp.mdga.notification.DrawCardNotification;
 | 
			
		||||
import pp.mdga.notification.InterruptNotification;
 | 
			
		||||
import pp.mdga.notification.StartDialogNotification;
 | 
			
		||||
 | 
			
		||||
@@ -286,6 +292,21 @@ public void received(ChoosePieceStateMessage msg){
 | 
			
		||||
        state.received(msg);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(DrawCardMessage msg){
 | 
			
		||||
        if(msg.getCard() instanceof HiddenCard){
 | 
			
		||||
            logic.addNotification(new DrawCardNotification(logic.getGame().getActiveColor(), BonusCard.HIDDEN));
 | 
			
		||||
        } else if(msg.getCard() instanceof TurboCard) {
 | 
			
		||||
            logic.addNotification(new AcquireCardNotification(BonusCard.TURBO));
 | 
			
		||||
        } else if(msg.getCard() instanceof ShieldCard) {
 | 
			
		||||
            logic.addNotification(new AcquireCardNotification(BonusCard.SHIELD));
 | 
			
		||||
        } else if(msg.getCard() instanceof SwapCard) {
 | 
			
		||||
            logic.addNotification(new AcquireCardNotification(BonusCard.SWAP));
 | 
			
		||||
        } else {
 | 
			
		||||
            throw new RuntimeException();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method returns the current state
 | 
			
		||||
     *
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,9 @@
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
import pp.mdga.game.Board;
 | 
			
		||||
import pp.mdga.game.BonusCard;
 | 
			
		||||
import pp.mdga.game.Node;
 | 
			
		||||
import pp.mdga.game.Piece;
 | 
			
		||||
import pp.mdga.game.PieceState;
 | 
			
		||||
import pp.mdga.game.ShieldState;
 | 
			
		||||
@@ -12,6 +14,7 @@
 | 
			
		||||
import pp.mdga.notification.SwapPieceNotification;
 | 
			
		||||
import pp.mdga.notification.ThrowPieceNotification;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.UUID;
 | 
			
		||||
 | 
			
		||||
public abstract class GameStates extends ClientState {
 | 
			
		||||
@@ -24,17 +27,12 @@ public GameStates(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
 | 
			
		||||
    protected void handlePowerCard(PlayCardMessage msg) {
 | 
			
		||||
        if (msg.getCard().getCard().equals(BonusCard.TURBO)) {
 | 
			
		||||
            logic.getGame().setTurboFlag(true);
 | 
			
		||||
            logic.getGame().setDiceModifier(msg.getDiceModifier());
 | 
			
		||||
        } else if (msg.getCard().getCard().equals(BonusCard.SHIELD)) {
 | 
			
		||||
            handleShield(msg.getPieces().get(0).getUuid());
 | 
			
		||||
        } else {
 | 
			
		||||
            Piece ownPiece = logic.getGame().getPieceThroughUUID(msg.getPieces().get(0).getUuid());
 | 
			
		||||
            Piece enemyPiece = logic.getGame().getPieceThroughUUID(msg.getPieces().get(1).getUuid());
 | 
			
		||||
            LOGGER.log(System.Logger.Level.INFO, "Swapping");
 | 
			
		||||
            int ownIndex = logic.getGame().getBoard().getInfieldIndexOfPiece(ownPiece);
 | 
			
		||||
            logic.addNotification(new SwapPieceNotification(ownPiece.getUuid(), enemyPiece.getUuid()));
 | 
			
		||||
            logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(enemyPiece)].setOccupant(ownPiece);
 | 
			
		||||
            logic.getGame().getBoard().getInfield()[ownIndex].setOccupant(enemyPiece);
 | 
			
		||||
            swapPieces(msg.getPieces().get(0), msg.getPieces().get(1));
 | 
			
		||||
        }
 | 
			
		||||
        logic.getGame().getDiscardPile().add(msg.getCard());
 | 
			
		||||
    }
 | 
			
		||||
@@ -57,4 +55,17 @@ private void handleShield(UUID uuid) {
 | 
			
		||||
            logic.addNotification(new ShieldActiveNotification(uuid));
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void swapPieces(Piece messageOwn, Piece messageEnemy) {
 | 
			
		||||
        //swap Pieces in Model
 | 
			
		||||
        Board board = logic.getGame().getBoard();
 | 
			
		||||
        Piece modelOwn = logic.getGame().getPieceThroughUUID(messageOwn.getUuid());
 | 
			
		||||
        Piece modelEnemy = logic.getGame().getPieceThroughUUID(messageEnemy.getUuid());
 | 
			
		||||
        Node ownNode = board.getInfield()[board.getInfieldIndexOfPiece(modelOwn)];
 | 
			
		||||
        Node enemyNode = board.getInfield()[board.getInfieldIndexOfPiece(modelEnemy)];
 | 
			
		||||
 | 
			
		||||
        ownNode.setOccupant(modelEnemy);
 | 
			
		||||
        enemyNode.setOccupant(modelOwn);
 | 
			
		||||
        logic.addNotification(new SwapPieceNotification(modelOwn.getUuid(), modelEnemy.getUuid()));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -31,6 +31,13 @@ public void received(CeremonyMessage msg) {
 | 
			
		||||
        logic.setState(logic.getCeremony());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(DrawCardMessage msg){
 | 
			
		||||
        logic.addNotification(new DrawCardNotification(logic.getGame().getActiveColor(), msg.getCard().getCard()));
 | 
			
		||||
        logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseActivatedBonusNodes();
 | 
			
		||||
        logic.getGame().getGameStatistics().increaseActivatedBonusNodes();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(DieMessage msg) {
 | 
			
		||||
        //logic.getGame().setDiceEyes(msg.getDiceEye());
 | 
			
		||||
@@ -87,6 +94,7 @@ public void received(MoveMessage msg) {
 | 
			
		||||
            //set new node
 | 
			
		||||
            logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].setOccupant(piece);
 | 
			
		||||
        }
 | 
			
		||||
        logic.getGame().setTurboFlag(false);
 | 
			
		||||
        parent.setState(parent.getAnimation());
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -11,7 +11,15 @@
 | 
			
		||||
import pp.mdga.client.gamestate.turnstate.TurnStates;
 | 
			
		||||
import pp.mdga.game.BonusCard;
 | 
			
		||||
import pp.mdga.game.Piece;
 | 
			
		||||
import pp.mdga.game.ShieldState;
 | 
			
		||||
import pp.mdga.game.card.HiddenCard;
 | 
			
		||||
import pp.mdga.game.card.ShieldCard;
 | 
			
		||||
import pp.mdga.game.card.SwapCard;
 | 
			
		||||
import pp.mdga.game.card.TurboCard;
 | 
			
		||||
import pp.mdga.message.server.*;
 | 
			
		||||
import pp.mdga.notification.RemoveShieldNotification;
 | 
			
		||||
import pp.mdga.notification.AcquireCardNotification;
 | 
			
		||||
import pp.mdga.notification.DrawCardNotification;
 | 
			
		||||
 | 
			
		||||
public class TurnState extends GameStates {
 | 
			
		||||
 | 
			
		||||
@@ -23,6 +31,7 @@ public class TurnState extends GameStates {
 | 
			
		||||
    private final PlayPowerCardState playPowerCardState = new PlayPowerCardState(this, logic);
 | 
			
		||||
    private final PowerCardState powerCardState = new PowerCardState(this, logic);
 | 
			
		||||
    private final RollDiceState rollDiceState = new RollDiceState(this, logic);
 | 
			
		||||
    private boolean canChangeTurbo = false;
 | 
			
		||||
 | 
			
		||||
    public TurnState(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
@@ -31,6 +40,13 @@ public TurnState(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void enter() {
 | 
			
		||||
        for (Piece piece : logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPieces()) {
 | 
			
		||||
            if (piece.isShielded() || piece.isSuppressed()){
 | 
			
		||||
                piece.setShield(ShieldState.NONE);
 | 
			
		||||
                logic.addNotification(new RemoveShieldNotification(piece.getUuid()));
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        logic.getGame().setTurboFlag(false);
 | 
			
		||||
        this.setState(this.powerCardState);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -143,6 +159,11 @@ public void received(ChoosePieceStateMessage msg){
 | 
			
		||||
        state.received(msg);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(DrawCardMessage msg){
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public ChoosePieceState getChoosePiece() {
 | 
			
		||||
        return choosePieceState;
 | 
			
		||||
    }
 | 
			
		||||
@@ -170,4 +191,12 @@ public GameState getParent(){
 | 
			
		||||
    public TurnStates getState(){
 | 
			
		||||
        return state;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean isCanChangeTurbo() {
 | 
			
		||||
        return canChangeTurbo;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setCanChangeTurbo(boolean canChangeTurbo) {
 | 
			
		||||
        this.canChangeTurbo = canChangeTurbo;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -42,7 +42,16 @@ public void received(DiceNowMessage msg) {
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(DieMessage msg) {
 | 
			
		||||
        logic.getGame().setDiceEyes(msg.getDiceEye());
 | 
			
		||||
        logic.addNotification(new RollDiceNotification(logic.getGame().getActiveColor(), logic.getGame().getDiceEyes()));
 | 
			
		||||
        if(logic.getGame().getTurboFlag()){
 | 
			
		||||
            logic.addNotification(new RollDiceNotification(logic.getGame().getActiveColor(), msg.getDiceEye(), logic.getGame().getDiceModifier()));
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            logic.addNotification(new RollDiceNotification(logic.getGame().getActiveColor(), msg.getDiceEye()));
 | 
			
		||||
        }
 | 
			
		||||
//        logic.addNotification(new RollDiceNotification(logic.getGame().getActiveColor(), logic.getGame().getDiceEyes()));
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        //stats
 | 
			
		||||
        if (msg.getDiceEye() == 6) {
 | 
			
		||||
            logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseDiced6();
 | 
			
		||||
            logic.getGame().getGameStatistics().increaseDiced6();
 | 
			
		||||
@@ -67,6 +76,13 @@ public void received(ActivePlayerMessage msg) {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
//    @Override
 | 
			
		||||
//    public void received(DrawCardMessage msg){
 | 
			
		||||
//        logic.addNotification(new DrawCardNotification(logic.getGame().getActiveColor(), msg.getCard().getCard()));
 | 
			
		||||
//        logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseActivatedBonusNodes();
 | 
			
		||||
//        logic.getGame().getGameStatistics().increaseActivatedBonusNodes();
 | 
			
		||||
//    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(MoveMessage msg) {
 | 
			
		||||
        Piece piece = logic.getGame().getPieceThroughUUID(msg.getPiece().getUuid());
 | 
			
		||||
@@ -95,6 +111,7 @@ public void received(MoveMessage msg) {
 | 
			
		||||
            //set new node
 | 
			
		||||
            logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].setOccupant(piece);
 | 
			
		||||
        }
 | 
			
		||||
        logic.getGame().setTurboFlag(false);
 | 
			
		||||
        parent.setState(parent.getAnimation());
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -6,6 +6,7 @@
 | 
			
		||||
import pp.mdga.message.client.AnimationEndMessage;
 | 
			
		||||
import pp.mdga.message.client.RequestDieMessage;
 | 
			
		||||
import pp.mdga.message.server.ChoosePieceStateMessage;
 | 
			
		||||
import pp.mdga.message.server.DiceNowMessage;
 | 
			
		||||
import pp.mdga.message.server.DieMessage;
 | 
			
		||||
import pp.mdga.message.server.NoTurnMessage;
 | 
			
		||||
import pp.mdga.notification.DiceNowNotification;
 | 
			
		||||
@@ -42,7 +43,14 @@ public void selectDice(){
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(DieMessage msg){
 | 
			
		||||
        logic.getGame().setDiceEyes(msg.getDiceEye());
 | 
			
		||||
        logic.addNotification(new RollDiceNotification(logic.getGame().getPlayerById(logic.getOwnPlayerId()).getColor(), msg.getDiceEye(),false));
 | 
			
		||||
 | 
			
		||||
        if(logic.getGame().getTurboFlag()){
 | 
			
		||||
            logic.addNotification(new RollDiceNotification(logic.getGame().getPlayerById(logic.getOwnPlayerId()).getColor(), msg.getDiceEye(), logic.getGame().getDiceModifier()));
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            logic.addNotification(new RollDiceNotification(logic.getGame().getPlayerById(logic.getOwnPlayerId()).getColor(), msg.getDiceEye()));
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
@@ -59,4 +67,9 @@ public void received(ChoosePieceStateMessage msg){
 | 
			
		||||
    public void received(NoTurnMessage msg){
 | 
			
		||||
        parent.getParent().setState(parent.getParent().getWaiting());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(DiceNowMessage msg){
 | 
			
		||||
        logic.addNotification(new DiceNowNotification());
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -41,8 +41,9 @@ public void received(SelectPieceMessage msg) {
 | 
			
		||||
        //TODO
 | 
			
		||||
        ArrayList<Piece> pieces = msg.getPieces().stream().map(piece -> logic.getGame().getPieceThroughUUID(piece.getUuid())).collect(Collectors.toCollection(ArrayList::new));
 | 
			
		||||
        parent.getSelectPiece().setPossiblePieces(pieces);
 | 
			
		||||
        ArrayList<UUID> listPiece = pieces.stream().map(Piece::getUuid).collect(Collectors.toCollection(ArrayList::new));
 | 
			
		||||
        LOGGER.log(System.Logger.Level.INFO, "Received " + msg.getPieces().size() + " pieces");
 | 
			
		||||
        logic.addNotification(new SelectableMoveNotification(pieces.stream().map(Piece::getUuid).collect(Collectors.toCollection(ArrayList::new)), msg.getTargetIndex(), msg.getIsHomeMove()));
 | 
			
		||||
        logic.addNotification(new SelectableMoveNotification(listPiece, msg.getTargetIndex(), msg.getIsHomeMove()));
 | 
			
		||||
        parent.setState(parent.getSelectPiece());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -71,6 +72,7 @@ public void received(StartPieceMessage msg){
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(NoTurnMessage msg){
 | 
			
		||||
        logic.getGame().setTurboFlag(false);
 | 
			
		||||
        parent.getParent().getParent().setState(parent.getParent().getParent().getWaiting());
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -71,7 +71,7 @@ public void received(MoveMessage msg) {
 | 
			
		||||
            //set new node
 | 
			
		||||
            logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].setOccupant(piece);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        logic.getGame().setTurboFlag(false);
 | 
			
		||||
        parent.getParent().setState(parent.getParent().getMovePiece());
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -65,7 +65,7 @@ public void received(MoveMessage msg){
 | 
			
		||||
 | 
			
		||||
        targetNode.setOccupant(msg.getPiece());
 | 
			
		||||
        logic.addNotification(new MovePieceNotification(msg.getPiece().getUuid(), oldIndex, targetIndex));
 | 
			
		||||
 | 
			
		||||
        logic.getGame().setTurboFlag(false);
 | 
			
		||||
        parent.getParent().setState(parent.getParent().getMovePiece());
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -49,7 +49,7 @@ public void received(MoveMessage msg){
 | 
			
		||||
 | 
			
		||||
        logic.addNotification(new MovePieceNotification(pieceToMove.getUuid(), logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getStartNodeIndex(), true));
 | 
			
		||||
        logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].setOccupant(msg.getPiece());
 | 
			
		||||
 | 
			
		||||
        logic.getGame().setTurboFlag(false);
 | 
			
		||||
        pieceToMove.setState(PieceState.ACTIVE);
 | 
			
		||||
        parent.getParent().setState(parent.getParent().getMovePiece());
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -4,6 +4,7 @@
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
import pp.mdga.client.gamestate.turnstate.PowerCardState;
 | 
			
		||||
import pp.mdga.game.BonusCard;
 | 
			
		||||
import pp.mdga.game.Piece;
 | 
			
		||||
import pp.mdga.game.card.*;
 | 
			
		||||
import pp.mdga.message.client.NoPowerCardMessage;
 | 
			
		||||
import pp.mdga.message.client.SelectCardMessage;
 | 
			
		||||
@@ -12,6 +13,7 @@
 | 
			
		||||
import pp.mdga.message.server.PossibleCardsMessage;
 | 
			
		||||
import pp.mdga.message.server.PossiblePieceMessage;
 | 
			
		||||
import pp.mdga.notification.SelectableCardsNotification;
 | 
			
		||||
import pp.mdga.notification.SelectableShieldNotification;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.stream.Collectors;
 | 
			
		||||
@@ -85,7 +87,9 @@ public void selectCard(BonusCard card){
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(PlayCardMessage msg){
 | 
			
		||||
        if(msg.getCard().getCard().equals(BonusCard.TURBO)){
 | 
			
		||||
            logic.getGame().setDiceModifier(msg.getDiceModifier());
 | 
			
		||||
            parent.getParent().getPlayPowerCard().setPlayCard(msg);
 | 
			
		||||
            logic.getGame().setTurboFlag(true);
 | 
			
		||||
            parent.getParent().setState(parent.getParent().getPlayPowerCard());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
@@ -108,6 +112,7 @@ public void received(PossiblePieceMessage msg){
 | 
			
		||||
        if (msg.getEnemyPossiblePieces().isEmpty()){
 | 
			
		||||
            parent.getShield().setPossiblePieces(msg.getOwnPossiblePieces().stream().map(piece -> logic.getGame().getPieceThroughUUID(piece.getUuid())).collect(Collectors.toCollection(ArrayList::new)));
 | 
			
		||||
            parent.setState(parent.getShield());
 | 
			
		||||
            logic.addNotification(new SelectableShieldNotification(msg.getOwnPossiblePieces().stream().map(Piece::getUuid).toList()));
 | 
			
		||||
        } else {
 | 
			
		||||
            System.out.println("Should enter Swap State");
 | 
			
		||||
            parent.getSwap().setPossibleOwnPieces(msg.getOwnPossiblePieces().stream().map(piece -> logic.getGame().getPieceThroughUUID(piece.getUuid())).collect(Collectors.toCollection(ArrayList::new)));
 | 
			
		||||
 
 | 
			
		||||
@@ -5,10 +5,12 @@
 | 
			
		||||
import pp.mdga.client.gamestate.turnstate.PowerCardState;
 | 
			
		||||
import pp.mdga.game.Piece;
 | 
			
		||||
import pp.mdga.message.client.RequestPlayCardMessage;
 | 
			
		||||
import pp.mdga.message.client.SelectedPiecesMessage;
 | 
			
		||||
import pp.mdga.message.server.PlayCardMessage;
 | 
			
		||||
 | 
			
		||||
import java.lang.System.Logger.Level;
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
public class ShieldState extends PowerCardStates {
 | 
			
		||||
 | 
			
		||||
@@ -40,7 +42,10 @@ public void setPossiblePieces(ArrayList<Piece> possiblePieces) {
 | 
			
		||||
 | 
			
		||||
    public void selectPiece(Piece piece) {
 | 
			
		||||
        if (possiblePieces.contains(piece)) {
 | 
			
		||||
            logic.send(RequestPlayCardMessage.requestPlayShield(piece.getUuid()));
 | 
			
		||||
//            logic.send(RequestPlayCardMessage.requestPlayShield(piece.getUuid()));
 | 
			
		||||
            ArrayList<Piece> temp = new ArrayList<>();
 | 
			
		||||
            temp.add(piece);
 | 
			
		||||
            logic.send(new SelectedPiecesMessage(temp));
 | 
			
		||||
        } else {
 | 
			
		||||
            LOGGER.log(Level.DEBUG, "Invalid piece selected");
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -13,4 +13,9 @@ public class BonusNode extends Node {
 | 
			
		||||
    BonusNode() {
 | 
			
		||||
        super(null);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean isBonus() {
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -78,6 +78,8 @@ public class Game {
 | 
			
		||||
     */
 | 
			
		||||
    private int diceEyes;
 | 
			
		||||
 | 
			
		||||
    private boolean turboFlag = false;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This constructor creates a new Game object.
 | 
			
		||||
     */
 | 
			
		||||
@@ -85,7 +87,7 @@ public Game() {
 | 
			
		||||
        gameStatistics = new Statistic();
 | 
			
		||||
        initializeDrawPile();
 | 
			
		||||
        board = new Board();
 | 
			
		||||
        die = new Die(5,5,5,5,5,5,5,5,5,1,1,6,2,4,6,5,5,5,5,5);
 | 
			
		||||
        die = new Die(2,5,6,3,6);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -309,6 +311,14 @@ public boolean isHost() {
 | 
			
		||||
        return this.host != -1;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setTurboFlag(boolean flag) {
 | 
			
		||||
        this.turboFlag = flag;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean getTurboFlag() {
 | 
			
		||||
        return this.turboFlag;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method returns the players.
 | 
			
		||||
     *
 | 
			
		||||
 
 | 
			
		||||
@@ -49,6 +49,10 @@ public void setOccupant(Piece occupant) {
 | 
			
		||||
        this.occupant = occupant;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean isBonus(){
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method handles the event when a new occupant is moved to the node,
 | 
			
		||||
     * it then returns the old occupant.
 | 
			
		||||
 
 | 
			
		||||
@@ -114,6 +114,8 @@ public void removeHandCard(PowerCard card) {
 | 
			
		||||
     * @param piece as the piece which should be added to the waitingArea attribute of Player class as a Piece object.
 | 
			
		||||
     */
 | 
			
		||||
    public void addWaitingPiece(Piece piece) {
 | 
			
		||||
        piece.setState(PieceState.WAITING);
 | 
			
		||||
 | 
			
		||||
        for (int i = 0; i < Resources.MAX_PIECES; i++) {
 | 
			
		||||
            if (this.waitingArea[i] == null) {
 | 
			
		||||
                this.waitingArea[i] = piece;
 | 
			
		||||
 
 | 
			
		||||
@@ -41,9 +41,9 @@ public RequestPlayCardMessage(BonusCard card, UUID ownPieceIdentifier, UUID enem
 | 
			
		||||
     * Default constructor for serialization purposes.
 | 
			
		||||
     */
 | 
			
		||||
    private RequestPlayCardMessage() {
 | 
			
		||||
        card = null;
 | 
			
		||||
        ownPieceIdentifier = null;
 | 
			
		||||
        enemyPieceIdentifier = null;
 | 
			
		||||
        card = BonusCard.HIDDEN;
 | 
			
		||||
        ownPieceIdentifier = UUID.randomUUID();
 | 
			
		||||
        enemyPieceIdentifier = UUID.randomUUID();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,39 @@
 | 
			
		||||
package pp.mdga.message.server;
 | 
			
		||||
 | 
			
		||||
import com.jme3.network.serializing.Serializable;
 | 
			
		||||
import pp.mdga.game.card.PowerCard;
 | 
			
		||||
 | 
			
		||||
@Serializable
 | 
			
		||||
public class DrawCardMessage extends  ServerMessage{
 | 
			
		||||
 | 
			
		||||
    private final PowerCard card;
 | 
			
		||||
 | 
			
		||||
    public DrawCardMessage(PowerCard card){
 | 
			
		||||
        super();
 | 
			
		||||
        this.card = card;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private DrawCardMessage(){
 | 
			
		||||
        super();
 | 
			
		||||
        card = null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Accepts a visitor to process this message.
 | 
			
		||||
     *
 | 
			
		||||
     * @param interpreter the visitor to process this message
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public void accept(ServerInterpreter interpreter) {
 | 
			
		||||
        interpreter.received(this);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public PowerCard getCard(){
 | 
			
		||||
        return card;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toString() {
 | 
			
		||||
        return "DrawCardMessage{" + "PowerCard=" + card +'}';
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -223,4 +223,6 @@ public interface ServerInterpreter {
 | 
			
		||||
    void received(IncorrectRequestMessage msg);
 | 
			
		||||
 | 
			
		||||
    void received(ChoosePieceStateMessage choosePieceStateMessage);
 | 
			
		||||
 | 
			
		||||
    void received(DrawCardMessage drawCardMessage);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,29 +0,0 @@
 | 
			
		||||
package pp.mdga.notification;
 | 
			
		||||
 | 
			
		||||
import java.util.UUID;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Notification that a piece has no shield.
 | 
			
		||||
 */
 | 
			
		||||
public class NoShieldNotification extends Notification{
 | 
			
		||||
    /**
 | 
			
		||||
     * The id of the piece that has no shield.
 | 
			
		||||
     */
 | 
			
		||||
    private final UUID pieceId;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Constructor.
 | 
			
		||||
     * @param pieceId the id of the piece that has no shield.
 | 
			
		||||
     */
 | 
			
		||||
    public NoShieldNotification(UUID pieceId) {
 | 
			
		||||
        this.pieceId = pieceId;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get the id of the piece that has no shield.
 | 
			
		||||
     * @return the id of the piece that has no shield.
 | 
			
		||||
     */
 | 
			
		||||
    public UUID getPieceId() {
 | 
			
		||||
        return pieceId;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,15 @@
 | 
			
		||||
package pp.mdga.notification;
 | 
			
		||||
 | 
			
		||||
import java.util.UUID;
 | 
			
		||||
 | 
			
		||||
public class RemoveShieldNotification extends Notification {
 | 
			
		||||
    private final UUID pieceUuid;
 | 
			
		||||
 | 
			
		||||
    public RemoveShieldNotification(UUID pieceUuid) {
 | 
			
		||||
        this.pieceUuid = pieceUuid;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public UUID getPieceUuid() {
 | 
			
		||||
        return pieceUuid;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -13,6 +13,7 @@ public class RollDiceNotification extends Notification{
 | 
			
		||||
    private int multiplier;
 | 
			
		||||
    private boolean isRanking;
 | 
			
		||||
 | 
			
		||||
    //normal
 | 
			
		||||
    /**
 | 
			
		||||
     * Constructor.
 | 
			
		||||
     * @param color the color of the player that rolled the die.
 | 
			
		||||
@@ -26,6 +27,7 @@ public RollDiceNotification(Color color, int eyes) {
 | 
			
		||||
        this.isRanking = false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    //ranking
 | 
			
		||||
    public RollDiceNotification(Color color, int eyes, boolean isRanking) {
 | 
			
		||||
        this.color = color;
 | 
			
		||||
        this.eyes = eyes;
 | 
			
		||||
@@ -34,10 +36,11 @@ public RollDiceNotification(Color color, int eyes, boolean isRanking) {
 | 
			
		||||
        this.isRanking = isRanking;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public RollDiceNotification(Color color, int eyes, boolean turbo, int multiplier) {
 | 
			
		||||
    //turbo
 | 
			
		||||
    public RollDiceNotification(Color color, int eyes, int multiplier) {
 | 
			
		||||
        this.color = color;
 | 
			
		||||
        this.eyes = eyes;
 | 
			
		||||
        this.turbo = turbo;
 | 
			
		||||
        this.turbo = true;
 | 
			
		||||
        this.multiplier = multiplier;
 | 
			
		||||
        this.isRanking = false;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,8 @@
 | 
			
		||||
package pp.mdga.server.automaton.game;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.game.Piece;
 | 
			
		||||
import pp.mdga.game.Player;
 | 
			
		||||
import pp.mdga.game.ShieldState;
 | 
			
		||||
import pp.mdga.message.client.*;
 | 
			
		||||
import pp.mdga.server.ServerGameLogic;
 | 
			
		||||
import pp.mdga.server.automaton.GameState;
 | 
			
		||||
@@ -52,6 +54,9 @@ public TurnState(GameState gameAutomaton, ServerGameLogic logic) {
 | 
			
		||||
    public void enter() {
 | 
			
		||||
        LOGGER.log(Level.INFO, "Entered TurnState state.");
 | 
			
		||||
        this.player = this.logic.getGame().getPlayerById(this.logic.getGame().getActivePlayerId());
 | 
			
		||||
        for (Piece piece : this.player.getPieces()) {
 | 
			
		||||
            piece.setShield(ShieldState.NONE);
 | 
			
		||||
        }
 | 
			
		||||
        this.setCurrentState(this.powerCardState);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -32,7 +32,6 @@ public PlayPowerCardState(TurnState turnAutomaton, ServerGameLogic logic) {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void enter() {
 | 
			
		||||
 | 
			
		||||
        LOGGER.log(System.Logger.Level.DEBUG, "Entered PlayPowerCardState state.");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -22,6 +22,7 @@ public class RollDiceState extends TurnAutomatonState {
 | 
			
		||||
    private final FirstRollState firstRollState;
 | 
			
		||||
    private final SecondRollState secondRollState;
 | 
			
		||||
    private final ThirdRollState thirdRollState;
 | 
			
		||||
    private boolean resetModifier = true;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Constructs a server state of the specified game logic.
 | 
			
		||||
@@ -39,12 +40,16 @@ public RollDiceState(TurnState turnAutomaton, ServerGameLogic logic) {
 | 
			
		||||
    @Override
 | 
			
		||||
    public void enter() {
 | 
			
		||||
        LOGGER.log(System.Logger.Level.DEBUG, "Entered RollDiceState state.");
 | 
			
		||||
        if (resetModifier){
 | 
			
		||||
            logic.getGame().setDiceModifier(1);
 | 
			
		||||
        }
 | 
			
		||||
        this.setCurrentState(this.firstRollState);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void exit() {
 | 
			
		||||
        LOGGER.log(System.Logger.Level.DEBUG, "Exited RollDiceState state.");
 | 
			
		||||
        resetModifier = true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -73,6 +78,10 @@ public RollDiceAutomatonState getCurrentState() {
 | 
			
		||||
        return this.currentState;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setResetModifier(boolean resetModifier) {
 | 
			
		||||
        this.resetModifier = resetModifier;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method will be used to return firstRollState attribute of RollDiceState class.
 | 
			
		||||
     *
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,5 @@
 | 
			
		||||
package pp.mdga.server.automaton.game.turn.choosepiece;
 | 
			
		||||
 | 
			
		||||
import com.jme3.util.SortUtil;
 | 
			
		||||
import pp.mdga.game.*;
 | 
			
		||||
import pp.mdga.message.client.AnimationEndMessage;
 | 
			
		||||
import pp.mdga.server.ServerGameLogic;
 | 
			
		||||
@@ -71,7 +70,10 @@ private boolean canInfieldMove(Piece piece, int steps) {
 | 
			
		||||
        int pieceIndex = logic.getGame().getBoard().getInfieldIndexOfPiece(piece);
 | 
			
		||||
        int moveIndex = (pieceIndex + steps) % logic.getGame().getBoard().getInfield().length;
 | 
			
		||||
        Piece occupant = logic.getGame().getBoard().getInfield()[moveIndex].getOccupant();
 | 
			
		||||
        if (occupant != null) {
 | 
			
		||||
        if (occupant != null){
 | 
			
		||||
            if (occupant.isShielded()){
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
            return occupant.getColor() != piece.getColor();
 | 
			
		||||
        }
 | 
			
		||||
        return true;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,9 @@
 | 
			
		||||
package pp.mdga.server.automaton.game.turn.choosepiece;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.game.*;
 | 
			
		||||
import pp.mdga.game.card.HiddenCard;
 | 
			
		||||
import pp.mdga.message.client.RequestMoveMessage;
 | 
			
		||||
import pp.mdga.message.server.DrawCardMessage;
 | 
			
		||||
import pp.mdga.message.server.MoveMessage;
 | 
			
		||||
import pp.mdga.message.server.SelectPieceMessage;
 | 
			
		||||
import pp.mdga.server.ServerGameLogic;
 | 
			
		||||
@@ -165,6 +167,17 @@ public void received(RequestMoveMessage msg, int from){
 | 
			
		||||
            movePiece.setShield(ShieldState.NONE);
 | 
			
		||||
        } else {
 | 
			
		||||
            Node targetNode = logic.getGame().getBoard().getInfield()[targIdx];
 | 
			
		||||
            //TODO durch merge auskommentiert
 | 
			
		||||
            if(targetNode.isBonus()) {
 | 
			
		||||
                for (Player p : logic.getGame().getPlayersAsList()) {
 | 
			
		||||
                    if(p.getColor() == logic.getGame().getActiveColor()) {
 | 
			
		||||
                        logic.getServerSender().send(logic.getGame().getPlayerIdByColor(p.getColor()), new DrawCardMessage(logic.getGame().draw()));
 | 
			
		||||
                    } else {
 | 
			
		||||
                        logic.getServerSender().send(logic.getGame().getPlayerIdByColor(p.getColor()), new DrawCardMessage(new HiddenCard()));
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            Piece occ = targetNode.getOccupant();
 | 
			
		||||
            if (occ != null) {
 | 
			
		||||
                logic.getGame().getPlayerByColor(occ.getColor()).addWaitingPiece(occ);
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,10 @@
 | 
			
		||||
 | 
			
		||||
import pp.mdga.game.Node;
 | 
			
		||||
import pp.mdga.game.Piece;
 | 
			
		||||
import pp.mdga.game.Player;
 | 
			
		||||
import pp.mdga.game.card.HiddenCard;
 | 
			
		||||
import pp.mdga.message.client.RequestMoveMessage;
 | 
			
		||||
import pp.mdga.message.server.DrawCardMessage;
 | 
			
		||||
import pp.mdga.message.server.MoveMessage;
 | 
			
		||||
import pp.mdga.message.server.StartPieceMessage;
 | 
			
		||||
import pp.mdga.server.ServerGameLogic;
 | 
			
		||||
@@ -42,6 +45,17 @@ public void received(RequestMoveMessage msg, int from){
 | 
			
		||||
        if (piece.equals(msg.getPiece())) {
 | 
			
		||||
            int targetIndex = calculateTargetIndex(piece);
 | 
			
		||||
            Node targetNode = logic.getGame().getBoard().getInfield()[targetIndex];
 | 
			
		||||
 | 
			
		||||
            if(targetNode.isBonus()) {
 | 
			
		||||
                for (Player p : logic.getGame().getPlayersAsList()) {
 | 
			
		||||
                    if(p.getColor() == logic.getGame().getActiveColor()) {
 | 
			
		||||
                        logic.getServerSender().send(logic.getGame().getPlayerIdByColor(p.getColor()), new DrawCardMessage(logic.getGame().draw()));
 | 
			
		||||
                    } else {
 | 
			
		||||
                        logic.getServerSender().send(logic.getGame().getPlayerIdByColor(p.getColor()), new DrawCardMessage(new HiddenCard()));
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            //send MoveMessage
 | 
			
		||||
            logic.getServerSender().broadcast(new MoveMessage(piece, false, targetIndex));
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -3,6 +3,7 @@
 | 
			
		||||
import pp.mdga.game.Piece;
 | 
			
		||||
import pp.mdga.game.PieceState;
 | 
			
		||||
import pp.mdga.game.ShieldState;
 | 
			
		||||
import pp.mdga.game.card.PowerCard;
 | 
			
		||||
import pp.mdga.message.client.SelectedPiecesMessage;
 | 
			
		||||
import pp.mdga.message.server.IncorrectRequestMessage;
 | 
			
		||||
import pp.mdga.message.server.PlayCardMessage;
 | 
			
		||||
@@ -55,7 +56,11 @@ public void received(SelectedPiecesMessage msg, int from) {
 | 
			
		||||
                    piece.setShield(ShieldState.ACTIVE);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            this.logic.getServerSender().send(this.logic.getGame().getActivePlayerId(), new PlayCardMessage(this.powerCardAutomaton.getSelectedCard(), new ArrayList<>(), this.logic.getGame().getDiceModifier()));
 | 
			
		||||
            ArrayList<Piece> temp = new ArrayList<>();
 | 
			
		||||
            temp.add(msg.getPieces().get(0));
 | 
			
		||||
            this.logic.getServerSender().broadcast(new PlayCardMessage(this.powerCardAutomaton.getSelectedCard(), temp, 1));
 | 
			
		||||
            this.logic.getGame().getPlayerByColor(this.logic.getGame().getActiveColor()).removeHandCard(this.powerCardAutomaton.getSelectedCard());
 | 
			
		||||
            this.logic.getGame().getDiscardPile().add(this.powerCardAutomaton.getSelectedCard());
 | 
			
		||||
            this.powerCardAutomaton.getTurnAutomaton().setCurrentState(this.powerCardAutomaton.getTurnAutomaton().getPlayPowerCardState());
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,10 @@
 | 
			
		||||
package pp.mdga.server.automaton.game.turn.powercard;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.game.Board;
 | 
			
		||||
import pp.mdga.game.Color;
 | 
			
		||||
import pp.mdga.game.Node;
 | 
			
		||||
import pp.mdga.game.Piece;
 | 
			
		||||
import pp.mdga.game.card.SwapCard;
 | 
			
		||||
import pp.mdga.message.client.SelectedPiecesMessage;
 | 
			
		||||
import pp.mdga.message.server.IncorrectRequestMessage;
 | 
			
		||||
import pp.mdga.message.server.PlayCardMessage;
 | 
			
		||||
@@ -9,6 +13,7 @@
 | 
			
		||||
import pp.mdga.server.automaton.game.turn.PowerCardState;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
public class SwapCardState extends PowerCardAutomatonState {
 | 
			
		||||
 | 
			
		||||
@@ -51,20 +56,30 @@ public void exit() {
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(SelectedPiecesMessage msg, int from) {
 | 
			
		||||
        if (msg.getPieces().size() == 2) {
 | 
			
		||||
            Piece first = msg.getPieces().get(0);
 | 
			
		||||
            Piece second = msg.getPieces().get(1);
 | 
			
		||||
            if ((this.powerCardAutomaton.getVisitor().getSwapOwnPieces().contains(first)
 | 
			
		||||
                && this.powerCardAutomaton.getVisitor().getSwapOtherPieces().contains(second))
 | 
			
		||||
                || (this.powerCardAutomaton.getVisitor().getSwapOwnPieces().contains(second)
 | 
			
		||||
                && this.powerCardAutomaton.getVisitor().getSwapOtherPieces().contains(first))) {
 | 
			
		||||
                this.powerCardAutomaton.addSelectedPiece(first);
 | 
			
		||||
                this.powerCardAutomaton.addSelectedPiece(second);
 | 
			
		||||
            Piece selOwn = msg.getPieces().get(0);
 | 
			
		||||
            Piece selEnemy = msg.getPieces().get(1);
 | 
			
		||||
            List<Piece> ownPieces = this.powerCardAutomaton.getVisitor().getSwapOwnPieces();
 | 
			
		||||
            List<Piece> enemyPieces = this.powerCardAutomaton.getVisitor().getSwapOtherPieces();
 | 
			
		||||
 | 
			
		||||
                ArrayList<Piece> temp = new ArrayList<>();
 | 
			
		||||
                temp.add(first);
 | 
			
		||||
                temp.add(second);
 | 
			
		||||
            //if selOwn and selEnemy is in wrong order
 | 
			
		||||
            if(ownPieces.contains(selEnemy) && enemyPieces.contains(selOwn)){
 | 
			
		||||
                Piece temp = selEnemy;
 | 
			
		||||
                selEnemy = selOwn;
 | 
			
		||||
                selOwn = temp;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
                logic.getServerSender().broadcast(new PlayCardMessage(this.powerCardAutomaton.getSelectedCard(), temp, 1));
 | 
			
		||||
            if (ownPieces.contains(selOwn) && enemyPieces.contains(selEnemy)) {
 | 
			
		||||
                this.powerCardAutomaton.addSelectedPiece(selOwn);
 | 
			
		||||
                this.powerCardAutomaton.addSelectedPiece(selEnemy);
 | 
			
		||||
 | 
			
		||||
                if(!(powerCardAutomaton.getSelectedCard() instanceof SwapCard)) throw new RuntimeException("getSelectedCard is not swapCard");
 | 
			
		||||
 | 
			
		||||
                swapPieces(selOwn, selEnemy);
 | 
			
		||||
 | 
			
		||||
                logic.getServerSender().broadcast(new PlayCardMessage(this.powerCardAutomaton.getSelectedCard(), msg.getPieces(), 1));
 | 
			
		||||
 | 
			
		||||
                this.logic.getGame().getPlayerByColor(this.logic.getGame().getActiveColor()).removeHandCard(this.powerCardAutomaton.getSelectedCard());
 | 
			
		||||
                this.logic.getGame().getDiscardPile().add(this.powerCardAutomaton.getSelectedCard());
 | 
			
		||||
 | 
			
		||||
                this.powerCardAutomaton.getTurnAutomaton().setCurrentState(this.powerCardAutomaton.getTurnAutomaton().getPlayPowerCardState());
 | 
			
		||||
            }
 | 
			
		||||
@@ -72,4 +87,16 @@ public void received(SelectedPiecesMessage msg, int from) {
 | 
			
		||||
            this.logic.getServerSender().send(from, new IncorrectRequestMessage(4));
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void swapPieces(Piece messageOwn, Piece messageEnemy) {
 | 
			
		||||
        //swap Pieces in Model
 | 
			
		||||
        Board board = logic.getGame().getBoard();
 | 
			
		||||
        Piece modelOwn = logic.getGame().getPieceThroughUUID(messageOwn.getUuid());
 | 
			
		||||
        Piece modelEnemy = logic.getGame().getPieceThroughUUID(messageEnemy.getUuid());
 | 
			
		||||
        Node ownNode = board.getInfield()[board.getInfieldIndexOfPiece(modelOwn)];
 | 
			
		||||
        Node enemyNode = board.getInfield()[board.getInfieldIndexOfPiece(modelEnemy)];
 | 
			
		||||
 | 
			
		||||
        ownNode.setOccupant(modelEnemy);
 | 
			
		||||
        enemyNode.setOccupant(modelOwn);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -25,7 +25,10 @@ public TurboCardState(PowerCardState powerCardAutomaton, ServerGameLogic logic)
 | 
			
		||||
    public void enter() {
 | 
			
		||||
        this.logic.getGame().getDie().modify();
 | 
			
		||||
        this.logic.getGame().setDiceModifier(this.logic.getGame().getDie().getDieModifier());
 | 
			
		||||
        this.logic.getServerSender().send(this.logic.getGame().getActivePlayerId(), new PlayCardMessage(this.powerCardAutomaton.getSelectedCard(), new ArrayList<>(), this.logic.getGame().getDiceModifier()));
 | 
			
		||||
        this.logic.getServerSender().broadcast(new PlayCardMessage(this.powerCardAutomaton.getSelectedCard(), new ArrayList<>(), this.logic.getGame().getDiceModifier()));
 | 
			
		||||
        this.logic.getGame().getPlayerByColor(this.logic.getGame().getActiveColor()).removeHandCard(this.powerCardAutomaton.getSelectedCard());
 | 
			
		||||
        this.logic.getGame().getDiscardPile().add(this.powerCardAutomaton.getSelectedCard());
 | 
			
		||||
        this.powerCardAutomaton.getTurnAutomaton().getRollDiceState().setResetModifier(false);
 | 
			
		||||
        this.powerCardAutomaton.getTurnAutomaton().setCurrentState(this.powerCardAutomaton.getTurnAutomaton().getPlayPowerCardState());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -38,7 +38,7 @@ public void enter() {
 | 
			
		||||
        LOGGER.log(System.Logger.Level.INFO, "Entered FirstRollState state.");
 | 
			
		||||
        roll = 0;
 | 
			
		||||
        moveablePieces = new ArrayList<>();
 | 
			
		||||
        for (Piece piece : this.rollDiceAutomaton.getTurnAutomaton().getPlayer().getPieces()) {
 | 
			
		||||
        for (Piece piece : this.logic.getGame().getPlayerByColor(this.logic.getGame().getActiveColor()).getPieces()) {
 | 
			
		||||
            if (piece.getState() == PieceState.HOME || piece.getState() == PieceState.ACTIVE) {
 | 
			
		||||
                moveablePieces.add(piece);
 | 
			
		||||
            }
 | 
			
		||||
@@ -66,6 +66,9 @@ public void received(RequestDieMessage msg, int from) {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(AnimationEndMessage msg, int from) {
 | 
			
		||||
        if (from != this.logic.getGame().getActivePlayerId()) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        if (!moveablePieces.isEmpty()) {
 | 
			
		||||
            this.logic.getServerSender().send(this.logic.getGame().getActivePlayerId(), new ChoosePieceStateMessage());
 | 
			
		||||
            this.rollDiceAutomaton.getTurnAutomaton().setCurrentState(this.rollDiceAutomaton.getTurnAutomaton().getChoosePieceState());
 | 
			
		||||
 
 | 
			
		||||
@@ -52,6 +52,9 @@ public void received(RequestDieMessage msg, int from) {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(AnimationEndMessage msg, int from) {
 | 
			
		||||
        if (from != this.logic.getGame().getActivePlayerId()) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        if (this.logic.getGame().getDiceEyes() == 6) {
 | 
			
		||||
            this.logic.getServerSender().send(this.logic.getGame().getActivePlayerId(), new ChoosePieceStateMessage());
 | 
			
		||||
            this.rollDiceAutomaton.getTurnAutomaton().setCurrentState(this.rollDiceAutomaton.getTurnAutomaton().getChoosePieceState());
 | 
			
		||||
 
 | 
			
		||||
@@ -49,6 +49,9 @@ public void received(RequestDieMessage msg, int from) {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(AnimationEndMessage msg, int from) {
 | 
			
		||||
        if (from != this.logic.getGame().getActivePlayerId()) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        if (this.logic.getGame().getDiceEyes() == 6) {
 | 
			
		||||
            this.logic.getServerSender().send(this.logic.getGame().getActivePlayerId(), new ChoosePieceStateMessage());
 | 
			
		||||
            this.rollDiceAutomaton.getTurnAutomaton().setCurrentState(this.rollDiceAutomaton.getTurnAutomaton().getChoosePieceState());
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user