merge development into dev/client_beck
This commit is contained in:
		
							
								
								
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -1,3 +1,5 @@
 | 
			
		||||
 | 
			
		||||
.run/
 | 
			
		||||
.gradle
 | 
			
		||||
build/
 | 
			
		||||
#!gradle/wrapper/gradle-wrapper.jar
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										19
									
								
								Projekte/.run/MdgaApp.run.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								Projekte/.run/MdgaApp.run.xml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,19 @@
 | 
			
		||||
<component name="ProjectRunConfigurationManager">
 | 
			
		||||
  <configuration default="false" name="MdgaApp" type="Application" factoryName="Application" singleton="false" nameIsGenerated="true">
 | 
			
		||||
    <option name="ALTERNATIVE_JRE_PATH" value="temurin-20" />
 | 
			
		||||
    <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
 | 
			
		||||
    <option name="MAIN_CLASS_NAME" value="pp.mdga.client.MdgaApp" />
 | 
			
		||||
    <module name="Projekte.mdga.client.main" />
 | 
			
		||||
    <option name="VM_PARAMETERS" value="-Djava.util.logging.config.file=logging.properties -ea" />
 | 
			
		||||
    <option name="WORKING_DIRECTORY" value="$MODULE_WORKING_DIR$" />
 | 
			
		||||
    <extension name="coverage">
 | 
			
		||||
      <pattern>
 | 
			
		||||
        <option name="PATTERN" value="pp.mdga.client.board.outline.*" />
 | 
			
		||||
        <option name="ENABLED" value="true" />
 | 
			
		||||
      </pattern>
 | 
			
		||||
    </extension>
 | 
			
		||||
    <method v="2">
 | 
			
		||||
      <option name="Make" enabled="true" />
 | 
			
		||||
    </method>
 | 
			
		||||
  </configuration>
 | 
			
		||||
</component>
 | 
			
		||||
@@ -39,6 +39,7 @@ public enum Asset {
 | 
			
		||||
    shieldCard,
 | 
			
		||||
    shieldSymbol("Models/shieldCard/shieldSymbol.j3o", "Models/shieldCard/shieldCard_diff.png"),
 | 
			
		||||
    dice,
 | 
			
		||||
    missile("Models/missile/AVMT300.obj", "Models/missile/texture.jpg", 0.1f),
 | 
			
		||||
    tankShoot("Models/tank/tankShoot_bot.j3o", "Models/tank/tank_diff.png"),
 | 
			
		||||
    tankShootTop("Models/tank/tankShoot_top.j3o", "Models/tank/tank_diff.png"),
 | 
			
		||||
    treesSmallBackground("Models/treeSmall/treesSmallBackground.j3o", "Models/treeSmall/treeSmall_diff.png", 1.2f),
 | 
			
		||||
 
 | 
			
		||||
@@ -149,25 +149,16 @@ else if(boardSelect != null) {
 | 
			
		||||
            if (name.equals("Right")) {
 | 
			
		||||
                isRotateRight = !isRotateRight;
 | 
			
		||||
            }
 | 
			
		||||
            if(name.equals("Test") &&isPressed){
 | 
			
		||||
            if(name.equals("Test2") &&isPressed){
 | 
			
		||||
                if(app.getView() instanceof GameView gameView){
 | 
			
		||||
 | 
			
		||||
                    if(p == null) {
 | 
			
		||||
                        p = UUID.randomUUID();
 | 
			
		||||
                        gameView.getBoardHandler().addPlayer(Color.AIRFORCE,List.of(p,UUID.randomUUID(),UUID.randomUUID(),UUID.randomUUID()));
 | 
			
		||||
                        gameView.getBoardHandler().movePieceStartAnim(p,0);
 | 
			
		||||
                        gameView.getGuiHandler().addCardOwn(BonusCard.SHIELD);
 | 
			
		||||
                        gameView.getGuiHandler().setSelectableCards(List.of(BonusCard.SHIELD));
 | 
			
		||||
 | 
			
		||||
//                        gameView.getBoardHandler().movePieceAnim(p,0, 8);
 | 
			
		||||
                        //gameView.getBoardHandler().movePieceAnim(p,0, 8);
 | 
			
		||||
                    } else {
 | 
			
		||||
//                        gameView.getBoardHandler().throwBombAnim(p);
 | 
			
		||||
                        gameView.getBoardHandler().throwPiece(p,Color.ARMY);
 | 
			
		||||
//                        gameView.getBoardHandler().movePieceAnim(p,0,20);
 | 
			
		||||
//                        gameView.getBoardHandler().throwPiece(p,Color.CYBER);
 | 
			
		||||
//                        gameView.getBoardHandler().throwPiece(p,Color.AIRFORCE);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                        gameView.getBoardHandler().throwPiece(p, Color.ARMY);
 | 
			
		||||
                        //gameView.getBoardHandler().movePieceStartAnim(p,0);
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,16 +1,8 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.acoustic.MdgaSound;
 | 
			
		||||
import pp.mdga.client.server.MdgaServer;
 | 
			
		||||
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.message.client.LobbyReadyMessage;
 | 
			
		||||
import pp.mdga.notification.AcquireCardNotification;
 | 
			
		||||
import pp.mdga.notification.DrawCardNotification;
 | 
			
		||||
import pp.mdga.notification.TskSelectNotification;
 | 
			
		||||
 | 
			
		||||
import java.util.UUID;
 | 
			
		||||
import java.util.logging.Level;
 | 
			
		||||
@@ -74,10 +66,11 @@ public void selectCard(BonusCard card) {
 | 
			
		||||
        this.card = card;
 | 
			
		||||
 | 
			
		||||
        GameView gameView = (GameView) app.getView();
 | 
			
		||||
 | 
			
		||||
        if(card != null) {
 | 
			
		||||
            gameView.needConfirm();
 | 
			
		||||
        } else {
 | 
			
		||||
            gameView.noConfirm();
 | 
			
		||||
            gameView.showNoPower();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -87,20 +80,19 @@ public void confirm() {
 | 
			
		||||
        GameView gameView = (GameView) app.getView();
 | 
			
		||||
 | 
			
		||||
        if(a != null && b != null) {
 | 
			
		||||
            selectPiece(a);
 | 
			
		||||
            selectPiece(b);
 | 
			
		||||
            app.getGameLogic().selectPiece(a);
 | 
			
		||||
            app.getGameLogic().selectPiece(b);
 | 
			
		||||
            gameView.getBoardHandler().clearSelectable();
 | 
			
		||||
        } else if (a != null) {
 | 
			
		||||
            selectPiece(a);
 | 
			
		||||
            app.getGameLogic().selectPiece(a);
 | 
			
		||||
            gameView.getBoardHandler().clearSelectable();
 | 
			
		||||
        } else if (card != null){
 | 
			
		||||
            selectCard(card);
 | 
			
		||||
            gameView.getGuiHandler().clearSelectableCards();
 | 
			
		||||
        } else {
 | 
			
		||||
            throw new RuntimeException("nothing to confirm");
 | 
			
		||||
            app.getGameLogic().selectCard(card);
 | 
			
		||||
            gameView.getGuiHandler().clearSelectableCards();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        gameView.noConfirm();
 | 
			
		||||
        gameView.hideNoPower();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void selectTsk(Color color) {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,6 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.acoustic.MdgaSound;
 | 
			
		||||
import pp.mdga.client.board.BoardHandler;
 | 
			
		||||
import pp.mdga.client.gui.GuiHandler;
 | 
			
		||||
import pp.mdga.client.view.CeremonyView;
 | 
			
		||||
@@ -15,13 +16,26 @@ public class NotificationSynchronizer {
 | 
			
		||||
 | 
			
		||||
    private ArrayList<Notification> notifications = new ArrayList<>();
 | 
			
		||||
 | 
			
		||||
    private NanoTimer timer = new NanoTimer();
 | 
			
		||||
    private float delay = 0;
 | 
			
		||||
 | 
			
		||||
    private static final float STANDARD_DELAY = 2.5f;
 | 
			
		||||
 | 
			
		||||
    NotificationSynchronizer(MdgaApp app) {
 | 
			
		||||
        this.app = app;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void update() {
 | 
			
		||||
        Notification n = app.getGameLogic().getNotification();
 | 
			
		||||
        while (n != null) {
 | 
			
		||||
        while (timer.getTimeInSeconds() >= delay) {
 | 
			
		||||
            Notification n = app.getGameLogic().getNotification();
 | 
			
		||||
 | 
			
		||||
            if(n == null) {
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            timer.reset();
 | 
			
		||||
            delay = 0;
 | 
			
		||||
 | 
			
		||||
            if(n instanceof InfoNotification infoNotification) {
 | 
			
		||||
                app.getView().showInfo(infoNotification.getMessage(), infoNotification.isError());
 | 
			
		||||
                return;
 | 
			
		||||
@@ -89,9 +103,13 @@ private void handleGame(Notification notification) {
 | 
			
		||||
 | 
			
		||||
        if (notification instanceof AcquireCardNotification n) {
 | 
			
		||||
            guiHandler.addCardOwn(n.getBonusCard());
 | 
			
		||||
            app.getAcousticHandler().playSound(MdgaSound.BONUS);
 | 
			
		||||
            delay = STANDARD_DELAY;
 | 
			
		||||
        } else if (notification instanceof ActivePlayerNotification n) {
 | 
			
		||||
            gameView.getGuiHandler().setActivePlayer(n.getColor());
 | 
			
		||||
            if(n.getColor() != ownColor) boardHandler.showDice(n.getColor());
 | 
			
		||||
            app.getAcousticHandler().playSound(MdgaSound.UI90);
 | 
			
		||||
            delay = STANDARD_DELAY;
 | 
			
		||||
        } else if (notification instanceof CeremonyNotification ceremonyNotification) {
 | 
			
		||||
            app.enter(MdgaState.CEREMONY);
 | 
			
		||||
            CeremonyView ceremonyView = (CeremonyView) app.getView();
 | 
			
		||||
@@ -126,8 +144,8 @@ private void handleGame(Notification notification) {
 | 
			
		||||
        } else if (notification instanceof HomeMoveNotification home) {
 | 
			
		||||
            boardHandler.movePieceHomeAnim(home.getPieceId(), home.getHomeIndex());
 | 
			
		||||
            guiHandler.hideText();
 | 
			
		||||
        } else if (notification instanceof InterruptNotification) {
 | 
			
		||||
            gameView.enterInterrupt();
 | 
			
		||||
        } else if (notification instanceof InterruptNotification notification1) {
 | 
			
		||||
            gameView.enterInterrupt(notification1.getColor());
 | 
			
		||||
        } else if (notification instanceof MovePieceNotification n) {
 | 
			
		||||
            if(n.isMoveStart()) {
 | 
			
		||||
                //StartMove
 | 
			
		||||
@@ -160,8 +178,10 @@ private void handleGame(Notification notification) {
 | 
			
		||||
                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();
 | 
			
		||||
        } else if (notification instanceof ShieldActiveNotification n) {
 | 
			
		||||
            boardHandler.shieldPiece(n.getPieceId());
 | 
			
		||||
        } else if (notification instanceof ShieldSuppressedNotification n) {
 | 
			
		||||
 
 | 
			
		||||
@@ -18,12 +18,14 @@ public class AcousticHandler {
 | 
			
		||||
 | 
			
		||||
    private boolean fading = false; // Indicates if a fade is in progress
 | 
			
		||||
    private NanoTimer fadeTimer = new NanoTimer(); // Timer to track fade progress
 | 
			
		||||
    private static final float FADE_DURATION = 3.0f; // Duration for outfade
 | 
			
		||||
    private static final float FADE_DURATION = 2.0f; // Duration for outfade
 | 
			
		||||
    private static final float CROSSFADE_DURATION = 1.5f; // Duration for infade
 | 
			
		||||
    private GameMusic playing = null; // Currently playing track
 | 
			
		||||
    private GameMusic scheduled = null; // Scheduled track to play next
 | 
			
		||||
    private GameMusic old = null; // Old track being faded out
 | 
			
		||||
 | 
			
		||||
    private GameMusic birds;
 | 
			
		||||
 | 
			
		||||
    private float mainVolume = 0.0f;
 | 
			
		||||
    private float musicVolume = 1.0f;
 | 
			
		||||
    private float soundVolume = 1.0f;
 | 
			
		||||
@@ -38,6 +40,8 @@ public AcousticHandler(MdgaApp app) {
 | 
			
		||||
        mainVolume = prefs.getFloat("mainVolume", 1.0f);
 | 
			
		||||
        musicVolume = prefs.getFloat("musicVolume", 1.0f);
 | 
			
		||||
        soundVolume = prefs.getFloat("soundVolume", 1.0f);
 | 
			
		||||
 | 
			
		||||
        birds = new GameMusic(app, MusicAsset.BIRDS, getSoundVolumeTotal(), MusicAsset.BIRDS.getSubVolume(), MusicAsset.BIRDS.getLoop(), 0.0f);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -60,6 +64,8 @@ public void update() {
 | 
			
		||||
                iterator.remove();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        birds.update(Math.min(getSoundVolumeTotal(), getMusicVolumeTotal() > 0 ? 0 : 1));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -113,9 +119,9 @@ public void playSound(MdgaSound sound) {
 | 
			
		||||
                assets.add(new SoundAssetDelayVolume(SoundAsset.JET, 1.0f, 0.0f));
 | 
			
		||||
                break;
 | 
			
		||||
            case EXPLOSION:
 | 
			
		||||
                assets.add(new SoundAssetDelayVolume(SoundAsset.EXPLOSION_1, 1.0f, 4f));
 | 
			
		||||
                assets.add(new SoundAssetDelayVolume(SoundAsset.EXPLOSION_2, 1.0f, 4f));
 | 
			
		||||
                assets.add(new SoundAssetDelayVolume(SoundAsset.THUNDER, 1.0f, 4f));
 | 
			
		||||
                assets.add(new SoundAssetDelayVolume(SoundAsset.EXPLOSION_1, 1.0f, 0f));
 | 
			
		||||
                assets.add(new SoundAssetDelayVolume(SoundAsset.EXPLOSION_2, 1.0f, 0f));
 | 
			
		||||
                assets.add(new SoundAssetDelayVolume(SoundAsset.THUNDER, 1.0f, 0f));
 | 
			
		||||
                break;
 | 
			
		||||
            case LOSE:
 | 
			
		||||
                assets.add(new SoundAssetDelayVolume(SoundAsset.LOSE, 1.0f, 0.0f));
 | 
			
		||||
@@ -123,6 +129,15 @@ public void playSound(MdgaSound sound) {
 | 
			
		||||
            case BONUS:
 | 
			
		||||
                assets.add(new SoundAssetDelayVolume(SoundAsset.BONUS, 1.0f, 0.0f));
 | 
			
		||||
                break;
 | 
			
		||||
            case UI90:
 | 
			
		||||
                assets.add(new SoundAssetDelayVolume(SoundAsset.UI90, 1.0f, 0.0f));
 | 
			
		||||
                break;
 | 
			
		||||
            case MISSILE:
 | 
			
		||||
                assets.add(new SoundAssetDelayVolume(SoundAsset.MISSILE, 1.0f, 0.0f));
 | 
			
		||||
                break;
 | 
			
		||||
            case MATRIX:
 | 
			
		||||
                assets.add(new SoundAssetDelayVolume(SoundAsset.MATRIX, 1.0f, 0.0f));
 | 
			
		||||
                break;
 | 
			
		||||
            case TURRET_ROTATE:
 | 
			
		||||
                assets.add(new SoundAssetDelayVolume(SoundAsset.TURRET_ROTATE, 0.7f, 0f));
 | 
			
		||||
                break;
 | 
			
		||||
@@ -153,6 +168,10 @@ public void playState(MdgaState state) {
 | 
			
		||||
        }
 | 
			
		||||
        MusicAsset asset = null;
 | 
			
		||||
 | 
			
		||||
        birds.pause();
 | 
			
		||||
 | 
			
		||||
        float pause = 0.0f;
 | 
			
		||||
 | 
			
		||||
        switch (state) {
 | 
			
		||||
            case MAIN:
 | 
			
		||||
                playGame = false;
 | 
			
		||||
@@ -163,10 +182,12 @@ public void playState(MdgaState state) {
 | 
			
		||||
                asset = MusicAsset.LOBBY;
 | 
			
		||||
                break;
 | 
			
		||||
            case GAME:
 | 
			
		||||
                birds.play();
 | 
			
		||||
                addGameTracks();
 | 
			
		||||
                playGame = true;
 | 
			
		||||
                assert (!gameTracks.isEmpty()) : "no more game music available";
 | 
			
		||||
                asset = gameTracks.remove(0);
 | 
			
		||||
                pause = 2.0f;
 | 
			
		||||
                break;
 | 
			
		||||
            case CEREMONY:
 | 
			
		||||
                playGame = false;
 | 
			
		||||
@@ -178,7 +199,7 @@ public void playState(MdgaState state) {
 | 
			
		||||
 | 
			
		||||
        assert (null != asset) : "music sceduling went wrong";
 | 
			
		||||
 | 
			
		||||
        scheduled = new GameMusic(app, asset, getMusicVolumeTotal(), asset.getSubVolume(), asset.getLoop(), 0.0f);
 | 
			
		||||
        scheduled = new GameMusic(app, asset, getMusicVolumeTotal(), asset.getSubVolume(), asset.getLoop(), pause);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -454,7 +475,7 @@ public void setSoundVolume(float soundVolume) {
 | 
			
		||||
     */
 | 
			
		||||
    float getMusicVolumeTotal() {
 | 
			
		||||
 | 
			
		||||
        return getMusicVolume() * getMainVolume();
 | 
			
		||||
        return getMusicVolume() * getMainVolume() / 2;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
@@ -35,6 +35,9 @@ public enum MdgaSound {
 | 
			
		||||
    EXPLOSION,
 | 
			
		||||
    LOSE,
 | 
			
		||||
    BONUS,
 | 
			
		||||
    UI90,
 | 
			
		||||
    MISSILE,
 | 
			
		||||
    MATRIX,
 | 
			
		||||
    TURRET_ROTATE,
 | 
			
		||||
    TANK_SHOOT,
 | 
			
		||||
    TANK_EXPLOSION
 | 
			
		||||
 
 | 
			
		||||
@@ -10,12 +10,13 @@ enum MusicAsset {
 | 
			
		||||
    MAIN_MENU("Spaceship.wav", true, 1.0f),
 | 
			
		||||
    LOBBY("DeadPlanet.wav", true, 1.0f),
 | 
			
		||||
    CEREMONY("80s,Disco,Life.wav", true, 1.0f),
 | 
			
		||||
    GAME_1("NeonRoadTrip.wav", 1.0f),
 | 
			
		||||
    GAME_2("NoPressureTrance.wav", 1.0f),
 | 
			
		||||
    GAME_3("TheSynthRave.wav", 1.0f),
 | 
			
		||||
    GAME_4("LaserParty.wav", 1.0f),
 | 
			
		||||
    GAME_5("RetroNoir.wav", 1.0f),
 | 
			
		||||
    GAME_6("SpaceInvaders.wav", 1.0f);
 | 
			
		||||
    GAME_1("NeonRoadTrip.wav", 0.5f),
 | 
			
		||||
    GAME_2("NoPressureTrance.wav", 0.5f),
 | 
			
		||||
    GAME_3("TheSynthRave.wav", 0.5f),
 | 
			
		||||
    GAME_4("LaserParty.wav", 0.5f),
 | 
			
		||||
    GAME_5("RetroNoir.wav", 0.5f),
 | 
			
		||||
    GAME_6("SpaceInvaders.wav", 0.5f),
 | 
			
		||||
    BIRDS("nature-ambience.ogg", true, 1.0f);
 | 
			
		||||
 | 
			
		||||
    private final String path;
 | 
			
		||||
    private final boolean loop;
 | 
			
		||||
 
 | 
			
		||||
@@ -35,6 +35,8 @@ enum SoundAsset {
 | 
			
		||||
    UI90("ui90.ogg"),
 | 
			
		||||
    BONUS("bonus.ogg"),
 | 
			
		||||
    LOSE("lose.ogg"),
 | 
			
		||||
    MISSILE("missile.ogg"),
 | 
			
		||||
    MATRIX("matrix.wav"),
 | 
			
		||||
    CONNECTED("connected.wav"),
 | 
			
		||||
    TURRET_ROTATE("turret_rotate.ogg"),
 | 
			
		||||
    TANK_SHOOT("tank_shoot.ogg")
 | 
			
		||||
 
 | 
			
		||||
@@ -8,7 +8,12 @@
 | 
			
		||||
import com.jme3.scene.Node;
 | 
			
		||||
import com.jme3.scene.control.AbstractControl;
 | 
			
		||||
import pp.mdga.client.MdgaApp;
 | 
			
		||||
import pp.mdga.client.acoustic.MdgaSound;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * The {@code Explosion} class represents an explosion effect in a 3D environment.
 | 
			
		||||
 * It manages the creation, configuration, and triggering of particle emitters for fire and smoke effects.
 | 
			
		||||
 */
 | 
			
		||||
public class Explosion {
 | 
			
		||||
 | 
			
		||||
    private final Node rootNode;
 | 
			
		||||
@@ -22,11 +27,11 @@ public class Explosion {
 | 
			
		||||
    private final Material mat;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Konstruktor für die Explosion.
 | 
			
		||||
     * Constructor for the {@code Explosion} class.
 | 
			
		||||
     *
 | 
			
		||||
     * @param app      Die Hauptanwendung.
 | 
			
		||||
     * @param rootNode Der Root-Knoten, an den die Explosion angefügt wird.
 | 
			
		||||
     * @param location Der Ort der Explosion in World-Koordinaten.
 | 
			
		||||
     * @param app      The main application managing the explosion.
 | 
			
		||||
     * @param rootNode The root node to which the explosion effects will be attached.
 | 
			
		||||
     * @param location The location of the explosion in world coordinates.
 | 
			
		||||
     */
 | 
			
		||||
    public Explosion(MdgaApp app, Node rootNode, Vector3f location) {
 | 
			
		||||
        this.app = app;
 | 
			
		||||
@@ -34,51 +39,54 @@ public Explosion(MdgaApp app, Node rootNode, Vector3f location) {
 | 
			
		||||
        this.location = location;
 | 
			
		||||
 | 
			
		||||
        this.mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Particle.j3md");
 | 
			
		||||
        mat.getAdditionalRenderState().setDepthWrite(false);
 | 
			
		||||
        mat.getAdditionalRenderState().setDepthTest(false);
 | 
			
		||||
        mat.setTexture("Texture", app.getAssetManager().loadTexture("Images/particle/flame.png"));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Initialisiert den Partikel-Emitter für die Explosion.
 | 
			
		||||
     * Initializes the particle emitters for the explosion effect.
 | 
			
		||||
     * Configures the fire and smoke emitters with appearance, behavior, and lifespan.
 | 
			
		||||
     */
 | 
			
		||||
    private void initializeEmitter() {
 | 
			
		||||
        fire = new ParticleEmitter("Effect", Type.Triangle,50);
 | 
			
		||||
        fire.setMaterial(mat);
 | 
			
		||||
        fire.setImagesX(2);
 | 
			
		||||
        fire.setImagesY(2);
 | 
			
		||||
        fire.setStartColor(ColorRGBA.Yellow);
 | 
			
		||||
        fire.setEndColor(ColorRGBA.Red);
 | 
			
		||||
        fire.getParticleInfluencer().setInitialVelocity(new Vector3f(0.2f,0.2f,4f));
 | 
			
		||||
        fire.getParticleInfluencer().setVelocityVariation(0.4f);
 | 
			
		||||
        fire.setStartSize(0.1f);
 | 
			
		||||
        fire.setEndSize(0.8f);
 | 
			
		||||
        fire.setStartSize(0.7f);
 | 
			
		||||
        fire.setEndSize(1.8f);
 | 
			
		||||
        fire.setGravity(0, 0, -0.1f);
 | 
			
		||||
        fire.setLowLife(0.5f);
 | 
			
		||||
        fire.setHighLife(2.2f);
 | 
			
		||||
        fire.setParticlesPerSec(0);
 | 
			
		||||
 | 
			
		||||
        fire.setLocalTranslation(location);
 | 
			
		||||
        fire.move(0, 0, 45);
 | 
			
		||||
 | 
			
		||||
        smoke = new ParticleEmitter("Effect2", Type.Triangle,40);
 | 
			
		||||
        smoke.setMaterial(mat);
 | 
			
		||||
        smoke.setImagesX(2);
 | 
			
		||||
        smoke.setImagesY(2);
 | 
			
		||||
        smoke.setImagesX(3);
 | 
			
		||||
        smoke.setImagesY(3);
 | 
			
		||||
        smoke.setStartColor(ColorRGBA.DarkGray);
 | 
			
		||||
        smoke.setEndColor(new ColorRGBA(0.05f, 0.05f, 0.05f, 1));
 | 
			
		||||
        smoke.getParticleInfluencer().setInitialVelocity(new Vector3f(0.0f,0.0f,0.7f));
 | 
			
		||||
        smoke.getParticleInfluencer().setVelocityVariation(0.5f);
 | 
			
		||||
        smoke.setStartSize(0.2f);
 | 
			
		||||
        smoke.setEndSize(0.5f);
 | 
			
		||||
        smoke.setStartSize(0.8f);
 | 
			
		||||
        smoke.setEndSize(1.5f);
 | 
			
		||||
        smoke.setGravity(0, 0, -0.3f);
 | 
			
		||||
        smoke.setLowLife(1.2f);
 | 
			
		||||
        smoke.setHighLife(5.5f);
 | 
			
		||||
        smoke.setParticlesPerSec(0);
 | 
			
		||||
 | 
			
		||||
        smoke.setLocalTranslation(location);
 | 
			
		||||
        smoke.move(0, 0, 45);
 | 
			
		||||
 | 
			
		||||
        app.getAcousticHandler().playSound(MdgaSound.EXPLOSION);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Löst die Explosion aus.
 | 
			
		||||
     * Triggers the explosion effect by attaching and activating the particle emitters for fire and smoke.
 | 
			
		||||
     * Both emitters are automatically detached after a predefined duration.
 | 
			
		||||
     */
 | 
			
		||||
    public void trigger() {
 | 
			
		||||
        if (!triggered) {
 | 
			
		||||
 
 | 
			
		||||
@@ -17,31 +17,34 @@
 | 
			
		||||
 | 
			
		||||
import java.util.UUID;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * The {@code JetAnimation} class handles the animation of a jet model in a 3D environment.
 | 
			
		||||
 * It creates a jet model, animates its movement along a curved path, triggers an explosion at a target point,
 | 
			
		||||
 * and performs additional actions upon animation completion.
 | 
			
		||||
 */
 | 
			
		||||
public class JetAnimation {
 | 
			
		||||
 | 
			
		||||
    private final MdgaApp app;         // Referenz auf die Hauptanwendung
 | 
			
		||||
    private final Node rootNode;      // Root-Knoten, an dem die Animation hängt
 | 
			
		||||
    private Spatial jetModel;         // Das Model des "jet"
 | 
			
		||||
    private final Vector3f spawnPoint; // Spawnpunkt des Jets
 | 
			
		||||
    private final Vector3f nodePoint; // Punkt des überflogenen Knotens
 | 
			
		||||
    private final Vector3f despawnPoint; // Punkt, an dem der Jet despawnt
 | 
			
		||||
    private final float curveHeight;  // Maximale Höhe der Kurve
 | 
			
		||||
    private final float animationDuration; // Dauer der Animation
 | 
			
		||||
    private final MdgaApp app;
 | 
			
		||||
    private final Node rootNode;
 | 
			
		||||
    private Spatial jetModel;
 | 
			
		||||
    private final Vector3f spawnPoint;
 | 
			
		||||
    private final Vector3f nodePoint;
 | 
			
		||||
    private final Vector3f despawnPoint;
 | 
			
		||||
    private final float curveHeight;
 | 
			
		||||
    private final float animationDuration;
 | 
			
		||||
    private Explosion explosion;
 | 
			
		||||
    private final UUID id;
 | 
			
		||||
    private Runnable actionAfter;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Konstruktor für die ThrowAnimation-Klasse.
 | 
			
		||||
     * Constructor for the {@code JetAnimation} class.
 | 
			
		||||
     *
 | 
			
		||||
     * @param app                Die Hauptanwendung
 | 
			
		||||
     * @param rootNode           Der Root-Knoten, an dem der Jet angefügt wird
 | 
			
		||||
     * @param uuid              Die UUID des pieces
 | 
			
		||||
     * @param targetPoint         Der Punkt, an dem der Jet spawnt
 | 
			
		||||
     * @param curveHeight        Die maximale Höhe der Flugkurve
 | 
			
		||||
     * @param animationDuration  Die Gesamtdauer der Animation in Sekunden
 | 
			
		||||
     * @param app              The main application managing the jet animation.
 | 
			
		||||
     * @param rootNode         The root node to which the jet model will be attached.
 | 
			
		||||
     * @param targetPoint      The target point where the explosion will occur.
 | 
			
		||||
     * @param curveHeight      The height of the curve for the jet's flight path.
 | 
			
		||||
     * @param animationDuration The total duration of the jet animation.
 | 
			
		||||
     */
 | 
			
		||||
    public JetAnimation(MdgaApp app, Node rootNode, UUID uuid, Vector3f targetPoint, float curveHeight, float animationDuration, Runnable actionAfter) {
 | 
			
		||||
    public JetAnimation(MdgaApp app, Node rootNode, Vector3f targetPoint, float curveHeight, float animationDuration, Runnable actionAfter) {
 | 
			
		||||
        Vector3f spawnPoint = targetPoint.add(170, 50, 50);
 | 
			
		||||
 | 
			
		||||
        Vector3f controlPoint = targetPoint.add(new Vector3f(0, 0, -45));
 | 
			
		||||
@@ -56,14 +59,12 @@ public JetAnimation(MdgaApp app, Node rootNode, UUID uuid, Vector3f targetPoint,
 | 
			
		||||
        this.curveHeight = curveHeight;
 | 
			
		||||
        this.animationDuration = animationDuration;
 | 
			
		||||
 | 
			
		||||
        id = uuid;
 | 
			
		||||
 | 
			
		||||
        explosion = new Explosion(app, rootNode, nodePoint);
 | 
			
		||||
        explosion = new Explosion(app, rootNode, targetPoint);
 | 
			
		||||
        this.actionAfter = actionAfter;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Startet die Animation.
 | 
			
		||||
     * Starts the jet animation by spawning the jet model and initiating its movement along the predefined path.
 | 
			
		||||
     */
 | 
			
		||||
    public void start() {
 | 
			
		||||
        app.getAcousticHandler().playSound(MdgaSound.JET);
 | 
			
		||||
@@ -72,7 +73,7 @@ public void start() {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Spawnt den Jet an der spezifizierten Position.
 | 
			
		||||
     * Spawns the jet model at the designated spawn point, applying material, scaling, and rotation.
 | 
			
		||||
     */
 | 
			
		||||
    private void spawnJet() {
 | 
			
		||||
        jetModel = app.getAssetManager().loadModel(Asset.jet.getModelPath());
 | 
			
		||||
@@ -85,12 +86,11 @@ private void spawnJet() {
 | 
			
		||||
        jetModel.setMaterial(mat);
 | 
			
		||||
 | 
			
		||||
        rootNode.attachChild(jetModel);
 | 
			
		||||
 | 
			
		||||
        app.getAcousticHandler().playSound(MdgaSound.EXPLOSION);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Animiert den Jet entlang einer Kurve und lässt ihn anschließend verschwinden.
 | 
			
		||||
    /**actionAfter
 | 
			
		||||
     * Animates the jet along a Bezier curve path, triggers the explosion effect at the appropriate time,
 | 
			
		||||
     * and performs cleanup operations after the animation completes.
 | 
			
		||||
     */
 | 
			
		||||
    private void animateJet() {
 | 
			
		||||
        Vector3f controlPoint1 = spawnPoint.add(0, curveHeight, 0);
 | 
			
		||||
@@ -127,9 +127,7 @@ protected void controlUpdate(float tpf) {
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            @Override
 | 
			
		||||
            protected void controlRender(RenderManager rm, ViewPort vp) {
 | 
			
		||||
                // Wird hier nicht benötigt
 | 
			
		||||
            }
 | 
			
		||||
            protected void controlRender(RenderManager rm, ViewPort vp) {}
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -138,11 +136,20 @@ private void endAnim(){
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Repräsentiert eine 3D-Bezier-Kurve mit vier Kontrollpunkten.
 | 
			
		||||
     * The {@code BezierCurve3f} class represents a 3D cubic Bezier curve.
 | 
			
		||||
     * It provides methods to interpolate positions and derivatives along the curve.
 | 
			
		||||
     */
 | 
			
		||||
    private static class BezierCurve3f {
 | 
			
		||||
        private final Vector3f p0, p1, p2, p3;
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
         * Constructor for the {@code BezierCurve3f} class.
 | 
			
		||||
         *
 | 
			
		||||
         * @param p0 The starting point of the curve.
 | 
			
		||||
         * @param p1 The first control point influencing the curve's shape.
 | 
			
		||||
         * @param p2 The second control point influencing the curve's shape.
 | 
			
		||||
         * @param p3 The endpoint of the curve.
 | 
			
		||||
         */
 | 
			
		||||
        public BezierCurve3f(Vector3f p0, Vector3f p1, Vector3f p2, Vector3f p3) {
 | 
			
		||||
            this.p0 = p0;
 | 
			
		||||
            this.p1 = p1;
 | 
			
		||||
@@ -150,6 +157,12 @@ public BezierCurve3f(Vector3f p0, Vector3f p1, Vector3f p2, Vector3f p3) {
 | 
			
		||||
            this.p3 = p3;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
         * Interpolates a position along the curve at a given progress value {@code t}.
 | 
			
		||||
         *
 | 
			
		||||
         * @param t The progress value (0.0 to 1.0) along the curve.
 | 
			
		||||
         * @return The interpolated position on the curve.
 | 
			
		||||
         */
 | 
			
		||||
        public Vector3f interpolate(float t) {
 | 
			
		||||
            float u = 1 - t;
 | 
			
		||||
            float tt = t * t;
 | 
			
		||||
@@ -164,6 +177,12 @@ public Vector3f interpolate(float t) {
 | 
			
		||||
            return point;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
         * Computes the derivative at a given progress value {@code t}, representing the direction along the curve.
 | 
			
		||||
         *
 | 
			
		||||
         * @param t The progress value (0.0 to 1.0) along the curve.
 | 
			
		||||
         * @return The derivative (direction vector) at the specified progress.
 | 
			
		||||
         */
 | 
			
		||||
        public Vector3f interpolateDerivative(float t) {
 | 
			
		||||
            float u = 1 - t;
 | 
			
		||||
            float tt = t * t;
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,185 @@
 | 
			
		||||
package pp.mdga.client.animation;
 | 
			
		||||
 | 
			
		||||
import com.jme3.effect.ParticleEmitter;
 | 
			
		||||
import com.jme3.effect.ParticleMesh;
 | 
			
		||||
import com.jme3.material.Material;
 | 
			
		||||
import com.jme3.math.ColorRGBA;
 | 
			
		||||
import com.jme3.math.FastMath;
 | 
			
		||||
import com.jme3.math.Vector3f;
 | 
			
		||||
import com.jme3.renderer.RenderManager;
 | 
			
		||||
import com.jme3.renderer.ViewPort;
 | 
			
		||||
import com.jme3.renderer.queue.RenderQueue;
 | 
			
		||||
import com.jme3.scene.Node;
 | 
			
		||||
import com.jme3.scene.Spatial;
 | 
			
		||||
import com.jme3.scene.control.AbstractControl;
 | 
			
		||||
import pp.mdga.client.Asset;
 | 
			
		||||
import pp.mdga.client.MdgaApp;
 | 
			
		||||
import pp.mdga.client.acoustic.MdgaSound;
 | 
			
		||||
import pp.mdga.client.board.BoardHandler;
 | 
			
		||||
 | 
			
		||||
import java.util.UUID;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * The {@code MissileAnimation} class handles the animation of a missile moving along a parabolic path
 | 
			
		||||
 * towards a target point in a 3D environment. It also triggers an explosion at the target upon impact.
 | 
			
		||||
 */
 | 
			
		||||
public class MissileAnimation {
 | 
			
		||||
 | 
			
		||||
    private final Node rootNode;
 | 
			
		||||
    private final MdgaApp app;
 | 
			
		||||
    private final Vector3f start;
 | 
			
		||||
    private final Vector3f target;
 | 
			
		||||
    private final float flightTime;
 | 
			
		||||
    private Explosion explosion;
 | 
			
		||||
    private Spatial missileModel;
 | 
			
		||||
    private Runnable actionAfter;
 | 
			
		||||
    private ParticleEmitter smoke;
 | 
			
		||||
 | 
			
		||||
    private Node missileNode = new Node();
 | 
			
		||||
 | 
			
		||||
    private final Material mat;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Constructor for the {@code MissileAnimation} class.
 | 
			
		||||
     *
 | 
			
		||||
     * @param app       The main application managing the missile animation.
 | 
			
		||||
     * @param rootNode  The root node to which the missile model will be attached.
 | 
			
		||||
     * @param target    The target point where the missile will explode.
 | 
			
		||||
     * @param flightTime The total flight time of the missile.
 | 
			
		||||
     */
 | 
			
		||||
    public MissileAnimation(MdgaApp app, Node rootNode, Vector3f target, float flightTime, Runnable actionAfter) {
 | 
			
		||||
        this.app = app;
 | 
			
		||||
        this.rootNode = rootNode;
 | 
			
		||||
        this.flightTime = flightTime;
 | 
			
		||||
        this.actionAfter = actionAfter;
 | 
			
		||||
 | 
			
		||||
        explosion = new Explosion(app, rootNode, target);
 | 
			
		||||
 | 
			
		||||
        this.target = target.add(new Vector3f(1.5f, -1, 0));
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        start = BoardHandler.gridToWorld(12, 0);
 | 
			
		||||
        start.add(new Vector3f(0, 0, 0));
 | 
			
		||||
 | 
			
		||||
        this.mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Particle.j3md");
 | 
			
		||||
        mat.setTexture("Texture", app.getAssetManager().loadTexture("Images/particle/vapor_cloud.png"));
 | 
			
		||||
 | 
			
		||||
        smoke = new ParticleEmitter("Effect2", ParticleMesh.Type.Triangle,400);
 | 
			
		||||
        smoke.setMaterial(mat);
 | 
			
		||||
        smoke.setImagesX(3);
 | 
			
		||||
        smoke.setImagesY(3);
 | 
			
		||||
        smoke.setStartColor(ColorRGBA.DarkGray);
 | 
			
		||||
        smoke.setEndColor(new ColorRGBA(0.05f, 0.05f, 0.05f, 1));
 | 
			
		||||
        smoke.getParticleInfluencer().setInitialVelocity(new Vector3f(0.0f,0.0f,0.0f));
 | 
			
		||||
        smoke.getParticleInfluencer().setVelocityVariation(0.1f);
 | 
			
		||||
        smoke.setStartSize(0.8f);
 | 
			
		||||
        smoke.setEndSize(1.5f);
 | 
			
		||||
        smoke.setGravity(0, 0, -0.3f);
 | 
			
		||||
        smoke.setLowLife(1.2f);
 | 
			
		||||
        smoke.setHighLife(3.5f);
 | 
			
		||||
        smoke.setParticlesPerSec(100);
 | 
			
		||||
        missileNode.attachChild(smoke);
 | 
			
		||||
        smoke.move(1, 0.85f, 1.0f);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Starts the missile animation by loading the missile model and initiating its parabolic movement.
 | 
			
		||||
     */
 | 
			
		||||
    public void start() {
 | 
			
		||||
        Smoke s = new Smoke(app, rootNode, start);
 | 
			
		||||
        s.trigger();
 | 
			
		||||
        loadMissile();
 | 
			
		||||
        app.getAcousticHandler().playSound(MdgaSound.MISSILE);
 | 
			
		||||
        animateMissile();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Loads the missile model into the scene, applies scaling, material, and sets its initial position.
 | 
			
		||||
     */
 | 
			
		||||
    private void loadMissile() {
 | 
			
		||||
        missileModel = app.getAssetManager().loadModel(Asset.missile.getModelPath());
 | 
			
		||||
        missileModel.scale(Asset.missile.getSize());
 | 
			
		||||
        missileModel.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
 | 
			
		||||
        Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md");
 | 
			
		||||
        mat.setTexture("DiffuseMap", app.getAssetManager().loadTexture(Asset.missile.getDiffPath()));
 | 
			
		||||
        missileModel.setMaterial(mat);
 | 
			
		||||
 | 
			
		||||
        missileNode.setLocalTranslation(start);
 | 
			
		||||
        missileNode.attachChild(missileModel);
 | 
			
		||||
 | 
			
		||||
        rootNode.attachChild(missileNode);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Animates the missile along a parabolic path, triggers the explosion near the target,
 | 
			
		||||
     * and removes the missile model after the animation completes.
 | 
			
		||||
     */
 | 
			
		||||
    private void animateMissile() {
 | 
			
		||||
        missileNode.addControl(new AbstractControl() {
 | 
			
		||||
            private float elapsedTime = 0;
 | 
			
		||||
 | 
			
		||||
            @Override
 | 
			
		||||
            protected void controlUpdate(float tpf) {
 | 
			
		||||
                if(elapsedTime > 6) {
 | 
			
		||||
                    endAnim();
 | 
			
		||||
                    rootNode.detachChild(missileNode);
 | 
			
		||||
                    this.spatial.removeControl(this);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                elapsedTime += tpf;
 | 
			
		||||
                float progress = elapsedTime / flightTime;
 | 
			
		||||
 | 
			
		||||
                if (progress >= 0.55) {
 | 
			
		||||
                    smoke.setParticlesPerSec(30);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                if (progress >= 0.7) {
 | 
			
		||||
                    smoke.setParticlesPerSec(0);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                if (progress >= 0.95f) {
 | 
			
		||||
                    explosion.trigger();
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                if (progress >= 1) {
 | 
			
		||||
                    explosion.trigger();
 | 
			
		||||
                    missileNode.detachChild(missileModel);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                Vector3f currentPosition = computeParabolicPath(start, target, progress);
 | 
			
		||||
                missileNode.setLocalTranslation(currentPosition);
 | 
			
		||||
 | 
			
		||||
                Vector3f direction = computeParabolicPath(start, target, progress + 0.01f)
 | 
			
		||||
                    .subtract(currentPosition)
 | 
			
		||||
                    .normalizeLocal();
 | 
			
		||||
                missileModel.lookAt(currentPosition.add(direction), Vector3f.UNIT_Y);
 | 
			
		||||
                missileModel.rotate(0, FastMath.HALF_PI, 0);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            @Override
 | 
			
		||||
            protected void controlRender(RenderManager rm, ViewPort vp) {
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void endAnim(){
 | 
			
		||||
        actionAfter.run();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Computes a position along a parabolic path at a given progress value {@code t}.
 | 
			
		||||
     *
 | 
			
		||||
     * @param start The starting point of the missile's flight.
 | 
			
		||||
     * @param target The target point of the missile's flight.
 | 
			
		||||
     * @param t The progress value (0.0 to 1.0) along the flight path.
 | 
			
		||||
     * @return The interpolated position along the parabolic path.
 | 
			
		||||
     */
 | 
			
		||||
    private Vector3f computeParabolicPath(Vector3f start, Vector3f target, float t) {
 | 
			
		||||
        Vector3f midPoint = start.add(target).multLocal(0.5f);
 | 
			
		||||
        midPoint.addLocal(0, 0, 20);
 | 
			
		||||
 | 
			
		||||
        Vector3f startToMid = FastMath.interpolateLinear(t, start, midPoint);
 | 
			
		||||
        Vector3f midToTarget = FastMath.interpolateLinear(t, midPoint, target);
 | 
			
		||||
        return FastMath.interpolateLinear(t, startToMid, midToTarget);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,127 @@
 | 
			
		||||
package pp.mdga.client.animation;
 | 
			
		||||
 | 
			
		||||
import com.jme3.effect.ParticleEmitter;
 | 
			
		||||
import com.jme3.effect.ParticleMesh;
 | 
			
		||||
import com.jme3.material.Material;
 | 
			
		||||
import com.jme3.math.ColorRGBA;
 | 
			
		||||
import com.jme3.math.Vector3f;
 | 
			
		||||
import com.jme3.scene.Node;
 | 
			
		||||
import com.jme3.scene.control.AbstractControl;
 | 
			
		||||
import pp.mdga.client.MdgaApp;
 | 
			
		||||
import pp.mdga.client.acoustic.MdgaSound;
 | 
			
		||||
 | 
			
		||||
public class Smoke {
 | 
			
		||||
 | 
			
		||||
    private final Node rootNode;
 | 
			
		||||
    private final MdgaApp app;
 | 
			
		||||
    private final Vector3f location;
 | 
			
		||||
    private ParticleEmitter fire;
 | 
			
		||||
    private ParticleEmitter smoke;
 | 
			
		||||
 | 
			
		||||
    private boolean triggered = false;
 | 
			
		||||
 | 
			
		||||
    private final Material mat;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Constructor for the {@code Explosion} class.
 | 
			
		||||
     *
 | 
			
		||||
     * @param app      The main application managing the explosion.
 | 
			
		||||
     * @param rootNode The root node to which the explosion effects will be attached.
 | 
			
		||||
     * @param location The location of the explosion in world coordinates.
 | 
			
		||||
     */
 | 
			
		||||
    public Smoke(MdgaApp app, Node rootNode, Vector3f location) {
 | 
			
		||||
        this.app = app;
 | 
			
		||||
        this.rootNode = rootNode;
 | 
			
		||||
        this.location = location;
 | 
			
		||||
 | 
			
		||||
        this.mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Particle.j3md");
 | 
			
		||||
        mat.setTexture("Texture", app.getAssetManager().loadTexture("Images/particle/vapor_cloud.png"));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Initializes the particle emitters for the explosion effect.
 | 
			
		||||
     * Configures the fire and smoke emitters with appearance, behavior, and lifespan.
 | 
			
		||||
     */
 | 
			
		||||
    private void initializeEmitter() {
 | 
			
		||||
        fire = new ParticleEmitter("Effect", ParticleMesh.Type.Triangle,50);
 | 
			
		||||
        fire.setMaterial(mat);
 | 
			
		||||
        fire.setStartColor(ColorRGBA.DarkGray);
 | 
			
		||||
        fire.setEndColor(ColorRGBA.DarkGray);
 | 
			
		||||
        fire.getParticleInfluencer().setInitialVelocity(new Vector3f(0.2f,0.2f,4f));
 | 
			
		||||
        fire.getParticleInfluencer().setVelocityVariation(0.4f);
 | 
			
		||||
        fire.setStartSize(0.7f);
 | 
			
		||||
        fire.setEndSize(3.8f);
 | 
			
		||||
        fire.setGravity(0, 0, -0.1f);
 | 
			
		||||
        fire.setLowLife(0.5f);
 | 
			
		||||
        fire.setHighLife(1.2f);
 | 
			
		||||
        fire.setParticlesPerSec(0);
 | 
			
		||||
 | 
			
		||||
        fire.setLocalTranslation(location);
 | 
			
		||||
 | 
			
		||||
        smoke = new ParticleEmitter("Effect2", ParticleMesh.Type.Triangle,40);
 | 
			
		||||
        smoke.setMaterial(mat);
 | 
			
		||||
        smoke.setImagesX(2);
 | 
			
		||||
        smoke.setImagesY(2);
 | 
			
		||||
        smoke.setStartColor(ColorRGBA.DarkGray);
 | 
			
		||||
        smoke.setEndColor(new ColorRGBA(0.05f, 0.05f, 0.05f, 1));
 | 
			
		||||
        smoke.getParticleInfluencer().setInitialVelocity(new Vector3f(0.0f,0.0f,2f));
 | 
			
		||||
        smoke.getParticleInfluencer().setVelocityVariation(0.5f);
 | 
			
		||||
        smoke.setStartSize(0.5f);
 | 
			
		||||
        smoke.setEndSize(1.5f);
 | 
			
		||||
        smoke.setGravity(0, 0, -0.3f);
 | 
			
		||||
        smoke.setLowLife(1.2f);
 | 
			
		||||
        smoke.setHighLife(2.5f);
 | 
			
		||||
        smoke.setParticlesPerSec(0);
 | 
			
		||||
 | 
			
		||||
        smoke.setLocalTranslation(location);
 | 
			
		||||
 | 
			
		||||
        app.getAcousticHandler().playSound(MdgaSound.EXPLOSION);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Triggers the explosion effect by attaching and activating the particle emitters for fire and smoke.
 | 
			
		||||
     * Both emitters are automatically detached after a predefined duration.
 | 
			
		||||
     */
 | 
			
		||||
    public void trigger() {
 | 
			
		||||
        if (!triggered) {
 | 
			
		||||
            triggered = true;
 | 
			
		||||
            initializeEmitter();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        rootNode.attachChild(fire);
 | 
			
		||||
        fire.emitAllParticles();
 | 
			
		||||
        fire.addControl(new AbstractControl() {
 | 
			
		||||
            private float elapsedTime = 0;
 | 
			
		||||
 | 
			
		||||
            @Override
 | 
			
		||||
            protected void controlUpdate(float tpf) {
 | 
			
		||||
                elapsedTime += tpf;
 | 
			
		||||
                if (elapsedTime > 10f) {
 | 
			
		||||
                    rootNode.detachChild(fire);
 | 
			
		||||
                    fire.removeControl(this);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            @Override
 | 
			
		||||
            protected void controlRender(com.jme3.renderer.RenderManager rm, com.jme3.renderer.ViewPort vp) {}
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        rootNode.attachChild(smoke);
 | 
			
		||||
        smoke.emitAllParticles();
 | 
			
		||||
        smoke.addControl(new AbstractControl() {
 | 
			
		||||
            private float elapsedTime = 0;
 | 
			
		||||
 | 
			
		||||
            @Override
 | 
			
		||||
            protected void controlUpdate(float tpf) {
 | 
			
		||||
                elapsedTime += tpf;
 | 
			
		||||
                if (elapsedTime > 10f) {
 | 
			
		||||
                    rootNode.detachChild(smoke);
 | 
			
		||||
                    smoke.removeControl(this);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            @Override
 | 
			
		||||
            protected void controlRender(com.jme3.renderer.RenderManager rm, com.jme3.renderer.ViewPort vp) {}
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -224,7 +224,7 @@ private Spatial createModel(Asset asset, Vector3f pos, float rot) {
 | 
			
		||||
     * @param y The y-coordinate on the grid
 | 
			
		||||
     * @return The corresponding world position
 | 
			
		||||
     */
 | 
			
		||||
    private static Vector3f gridToWorld(int x, int y) {
 | 
			
		||||
    public static Vector3f gridToWorld(int x, int y) {
 | 
			
		||||
        return new Vector3f(GRID_SIZE * x, GRID_SIZE * y, GRID_ELEVATION);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -240,16 +240,38 @@ private Spatial displayAsset(AssetOnMap assetOnMap) {
 | 
			
		||||
        return createModel(assetOnMap.asset(), gridToWorld(x, y), assetOnMap.rot());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Adds a visual representation of an asset to the scene, attaches a control to it, and returns the control.
 | 
			
		||||
     *
 | 
			
		||||
     * @param assetOnMap The asset to be displayed in the 3D environment.
 | 
			
		||||
     * @param control    The control to be added to the spatial representing the asset.
 | 
			
		||||
     * @param <T>        The type of control, extending {@code AbstractControl}.
 | 
			
		||||
     * @return The control that was added to the spatial.
 | 
			
		||||
     */
 | 
			
		||||
    private <T extends AbstractControl> T displayAndControl(AssetOnMap assetOnMap, T control) {
 | 
			
		||||
        Spatial spatial = displayAsset(assetOnMap);
 | 
			
		||||
        spatial.addControl(control);
 | 
			
		||||
        return control;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Moves a piece in the 3D environment to the location of a specified node.
 | 
			
		||||
     *
 | 
			
		||||
     * @param pieceControl The control managing the piece to be moved.
 | 
			
		||||
     * @param nodeControl  The control managing the target node to which the piece will move.
 | 
			
		||||
     */
 | 
			
		||||
    private void movePieceToNode(PieceControl pieceControl, NodeControl nodeControl){
 | 
			
		||||
        pieceControl.setLocation(nodeControl.getLocation());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Adds a home node for a specific player color, attaching it to the map of home nodes.
 | 
			
		||||
     *
 | 
			
		||||
     * @param map          The map storing lists of home nodes by player color.
 | 
			
		||||
     * @param color        The color associated with the home nodes to be added.
 | 
			
		||||
     * @param assetOnMap   The asset representing the home node in the 3D environment.
 | 
			
		||||
     * @throws RuntimeException if more than 4 home nodes are added for a single color.
 | 
			
		||||
     */
 | 
			
		||||
    private void addHomeNode(Map<Color, List<NodeControl>> map, Color color, AssetOnMap assetOnMap){
 | 
			
		||||
        List<NodeControl> homeNodes = addItemToMapList(map, color, displayAndControl(assetOnMap, new NodeControl(app, fpp)));
 | 
			
		||||
        if (homeNodes.size() > 4) throw new RuntimeException("too many homeNodes for " + color);
 | 
			
		||||
@@ -293,6 +315,16 @@ private void movePieceRek(UUID uuid, int curIndex, int moveIndex){
 | 
			
		||||
        movePieceRek(uuid, curIndex, moveIndex);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Adds an item to a list in a map. If the key does not exist in the map, a new list is created.
 | 
			
		||||
     *
 | 
			
		||||
     * @param map  The map containing lists of items.
 | 
			
		||||
     * @param key  The key associated with the list in the map.
 | 
			
		||||
     * @param item The item to be added to the list.
 | 
			
		||||
     * @param <T>  The type of items in the list.
 | 
			
		||||
     * @param <E>  The type of the key in the map.
 | 
			
		||||
     * @return The updated list associated with the specified key.
 | 
			
		||||
     */
 | 
			
		||||
    private <T, E> List<T> addItemToMapList(Map<E,List<T>> map, E key, T item){
 | 
			
		||||
        List<T> list = map.getOrDefault(key, new ArrayList<>());
 | 
			
		||||
        list.add(item);
 | 
			
		||||
@@ -300,12 +332,27 @@ private <T, E> List<T> addItemToMapList(Map<E,List<T>> map, E key, T item){
 | 
			
		||||
        return list;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Removes an item from a list in a map. If the key does not exist in the map, a new list is created.
 | 
			
		||||
     *
 | 
			
		||||
     * @param map  The map containing lists of items.
 | 
			
		||||
     * @param key  The key associated with the list in the map.
 | 
			
		||||
     * @param item The item to be removed from the list.
 | 
			
		||||
     * @param <T>  The type of items in the list.
 | 
			
		||||
     * @param <E>  The type of the key in the map.
 | 
			
		||||
     */
 | 
			
		||||
    private <T, E> void removeItemFromMapList(Map<E,List<T>> map, E key, T item){
 | 
			
		||||
        List<T> list = map.getOrDefault(key, new ArrayList<>());
 | 
			
		||||
        list.remove(item);
 | 
			
		||||
        map.put(key, list);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Calculates the mean position of the waiting nodes for a specific color.
 | 
			
		||||
     *
 | 
			
		||||
     * @param color The color associated with the waiting nodes.
 | 
			
		||||
     * @return The mean position of the waiting nodes as a {@code Vector3f}.
 | 
			
		||||
     */
 | 
			
		||||
    private Vector3f getWaitingPos(Color color){
 | 
			
		||||
        return getMeanPosition(waitingNodesMap.get(color).stream().map(NodeControl::getLocation).toList());
 | 
			
		||||
    }
 | 
			
		||||
@@ -753,7 +800,7 @@ public void throwPieceAnim(UUID uuid){
 | 
			
		||||
    public void throwPiece(UUID uuid, Color throwColor){
 | 
			
		||||
        switch(throwColor){
 | 
			
		||||
            case ARMY -> throwShell(uuid);
 | 
			
		||||
            case NAVY -> throwMissle(uuid);
 | 
			
		||||
            case NAVY -> throwMissile(uuid);
 | 
			
		||||
            case CYBER -> throwMatrix(uuid);
 | 
			
		||||
            case AIRFORCE -> throwBomb(uuid);
 | 
			
		||||
            default -> throw new RuntimeException("invalid color");
 | 
			
		||||
@@ -768,7 +815,7 @@ public void throwPiece(UUID uuid, Color throwColor){
 | 
			
		||||
    private void throwBomb(UUID uuid) {
 | 
			
		||||
        Vector3f targetPoint = pieces.get(uuid).getLocation();
 | 
			
		||||
 | 
			
		||||
        JetAnimation anim = new JetAnimation(app, rootNode, uuid, targetPoint, 40, 6, ()->throwPieceAnim(uuid));
 | 
			
		||||
        JetAnimation anim = new JetAnimation(app, rootNode, targetPoint, 40, 6, ()->throwPieceAnim(uuid));
 | 
			
		||||
        anim.start();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -785,8 +832,11 @@ private void throwMatrix(UUID uuid) {
 | 
			
		||||
        }));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void throwMissle(UUID uuid) {
 | 
			
		||||
    private void throwMissile(UUID uuid) {
 | 
			
		||||
        Vector3f targetPoint = pieces.get(uuid).getLocation();
 | 
			
		||||
 | 
			
		||||
        MissileAnimation anim = new MissileAnimation(app, rootNode, targetPoint, 2f, ()->throwPieceAnim(uuid));
 | 
			
		||||
        anim.start();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void throwShell(UUID uuid) {
 | 
			
		||||
 
 | 
			
		||||
@@ -18,17 +18,37 @@ public class OutlineControl extends InitControl {
 | 
			
		||||
    private static final int THICKNESS_DEFAULT = 6;
 | 
			
		||||
    private MdgaApp app;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Constructs an {@code OutlineControl} with default thickness for the object outline.
 | 
			
		||||
     *
 | 
			
		||||
     * @param app The main application managing the outline control.
 | 
			
		||||
     * @param fpp The {@code FilterPostProcessor} used for post-processing effects.
 | 
			
		||||
     */
 | 
			
		||||
    public OutlineControl(MdgaApp app, FilterPostProcessor fpp){
 | 
			
		||||
        this.app = app;
 | 
			
		||||
        outlineOwn = new SelectObjectOutliner(THICKNESS_DEFAULT, fpp, app.getRenderManager(), app.getAssetManager(), app.getCamera(), app);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Constructs an {@code OutlineControl} with default thickness, allowing a custom camera to be specified.
 | 
			
		||||
     *
 | 
			
		||||
     * @param app The main application managing the outline control.
 | 
			
		||||
     * @param fpp The {@code FilterPostProcessor} used for post-processing effects.
 | 
			
		||||
     * @param cam The camera used for rendering the outlined objects.
 | 
			
		||||
     */
 | 
			
		||||
    public OutlineControl(MdgaApp app, FilterPostProcessor fpp, Camera cam){
 | 
			
		||||
        this.app = app;
 | 
			
		||||
        outlineOwn = new SelectObjectOutliner(THICKNESS_DEFAULT, fpp, app.getRenderManager(), app.getAssetManager(), cam, app);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Constructs an {@code OutlineControl} with a specified thickness and custom camera.
 | 
			
		||||
     *
 | 
			
		||||
     * @param app       The main application managing the outline control.
 | 
			
		||||
     * @param fpp       The {@code FilterPostProcessor} used for post-processing effects.
 | 
			
		||||
     * @param cam       The camera used for rendering the outlined objects.
 | 
			
		||||
     * @param thickness The thickness of the outline.
 | 
			
		||||
     */
 | 
			
		||||
    public OutlineControl(MdgaApp app, FilterPostProcessor fpp, Camera cam, int thickness){
 | 
			
		||||
        this.app = app;
 | 
			
		||||
        outlineOwn = new SelectObjectOutliner(thickness, fpp, app.getRenderManager(), app.getAssetManager(), cam, app);
 | 
			
		||||
@@ -61,6 +81,11 @@ public void deOutline(){
 | 
			
		||||
        outlineOwn.deselect(spatial);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Retrieves the instance of the {@code MdgaApp} associated with this control.
 | 
			
		||||
     *
 | 
			
		||||
     * @return The {@code MdgaApp} instance.
 | 
			
		||||
     */
 | 
			
		||||
    public MdgaApp getApp() {
 | 
			
		||||
        return app;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -77,12 +77,17 @@ public SliderButton(MdgaApp app, Node node, String label) {
 | 
			
		||||
        QuadBackgroundComponent background = new QuadBackgroundComponent(BUTTON_NORMAL);
 | 
			
		||||
        slider.setBackground(background);
 | 
			
		||||
 | 
			
		||||
        // Set label background
 | 
			
		||||
        QuadBackgroundComponent labelBackground = new QuadBackgroundComponent(BUTTON_NORMAL);
 | 
			
		||||
        this.label.setBackground(labelBackground);
 | 
			
		||||
 | 
			
		||||
        // Configure the label font
 | 
			
		||||
        this.label.setFont(font);
 | 
			
		||||
        this.label.setTextHAlignment(HAlignment.Center);
 | 
			
		||||
 | 
			
		||||
        // Default position and size
 | 
			
		||||
        pos = new Vector2f(0, 0);
 | 
			
		||||
        size = new Vector2f(5.5f, 1);
 | 
			
		||||
        size = new Vector2f(6f, 1);
 | 
			
		||||
 | 
			
		||||
        // Add label and slider to container
 | 
			
		||||
        container.addChild(this.label);
 | 
			
		||||
 
 | 
			
		||||
@@ -7,6 +7,11 @@
 | 
			
		||||
import pp.mdga.client.button.SliderButton;
 | 
			
		||||
import pp.mdga.client.view.MdgaView;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * The {@code AudioSettingsDialog} class represents a dialog for adjusting audio settings in the application.
 | 
			
		||||
 * It provides controls for managing main volume, music volume, and sound effect volume, and includes
 | 
			
		||||
 * a button to return to the previous menu.
 | 
			
		||||
 */
 | 
			
		||||
public class AudioSettingsDialog extends Dialog {
 | 
			
		||||
    private final MdgaView view;
 | 
			
		||||
 | 
			
		||||
@@ -18,6 +23,13 @@ public class AudioSettingsDialog extends Dialog {
 | 
			
		||||
 | 
			
		||||
    private boolean active = false;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Constructs an {@code AudioSettingsDialog}.
 | 
			
		||||
     *
 | 
			
		||||
     * @param app  The main application managing the dialog.
 | 
			
		||||
     * @param node The root node for attaching UI elements.
 | 
			
		||||
     * @param view The current view, used for navigation and interaction with the dialog.
 | 
			
		||||
     */
 | 
			
		||||
    public AudioSettingsDialog(MdgaApp app, Node node, MdgaView view) {
 | 
			
		||||
        super(app, node);
 | 
			
		||||
 | 
			
		||||
@@ -42,6 +54,9 @@ public AudioSettingsDialog(MdgaApp app, Node node, MdgaView view) {
 | 
			
		||||
        backButton.setPos(new Vector2f(0, 1.8f));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Called when the dialog is shown. Initializes and displays the volume controls and back button.
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void onShow() {
 | 
			
		||||
        active = true;
 | 
			
		||||
@@ -57,6 +72,9 @@ protected void onShow() {
 | 
			
		||||
        soundVolume.show();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Called when the dialog is hidden. Hides all volume controls and the back button.
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void onHide() {
 | 
			
		||||
        active = false;
 | 
			
		||||
@@ -68,6 +86,10 @@ protected void onHide() {
 | 
			
		||||
        soundVolume.hide();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Updates the application audio settings based on the current values of the sliders.
 | 
			
		||||
     * This method is called continuously while the dialog is active.
 | 
			
		||||
     */
 | 
			
		||||
    public void update() {
 | 
			
		||||
        if(!active) {
 | 
			
		||||
            return;
 | 
			
		||||
 
 | 
			
		||||
@@ -10,17 +10,30 @@
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * The {@code CeremonyDialog} class displays a dialog containing statistical data in a tabular format.
 | 
			
		||||
 * It allows adding rows of statistics and manages their visibility when shown or hidden.
 | 
			
		||||
 */
 | 
			
		||||
public class CeremonyDialog extends Dialog {
 | 
			
		||||
    private ArrayList<ArrayList<LabelButton>> labels;
 | 
			
		||||
 | 
			
		||||
    float offsetX;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Constructs a {@code CeremonyDialog}.
 | 
			
		||||
     *
 | 
			
		||||
     * @param app  The main application managing the dialog.
 | 
			
		||||
     * @param node The root node for attaching UI elements.
 | 
			
		||||
     */
 | 
			
		||||
    public CeremonyDialog(MdgaApp app, Node node) {
 | 
			
		||||
        super(app, node);
 | 
			
		||||
 | 
			
		||||
        prepare();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Called when the dialog is shown. Makes all label buttons in the table visible.
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void onShow() {
 | 
			
		||||
        for (ArrayList<LabelButton> row : labels) {
 | 
			
		||||
@@ -30,6 +43,9 @@ protected void onShow() {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Called when the dialog is hidden. Hides all label buttons in the table.
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void onHide() {
 | 
			
		||||
        for (ArrayList<LabelButton> row : labels) {
 | 
			
		||||
@@ -39,6 +55,17 @@ protected void onHide() {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Adds a row of statistical data to the dialog.
 | 
			
		||||
     *
 | 
			
		||||
     * @param name The name of the player or category for the row.
 | 
			
		||||
     * @param v1   The value for the first column.
 | 
			
		||||
     * @param v2   The value for the second column.
 | 
			
		||||
     * @param v3   The value for the third column.
 | 
			
		||||
     * @param v4   The value for the fourth column.
 | 
			
		||||
     * @param v5   The value for the fifth column.
 | 
			
		||||
     * @param v6   The value for the sixth column.
 | 
			
		||||
     */
 | 
			
		||||
    public void addStatisticsRow(String name, int v1, int v2, int v3, int v4, int v5, int v6) {
 | 
			
		||||
        float offsetYSmall = 0.5f;
 | 
			
		||||
 | 
			
		||||
@@ -76,6 +103,9 @@ public void addStatisticsRow(String name, int v1, int v2, int v3, int v4, int v5
 | 
			
		||||
        labels.add(row);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Prepares the initial layout of the dialog, including header labels.
 | 
			
		||||
     */
 | 
			
		||||
    public void prepare() {
 | 
			
		||||
        offsetX = 0.5f;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -4,30 +4,53 @@
 | 
			
		||||
import com.simsilica.lemur.Container;
 | 
			
		||||
import pp.mdga.client.MdgaApp;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * The {@code Dialog} class serves as an abstract base class for dialogs in the application.
 | 
			
		||||
 * It provides functionality for showing and hiding the dialog and defines abstract methods
 | 
			
		||||
 * for custom behavior when the dialog is shown or hidden.
 | 
			
		||||
 */
 | 
			
		||||
public abstract class Dialog {
 | 
			
		||||
    protected final MdgaApp app;
 | 
			
		||||
    protected final Node node = new Node();
 | 
			
		||||
 | 
			
		||||
    private final Node root;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Constructs a {@code Dialog}.
 | 
			
		||||
     *
 | 
			
		||||
     * @param app  The main application managing the dialog.
 | 
			
		||||
     * @param node The root node to which the dialog's node will be attached.
 | 
			
		||||
     */
 | 
			
		||||
    Dialog(MdgaApp app, Node node) {
 | 
			
		||||
        this.app = app;
 | 
			
		||||
        this.root = node;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Shows the dialog by attaching its node to the root node and invoking the {@code onShow} method.
 | 
			
		||||
     */
 | 
			
		||||
    public void show() {
 | 
			
		||||
        root.attachChild(node);
 | 
			
		||||
 | 
			
		||||
        onShow();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Hides the dialog by detaching its node from the root node and invoking the {@code onHide} method.
 | 
			
		||||
     */
 | 
			
		||||
    public void hide() {
 | 
			
		||||
        root.detachChild(node);
 | 
			
		||||
 | 
			
		||||
        onHide();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Called when the dialog is shown. Subclasses must implement this method to define custom behavior.
 | 
			
		||||
     */
 | 
			
		||||
    protected abstract void onShow();
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Called when the dialog is hidden. Subclasses must implement this method to define custom behavior.
 | 
			
		||||
     */
 | 
			
		||||
    protected abstract void onHide();
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -12,6 +12,10 @@
 | 
			
		||||
 | 
			
		||||
import java.util.prefs.Preferences;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * The {@code HostDialog} class represents a dialog for hosting a network game session.
 | 
			
		||||
 * It allows users to input a port number, start hosting a server, and navigate back to the previous view.
 | 
			
		||||
 */
 | 
			
		||||
public class HostDialog  extends NetworkDialog {
 | 
			
		||||
    private InputButton portInput;
 | 
			
		||||
 | 
			
		||||
@@ -22,6 +26,13 @@ public class HostDialog  extends NetworkDialog {
 | 
			
		||||
 | 
			
		||||
    private Preferences prefs = Preferences.userNodeForPackage(JoinDialog.class);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Constructs a {@code HostDialog}.
 | 
			
		||||
     *
 | 
			
		||||
     * @param app  The main application managing the dialog.
 | 
			
		||||
     * @param node The root node for attaching UI elements.
 | 
			
		||||
     * @param view The main view used for navigation and interaction with the dialog.
 | 
			
		||||
     */
 | 
			
		||||
    public HostDialog(MdgaApp app, Node node, MainView view) {
 | 
			
		||||
        super(app, node, (NetworkSupport) app.getNetworkSupport());
 | 
			
		||||
 | 
			
		||||
@@ -39,6 +50,9 @@ public HostDialog(MdgaApp app, Node node, MainView view) {
 | 
			
		||||
        offset += 1.5f;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Called when the dialog is shown. Displays all input fields and buttons.
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void onShow() {
 | 
			
		||||
        portInput.show();
 | 
			
		||||
@@ -46,6 +60,9 @@ protected void onShow() {
 | 
			
		||||
        backButton.show();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Called when the dialog is hidden. Hides all input fields and buttons.
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void onHide() {
 | 
			
		||||
        portInput.hide();
 | 
			
		||||
@@ -53,27 +70,44 @@ protected void onHide() {
 | 
			
		||||
        backButton.hide();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Updates the state of the port input field.
 | 
			
		||||
     * This method is called periodically to synchronize the dialog state.
 | 
			
		||||
     */
 | 
			
		||||
    public void update() {
 | 
			
		||||
        portInput.update();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Retrieves the currently entered port number, saves it to preferences, and sets it as the active port.
 | 
			
		||||
     *
 | 
			
		||||
     * @return The port number as a string.
 | 
			
		||||
     */
 | 
			
		||||
    public String getPort() {
 | 
			
		||||
        prefs.put("hostPort", portInput.getString());
 | 
			
		||||
        setPortNumber(Integer.parseInt(portInput.getString()));
 | 
			
		||||
        return portInput.getString();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Resets the port input field to its default value and updates preferences accordingly.
 | 
			
		||||
     */
 | 
			
		||||
    public void resetPort() {
 | 
			
		||||
        portInput.reset();
 | 
			
		||||
        prefs.put("hostPort", "11111");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Starts the server to host a network game.
 | 
			
		||||
     */
 | 
			
		||||
    public void hostServer() {
 | 
			
		||||
        startServer();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Connects to the server as a client.
 | 
			
		||||
     */
 | 
			
		||||
    public void connectServerAsClient() {
 | 
			
		||||
        connectServer();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -8,36 +8,77 @@
 | 
			
		||||
import pp.mdga.client.button.LabelButton;
 | 
			
		||||
import pp.mdga.client.button.MenuButton;
 | 
			
		||||
import pp.mdga.client.view.MdgaView;
 | 
			
		||||
import pp.mdga.game.Color;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * The {@code InterruptDialog} class represents a dialog that interrupts the game flow,
 | 
			
		||||
 * providing a message and the option to force an action if the user is a host.
 | 
			
		||||
 */
 | 
			
		||||
public class InterruptDialog extends Dialog {
 | 
			
		||||
    private ButtonRight forceButton;
 | 
			
		||||
 | 
			
		||||
    private LabelButton label;
 | 
			
		||||
 | 
			
		||||
    private String text = "";
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Constructs an {@code InterruptDialog}.
 | 
			
		||||
     *
 | 
			
		||||
     * @param app  The main application managing the dialog.
 | 
			
		||||
     * @param node The root node for attaching UI elements.
 | 
			
		||||
     */
 | 
			
		||||
    public InterruptDialog(MdgaApp app, Node node) {
 | 
			
		||||
        super(app, node);
 | 
			
		||||
 | 
			
		||||
        forceButton = new ButtonRight(app, node, () -> app.getModelSynchronize().force(), "Erzwingen", 1);
 | 
			
		||||
 | 
			
		||||
        label = new LabelButton(app, node, "Warte auf Spieler...", new Vector2f(5.5f * 1.5f, 2), new Vector2f(0.5f, 0f), false);
 | 
			
		||||
 | 
			
		||||
        float offset = 2.8f;
 | 
			
		||||
 | 
			
		||||
        label.setPos(new Vector2f(0, MenuButton.VERTICAL - offset));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Called when the dialog is shown. Displays the label and optionally the force button if the user is the host.
 | 
			
		||||
     */
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void onShow() {
 | 
			
		||||
        if(app.getGameLogic().isHost()) {
 | 
			
		||||
            forceButton.show();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        label = new LabelButton(app, node, "Warte auf " + text + "...", new Vector2f(5.5f * 1.5f, 2), new Vector2f(0.5f, 0f), false);
 | 
			
		||||
 | 
			
		||||
        float offset = 2.8f;
 | 
			
		||||
        label.setPos(new Vector2f(0, MenuButton.VERTICAL - offset));
 | 
			
		||||
 | 
			
		||||
        label.show();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Called when the dialog is hidden. Hides the label and the force button.
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void onHide() {
 | 
			
		||||
        forceButton.hide();
 | 
			
		||||
        label.hide();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Sets the displayed text based on the specified color.
 | 
			
		||||
     *
 | 
			
		||||
     * @param color The color used to determine the text (e.g., "Luftwaffe" for AIRFORCE).
 | 
			
		||||
     */
 | 
			
		||||
    public void setColor(Color color) {
 | 
			
		||||
        switch (color) {
 | 
			
		||||
            case AIRFORCE:
 | 
			
		||||
                text = "Luftwaffe";
 | 
			
		||||
                break;
 | 
			
		||||
            case ARMY:
 | 
			
		||||
                text = "Heer";
 | 
			
		||||
                break;
 | 
			
		||||
            case NAVY:
 | 
			
		||||
                text = "Marine";
 | 
			
		||||
                break;
 | 
			
		||||
            case CYBER:
 | 
			
		||||
                text = "CIR";
 | 
			
		||||
                break;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -13,6 +13,10 @@
 | 
			
		||||
 | 
			
		||||
import java.util.prefs.Preferences;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * The {@code JoinDialog} class represents a dialog for joining a network game.
 | 
			
		||||
 * It allows users to input an IP address and port number, connect to a server, or navigate back to the previous view.
 | 
			
		||||
 */
 | 
			
		||||
public class JoinDialog extends NetworkDialog {
 | 
			
		||||
    private InputButton ipInput;
 | 
			
		||||
    private InputButton portInput;
 | 
			
		||||
@@ -24,6 +28,13 @@ public class JoinDialog extends NetworkDialog {
 | 
			
		||||
 | 
			
		||||
    private Preferences prefs = Preferences.userNodeForPackage(JoinDialog.class);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Constructs a {@code JoinDialog}.
 | 
			
		||||
     *
 | 
			
		||||
     * @param app  The main application managing the dialog.
 | 
			
		||||
     * @param node The root node for attaching UI elements.
 | 
			
		||||
     * @param view The main view used for navigation and interaction with the dialog.
 | 
			
		||||
     */
 | 
			
		||||
    public JoinDialog(MdgaApp app, Node node, MainView view) {
 | 
			
		||||
        super(app, node, (NetworkSupport) app.getNetworkSupport());
 | 
			
		||||
 | 
			
		||||
@@ -46,6 +57,9 @@ public JoinDialog(MdgaApp app, Node node, MainView view) {
 | 
			
		||||
        offset += 1.5f;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Called when the dialog is shown. Displays all input fields and buttons.
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void onShow() {
 | 
			
		||||
        ipInput.show();
 | 
			
		||||
@@ -54,6 +68,9 @@ protected void onShow() {
 | 
			
		||||
        backButton.show();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Called when the dialog is hidden. Hides all input fields and buttons.
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void onHide() {
 | 
			
		||||
        ipInput.hide();
 | 
			
		||||
@@ -62,37 +79,62 @@ protected void onHide() {
 | 
			
		||||
        backButton.hide();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Updates the state of the input fields. This method is called periodically to synchronize the dialog state.
 | 
			
		||||
     */
 | 
			
		||||
    public void update() {
 | 
			
		||||
        ipInput.update();
 | 
			
		||||
        portInput.update();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Retrieves the currently entered IP address, saves it to preferences, and sets it as the hostname.
 | 
			
		||||
     *
 | 
			
		||||
     * @return The IP address as a string.
 | 
			
		||||
     */
 | 
			
		||||
    public String getIpt() {
 | 
			
		||||
        prefs.put("joinIp", ipInput.getString());
 | 
			
		||||
        setHostname(ipInput.getString());
 | 
			
		||||
        return ipInput.getString();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Resets the IP input field to its default value and updates preferences accordingly.
 | 
			
		||||
     */
 | 
			
		||||
    public void resetIp() {
 | 
			
		||||
        ipInput.reset();
 | 
			
		||||
        prefs.put("joinIp", "");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Retrieves the currently entered port number, saves it to preferences, and sets it as the active port.
 | 
			
		||||
     *
 | 
			
		||||
     * @return The port number as a string.
 | 
			
		||||
     */
 | 
			
		||||
    public String getPort() {
 | 
			
		||||
        prefs.put("joinPort", portInput.getString());
 | 
			
		||||
        setPortNumber(Integer.parseInt(portInput.getString()));
 | 
			
		||||
        return portInput.getString();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Resets the port input field to its default value and updates preferences accordingly.
 | 
			
		||||
     */
 | 
			
		||||
    public void resetPort() {
 | 
			
		||||
        portInput.reset();
 | 
			
		||||
        prefs.put("joinPort", "11111");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Connects to the server using the current IP address and port number.
 | 
			
		||||
     */
 | 
			
		||||
    public void connectToServer() {
 | 
			
		||||
        connectServer();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Disconnects from the server if a network connection exists.
 | 
			
		||||
     */
 | 
			
		||||
    public void disconnect() {
 | 
			
		||||
        NetworkSupport network = getNetwork();
 | 
			
		||||
        if (network != null) {
 | 
			
		||||
@@ -104,4 +146,3 @@ public void disconnect() {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -8,6 +8,11 @@
 | 
			
		||||
import java.util.concurrent.ExecutionException;
 | 
			
		||||
import java.util.concurrent.Future;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * The {@code NetworkDialog} class serves as an abstract base class for dialogs
 | 
			
		||||
 * that involve network-related functionalities, such as connecting to a server or hosting a game.
 | 
			
		||||
 * It provides methods for initializing, connecting to, and managing a network server.
 | 
			
		||||
 */
 | 
			
		||||
public abstract class NetworkDialog extends Dialog {
 | 
			
		||||
 | 
			
		||||
    private NetworkSupport network;
 | 
			
		||||
@@ -17,19 +22,41 @@ public abstract class NetworkDialog extends Dialog {
 | 
			
		||||
    private MdgaServer serverInstance;
 | 
			
		||||
    private Thread serverThread;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Constructs a {@code NetworkDialog}.
 | 
			
		||||
     *
 | 
			
		||||
     * @param app      The main application managing the dialog.
 | 
			
		||||
     * @param node     The root node for attaching UI elements.
 | 
			
		||||
     * @param network  The network support instance for managing network interactions.
 | 
			
		||||
     */
 | 
			
		||||
    public NetworkDialog(MdgaApp app, Node node, NetworkSupport network) {
 | 
			
		||||
        super(app, node);
 | 
			
		||||
        this.network = network;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Sets the hostname for the network connection.
 | 
			
		||||
     *
 | 
			
		||||
     * @param hostname The hostname or IP address of the server.
 | 
			
		||||
     */
 | 
			
		||||
    public void setHostname(String hostname) {
 | 
			
		||||
        this.hostname = hostname;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Sets the port number for the network connection.
 | 
			
		||||
     *
 | 
			
		||||
     * @param portNumber The port number to use for the connection.
 | 
			
		||||
     */
 | 
			
		||||
    public void setPortNumber(int portNumber) {
 | 
			
		||||
        this.portNumber = portNumber;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Initializes the network connection using the current hostname and port number.
 | 
			
		||||
     *
 | 
			
		||||
     * @return {@code null} if successful, otherwise throws an exception.
 | 
			
		||||
     */
 | 
			
		||||
    protected Object initNetwork() {
 | 
			
		||||
        try {
 | 
			
		||||
            this.network.initNetwork(this.hostname, this.portNumber);
 | 
			
		||||
@@ -39,6 +66,9 @@ protected Object initNetwork() {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Starts the process of connecting to a server asynchronously.
 | 
			
		||||
     */
 | 
			
		||||
    protected void connectServer() {
 | 
			
		||||
        try {
 | 
			
		||||
            connectionFuture = this.network.getApp().getExecutor().submit(this::initNetwork);
 | 
			
		||||
@@ -47,6 +77,9 @@ protected void connectServer() {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Starts hosting a server in a separate thread.
 | 
			
		||||
     */
 | 
			
		||||
    protected void startServer() {
 | 
			
		||||
        serverThread = new Thread(() -> {
 | 
			
		||||
            try {
 | 
			
		||||
@@ -60,6 +93,9 @@ protected void startServer() {
 | 
			
		||||
        serverThread.start();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Shuts down the hosted server and cleans up resources.
 | 
			
		||||
     */
 | 
			
		||||
    public void shutdownServer() {
 | 
			
		||||
 | 
			
		||||
        try {
 | 
			
		||||
@@ -85,6 +121,11 @@ public void shutdownServer() {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Updates the state of the connection process.
 | 
			
		||||
     *
 | 
			
		||||
     * @param delta The time elapsed since the last update call.
 | 
			
		||||
     */
 | 
			
		||||
    public void update(float delta) {
 | 
			
		||||
        if (this.connectionFuture != null && this.connectionFuture.isDone()) {
 | 
			
		||||
            try {
 | 
			
		||||
@@ -97,6 +138,11 @@ public void update(float delta) {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Retrieves the {@code NetworkSupport} instance associated with this dialog.
 | 
			
		||||
     *
 | 
			
		||||
     * @return The {@code NetworkSupport} instance.
 | 
			
		||||
     */
 | 
			
		||||
    public NetworkSupport getNetwork() {
 | 
			
		||||
        return network;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -8,6 +8,10 @@
 | 
			
		||||
import pp.mdga.client.view.MainView;
 | 
			
		||||
import pp.mdga.client.view.MdgaView;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * The {@code SettingsDialog} class represents a dialog for navigating to various settings sections,
 | 
			
		||||
 * such as video and audio settings, or returning to the previous view.
 | 
			
		||||
 */
 | 
			
		||||
public class SettingsDialog extends Dialog {
 | 
			
		||||
    private MenuButton videoButton;
 | 
			
		||||
    private MenuButton audioButton;
 | 
			
		||||
@@ -15,6 +19,13 @@ public class SettingsDialog extends Dialog {
 | 
			
		||||
 | 
			
		||||
    private final MdgaView view;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Constructs a {@code SettingsDialog}.
 | 
			
		||||
     *
 | 
			
		||||
     * @param app  The main application managing the dialog.
 | 
			
		||||
     * @param node The root node for attaching UI elements.
 | 
			
		||||
     * @param view The view managing navigation and interaction with the settings dialog.
 | 
			
		||||
     */
 | 
			
		||||
    public SettingsDialog(MdgaApp app, Node node, MdgaView view) {
 | 
			
		||||
        super(app, node);
 | 
			
		||||
 | 
			
		||||
@@ -34,6 +45,9 @@ public SettingsDialog(MdgaApp app, Node node, MdgaView view) {
 | 
			
		||||
        backButton.setPos(new Vector2f(0, 1.8f));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Called when the dialog is shown. Displays all buttons for video settings, audio settings, and back navigation.
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void onShow() {
 | 
			
		||||
        videoButton.show();
 | 
			
		||||
@@ -41,6 +55,9 @@ protected void onShow() {
 | 
			
		||||
        backButton.show();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Called when the dialog is hidden. Hides all buttons for video settings, audio settings, and back navigation.
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void onHide() {
 | 
			
		||||
        videoButton.hide();
 | 
			
		||||
 
 | 
			
		||||
@@ -14,6 +14,10 @@
 | 
			
		||||
import java.util.Random;
 | 
			
		||||
import java.util.random.RandomGenerator;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * The {@code StartDialog} class represents the initial dialog in the application,
 | 
			
		||||
 * allowing the user to input their name, host or join a game, or exit the application.
 | 
			
		||||
 */
 | 
			
		||||
public class StartDialog extends Dialog {
 | 
			
		||||
    private InputButton nameInput;
 | 
			
		||||
 | 
			
		||||
@@ -23,6 +27,13 @@ public class StartDialog extends Dialog {
 | 
			
		||||
 | 
			
		||||
    private final MainView view;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Constructs a {@code StartDialog}.
 | 
			
		||||
     *
 | 
			
		||||
     * @param app  The main application managing the dialog.
 | 
			
		||||
     * @param node The root node for attaching UI elements.
 | 
			
		||||
     * @param view The main view used for navigation and interaction with the dialog.
 | 
			
		||||
     */
 | 
			
		||||
    public StartDialog(MdgaApp app, Node node, MainView view) {
 | 
			
		||||
        super(app, node);
 | 
			
		||||
 | 
			
		||||
@@ -48,6 +59,9 @@ public StartDialog(MdgaApp app, Node node, MainView view) {
 | 
			
		||||
        endButton.setPos(new Vector2f(0, 1.8f));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Called when the dialog is shown. Displays the name input field and all buttons.
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void onShow() {
 | 
			
		||||
        nameInput.show();
 | 
			
		||||
@@ -57,6 +71,9 @@ protected void onShow() {
 | 
			
		||||
        endButton.show();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Called when the dialog is hidden. Hides the name input field and all buttons.
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void onHide ()
 | 
			
		||||
    {
 | 
			
		||||
@@ -67,10 +84,18 @@ protected void onHide ()
 | 
			
		||||
        endButton.hide();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Updates the state of the name input field. This method is called periodically to synchronize the dialog state.
 | 
			
		||||
     */
 | 
			
		||||
    public void update() {
 | 
			
		||||
        nameInput.update();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Retrieves the name entered by the user. If no name is provided, a random name is generated.
 | 
			
		||||
     *
 | 
			
		||||
     * @return The user's name or a randomly generated name.
 | 
			
		||||
     */
 | 
			
		||||
    public String getName() {
 | 
			
		||||
        String name = nameInput.getString();
 | 
			
		||||
 | 
			
		||||
@@ -206,7 +231,7 @@ public String getName() {
 | 
			
		||||
                "FluffiKopf",
 | 
			
		||||
                "DonutDöner",
 | 
			
		||||
                "VollpfostenX",
 | 
			
		||||
                "Schraubenschlüssel",
 | 
			
		||||
                "Waschlappen",
 | 
			
		||||
                "Witzepumper",
 | 
			
		||||
                "ToastTraum",
 | 
			
		||||
                "FroschFighter",
 | 
			
		||||
@@ -263,22 +288,22 @@ public String getName() {
 | 
			
		||||
                "VulkanKeks",
 | 
			
		||||
                "WasserToast",
 | 
			
		||||
                "MenschSalat",
 | 
			
		||||
                "KampfKohlenhydrate",
 | 
			
		||||
                "KampfKohl",
 | 
			
		||||
                "SockenZirkus",
 | 
			
		||||
                "SchwimmBärchen",
 | 
			
		||||
                "TanzenderDachgepäckträger",
 | 
			
		||||
                "TanzenderPudel",
 | 
			
		||||
                "PizzamarktMensch",
 | 
			
		||||
                "ZahnarztZocker",
 | 
			
		||||
                "RollerCoasterTester",
 | 
			
		||||
                "WaschmaschinenPilot",
 | 
			
		||||
                "RollerRudi",
 | 
			
		||||
                "PupsPilot",
 | 
			
		||||
                "WitzigeZwiebel",
 | 
			
		||||
                "Pillenschlucker",
 | 
			
		||||
                "ZwiebelReiter",
 | 
			
		||||
                "HüpfenderKaktus",
 | 
			
		||||
                "KochenderAsteroid",
 | 
			
		||||
                "AsteroidenAlf",
 | 
			
		||||
                "ChaosKarotte",
 | 
			
		||||
                "WolkenFurz",
 | 
			
		||||
                "SchnitzelPartikel",
 | 
			
		||||
                "Krümelmonster",
 | 
			
		||||
                "WackelBiene",
 | 
			
		||||
            };
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -11,6 +11,11 @@
 | 
			
		||||
 | 
			
		||||
import java.util.prefs.Preferences;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * The {@code VideoSettingsDialog} class represents a dialog for configuring video settings,
 | 
			
		||||
 * such as resolution and fullscreen mode. It also provides an option to restart the application
 | 
			
		||||
 * when certain settings are changed.
 | 
			
		||||
 */
 | 
			
		||||
public class VideoSettingsDialog extends Dialog {
 | 
			
		||||
    private static Preferences prefs = Preferences.userNodeForPackage(JoinDialog.class);
 | 
			
		||||
 | 
			
		||||
@@ -29,6 +34,13 @@ public class VideoSettingsDialog extends Dialog {
 | 
			
		||||
 | 
			
		||||
    private boolean active = false;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Constructs a {@code VideoSettingsDialog}.
 | 
			
		||||
     *
 | 
			
		||||
     * @param app  The main application managing the dialog.
 | 
			
		||||
     * @param node The root node for attaching UI elements.
 | 
			
		||||
     * @param view The view managing navigation and interaction with the video settings dialog.
 | 
			
		||||
     */
 | 
			
		||||
    public VideoSettingsDialog(MdgaApp app, Node node, MdgaView view) {
 | 
			
		||||
        super(app, node);
 | 
			
		||||
 | 
			
		||||
@@ -67,6 +79,9 @@ public VideoSettingsDialog(MdgaApp app, Node node, MdgaView view) {
 | 
			
		||||
        backButton.setPos(new Vector2f(0, 1.8f));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Called when the dialog is shown. Displays all buttons and marks the dialog as active.
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void onShow() {
 | 
			
		||||
        active = true;
 | 
			
		||||
@@ -83,6 +98,9 @@ protected void onShow() {
 | 
			
		||||
        backButton.show();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Called when the dialog is hidden. Hides all buttons and marks the dialog as inactive.
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void onHide() {
 | 
			
		||||
        active = false;
 | 
			
		||||
@@ -100,12 +118,23 @@ protected void onHide() {
 | 
			
		||||
        restartButton.hide();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Updates the dialog's state. This method can be used for periodic updates while the dialog is active.
 | 
			
		||||
     */
 | 
			
		||||
    public void update() {
 | 
			
		||||
        if(!active) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Updates the resolution settings and optionally triggers the restart button if changes are detected.
 | 
			
		||||
     *
 | 
			
		||||
     * @param width         The width of the resolution.
 | 
			
		||||
     * @param height        The height of the resolution.
 | 
			
		||||
     * @param imageFactor   The scaling factor for the resolution.
 | 
			
		||||
     * @param isFullscreen  {@code true} if fullscreen mode is enabled, {@code false} otherwise.
 | 
			
		||||
     */
 | 
			
		||||
    public void updateResolution(int width, int height, float imageFactor, boolean isFullscreen) {
 | 
			
		||||
        if(width != prefs.getInt("width", 1280) || height != prefs.getInt("height", 720) || isFullscreen != prefs.getBoolean("fullscreen", false)) {
 | 
			
		||||
            restartButton.show();
 | 
			
		||||
 
 | 
			
		||||
@@ -10,12 +10,25 @@
 | 
			
		||||
import pp.mdga.client.animation.ZoomControl;
 | 
			
		||||
import pp.mdga.game.Color;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * The {@code ActionTextHandler} class manages the display of animated and stylized text messages in the game's UI.
 | 
			
		||||
 * It supports dynamic text creation with spacing, color, and effects, such as dice rolls, player actions, and rankings.
 | 
			
		||||
 */
 | 
			
		||||
 class ActionTextHandler {
 | 
			
		||||
    private Node root;
 | 
			
		||||
    private BitmapFont font;
 | 
			
		||||
    private AppSettings appSettings;
 | 
			
		||||
    private int ranking;
 | 
			
		||||
 | 
			
		||||
    float paddingRanked = 100;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Constructs an {@code ActionTextHandler}.
 | 
			
		||||
     *
 | 
			
		||||
     * @param guiNode      The GUI node where the text messages will be displayed.
 | 
			
		||||
     * @param assetManager The asset manager used to load fonts and other assets.
 | 
			
		||||
     * @param appSettings  The application settings for positioning and sizing.
 | 
			
		||||
     */
 | 
			
		||||
     ActionTextHandler(Node guiNode, AssetManager assetManager, AppSettings appSettings){
 | 
			
		||||
        root = new Node("actionTextRoot");
 | 
			
		||||
        guiNode.attachChild(root);
 | 
			
		||||
@@ -26,6 +39,16 @@ class ActionTextHandler {
 | 
			
		||||
        ranking = 0;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Creates a {@code Node} containing text with specified spacing, size, and colors for each segment of the text.
 | 
			
		||||
     *
 | 
			
		||||
     * @param textArr  An array of strings representing the text to be displayed.
 | 
			
		||||
     * @param spacing  The spacing between individual characters.
 | 
			
		||||
     * @param size     The size of the text.
 | 
			
		||||
     * @param colorArr An array of {@code ColorRGBA} representing the color for each string in {@code textArr}.
 | 
			
		||||
     * @return A {@code Node} containing the styled text with spacing and color applied.
 | 
			
		||||
     * @throws RuntimeException if the lengths of {@code textArr} and {@code colorArr} do not match.
 | 
			
		||||
     */
 | 
			
		||||
    private Node createTextWithSpacing(String[] textArr, float spacing, float size, ColorRGBA[] colorArr) {
 | 
			
		||||
        if(textArr.length != colorArr.length) throw new RuntimeException("text and color are not the same length");
 | 
			
		||||
 | 
			
		||||
@@ -52,18 +75,55 @@ private Node createTextWithSpacing(String[] textArr, float spacing, float size,
 | 
			
		||||
        return textNode;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Creates a {@code Node} containing text with specified spacing, size, and a single color.
 | 
			
		||||
     *
 | 
			
		||||
     * @param text    The text to be displayed.
 | 
			
		||||
     * @param spacing The spacing between individual characters.
 | 
			
		||||
     * @param size    The size of the text.
 | 
			
		||||
     * @param color   The color of the text.
 | 
			
		||||
     * @return A {@code Node} containing the styled text.
 | 
			
		||||
     */
 | 
			
		||||
    private Node createTextWithSpacing(String text, float spacing, float size, ColorRGBA color) {
 | 
			
		||||
        return createTextWithSpacing(new String[]{text}, spacing, size, new ColorRGBA[]{color});
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Calculates the center position of a rectangle given its width, height, and an origin position.
 | 
			
		||||
     *
 | 
			
		||||
     * @param width  The width of the rectangle.
 | 
			
		||||
     * @param height The height of the rectangle.
 | 
			
		||||
     * @param pos    The origin position of the rectangle.
 | 
			
		||||
     * @return A {@code Vector3f} representing the center position.
 | 
			
		||||
     */
 | 
			
		||||
    private Vector3f center(float width, float height, Vector3f pos){
 | 
			
		||||
        return new Vector3f(pos.x+width/2, pos.y+height/2,0);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Creates and positions a single-line text at the top of the screen with a specified vertical offset.
 | 
			
		||||
     *
 | 
			
		||||
     * @param name    The text to be displayed.
 | 
			
		||||
     * @param spacing The spacing between individual characters.
 | 
			
		||||
     * @param size    The size of the text.
 | 
			
		||||
     * @param color   The color of the text.
 | 
			
		||||
     * @param top     The vertical offset from the top of the screen.
 | 
			
		||||
     * @return A {@code Node} containing the styled text positioned at the top.
 | 
			
		||||
     */
 | 
			
		||||
    private Node createTopText(String name, float spacing, float size, ColorRGBA color, float top){
 | 
			
		||||
        return createTopText(new String[]{name}, spacing, size, new ColorRGBA[]{color}, top);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Creates and positions multi-line text at the top of the screen with specified vertical offset, spacing, and colors.
 | 
			
		||||
     *
 | 
			
		||||
     * @param name    An array of strings representing the text to be displayed.
 | 
			
		||||
     * @param spacing The spacing between individual characters.
 | 
			
		||||
     * @param size    The size of the text.
 | 
			
		||||
     * @param color   An array of {@code ColorRGBA} representing the color for each string in {@code name}.
 | 
			
		||||
     * @param top     The vertical offset from the top of the screen.
 | 
			
		||||
     * @return A {@code Node} containing the styled text positioned at the top.
 | 
			
		||||
     */
 | 
			
		||||
    private Node createTopText(String[] name, float spacing, float size, ColorRGBA color[], float top){
 | 
			
		||||
        Node text = createTextWithSpacing(name, spacing, size, color);
 | 
			
		||||
        text.setLocalTranslation(0, (appSettings.getHeight()/2f)*0.8f-top,0);
 | 
			
		||||
@@ -71,18 +131,44 @@ private Node createTopText(String[] name, float spacing, float size, ColorRGBA c
 | 
			
		||||
        return text;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Calculates the center position of a rectangle with negative width offset.
 | 
			
		||||
     *
 | 
			
		||||
     * @param width  The negative width of the rectangle.
 | 
			
		||||
     * @param height The height of the rectangle.
 | 
			
		||||
     * @param pos    The origin position of the rectangle.
 | 
			
		||||
     * @return A {@code Vector3f} representing the center position.
 | 
			
		||||
     */
 | 
			
		||||
    private Vector3f centerText(float width, float height, Vector3f pos){
 | 
			
		||||
        return center(-width, height, pos);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Displays a message indicating the active player.
 | 
			
		||||
     *
 | 
			
		||||
     * @param name  The name of the active player.
 | 
			
		||||
     * @param color The color representing the player's team.
 | 
			
		||||
     */
 | 
			
		||||
     void activePlayer(String name, Color color){
 | 
			
		||||
        createTopText(new String[]{name," ist dran"}, 10,90,new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0).addControl(new ZoomControl());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Displays a message indicating that the current player is active.
 | 
			
		||||
     *
 | 
			
		||||
     * @param color The color representing the player's team.
 | 
			
		||||
     */
 | 
			
		||||
     void ownActive(Color color){
 | 
			
		||||
        createTopText(new String[]{"Du"," bist dran"}, 10,90,new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0).addControl(new ZoomControl());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Displays a dice roll result for a player.
 | 
			
		||||
     *
 | 
			
		||||
     * @param diceNum The number rolled on the dice.
 | 
			
		||||
     * @param name    The name of the player.
 | 
			
		||||
     * @param color   The color representing the player's team.
 | 
			
		||||
     */
 | 
			
		||||
     void diceNum(int diceNum, String name, Color color){
 | 
			
		||||
        createTopText(new String[]{name," würfelt:"}, 10,90,new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0);
 | 
			
		||||
 | 
			
		||||
@@ -90,38 +176,84 @@ void diceNum(int diceNum, String name, Color color){
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Displays a dice roll result with a multiplier for a player.
 | 
			
		||||
     *
 | 
			
		||||
     * @param diceNum The number rolled on the dice.
 | 
			
		||||
     * @param mult    The multiplier applied to the dice result.
 | 
			
		||||
     * @param name    The name of the player.
 | 
			
		||||
     * @param color   The color representing the player's team.
 | 
			
		||||
     */
 | 
			
		||||
     void diceNumMult(int diceNum,int mult, String name, Color color){
 | 
			
		||||
        createTopText(new String[]{name," würfelt:"}, 10,90,new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0);
 | 
			
		||||
 | 
			
		||||
        createTopText(new String[]{String.valueOf(diceNum), " x" + mult + " = " + (diceNum*mult)}, 20, 100, new ColorRGBA[]{ColorRGBA.White,ColorRGBA.Red}, 100);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Displays the dice roll result for the current player.
 | 
			
		||||
     *
 | 
			
		||||
     * @param diceNum The number rolled on the dice.
 | 
			
		||||
     */
 | 
			
		||||
     void ownDice(int diceNum){
 | 
			
		||||
        createTopText(String.valueOf(diceNum), 10, 100, ColorRGBA.White, 0);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Displays the dice roll result with a multiplier for the current player.
 | 
			
		||||
     *
 | 
			
		||||
     * @param diceNum The number rolled on the dice.
 | 
			
		||||
     * @param mult    The multiplier applied to the dice result.
 | 
			
		||||
     */
 | 
			
		||||
     void ownDiceMult(int diceNum, int mult){
 | 
			
		||||
        createTopText(new String[]{String.valueOf(diceNum), " x" + mult + " = " + (diceNum*mult)}, 20, 100, new ColorRGBA[]{ColorRGBA.White,ColorRGBA.Red}, 0);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Displays a message indicating that a specified player received a bonus card.
 | 
			
		||||
     *
 | 
			
		||||
     * @param name  The name of the player who received the bonus card.
 | 
			
		||||
     * @param color The color representing the player's team.
 | 
			
		||||
     */
 | 
			
		||||
     void drawCard(String name, Color color){
 | 
			
		||||
        createTopText(new String[]{name," erhält eine Bonuskarte"}, 7,70, new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0).addControl(new ZoomControl());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Displays a message indicating that the current player received a bonus card.
 | 
			
		||||
     *
 | 
			
		||||
     * @param color The color representing the player's team.
 | 
			
		||||
     */
 | 
			
		||||
     void drawCardOwn(Color color){
 | 
			
		||||
        createTopText(new String[]{"Du","  erhälst eine Bonuskarte"}, 5,70, new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0).addControl(new ZoomControl());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Displays a message indicating that a specified player has completed their turn or action.
 | 
			
		||||
     *
 | 
			
		||||
     * @param name  The name of the player who finished.
 | 
			
		||||
     * @param color The color representing the player's team.
 | 
			
		||||
     */
 | 
			
		||||
     void finishText(String name, Color color){
 | 
			
		||||
        createTopText(new String[]{name," ist fertig!"}, 7,70, new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0).addControl(new ZoomControl());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Displays a message indicating that the current player has completed their turn or action.
 | 
			
		||||
     *
 | 
			
		||||
     * @param color The color representing the player's team.
 | 
			
		||||
     */
 | 
			
		||||
     void finishTextOwn(Color color){
 | 
			
		||||
        createTopText(new String[]{"Du", " bist fertig!"}, 7,70, new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, 0).addControl(new ZoomControl());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Converts a player's team color to a corresponding {@code ColorRGBA}.
 | 
			
		||||
     *
 | 
			
		||||
     * @param color The player's team color.
 | 
			
		||||
     * @return The corresponding {@code ColorRGBA}.
 | 
			
		||||
     * @throws RuntimeException if the color is invalid.
 | 
			
		||||
     */
 | 
			
		||||
    private ColorRGBA playerColorToColorRGBA(Color color){
 | 
			
		||||
        return switch (color){
 | 
			
		||||
            case ARMY -> ColorRGBA.Green;
 | 
			
		||||
@@ -132,23 +264,40 @@ private ColorRGBA playerColorToColorRGBA(Color color){
 | 
			
		||||
        };
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Hides all text messages displayed by the handler and resets the ranking counter.
 | 
			
		||||
     */
 | 
			
		||||
     void hide(){
 | 
			
		||||
         ranking = 0;
 | 
			
		||||
         root.detachAllChildren();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    float paddingRanked = 100;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Displays a ranked dice roll result for a specified player.
 | 
			
		||||
     *
 | 
			
		||||
     * @param name  The name of the player.
 | 
			
		||||
     * @param color The color representing the player's team.
 | 
			
		||||
     * @param eye   The dice roll result.
 | 
			
		||||
     */
 | 
			
		||||
    void rollRankingResult(String name, Color color, int eye){
 | 
			
		||||
        createTopText(new String[]{name,":  "+eye}, 10,90,new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, paddingRanked*ranking);
 | 
			
		||||
        ranking++;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Displays a ranked dice roll result for the current player.
 | 
			
		||||
     *
 | 
			
		||||
     * @param color The color representing the player's team.
 | 
			
		||||
     * @param eye   The dice roll result.
 | 
			
		||||
     */
 | 
			
		||||
     void rollRankingResultOwn(Color color, int eye){
 | 
			
		||||
         createTopText(new String[]{"Du",":  "+eye}, 10,90,new ColorRGBA[]{playerColorToColorRGBA(color),ColorRGBA.White}, paddingRanked*ranking);
 | 
			
		||||
         ranking++;
 | 
			
		||||
     }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Displays a message prompting the player to roll the dice.
 | 
			
		||||
     */
 | 
			
		||||
     void diceNow(){
 | 
			
		||||
         createTopText("Klicke  zum  Würfeln", 5, 80, ColorRGBA.White, 0);
 | 
			
		||||
     }
 | 
			
		||||
 
 | 
			
		||||
@@ -131,6 +131,8 @@ public void selectCard(CardControl cardControl) {
 | 
			
		||||
            cardControl.select();
 | 
			
		||||
            cardSelect = getKeyByValue(bonusCardControlMap, cardControl);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        app.getModelSynchronize().selectCard(cardSelect);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Camera getCardLayerCamera() {
 | 
			
		||||
 
 | 
			
		||||
@@ -5,6 +5,7 @@
 | 
			
		||||
import com.jme3.network.serializing.serializers.EnumSerializer;
 | 
			
		||||
import pp.mdga.Resources;
 | 
			
		||||
import pp.mdga.game.*;
 | 
			
		||||
import pp.mdga.game.card.*;
 | 
			
		||||
import pp.mdga.message.client.*;
 | 
			
		||||
import pp.mdga.message.server.*;
 | 
			
		||||
import pp.mdga.server.ServerGameLogic;
 | 
			
		||||
@@ -124,7 +125,7 @@ private void initializeSerializables() {
 | 
			
		||||
        Serializer.registerClass(NoTurnMessage.class);
 | 
			
		||||
        Serializer.registerClass(PauseGameMessage.class);
 | 
			
		||||
        Serializer.registerClass(PlayCardMessage.class);
 | 
			
		||||
        Serializer.registerClass(PossibleCardMessage.class);
 | 
			
		||||
        Serializer.registerClass(PossibleCardsMessage.class);
 | 
			
		||||
        Serializer.registerClass(PossiblePieceMessage.class);
 | 
			
		||||
        Serializer.registerClass(RankingResponseMessage.class);
 | 
			
		||||
        Serializer.registerClass(RankingRollAgainMessage.class);
 | 
			
		||||
@@ -144,12 +145,17 @@ private void initializeSerializables() {
 | 
			
		||||
        Serializer.registerClass(Piece.class);
 | 
			
		||||
        Serializer.registerClass(BonusNode.class);
 | 
			
		||||
        Serializer.registerClass(StartNode.class);
 | 
			
		||||
        Serializer.registerClass(PlayerData.class);
 | 
			
		||||
        Serializer.registerClass(HomeNode.class);
 | 
			
		||||
        Serializer.registerClass(PowerCard.class);
 | 
			
		||||
        Serializer.registerClass(TurboCard.class);
 | 
			
		||||
        Serializer.registerClass(SwapCard.class);
 | 
			
		||||
        Serializer.registerClass(ShieldCard.class);
 | 
			
		||||
        Serializer.registerClass(HiddenCard.class);
 | 
			
		||||
 | 
			
		||||
        Serializer.registerClass(Color.class, new EnumSerializer());
 | 
			
		||||
        Serializer.registerClass(PieceState.class, new EnumSerializer());
 | 
			
		||||
        Serializer.registerClass(ShieldState.class, new EnumSerializer());
 | 
			
		||||
        Serializer.registerClass(BonusCard.class, new EnumSerializer());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void registerListeners() {
 | 
			
		||||
 
 | 
			
		||||
@@ -20,6 +20,8 @@ public class GameView extends MdgaView {
 | 
			
		||||
    private ButtonLeft leaveButton;
 | 
			
		||||
    private ButtonRight confirmButton;
 | 
			
		||||
 | 
			
		||||
    private ButtonRight noPowerButton;
 | 
			
		||||
 | 
			
		||||
    private Color ownColor = null;
 | 
			
		||||
 | 
			
		||||
    private InterruptDialog interruptDialog;
 | 
			
		||||
@@ -35,6 +37,8 @@ public GameView(MdgaApp app) {
 | 
			
		||||
 | 
			
		||||
        confirmButton = new ButtonRight(app, guiNode, () -> app.getModelSynchronize().confirm(), "Bestätigen", 1);
 | 
			
		||||
 | 
			
		||||
        noPowerButton = new ButtonRight(app, guiNode, () -> app.getModelSynchronize().confirm(), "Verzichten", 1);
 | 
			
		||||
 | 
			
		||||
        interruptDialog = new InterruptDialog(app, guiNode);
 | 
			
		||||
 | 
			
		||||
        fpp = new FilterPostProcessor(app.getAssetManager());
 | 
			
		||||
@@ -65,6 +69,7 @@ public void onLeave() {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        confirmButton.hide();
 | 
			
		||||
        noPowerButton.hide();
 | 
			
		||||
 | 
			
		||||
        app.getViewPort().removeProcessor(fpp);
 | 
			
		||||
    }
 | 
			
		||||
@@ -109,6 +114,7 @@ public Color getOwnColor() {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void needConfirm() {
 | 
			
		||||
        noPowerButton.hide();
 | 
			
		||||
        confirmButton.show();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -116,7 +122,16 @@ public void noConfirm() {
 | 
			
		||||
        confirmButton.hide();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void enterInterrupt() {
 | 
			
		||||
    public void showNoPower() {
 | 
			
		||||
        confirmButton.hide();
 | 
			
		||||
        noPowerButton.show();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void hideNoPower() {
 | 
			
		||||
        noPowerButton.hide();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void enterInterrupt(Color color) {
 | 
			
		||||
        enterOverlay(Overlay.INTERRUPT);
 | 
			
		||||
 | 
			
		||||
        guiNode.detachChild(guiHandlerNode);
 | 
			
		||||
@@ -124,6 +139,7 @@ public void enterInterrupt() {
 | 
			
		||||
 | 
			
		||||
        app.getInputSynchronize().setClickAllowed(false);
 | 
			
		||||
 | 
			
		||||
        interruptDialog.setColor(color);
 | 
			
		||||
        interruptDialog.show();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -135,6 +151,8 @@ public void leaveInterrupt() {
 | 
			
		||||
 | 
			
		||||
        app.getInputSynchronize().setClickAllowed(true);
 | 
			
		||||
 | 
			
		||||
        app.getAcousticHandler().playSound(MdgaSound.START);
 | 
			
		||||
 | 
			
		||||
        interruptDialog.hide();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
										
											Binary file not shown.
										
									
								
							| 
		 Before Width: | Height: | Size: 216 KiB  | 
										
											Binary file not shown.
										
									
								
							| 
		 Before Width: | Height: | Size: 274 KiB  | 
@@ -1,7 +1,6 @@
 | 
			
		||||
// Samplers for textures
 | 
			
		||||
uniform sampler2D m_Texture;
 | 
			
		||||
uniform sampler2D m_OutlineDepthTexture;
 | 
			
		||||
uniform sampler2D m_DepthTexture;
 | 
			
		||||
 | 
			
		||||
// Input texture coordinates from the vertex shader
 | 
			
		||||
in vec2 texCoord;
 | 
			
		||||
@@ -15,26 +14,25 @@ uniform float m_OutlineWidth;
 | 
			
		||||
out vec4 fragColor;
 | 
			
		||||
 | 
			
		||||
void main() {
 | 
			
		||||
    // Sample depth textures
 | 
			
		||||
    // Sample depth textures at various offsets
 | 
			
		||||
    vec4 depth = texture(m_OutlineDepthTexture, texCoord);
 | 
			
		||||
    vec4 depth1 = texture(m_OutlineDepthTexture, ((texCoord * m_Resolution) + vec2(m_OutlineWidth, m_OutlineWidth)) / m_Resolution);
 | 
			
		||||
    vec4 depth2 = texture(m_OutlineDepthTexture, ((texCoord * m_Resolution) + vec2(m_OutlineWidth, -m_OutlineWidth)) / m_Resolution);
 | 
			
		||||
    vec4 depth3 = texture(m_OutlineDepthTexture, ((texCoord * m_Resolution) + vec2(-m_OutlineWidth, m_OutlineWidth)) / m_Resolution);
 | 
			
		||||
    vec4 depth4 = texture(m_OutlineDepthTexture, ((texCoord * m_Resolution) + vec2(-m_OutlineWidth, -m_OutlineWidth)) / m_Resolution);
 | 
			
		||||
    vec4 depth5 = texture(m_OutlineDepthTexture, ((texCoord * m_Resolution) + vec2(0.0, m_OutlineWidth)) / m_Resolution);
 | 
			
		||||
    vec4 depth6 = texture(m_OutlineDepthTexture, ((texCoord * m_Resolution) + vec2(0.0, -m_OutlineWidth)) / m_Resolution);
 | 
			
		||||
    vec4 depth7 = texture(m_OutlineDepthTexture, ((texCoord * m_Resolution) + vec2(m_OutlineWidth, 0.0)) / m_Resolution);
 | 
			
		||||
    vec4 depth8 = texture(m_OutlineDepthTexture, ((texCoord * m_Resolution) + vec2(-m_OutlineWidth, 0.0)) / m_Resolution);
 | 
			
		||||
    vec4 depth1 = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(m_OutlineWidth, m_OutlineWidth)) / m_Resolution);
 | 
			
		||||
    vec4 depth2 = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(m_OutlineWidth, -m_OutlineWidth)) / m_Resolution);
 | 
			
		||||
    vec4 depth3 = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(-m_OutlineWidth, m_OutlineWidth)) / m_Resolution);
 | 
			
		||||
    vec4 depth4 = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(-m_OutlineWidth, -m_OutlineWidth)) / m_Resolution);
 | 
			
		||||
    vec4 depth5 = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(0.0, m_OutlineWidth)) / m_Resolution);
 | 
			
		||||
    vec4 depth6 = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(0.0, -m_OutlineWidth)) / m_Resolution);
 | 
			
		||||
    vec4 depth7 = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(m_OutlineWidth, 0.0)) / m_Resolution);
 | 
			
		||||
    vec4 depth8 = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(-m_OutlineWidth, 0.0)) / m_Resolution);
 | 
			
		||||
 | 
			
		||||
    // Sample the main texture
 | 
			
		||||
    vec4 color = texture(m_Texture, texCoord);
 | 
			
		||||
 | 
			
		||||
    // Determine whether to apply the outline color
 | 
			
		||||
    if (depth == vec4(0.0) &&
 | 
			
		||||
       (depth1 != depth || depth2 != depth || depth3 != depth || depth4 != depth ||
 | 
			
		||||
        depth5 != depth || depth6 != depth || depth7 != depth || depth8 != depth)) {
 | 
			
		||||
        fragColor = m_OutlineColor; // Apply outline color
 | 
			
		||||
    } else {
 | 
			
		||||
        fragColor = color; // Use the original texture color
 | 
			
		||||
    }
 | 
			
		||||
    // Check if an outline should be applied
 | 
			
		||||
    bool isEdge = (depth == vec4(0.0)) &&
 | 
			
		||||
                  (depth1 != depth || depth2 != depth || depth3 != depth || depth4 != depth ||
 | 
			
		||||
                   depth5 != depth || depth6 != depth || depth7 != depth || depth8 != depth);
 | 
			
		||||
 | 
			
		||||
    // Output the final color
 | 
			
		||||
    fragColor = isEdge ? m_OutlineColor : color;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,11 +1,10 @@
 | 
			
		||||
 | 
			
		||||
// Use 'in' instead of 'varying' for inputs from the vertex shader
 | 
			
		||||
// Input texture coordinates from the vertex shader
 | 
			
		||||
in vec2 texCoord;
 | 
			
		||||
 | 
			
		||||
// Declare a custom output variable for the fragment color
 | 
			
		||||
// Output variable for the fragment color
 | 
			
		||||
out vec4 fragColor;
 | 
			
		||||
 | 
			
		||||
// Uniform samplers
 | 
			
		||||
// Uniform samplers for textures
 | 
			
		||||
uniform sampler2D m_Texture;
 | 
			
		||||
uniform sampler2D m_NormalsTexture;
 | 
			
		||||
uniform sampler2D m_DepthTexture;
 | 
			
		||||
@@ -13,6 +12,7 @@ uniform sampler2D m_DepthTexture;
 | 
			
		||||
void main() {
 | 
			
		||||
    // Sample the texture at the given texture coordinates
 | 
			
		||||
    vec4 color = texture(m_Texture, texCoord);
 | 
			
		||||
 | 
			
		||||
    // Assign the color to the output variable
 | 
			
		||||
    fragColor = color;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,109 +1,78 @@
 | 
			
		||||
// Uniform samplers
 | 
			
		||||
uniform sampler2D m_Texture;
 | 
			
		||||
uniform sampler2D m_OutlineDepthTexture;
 | 
			
		||||
uniform sampler2D m_DepthTexture;
 | 
			
		||||
varying vec2 texCoord;
 | 
			
		||||
 | 
			
		||||
// Input texture coordinates from the vertex shader
 | 
			
		||||
in vec2 texCoord;
 | 
			
		||||
 | 
			
		||||
// Uniforms for resolution, outline color, and width
 | 
			
		||||
uniform vec2 m_Resolution;
 | 
			
		||||
uniform vec4 m_OutlineColor;
 | 
			
		||||
uniform float m_OutlineWidth;
 | 
			
		||||
 | 
			
		||||
// Output variable for fragment color
 | 
			
		||||
out vec4 fragColor;
 | 
			
		||||
 | 
			
		||||
void main() {
 | 
			
		||||
	vec4 depth = texture2D(m_OutlineDepthTexture, texCoord);
 | 
			
		||||
	vec4 depth1 = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(m_OutlineWidth,m_OutlineWidth))/m_Resolution);
 | 
			
		||||
	vec4 depth2 = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(m_OutlineWidth,-m_OutlineWidth))/m_Resolution);
 | 
			
		||||
	vec4 depth3 = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(-m_OutlineWidth,m_OutlineWidth))/m_Resolution);
 | 
			
		||||
	vec4 depth4 = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(-m_OutlineWidth,-m_OutlineWidth))/m_Resolution);
 | 
			
		||||
	vec4 depth5 = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(0.,m_OutlineWidth))/m_Resolution);
 | 
			
		||||
	vec4 depth6 = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(0.,-m_OutlineWidth))/m_Resolution);
 | 
			
		||||
	vec4 depth7 = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(m_OutlineWidth,0.))/m_Resolution);
 | 
			
		||||
	vec4 depth8 = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(-m_OutlineWidth,0.))/m_Resolution);
 | 
			
		||||
	vec4 color = texture2D(m_Texture, texCoord);
 | 
			
		||||
	//如果是背景
 | 
			
		||||
	float ratio=0.;
 | 
			
		||||
	if(depth==vec4(0.) && (depth1 != depth || depth2 != depth || depth3 != depth || depth4 != depth||depth5 != depth || depth6 != depth || depth7 != depth || depth8 != depth)){
 | 
			
		||||
		float dist=m_OutlineWidth;
 | 
			
		||||
		//距离边的像素
 | 
			
		||||
		vec4 nearDepth;
 | 
			
		||||
		if(depth1 != depth){
 | 
			
		||||
			for(float i=0.;i<m_OutlineWidth;i++){
 | 
			
		||||
				nearDepth = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(i,i))/m_Resolution);
 | 
			
		||||
				if(nearDepth != depth){
 | 
			
		||||
					dist = i;
 | 
			
		||||
					break;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}else
 | 
			
		||||
		if(depth2 != depth){
 | 
			
		||||
			for(float i=0.;i<m_OutlineWidth;i++){
 | 
			
		||||
				nearDepth = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(i,-i))/m_Resolution);
 | 
			
		||||
				if(nearDepth != depth){
 | 
			
		||||
					dist = i;
 | 
			
		||||
					break;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}else
 | 
			
		||||
		if(depth3 != depth){
 | 
			
		||||
			for(float i=0.;i<m_OutlineWidth;i++){
 | 
			
		||||
				nearDepth = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(-i,i))/m_Resolution);
 | 
			
		||||
				if(nearDepth != depth){
 | 
			
		||||
					dist = i;
 | 
			
		||||
					break;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}else
 | 
			
		||||
		if(depth4 != depth){
 | 
			
		||||
			for(float i=0.;i<m_OutlineWidth;i++){
 | 
			
		||||
				nearDepth = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(-i,-i))/m_Resolution);
 | 
			
		||||
				if(nearDepth != depth){
 | 
			
		||||
					dist = i;
 | 
			
		||||
					break;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}else
 | 
			
		||||
		if(depth5 != depth){
 | 
			
		||||
			for(float i=0.;i<m_OutlineWidth;i++){
 | 
			
		||||
				nearDepth = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(0.,i))/m_Resolution);
 | 
			
		||||
				if(nearDepth != depth){
 | 
			
		||||
					dist = i;
 | 
			
		||||
					break;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}else
 | 
			
		||||
		if(depth6 != depth){
 | 
			
		||||
			for(float i=0.;i<m_OutlineWidth;i++){
 | 
			
		||||
				nearDepth = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(0.,-i))/m_Resolution);
 | 
			
		||||
				if(nearDepth != depth){
 | 
			
		||||
					dist = i;
 | 
			
		||||
					break;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}else
 | 
			
		||||
		if(depth7 != depth){
 | 
			
		||||
			for(float i=0.;i<m_OutlineWidth;i++){
 | 
			
		||||
				nearDepth = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(i,0.))/m_Resolution);
 | 
			
		||||
				if(nearDepth != depth){
 | 
			
		||||
					dist = i;
 | 
			
		||||
					break;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}else
 | 
			
		||||
		if(depth8 != depth){
 | 
			
		||||
			for(float i=0.;i<m_OutlineWidth;i++){
 | 
			
		||||
				nearDepth = texture2D(m_OutlineDepthTexture, ((texCoord*m_Resolution)+vec2(-i,0.))/m_Resolution);
 | 
			
		||||
				if(nearDepth != depth){
 | 
			
		||||
					dist = i;
 | 
			
		||||
					break;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		//0:场景颜色		1:outline颜色 
 | 
			
		||||
		ratio = clamp(1.- dist/m_OutlineWidth,0.,1.);
 | 
			
		||||
		//float off = (1.-ratio*ratio)*(1.-ratio*ratio);
 | 
			
		||||
		gl_FragColor = color*(1.-ratio) +m_OutlineColor*ratio;
 | 
			
		||||
		//gl_FragColor = m_OutlineColor;
 | 
			
		||||
	}else{
 | 
			
		||||
		gl_FragColor = color;
 | 
			
		||||
	}
 | 
			
		||||
	//debug
 | 
			
		||||
	//gl_FragColor = vec4(0.,(1.-ratio),0.,1.);
 | 
			
		||||
}
 | 
			
		||||
    vec4 depth = texture(m_OutlineDepthTexture, texCoord);
 | 
			
		||||
    vec4 depth1 = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(m_OutlineWidth, m_OutlineWidth)) / m_Resolution);
 | 
			
		||||
    vec4 depth2 = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(m_OutlineWidth, -m_OutlineWidth)) / m_Resolution);
 | 
			
		||||
    vec4 depth3 = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(-m_OutlineWidth, m_OutlineWidth)) / m_Resolution);
 | 
			
		||||
    vec4 depth4 = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(-m_OutlineWidth, -m_OutlineWidth)) / m_Resolution);
 | 
			
		||||
    vec4 depth5 = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(0.0, m_OutlineWidth)) / m_Resolution);
 | 
			
		||||
    vec4 depth6 = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(0.0, -m_OutlineWidth)) / m_Resolution);
 | 
			
		||||
    vec4 depth7 = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(m_OutlineWidth, 0.0)) / m_Resolution);
 | 
			
		||||
    vec4 depth8 = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(-m_OutlineWidth, 0.0)) / m_Resolution);
 | 
			
		||||
 | 
			
		||||
    vec4 color = texture(m_Texture, texCoord);
 | 
			
		||||
 | 
			
		||||
    float ratio = 0.0;
 | 
			
		||||
    if (depth == vec4(0.0) &&
 | 
			
		||||
        (depth1 != depth || depth2 != depth || depth3 != depth || depth4 != depth ||
 | 
			
		||||
         depth5 != depth || depth6 != depth || depth7 != depth || depth8 != depth)) {
 | 
			
		||||
        float dist = m_OutlineWidth;
 | 
			
		||||
        vec4 nearDepth;
 | 
			
		||||
 | 
			
		||||
        // Iterate to find the distance to the nearest edge
 | 
			
		||||
        for (float i = 0.0; i < m_OutlineWidth; i++) {
 | 
			
		||||
            if (depth1 != depth) {
 | 
			
		||||
                nearDepth = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(i, i)) / m_Resolution);
 | 
			
		||||
                if (nearDepth != depth) { dist = i; break; }
 | 
			
		||||
            } else if (depth2 != depth) {
 | 
			
		||||
                nearDepth = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(i, -i)) / m_Resolution);
 | 
			
		||||
                if (nearDepth != depth) { dist = i; break; }
 | 
			
		||||
            } else if (depth3 != depth) {
 | 
			
		||||
                nearDepth = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(-i, i)) / m_Resolution);
 | 
			
		||||
                if (nearDepth != depth) { dist = i; break; }
 | 
			
		||||
            } else if (depth4 != depth) {
 | 
			
		||||
                nearDepth = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(-i, -i)) / m_Resolution);
 | 
			
		||||
                if (nearDepth != depth) { dist = i; break; }
 | 
			
		||||
            } else if (depth5 != depth) {
 | 
			
		||||
                nearDepth = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(0.0, i)) / m_Resolution);
 | 
			
		||||
                if (nearDepth != depth) { dist = i; break; }
 | 
			
		||||
            } else if (depth6 != depth) {
 | 
			
		||||
                nearDepth = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(0.0, -i)) / m_Resolution);
 | 
			
		||||
                if (nearDepth != depth) { dist = i; break; }
 | 
			
		||||
            } else if (depth7 != depth) {
 | 
			
		||||
                nearDepth = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(i, 0.0)) / m_Resolution);
 | 
			
		||||
                if (nearDepth != depth) { dist = i; break; }
 | 
			
		||||
            } else if (depth8 != depth) {
 | 
			
		||||
                nearDepth = texture(m_OutlineDepthTexture, (texCoord * m_Resolution + vec2(-i, 0.0)) / m_Resolution);
 | 
			
		||||
                if (nearDepth != depth) { dist = i; break; }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Calculate ratio for outline blending
 | 
			
		||||
        ratio = clamp(1.0 - dist / m_OutlineWidth, 0.0, 1.0);
 | 
			
		||||
 | 
			
		||||
        // Blend the outline color with the base color
 | 
			
		||||
        fragColor = color * (1.0 - ratio) + m_OutlineColor * ratio;
 | 
			
		||||
    } else {
 | 
			
		||||
        // No outline, use the base texture color
 | 
			
		||||
        fragColor = color;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Optional: Debugging outline visualization
 | 
			
		||||
    // fragColor = vec4(0.0, 1.0 - ratio, 0.0, 1.0);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,8 +1,8 @@
 | 
			
		||||
// Use 'in' for vertex attributes
 | 
			
		||||
// Vertex attributes
 | 
			
		||||
in vec4 inPosition;
 | 
			
		||||
in vec2 inTexCoord;
 | 
			
		||||
 | 
			
		||||
// Use 'out' for passing data to the fragment shader
 | 
			
		||||
// Output to fragment shader
 | 
			
		||||
out vec2 texCoord;
 | 
			
		||||
 | 
			
		||||
void main() {
 | 
			
		||||
 
 | 
			
		||||
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										3052
									
								
								Projekte/mdga/client/src/main/resources/Models/missile/AVMT300.fbx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3052
									
								
								Projekte/mdga/client/src/main/resources/Models/missile/AVMT300.fbx
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -0,0 +1,32 @@
 | 
			
		||||
# Blender MTL File: 'untitled.blend'
 | 
			
		||||
# Material Count: 3
 | 
			
		||||
 | 
			
		||||
newmtl Material.001
 | 
			
		||||
Ns 96.078431
 | 
			
		||||
Ka 0.000000 0.000000 0.000000
 | 
			
		||||
Kd 0.640000 0.640000 0.640000
 | 
			
		||||
Ks 0.500000 0.500000 0.500000
 | 
			
		||||
Ni 1.000000
 | 
			
		||||
d 1.000000
 | 
			
		||||
illum 2
 | 
			
		||||
map_Kd untiffftled.jpg
 | 
			
		||||
 | 
			
		||||
newmtl Material.002
 | 
			
		||||
Ns 96.078431
 | 
			
		||||
Ka 0.000000 0.000000 0.000000
 | 
			
		||||
Kd 0.640000 0.640000 0.640000
 | 
			
		||||
Ks 0.500000 0.500000 0.500000
 | 
			
		||||
Ni 1.000000
 | 
			
		||||
d 1.000000
 | 
			
		||||
illum 2
 | 
			
		||||
map_Kd untiffftled.jpg
 | 
			
		||||
 | 
			
		||||
newmtl Material.004
 | 
			
		||||
Ns 96.078431
 | 
			
		||||
Ka 0.000000 0.000000 0.000000
 | 
			
		||||
Kd 0.640000 0.640000 0.640000
 | 
			
		||||
Ks 0.500000 0.500000 0.500000
 | 
			
		||||
Ni 1.000000
 | 
			
		||||
d 1.000000
 | 
			
		||||
illum 2
 | 
			
		||||
map_Kd untiffftled.jpg
 | 
			
		||||
							
								
								
									
										2523
									
								
								Projekte/mdga/client/src/main/resources/Models/missile/AVMT300.obj
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2523
									
								
								Projekte/mdga/client/src/main/resources/Models/missile/AVMT300.obj
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 42 KiB  | 
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								Projekte/mdga/client/src/main/resources/Sounds/missile.ogg
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Projekte/mdga/client/src/main/resources/Sounds/missile.ogg
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							@@ -1,9 +1,8 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ceremonyState.CeremonyStates;
 | 
			
		||||
import pp.mdga.client.ceremonyState.PodiumState;
 | 
			
		||||
import pp.mdga.client.ceremonyState.StatisticsState;
 | 
			
		||||
import pp.mdga.notification.CeremonyNotification;
 | 
			
		||||
import pp.mdga.client.ceremonystate.CeremonyStates;
 | 
			
		||||
import pp.mdga.client.ceremonystate.PodiumState;
 | 
			
		||||
import pp.mdga.client.ceremonystate.StatisticsState;
 | 
			
		||||
 | 
			
		||||
public class CeremonyState extends ClientState {
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -5,13 +5,13 @@
 | 
			
		||||
import pp.mdga.game.Color;
 | 
			
		||||
import pp.mdga.game.Game;
 | 
			
		||||
import pp.mdga.game.Piece;
 | 
			
		||||
import pp.mdga.game.PlayerData;
 | 
			
		||||
import pp.mdga.message.client.ClientMessage;
 | 
			
		||||
import pp.mdga.message.server.*;
 | 
			
		||||
import pp.mdga.notification.*;
 | 
			
		||||
import pp.mdga.notification.InfoNotification;
 | 
			
		||||
import pp.mdga.notification.Notification;
 | 
			
		||||
import pp.mdga.notification.StartDialogNotification;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
import java.util.UUID;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -52,20 +52,21 @@ public ClientGameLogic(ClientSender clientSender) {
 | 
			
		||||
     *
 | 
			
		||||
     * @param msg the message to be sent
 | 
			
		||||
     */
 | 
			
		||||
    public void send(ClientMessage msg){
 | 
			
		||||
    public void send(ClientMessage msg) {
 | 
			
		||||
        LOGGER.log(System.Logger.Level.INFO, "send {0}", msg);
 | 
			
		||||
        clientSender.send(msg);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method is used to get a piece by its id
 | 
			
		||||
     *
 | 
			
		||||
     * @param pieceId the UUID of the piece
 | 
			
		||||
     * @return the piece
 | 
			
		||||
     */
 | 
			
		||||
    private Piece getPiece(UUID pieceId){
 | 
			
		||||
        for(Map.Entry<Color, PlayerData> entry : game.getBoard().getPlayerData().entrySet()){
 | 
			
		||||
            for(Piece piece : entry.getValue().getPieces()){
 | 
			
		||||
                if(piece.getUuid().equals(pieceId)){
 | 
			
		||||
    private Piece getPiece(UUID pieceId) {
 | 
			
		||||
        for (var player : this.game.getPlayers().values()) {
 | 
			
		||||
            for (Piece piece : player.getPieces()) {
 | 
			
		||||
                if (piece.getUuid().equals(pieceId)) {
 | 
			
		||||
                    return piece;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
@@ -78,7 +79,7 @@ private Piece getPiece(UUID pieceId){
 | 
			
		||||
     *
 | 
			
		||||
     * @return the clientSender
 | 
			
		||||
     */
 | 
			
		||||
    public ClientSender getClientSender(){
 | 
			
		||||
    public ClientSender getClientSender() {
 | 
			
		||||
        return clientSender;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -123,7 +124,7 @@ public void setOwnPlayerId(int ownPlayerId) {
 | 
			
		||||
     *
 | 
			
		||||
     * @return the game
 | 
			
		||||
     */
 | 
			
		||||
    public Game getGame(){
 | 
			
		||||
    public Game getGame() {
 | 
			
		||||
        return game;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -132,7 +133,7 @@ public Game getGame(){
 | 
			
		||||
     *
 | 
			
		||||
     * @return the current State
 | 
			
		||||
     */
 | 
			
		||||
    public ClientState getState(){
 | 
			
		||||
    public ClientState getState() {
 | 
			
		||||
        return state;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -141,7 +142,7 @@ public ClientState getState(){
 | 
			
		||||
     *
 | 
			
		||||
     * @return if the client is a host
 | 
			
		||||
     */
 | 
			
		||||
    public boolean isHost(){
 | 
			
		||||
    public boolean isHost() {
 | 
			
		||||
        return isHost;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -150,8 +151,8 @@ public boolean isHost(){
 | 
			
		||||
     *
 | 
			
		||||
     * @return the calculated moves as int
 | 
			
		||||
     */
 | 
			
		||||
    public int getCalculatedMoves(){
 | 
			
		||||
        return game.getDiceEyes() * game.getDiceModifier();
 | 
			
		||||
    public int getCalculatedMoves() {
 | 
			
		||||
        return 0;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -159,7 +160,7 @@ public int getCalculatedMoves(){
 | 
			
		||||
     *
 | 
			
		||||
     * @param isHost the boolean value
 | 
			
		||||
     */
 | 
			
		||||
    public void setHost(boolean isHost){
 | 
			
		||||
    public void setHost(boolean isHost) {
 | 
			
		||||
        this.isHost = isHost;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -329,7 +330,7 @@ public void received(PlayCardMessage msg) {
 | 
			
		||||
     * @param msg the PossibleCard message received
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(PossibleCardMessage msg) {
 | 
			
		||||
    public void received(PossibleCardsMessage msg) {
 | 
			
		||||
        state.received(msg);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -412,7 +413,7 @@ public void received(ShutdownMessage msg) {
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(IncorrectRequestMessage msg) {
 | 
			
		||||
        state.received(msg);
 | 
			
		||||
        addNotification(new InfoNotification(Resources.stringLookup("incorrect.request." + msg.getId())));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -480,14 +481,14 @@ public void received(SelectPieceMessage msg) {
 | 
			
		||||
     *
 | 
			
		||||
     * @param pieceId the pieceID
 | 
			
		||||
     */
 | 
			
		||||
    public void selectPiece(UUID pieceId){
 | 
			
		||||
    public void selectPiece(UUID pieceId) {
 | 
			
		||||
        state.selectPiece(getPiece(pieceId));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method call the method selectNExt of the state
 | 
			
		||||
     */
 | 
			
		||||
    public void selectNext(){
 | 
			
		||||
    public void selectNext() {
 | 
			
		||||
        state.selectNext();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -496,7 +497,7 @@ public void selectNext(){
 | 
			
		||||
     *
 | 
			
		||||
     * @param card the BonusCard to selected
 | 
			
		||||
     */
 | 
			
		||||
    public void selectCard(BonusCard card){
 | 
			
		||||
    public void selectCard(BonusCard card) {
 | 
			
		||||
        state.selectCard(card);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -505,7 +506,7 @@ public void selectCard(BonusCard card){
 | 
			
		||||
     *
 | 
			
		||||
     * @param color the Color to be selected
 | 
			
		||||
     */
 | 
			
		||||
    public void selectTsk(Color color){
 | 
			
		||||
    public void selectTsk(Color color) {
 | 
			
		||||
        state.selectTSK(color);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -514,14 +515,14 @@ public void selectTsk(Color color){
 | 
			
		||||
     *
 | 
			
		||||
     * @param color the color to be deselcted
 | 
			
		||||
     */
 | 
			
		||||
    public void deselectTSK(Color color){
 | 
			
		||||
    public void deselectTSK(Color color) {
 | 
			
		||||
        state.deselectTSK(color);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method calls the selectDice method of the state
 | 
			
		||||
     */
 | 
			
		||||
    public void selectDice(){
 | 
			
		||||
    public void selectDice() {
 | 
			
		||||
        state.selectDice();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -530,7 +531,7 @@ public void selectDice(){
 | 
			
		||||
     *
 | 
			
		||||
     * @param name the name to be set
 | 
			
		||||
     */
 | 
			
		||||
    public void selectName(String name){
 | 
			
		||||
    public void selectName(String name) {
 | 
			
		||||
        state.setName(name);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -539,8 +540,8 @@ public void selectName(String name){
 | 
			
		||||
     *
 | 
			
		||||
     * @param ready the value if this method should ready or unready
 | 
			
		||||
     */
 | 
			
		||||
    public void selectReady(boolean ready){
 | 
			
		||||
        if(ready){
 | 
			
		||||
    public void selectReady(boolean ready) {
 | 
			
		||||
        if (ready) {
 | 
			
		||||
            state.selectReady();
 | 
			
		||||
        } else {
 | 
			
		||||
            state.selectUnready();
 | 
			
		||||
@@ -552,14 +553,14 @@ public void selectReady(boolean ready){
 | 
			
		||||
     *
 | 
			
		||||
     * @param name the name of the player hosting
 | 
			
		||||
     */
 | 
			
		||||
    public void selectHost(String name){
 | 
			
		||||
    public void selectHost(String name) {
 | 
			
		||||
        state.selectHost(name);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method calls the selectLeave method of the state
 | 
			
		||||
     */
 | 
			
		||||
    public void selectLeave(){
 | 
			
		||||
    public void selectLeave() {
 | 
			
		||||
        state.selectLeave();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -568,28 +569,28 @@ public void selectLeave(){
 | 
			
		||||
     *
 | 
			
		||||
     * @param ip the ip to cennect to
 | 
			
		||||
     */
 | 
			
		||||
    public void selectJoin(String ip){
 | 
			
		||||
    public void selectJoin(String ip) {
 | 
			
		||||
        state.selectJoin(ip);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method calls the selectAnimationEnd method of the state
 | 
			
		||||
     */
 | 
			
		||||
    public void selectAnimationEnd(){
 | 
			
		||||
    public void selectAnimationEnd() {
 | 
			
		||||
        state.selectAnimationEnd();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method calls the selectStart method of the state
 | 
			
		||||
     */
 | 
			
		||||
    public void selectStart(){
 | 
			
		||||
    public void selectStart() {
 | 
			
		||||
        state.selectStart();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method calls the selectResume method of the state
 | 
			
		||||
     */
 | 
			
		||||
    public void selectResume(){
 | 
			
		||||
    public void selectResume() {
 | 
			
		||||
        state.selectResume();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -598,7 +599,7 @@ public void selectResume(){
 | 
			
		||||
     *
 | 
			
		||||
     * @param state the new state
 | 
			
		||||
     */
 | 
			
		||||
    public void setState(ClientState state){
 | 
			
		||||
    public void setState(ClientState state) {
 | 
			
		||||
        this.state.exit();
 | 
			
		||||
        state.enter();
 | 
			
		||||
        this.state = state;
 | 
			
		||||
@@ -607,7 +608,7 @@ public void setState(ClientState state){
 | 
			
		||||
    /**
 | 
			
		||||
     * This method is used to enter the interrupt state and save the previous state
 | 
			
		||||
     */
 | 
			
		||||
    public void enterInterrupt(){
 | 
			
		||||
    public void enterInterrupt() {
 | 
			
		||||
        interruptState.enter();
 | 
			
		||||
        interruptState.setPreviousState(state);
 | 
			
		||||
        this.state = interruptState;
 | 
			
		||||
@@ -618,7 +619,7 @@ public void enterInterrupt(){
 | 
			
		||||
     *
 | 
			
		||||
     * @return the GameState
 | 
			
		||||
     */
 | 
			
		||||
    public GameState getGameState(){
 | 
			
		||||
    public GameState getGameState() {
 | 
			
		||||
        return gameState;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -627,7 +628,7 @@ public GameState getGameState(){
 | 
			
		||||
     *
 | 
			
		||||
     * @return the CeremonyState
 | 
			
		||||
     */
 | 
			
		||||
    public CeremonyState getCeremony(){
 | 
			
		||||
    public CeremonyState getCeremony() {
 | 
			
		||||
        return ceremonyState;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -636,7 +637,7 @@ public CeremonyState getCeremony(){
 | 
			
		||||
     *
 | 
			
		||||
     * @return the InterruptState
 | 
			
		||||
     */
 | 
			
		||||
    public InterruptState getInterrupt(){
 | 
			
		||||
    public InterruptState getInterrupt() {
 | 
			
		||||
        return interruptState;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -645,7 +646,7 @@ public InterruptState getInterrupt(){
 | 
			
		||||
     *
 | 
			
		||||
     * @return the DialogsState
 | 
			
		||||
     */
 | 
			
		||||
    public DialogsState getDialogs(){
 | 
			
		||||
    public DialogsState getDialogs() {
 | 
			
		||||
        return dialogsState;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -654,7 +655,7 @@ public DialogsState getDialogs(){
 | 
			
		||||
     *
 | 
			
		||||
     * @return the SettingsState
 | 
			
		||||
     */
 | 
			
		||||
    public SettingsState getSettings(){
 | 
			
		||||
    public SettingsState getSettings() {
 | 
			
		||||
        return settingsState;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -663,8 +664,8 @@ public SettingsState getSettings(){
 | 
			
		||||
     *
 | 
			
		||||
     * @return the next notification
 | 
			
		||||
     */
 | 
			
		||||
    public Notification getNotification(){
 | 
			
		||||
        if(!notifications.isEmpty()){
 | 
			
		||||
    public Notification getNotification() {
 | 
			
		||||
        if (!notifications.isEmpty()) {
 | 
			
		||||
            return notifications.remove(0);
 | 
			
		||||
        } else {
 | 
			
		||||
            return null;
 | 
			
		||||
@@ -676,7 +677,7 @@ public Notification getNotification(){
 | 
			
		||||
     *
 | 
			
		||||
     * @param notification the notification to be added
 | 
			
		||||
     */
 | 
			
		||||
    public void addNotification(Notification notification){
 | 
			
		||||
    public void addNotification(Notification notification) {
 | 
			
		||||
        notifications.add(notification);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -116,7 +116,7 @@ public void received(PlayCardMessage msg) {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(PossibleCardMessage msg) {
 | 
			
		||||
    public void received(PossibleCardsMessage msg) {
 | 
			
		||||
        LOGGER.log(Level.DEBUG, "Received {0} not allowed.", msg.toString());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,9 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.dialogState.DialogStates;
 | 
			
		||||
import pp.mdga.client.dialogState.LobbyState;
 | 
			
		||||
import pp.mdga.client.dialogState.NetworkDialogState;
 | 
			
		||||
import pp.mdga.client.dialogState.StartDialogState;
 | 
			
		||||
import pp.mdga.client.dialogstate.DialogStates;
 | 
			
		||||
import pp.mdga.client.dialogstate.LobbyState;
 | 
			
		||||
import pp.mdga.client.dialogstate.NetworkDialogState;
 | 
			
		||||
import pp.mdga.client.dialogstate.StartDialogState;
 | 
			
		||||
import pp.mdga.game.Color;
 | 
			
		||||
import pp.mdga.message.server.*;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.gameState.*;
 | 
			
		||||
import pp.mdga.client.gamestate.*;
 | 
			
		||||
import pp.mdga.game.BonusCard;
 | 
			
		||||
import pp.mdga.game.Piece;
 | 
			
		||||
import pp.mdga.message.client.LeaveGameMessage;
 | 
			
		||||
@@ -241,7 +241,7 @@ public void received(DiceAgainMessage msg){
 | 
			
		||||
     * @param msg the message to be received
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(PossibleCardMessage msg){
 | 
			
		||||
    public void received(PossibleCardsMessage msg){
 | 
			
		||||
        state.received(msg);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,9 @@
 | 
			
		||||
package pp.mdga.client;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.settingsState.AudioSettingsState;
 | 
			
		||||
import pp.mdga.client.settingsState.MainSettingsState;
 | 
			
		||||
import pp.mdga.client.settingsState.SettingStates;
 | 
			
		||||
import pp.mdga.client.settingsState.VideoSettingsState;
 | 
			
		||||
import pp.mdga.client.settingsstate.AudioSettingsState;
 | 
			
		||||
import pp.mdga.client.settingsstate.MainSettingsState;
 | 
			
		||||
import pp.mdga.client.settingsstate.SettingStates;
 | 
			
		||||
import pp.mdga.client.settingsstate.VideoSettingsState;
 | 
			
		||||
 | 
			
		||||
public class SettingsState extends ClientState {
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
package pp.mdga.client.ceremonyState;
 | 
			
		||||
package pp.mdga.client.ceremonystate;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
package pp.mdga.client.ceremonyState;
 | 
			
		||||
package pp.mdga.client.ceremonystate;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.CeremonyState;
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
package pp.mdga.client.ceremonyState;
 | 
			
		||||
package pp.mdga.client.ceremonystate;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
package pp.mdga.client.dialogState;
 | 
			
		||||
package pp.mdga.client.dialogstate;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
package pp.mdga.client.dialogState;
 | 
			
		||||
package pp.mdga.client.dialogstate;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
@@ -6,16 +6,14 @@
 | 
			
		||||
import pp.mdga.game.Color;
 | 
			
		||||
import pp.mdga.game.Piece;
 | 
			
		||||
import pp.mdga.game.Player;
 | 
			
		||||
import pp.mdga.game.PlayerData;
 | 
			
		||||
import pp.mdga.message.client.*;
 | 
			
		||||
import pp.mdga.message.server.LobbyPlayerJoinedMessage;
 | 
			
		||||
import pp.mdga.message.server.LobbyPlayerLeaveMessage;
 | 
			
		||||
import pp.mdga.message.server.ServerStartGameMessage;
 | 
			
		||||
import pp.mdga.message.server.UpdateReadyMessage;
 | 
			
		||||
import pp.mdga.message.server.UpdateTSKMessage;
 | 
			
		||||
import pp.mdga.message.server.*;
 | 
			
		||||
import pp.mdga.notification.*;
 | 
			
		||||
 | 
			
		||||
import java.util.*;
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
import java.util.UUID;
 | 
			
		||||
 | 
			
		||||
public class LobbyState extends DialogStates {
 | 
			
		||||
 | 
			
		||||
@@ -58,41 +56,47 @@ public void selectReady() {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void selectUnready(){
 | 
			
		||||
    public void selectUnready() {
 | 
			
		||||
        logic.send(new LobbyNotReadyMessage());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void selectStart(){
 | 
			
		||||
        if(logic.isHost() && logic.getGame().areAllReady()){
 | 
			
		||||
            logic.send(new StartGameMessage(false));
 | 
			
		||||
        } else if(logic.isHost() && !logic.getGame().areAllReady()) {
 | 
			
		||||
            logic.send(new StartGameMessage(true));
 | 
			
		||||
    public void selectStart() {
 | 
			
		||||
        if (logic.isHost() && logic.getGame().areAllReady()) {
 | 
			
		||||
            logic.send(new StartGameMessage());
 | 
			
		||||
        } else {
 | 
			
		||||
            logic.send(new StartGameMessage());
 | 
			
		||||
            LOGGER.log(System.Logger.Level.ERROR, "You are not the host");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(ServerStartGameMessage msg){
 | 
			
		||||
    public void received(ServerStartGameMessage msg) {
 | 
			
		||||
        for (Player player: msg.getPlayers()) {
 | 
			
		||||
            for (Map.Entry<Integer, Player> entry: this.logic.getGame().getPlayers().entrySet()) {
 | 
			
		||||
                if (entry.getValue().getColor() == player.getColor()) {
 | 
			
		||||
                    this.logic.getGame().getPlayers().put(entry.getKey(), player);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        logic.getGame().setBoard(msg.getBoard());
 | 
			
		||||
        logic.addNotification(new GameNotification(logic.getGame().getPlayerById(logic.getOwnPlayerId()).getColor()));
 | 
			
		||||
        for (Map.Entry<Integer, Player> entry : logic.getGame().getPlayers().entrySet()) {
 | 
			
		||||
        for (var player : logic.getGame().getPlayers().values()) {
 | 
			
		||||
            List<UUID> pieces = new ArrayList<>();
 | 
			
		||||
            for (Piece piece : logic.getGame().getBoard().getPlayerData().get(entry.getValue().getColor()).getPieces()) {
 | 
			
		||||
            for (Piece piece : player.getPieces()) {
 | 
			
		||||
                pieces.add(piece.getUuid());
 | 
			
		||||
            }
 | 
			
		||||
            logic.addNotification(new PlayerInGameNotification(entry.getValue().getColor(), pieces, entry.getValue().getName()));
 | 
			
		||||
            logic.addNotification(new PlayerInGameNotification(player.getColor(), pieces, player.getName()));
 | 
			
		||||
        }
 | 
			
		||||
        logic.setState(logic.getGameState());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(LobbyPlayerJoinedMessage msg){
 | 
			
		||||
        if(msg.getPlayer().getName().equals(logic.getOwnPlayerName())){
 | 
			
		||||
    public void received(LobbyPlayerJoinedMessage msg) {
 | 
			
		||||
        if (msg.getPlayer().getName().equals(logic.getOwnPlayerName())) {
 | 
			
		||||
            logic.setOwnPlayerId(msg.getId());
 | 
			
		||||
        }
 | 
			
		||||
        if (msg.isHost() && msg.getId() == logic.getOwnPlayerId()){
 | 
			
		||||
        if (msg.isHost() && msg.getId() == logic.getOwnPlayerId()) {
 | 
			
		||||
            logic.setHost(true);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@@ -101,9 +105,9 @@ public void received(LobbyPlayerJoinedMessage msg){
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(UpdateTSKMessage msg){
 | 
			
		||||
        if(msg.isTaken()) {
 | 
			
		||||
            logic.addNotification(new TskSelectNotification(msg.getColor(), logic.getGame().getPlayers().get(msg.getId()).getName(), logic.getOwnPlayerId()== msg.getId()));
 | 
			
		||||
    public void received(UpdateTSKMessage msg) {
 | 
			
		||||
        if (msg.isTaken()) {
 | 
			
		||||
            logic.addNotification(new TskSelectNotification(msg.getColor(), logic.getGame().getPlayers().get(msg.getId()).getName(), logic.getOwnPlayerId() == msg.getId()));
 | 
			
		||||
        } else {
 | 
			
		||||
            logic.addNotification(new TskUnselectNotification(logic.getGame().getPlayers().get(msg.getId()).getColor()));
 | 
			
		||||
        }
 | 
			
		||||
@@ -112,13 +116,13 @@ public void received(UpdateTSKMessage msg){
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(LobbyPlayerLeaveMessage msg){
 | 
			
		||||
    public void received(LobbyPlayerLeaveMessage msg) {
 | 
			
		||||
        logic.addNotification(new TskUnselectNotification(logic.getGame().getPlayers().get(msg.getId()).getColor()));
 | 
			
		||||
        logic.getGame().getPlayers().remove(msg.getId());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(UpdateReadyMessage msg){
 | 
			
		||||
    public void received(UpdateReadyMessage msg) {
 | 
			
		||||
        //TODO server sendet kein update on UNready
 | 
			
		||||
        logic.addNotification(new LobbyReadyNotification(logic.getGame().getPlayers().get(msg.getPlayerId()).getColor(), msg.isReady()));
 | 
			
		||||
        logic.getGame().getPlayers().get(msg.getPlayerId()).setReady(msg.isReady());
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
package pp.mdga.client.dialogState;
 | 
			
		||||
package pp.mdga.client.dialogstate;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.Resources;
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
package pp.mdga.client.dialogState;
 | 
			
		||||
package pp.mdga.client.dialogstate;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
@@ -1,40 +0,0 @@
 | 
			
		||||
package pp.mdga.client.gameState.determineStartPlayerState;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
import pp.mdga.client.gameState.DetermineStartPlayerState;
 | 
			
		||||
import pp.mdga.message.server.RankingResponseMessage;
 | 
			
		||||
import pp.mdga.message.server.RankingRollAgainMessage;
 | 
			
		||||
import pp.mdga.notification.ActivePlayerNotification;
 | 
			
		||||
 | 
			
		||||
public class WaitRankingState extends DetermineStartPlayerStates {
 | 
			
		||||
 | 
			
		||||
    private final DetermineStartPlayerState parent;
 | 
			
		||||
 | 
			
		||||
    public WaitRankingState(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
        this.parent = (DetermineStartPlayerState) parent;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void enter() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void exit() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(RankingRollAgainMessage msg){
 | 
			
		||||
        parent.setState(parent.getRollRankingDice());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(RankingResponseMessage msg){
 | 
			
		||||
        logic.addNotification(new ActivePlayerNotification(logic.getGame().getPlayers().get(msg.getStartingPlayerId()).getColor()));
 | 
			
		||||
        logic.getGame().setActiveColor(logic.getGame().getPlayers().get(msg.getStartingPlayerId()).getColor());
 | 
			
		||||
        parent.getParent().setState(parent.getParent().getWaiting());
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
package pp.mdga.client.gameState;
 | 
			
		||||
package pp.mdga.client.gamestate;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
@@ -1,11 +1,14 @@
 | 
			
		||||
package pp.mdga.client.gameState;
 | 
			
		||||
package pp.mdga.client.gamestate;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
import pp.mdga.client.GameState;
 | 
			
		||||
import pp.mdga.client.gameState.determineStartPlayerState.DetermineStartPlayerStates;
 | 
			
		||||
import pp.mdga.client.gameState.determineStartPlayerState.RollRankingDiceState;
 | 
			
		||||
import pp.mdga.client.gameState.determineStartPlayerState.WaitRankingState;
 | 
			
		||||
import pp.mdga.client.gamestate.determinestartplayerstate.DetermineStartPlayerStates;
 | 
			
		||||
import pp.mdga.client.gamestate.determinestartplayerstate.Intro;
 | 
			
		||||
import pp.mdga.client.gamestate.determinestartplayerstate.RollRankingDiceState;
 | 
			
		||||
import pp.mdga.client.gamestate.determinestartplayerstate.WaitRankingState;
 | 
			
		||||
import pp.mdga.message.client.AnimationEndMessage;
 | 
			
		||||
import pp.mdga.message.server.ActivePlayerMessage;
 | 
			
		||||
import pp.mdga.message.server.DieMessage;
 | 
			
		||||
import pp.mdga.message.server.RankingResponseMessage;
 | 
			
		||||
import pp.mdga.message.server.RankingRollAgainMessage;
 | 
			
		||||
@@ -17,12 +20,33 @@ public class DetermineStartPlayerState extends GameStates {
 | 
			
		||||
 | 
			
		||||
    private final RollRankingDiceState rollRankingDiceState = new RollRankingDiceState(this, logic);
 | 
			
		||||
    private final WaitRankingState waitRankingState = new WaitRankingState(this, logic);
 | 
			
		||||
    private final Intro intro = new Intro(this, logic);
 | 
			
		||||
 | 
			
		||||
    public DetermineStartPlayerState(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
        this.parent = (GameState) parent;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public RollRankingDiceState getRollRankingDice() {
 | 
			
		||||
        return rollRankingDiceState;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public WaitRankingState getWaitRanking() {
 | 
			
		||||
        return waitRankingState;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public DetermineStartPlayerStates getState(){
 | 
			
		||||
        return state;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Intro getIntro(){
 | 
			
		||||
        return intro;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public GameState getParent() {
 | 
			
		||||
        return parent;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void enter() {
 | 
			
		||||
        this.setState(this.rollRankingDiceState);
 | 
			
		||||
@@ -46,6 +70,11 @@ public void selectDice() {
 | 
			
		||||
        state.selectDice();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void selectAnimationEnd(){
 | 
			
		||||
        state.selectAnimationEnd();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(DieMessage msg){
 | 
			
		||||
        state.received(msg);
 | 
			
		||||
@@ -61,19 +90,8 @@ public void received(RankingResponseMessage msg){
 | 
			
		||||
        state.received(msg);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public RollRankingDiceState getRollRankingDice() {
 | 
			
		||||
        return rollRankingDiceState;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public WaitRankingState getWaitRanking() {
 | 
			
		||||
        return waitRankingState;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public DetermineStartPlayerStates getState(){
 | 
			
		||||
        return state;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public GameState getParent() {
 | 
			
		||||
        return parent;
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(ActivePlayerMessage msg){
 | 
			
		||||
        state.received(msg);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
package pp.mdga.client.gameState;
 | 
			
		||||
package pp.mdga.client.gamestate;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
@@ -12,39 +12,45 @@
 | 
			
		||||
import pp.mdga.notification.SwapPieceNotification;
 | 
			
		||||
import pp.mdga.notification.ThrowPieceNotification;
 | 
			
		||||
 | 
			
		||||
import java.util.UUID;
 | 
			
		||||
 | 
			
		||||
public abstract class GameStates extends ClientState {
 | 
			
		||||
    public GameStates(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected void handlePowerCard(PlayCardMessage msg){
 | 
			
		||||
        if (msg.getCard().equals(BonusCard.TURBO)){
 | 
			
		||||
    protected void handlePowerCard(PlayCardMessage msg) {
 | 
			
		||||
        if (msg.getCard().getCard().equals(BonusCard.TURBO)) {
 | 
			
		||||
            logic.getGame().setDiceModifier(msg.getDiceModifier());
 | 
			
		||||
        } else if (msg.getCard().equals(BonusCard.SHIELD)){
 | 
			
		||||
            if (logic.getGame().getBoard().getInfieldIndexOfPiece(logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier())) % 10 != 0) {
 | 
			
		||||
                logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier()).setShield(ShieldState.SUPPRESSED);
 | 
			
		||||
                logic.addNotification(new ShieldSuppressedNotification(logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier()).getUuid()));
 | 
			
		||||
            } else {
 | 
			
		||||
                logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier()).setShield(ShieldState.ACTIVE);
 | 
			
		||||
                logic.addNotification(new ShieldActiveNotification(logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier()).getUuid()));
 | 
			
		||||
            }
 | 
			
		||||
        } else if (msg.getCard().getCard().equals(BonusCard.SHIELD)) {
 | 
			
		||||
            handleShield(msg.getPieces().get(0).getUuid());
 | 
			
		||||
        } else {
 | 
			
		||||
            Piece ownPiece = logic.getGame().getPieceThroughUUID(msg.getPieceIdentifier());
 | 
			
		||||
            Piece enemyPiece = logic.getGame().getPieceThroughUUID(msg.getPieceIdentifierEnemy());
 | 
			
		||||
            Piece ownPiece = logic.getGame().getPieceThroughUUID(msg.getPieces().get(0).getUuid());
 | 
			
		||||
            Piece enemyPiece = logic.getGame().getPieceThroughUUID(msg.getPieces().get(1).getUuid());
 | 
			
		||||
            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);
 | 
			
		||||
        }
 | 
			
		||||
        logic.getGame().getDiscardPile().add(logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).removeHandCard(msg.getCard()));
 | 
			
		||||
        logic.getGame().getDiscardPile().add(msg.getCard());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected void throwPiece(Piece piece){
 | 
			
		||||
    protected void throwPiece(Piece piece) {
 | 
			
		||||
        logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(piece)].clearOccupant();
 | 
			
		||||
        logic.getGame().getBoard().getPlayerData().get(piece.getColor()).addWaitingPiece(piece);
 | 
			
		||||
//        logic.addNotification(new ThrowPieceNotification(piece.getUuid()));
 | 
			
		||||
        logic.getGame().getPlayerByColor(piece.getColor()).addWaitingPiece(piece);
 | 
			
		||||
        logic.addNotification(new ThrowPieceNotification(piece.getUuid(), piece.getColor()));
 | 
			
		||||
        logic.getGame().getPlayerByColor(piece.getColor()).getPlayerStatistic().increasePiecesBeingThrown();
 | 
			
		||||
        logic.getGame().getGameStatistics().increasePiecesBeingThrown();
 | 
			
		||||
        piece.setState(PieceState.WAITING);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void handleShield(UUID uuid) {
 | 
			
		||||
        if (logic.getGame().getBoard().getInfieldIndexOfPiece(logic.getGame().getPieceThroughUUID(uuid)) % 10 != 0) {
 | 
			
		||||
            logic.getGame().getPieceThroughUUID(uuid).setShield(ShieldState.SUPPRESSED);
 | 
			
		||||
            logic.addNotification(new ShieldSuppressedNotification(uuid));
 | 
			
		||||
        } else {
 | 
			
		||||
            logic.getGame().getPieceThroughUUID(uuid).setShield(ShieldState.ACTIVE);
 | 
			
		||||
            logic.addNotification(new ShieldActiveNotification(uuid));
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,11 +1,14 @@
 | 
			
		||||
package pp.mdga.client.gameState;
 | 
			
		||||
package pp.mdga.client.gamestate;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
import pp.mdga.client.GameState;
 | 
			
		||||
import pp.mdga.game.Piece;
 | 
			
		||||
import pp.mdga.message.server.*;
 | 
			
		||||
import pp.mdga.notification.*;
 | 
			
		||||
import pp.mdga.notification.ActivePlayerNotification;
 | 
			
		||||
import pp.mdga.notification.HomeMoveNotification;
 | 
			
		||||
import pp.mdga.notification.MovePieceNotification;
 | 
			
		||||
import pp.mdga.notification.PlayCardNotification;
 | 
			
		||||
 | 
			
		||||
public class SpectatorState extends GameStates {
 | 
			
		||||
 | 
			
		||||
@@ -27,15 +30,15 @@ public void exit() {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(CeremonyMessage msg){
 | 
			
		||||
    public void received(CeremonyMessage msg) {
 | 
			
		||||
        logic.setState(logic.getCeremony());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(DieMessage msg){
 | 
			
		||||
        logic.getGame().setDiceEyes(msg.getDiceEye());
 | 
			
		||||
    public void received(DieMessage msg) {
 | 
			
		||||
        //logic.getGame().setDiceEyes(msg.getDiceEye());
 | 
			
		||||
//        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().getGameStatistics().increaseDiced6();
 | 
			
		||||
        }
 | 
			
		||||
@@ -43,8 +46,8 @@ public void received(DieMessage msg){
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(PlayCardMessage msg){
 | 
			
		||||
        logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor(), msg.getCard()));
 | 
			
		||||
    public void received(PlayCardMessage msg) {
 | 
			
		||||
        logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor(), msg.getCard().getCard()));
 | 
			
		||||
        handlePowerCard(msg);
 | 
			
		||||
        logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseCardsPlayed();
 | 
			
		||||
        logic.getGame().getGameStatistics().increaseCardsPlayed();
 | 
			
		||||
@@ -52,26 +55,26 @@ public void received(PlayCardMessage msg){
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(ActivePlayerMessage msg){
 | 
			
		||||
    public void received(ActivePlayerMessage msg) {
 | 
			
		||||
        logic.addNotification(new ActivePlayerNotification(msg.getColor()));
 | 
			
		||||
        logic.getGame().setActiveColor(msg.getColor());
 | 
			
		||||
        parent.setState(parent.getAnimation());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(MoveMessage msg){
 | 
			
		||||
    public void received(MoveMessage msg) {
 | 
			
		||||
        Piece pieceToMove = logic.getGame().getPieceThroughUUID(msg.getIdentifier());
 | 
			
		||||
        if (msg.isHomeMove()){
 | 
			
		||||
        if (msg.isHomeMove()) {
 | 
			
		||||
            logic.addNotification(new HomeMoveNotification(pieceToMove.getUuid(), msg.getTargetIndex()));
 | 
			
		||||
            logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)].clearOccupant();
 | 
			
		||||
            logic.getGame().getBoard().getPlayerData().get(pieceToMove.getColor()).setPieceInHome(msg.getTargetIndex(), pieceToMove);
 | 
			
		||||
            logic.getGame().getPlayerByColor(pieceToMove.getColor()).setPieceInHome(msg.getTargetIndex(), pieceToMove);
 | 
			
		||||
        } else {
 | 
			
		||||
            if (logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].isOccupied()) {
 | 
			
		||||
                throwPiece(logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].getOccupant());
 | 
			
		||||
                logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increasePiecesThrown();
 | 
			
		||||
                logic.getGame().getGameStatistics().increasePiecesThrown();
 | 
			
		||||
            }
 | 
			
		||||
            if(logic.getGame().getBoard().getPlayerData().get(pieceToMove.getColor()).getStartNodeIndex() == logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)){
 | 
			
		||||
            if (logic.getGame().getPlayerByColor(pieceToMove.getColor()).getStartNodeIndex() == logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)) {
 | 
			
		||||
                logic.addNotification(new MovePieceNotification(pieceToMove.getUuid(), msg.getTargetIndex(), true));
 | 
			
		||||
                logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].setOccupant(pieceToMove);
 | 
			
		||||
            } else {
 | 
			
		||||
@@ -1,14 +1,14 @@
 | 
			
		||||
package pp.mdga.client.gameState;
 | 
			
		||||
package pp.mdga.client.gamestate;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
import pp.mdga.client.GameState;
 | 
			
		||||
import pp.mdga.client.gameState.turnState.ChoosePieceState;
 | 
			
		||||
import pp.mdga.client.gameState.turnState.MovePieceState;
 | 
			
		||||
import pp.mdga.client.gameState.turnState.PlayPowerCardState;
 | 
			
		||||
import pp.mdga.client.gameState.turnState.PowerCardState;
 | 
			
		||||
import pp.mdga.client.gameState.turnState.RollDiceState;
 | 
			
		||||
import pp.mdga.client.gameState.turnState.TurnStates;
 | 
			
		||||
import pp.mdga.client.gamestate.turnstate.ChoosePieceState;
 | 
			
		||||
import pp.mdga.client.gamestate.turnstate.MovePieceState;
 | 
			
		||||
import pp.mdga.client.gamestate.turnstate.PlayPowerCardState;
 | 
			
		||||
import pp.mdga.client.gamestate.turnstate.PowerCardState;
 | 
			
		||||
import pp.mdga.client.gamestate.turnstate.RollDiceState;
 | 
			
		||||
import pp.mdga.client.gamestate.turnstate.TurnStates;
 | 
			
		||||
import pp.mdga.game.BonusCard;
 | 
			
		||||
import pp.mdga.game.Piece;
 | 
			
		||||
import pp.mdga.message.server.*;
 | 
			
		||||
@@ -47,6 +47,11 @@ public void setState(TurnStates state){
 | 
			
		||||
        this.state = state;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void selectDice(){
 | 
			
		||||
        state.selectDice();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void selectPiece(Piece piece){
 | 
			
		||||
        state.selectPiece(piece);
 | 
			
		||||
@@ -108,7 +113,7 @@ public void received(DiceAgainMessage msg){
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(PossibleCardMessage msg){
 | 
			
		||||
    public void received(PossibleCardsMessage msg){
 | 
			
		||||
        state.received(msg);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package pp.mdga.client.gameState;
 | 
			
		||||
package pp.mdga.client.gamestate;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
import pp.mdga.client.GameState;
 | 
			
		||||
import pp.mdga.game.*;
 | 
			
		||||
import pp.mdga.game.Piece;
 | 
			
		||||
import pp.mdga.game.PieceState;
 | 
			
		||||
import pp.mdga.message.server.*;
 | 
			
		||||
import pp.mdga.notification.*;
 | 
			
		||||
 | 
			
		||||
@@ -27,21 +28,21 @@ public void exit() {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(CeremonyMessage msg){
 | 
			
		||||
    public void received(CeremonyMessage msg) {
 | 
			
		||||
        logic.setState(logic.getCeremony());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(DiceNowMessage msg){
 | 
			
		||||
    public void received(DiceNowMessage msg) {
 | 
			
		||||
        logic.addNotification(new DiceNowNotification());
 | 
			
		||||
        parent.setState(parent.getTurn());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(DieMessage msg){
 | 
			
		||||
    public void received(DieMessage msg) {
 | 
			
		||||
        logic.getGame().setDiceEyes(msg.getDiceEye());
 | 
			
		||||
//        logic.addNotification(new RollDiceNotification(logic.getGame().getActiveColor(), logic.getGame().getDiceEyes(), logic.getGame().getDiceEyes() * logic.getGame().getDiceModifier()));
 | 
			
		||||
        if(msg.getDiceEye() == 6){
 | 
			
		||||
        logic.addNotification(new RollDiceNotification(logic.getGame().getActiveColor(), logic.getGame().getDiceEyes()));
 | 
			
		||||
        if (msg.getDiceEye() == 6) {
 | 
			
		||||
            logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseDiced6();
 | 
			
		||||
            logic.getGame().getGameStatistics().increaseDiced6();
 | 
			
		||||
        }
 | 
			
		||||
@@ -49,8 +50,8 @@ public void received(DieMessage msg){
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(PlayCardMessage msg){
 | 
			
		||||
        logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor(), msg.getCard()));
 | 
			
		||||
    public void received(PlayCardMessage msg) {
 | 
			
		||||
        logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor(), msg.getCard().getCard()));
 | 
			
		||||
        handlePowerCard(msg);
 | 
			
		||||
        logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseCardsPlayed();
 | 
			
		||||
        logic.getGame().getGameStatistics().increaseCardsPlayed();
 | 
			
		||||
@@ -58,21 +59,21 @@ public void received(PlayCardMessage msg){
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(ActivePlayerMessage msg){
 | 
			
		||||
    public void received(ActivePlayerMessage msg) {
 | 
			
		||||
        logic.addNotification(new ActivePlayerNotification(msg.getColor()));
 | 
			
		||||
        logic.getGame().setActiveColor(msg.getColor());
 | 
			
		||||
        parent.setState(parent.getAnimation());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(MoveMessage msg){
 | 
			
		||||
    public void received(MoveMessage msg) {
 | 
			
		||||
        Piece pieceToMove = logic.getGame().getPieceThroughUUID(msg.getIdentifier());
 | 
			
		||||
        if (msg.isHomeMove()){
 | 
			
		||||
        if (msg.isHomeMove()) {
 | 
			
		||||
            logic.addNotification(new HomeMoveNotification(pieceToMove.getUuid(), msg.getTargetIndex()));
 | 
			
		||||
            logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)].clearOccupant();
 | 
			
		||||
            logic.getGame().getBoard().getPlayerData().get(pieceToMove.getColor()).setPieceInHome(msg.getTargetIndex(), pieceToMove);
 | 
			
		||||
            for(int i = msg.getTargetIndex() + 1; i < 4; i++){
 | 
			
		||||
                if(!logic.getGame().getBoard().getPlayerData().get(pieceToMove.getColor()).getHomeNodes()[i].isOccupied()){
 | 
			
		||||
            logic.getGame().getPlayerByColor(pieceToMove.getColor()).setPieceInHome(msg.getTargetIndex(), pieceToMove);
 | 
			
		||||
            for (int i = msg.getTargetIndex() + 1; i < 4; i++) {
 | 
			
		||||
                if (!logic.getGame().getPlayerByColor(pieceToMove.getColor()).getHomeNodes()[i].isOccupied()) {
 | 
			
		||||
                    pieceToMove.setState(PieceState.HOME);
 | 
			
		||||
                    break;
 | 
			
		||||
                }
 | 
			
		||||
@@ -84,7 +85,7 @@ public void received(MoveMessage msg){
 | 
			
		||||
                logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increasePiecesThrown();
 | 
			
		||||
                logic.getGame().getGameStatistics().increasePiecesThrown();
 | 
			
		||||
            }
 | 
			
		||||
            if(logic.getGame().getBoard().getPlayerData().get(pieceToMove.getColor()).getStartNodeIndex() == logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)){
 | 
			
		||||
            if (logic.getGame().getPlayerByColor(pieceToMove.getColor()).getStartNodeIndex() == logic.getGame().getBoard().getInfieldIndexOfPiece(pieceToMove)) {
 | 
			
		||||
                logic.addNotification(new MovePieceNotification(pieceToMove.getUuid(), msg.getTargetIndex(), true));
 | 
			
		||||
                logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].setOccupant(pieceToMove);
 | 
			
		||||
            } else {
 | 
			
		||||
@@ -1,8 +1,8 @@
 | 
			
		||||
package pp.mdga.client.gameState.determineStartPlayerState;
 | 
			
		||||
package pp.mdga.client.gamestate.determinestartplayerstate;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
import pp.mdga.client.gameState.GameStates;
 | 
			
		||||
import pp.mdga.client.gamestate.GameStates;
 | 
			
		||||
 | 
			
		||||
public abstract class DetermineStartPlayerStates extends GameStates {
 | 
			
		||||
    public DetermineStartPlayerStates(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
@@ -0,0 +1,85 @@
 | 
			
		||||
package pp.mdga.client.gamestate.determinestartplayerstate;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
import pp.mdga.client.gamestate.DetermineStartPlayerState;
 | 
			
		||||
import pp.mdga.game.Player;
 | 
			
		||||
import pp.mdga.message.client.AnimationEndMessage;
 | 
			
		||||
import pp.mdga.notification.AcquireCardNotification;
 | 
			
		||||
import pp.mdga.notification.ActivePlayerNotification;
 | 
			
		||||
import pp.mdga.notification.DrawCardNotification;
 | 
			
		||||
import pp.mdga.notification.MovePieceNotification;
 | 
			
		||||
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
public class Intro extends DetermineStartPlayerStates{
 | 
			
		||||
 | 
			
		||||
    private final DetermineStartPlayerState parent;
 | 
			
		||||
 | 
			
		||||
    private int animationCounter = 0;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Constructor for Intro
 | 
			
		||||
     *
 | 
			
		||||
     * @param parent the parent state
 | 
			
		||||
     * @param logic the client game logic
 | 
			
		||||
     */
 | 
			
		||||
    public Intro(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
        this.parent = (DetermineStartPlayerState) parent;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method is used to get the parent state;
 | 
			
		||||
     *
 | 
			
		||||
     * @return the parent state
 | 
			
		||||
     */
 | 
			
		||||
    public DetermineStartPlayerState getParent(){
 | 
			
		||||
        return parent;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method is used to enter this state and play all necessary intro animations.
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public void enter() {
 | 
			
		||||
        for(Map.Entry<Integer, Player> entry : logic.getGame().getPlayers().entrySet()){
 | 
			
		||||
            //logic.addNotification(new WaitMoveNotification(entry.getValue().getPieces()[0].getUuid()));
 | 
			
		||||
            logic.addNotification(new MovePieceNotification(entry.getValue().getPieces()[0].getUuid(), entry.getValue().getStartNodeIndex(), true));
 | 
			
		||||
            logic.getGame().getBoard().getInfield()[entry.getValue().getStartNodeIndex()].setOccupant(entry.getValue().getPieces()[0]);
 | 
			
		||||
            animationCounter++;
 | 
			
		||||
            if(entry.getKey() == logic.getOwnPlayerId()){
 | 
			
		||||
                logic.addNotification(new AcquireCardNotification(entry.getValue().getHandCards().get(0).getCard()));
 | 
			
		||||
            } else {
 | 
			
		||||
                logic.addNotification(new DrawCardNotification(entry.getValue().getColor(), entry.getValue().getHandCards().get(0).getCard()));
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method i s used to exit this state.
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public void exit() {
 | 
			
		||||
        animationCounter = 0;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method is used when the view has completed the animation.
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public void selectAnimationEnd(){
 | 
			
		||||
        animationCounter--;
 | 
			
		||||
        if(animationCounter != 0){
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        logic.send(new AnimationEndMessage());
 | 
			
		||||
        if (logic.getGame().getActivePlayerId() == logic.getOwnPlayerId()){
 | 
			
		||||
            parent.getParent().setState(parent.getParent().getTurn());
 | 
			
		||||
            logic.addNotification(new ActivePlayerNotification(logic.getGame().getActiveColor()));
 | 
			
		||||
        } else {
 | 
			
		||||
            parent.getParent().setState(parent.getParent().getWaiting());
 | 
			
		||||
            logic.addNotification(new ActivePlayerNotification(logic.getGame().getActiveColor()));
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,8 +1,8 @@
 | 
			
		||||
package pp.mdga.client.gameState.determineStartPlayerState;
 | 
			
		||||
package pp.mdga.client.gamestate.determinestartplayerstate;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
import pp.mdga.client.gameState.DetermineStartPlayerState;
 | 
			
		||||
import pp.mdga.client.gamestate.DetermineStartPlayerState;
 | 
			
		||||
import pp.mdga.message.client.RequestDieMessage;
 | 
			
		||||
import pp.mdga.message.server.DieMessage;
 | 
			
		||||
import pp.mdga.notification.DiceNowNotification;
 | 
			
		||||
@@ -28,13 +28,12 @@ public void exit() {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void selectDice(){
 | 
			
		||||
        System.out.println("selectDice");
 | 
			
		||||
        logic.send(new RequestDieMessage());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(DieMessage msg){
 | 
			
		||||
        logic.addNotification(new RollDiceNotification(logic.getGame().getPlayerById(logic.getOwnPlayerId()).getColor(), msg.getDiceEye(),true));
 | 
			
		||||
        parent.setState(parent.getWaitRanking());
 | 
			
		||||
        logic.addNotification(new RollDiceNotification(logic.getGame().getPlayerById(logic.getOwnPlayerId()).getColor(), msg.getDiceEye(),true));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,58 @@
 | 
			
		||||
package pp.mdga.client.gamestate.determinestartplayerstate;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
import pp.mdga.client.gamestate.DetermineStartPlayerState;
 | 
			
		||||
import pp.mdga.message.client.AnimationEndMessage;
 | 
			
		||||
import pp.mdga.message.server.*;
 | 
			
		||||
import pp.mdga.notification.ActivePlayerNotification;
 | 
			
		||||
 | 
			
		||||
public class WaitRankingState extends DetermineStartPlayerStates {
 | 
			
		||||
 | 
			
		||||
    private final DetermineStartPlayerState parent;
 | 
			
		||||
    private boolean canChange = false;
 | 
			
		||||
 | 
			
		||||
    public WaitRankingState(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
        super(parent, logic);
 | 
			
		||||
        this.parent = (DetermineStartPlayerState) parent;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void changeToIntro(){
 | 
			
		||||
        if(!canChange){
 | 
			
		||||
            canChange = true;
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        parent.setState(parent.getIntro());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void enter() {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void exit() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(DiceNowMessage msg){
 | 
			
		||||
        parent.setState(parent.getRollRankingDice());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(RankingResponseMessage msg){
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void selectAnimationEnd(){
 | 
			
		||||
        changeToIntro();
 | 
			
		||||
        logic.send(new AnimationEndMessage());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(ActivePlayerMessage msg){
 | 
			
		||||
        logic.getGame().setActiveColor(msg.getColor());
 | 
			
		||||
        changeToIntro();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,9 +1,9 @@
 | 
			
		||||
package pp.mdga.client.gameState.turnState;
 | 
			
		||||
package pp.mdga.client.gamestate.turnstate;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
import pp.mdga.client.gameState.TurnState;
 | 
			
		||||
import pp.mdga.client.gameState.turnState.choosePieceState.*;
 | 
			
		||||
import pp.mdga.client.gamestate.TurnState;
 | 
			
		||||
import pp.mdga.client.gamestate.turnstate.choosepiecestate.*;
 | 
			
		||||
import pp.mdga.game.Piece;
 | 
			
		||||
import pp.mdga.message.server.*;
 | 
			
		||||
 | 
			
		||||
@@ -1,8 +1,8 @@
 | 
			
		||||
package pp.mdga.client.gameState.turnState;
 | 
			
		||||
package pp.mdga.client.gamestate.turnstate;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
import pp.mdga.client.gameState.TurnState;
 | 
			
		||||
import pp.mdga.client.gamestate.TurnState;
 | 
			
		||||
import pp.mdga.message.client.AnimationEndMessage;
 | 
			
		||||
import pp.mdga.message.server.*;
 | 
			
		||||
 | 
			
		||||
@@ -46,7 +46,7 @@ public void received(SpectatorMessage msg){
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(DiceAgainMessage msg){
 | 
			
		||||
    public void received(DiceNowMessage msg){
 | 
			
		||||
        parent.setState(parent.getRollDice());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -1,8 +1,8 @@
 | 
			
		||||
package pp.mdga.client.gameState.turnState;
 | 
			
		||||
package pp.mdga.client.gamestate.turnstate;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
import pp.mdga.client.gameState.TurnState;
 | 
			
		||||
import pp.mdga.client.gamestate.TurnState;
 | 
			
		||||
import pp.mdga.message.client.AnimationEndMessage;
 | 
			
		||||
import pp.mdga.message.server.PlayCardMessage;
 | 
			
		||||
import pp.mdga.notification.PlayCardNotification;
 | 
			
		||||
@@ -20,7 +20,7 @@ public PlayPowerCardState(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void enter() {
 | 
			
		||||
        logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor() , playCardMessage.getCard()));
 | 
			
		||||
        logic.addNotification(new PlayCardNotification(logic.getGame().getActiveColor() , playCardMessage.getCard().getCard()));
 | 
			
		||||
        handlePowerCard(playCardMessage);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -35,7 +35,7 @@ public void setPlayCard(PlayCardMessage playCardMessage) {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void selectAnimationEnd(){
 | 
			
		||||
        parent.setState(parent.getRollDice());
 | 
			
		||||
        logic.send(new AnimationEndMessage());
 | 
			
		||||
        parent.setState(parent.getRollDice());
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,17 +1,17 @@
 | 
			
		||||
package pp.mdga.client.gameState.turnState;
 | 
			
		||||
package pp.mdga.client.gamestate.turnstate;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
import pp.mdga.client.gameState.TurnState;
 | 
			
		||||
import pp.mdga.client.gameState.turnState.powerCardState.ChoosePowerCardState;
 | 
			
		||||
import pp.mdga.client.gameState.turnState.powerCardState.PowerCardStates;
 | 
			
		||||
import pp.mdga.client.gameState.turnState.powerCardState.ShieldState;
 | 
			
		||||
import pp.mdga.client.gameState.turnState.powerCardState.SwapState;
 | 
			
		||||
import pp.mdga.client.gamestate.TurnState;
 | 
			
		||||
import pp.mdga.client.gamestate.turnstate.powercardstate.ChoosePowerCardState;
 | 
			
		||||
import pp.mdga.client.gamestate.turnstate.powercardstate.PowerCardStates;
 | 
			
		||||
import pp.mdga.client.gamestate.turnstate.powercardstate.ShieldState;
 | 
			
		||||
import pp.mdga.client.gamestate.turnstate.powercardstate.SwapState;
 | 
			
		||||
import pp.mdga.game.BonusCard;
 | 
			
		||||
import pp.mdga.game.Piece;
 | 
			
		||||
import pp.mdga.message.server.DiceNowMessage;
 | 
			
		||||
import pp.mdga.message.server.PlayCardMessage;
 | 
			
		||||
import pp.mdga.message.server.PossibleCardMessage;
 | 
			
		||||
import pp.mdga.message.server.PossibleCardsMessage;
 | 
			
		||||
import pp.mdga.message.server.PossiblePieceMessage;
 | 
			
		||||
 | 
			
		||||
public class PowerCardState extends TurnStates {
 | 
			
		||||
@@ -48,7 +48,7 @@ public void setState(PowerCardStates state) {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(PossibleCardMessage msg){
 | 
			
		||||
    public void received(PossibleCardsMessage msg){
 | 
			
		||||
        state.received(msg);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -1,10 +1,14 @@
 | 
			
		||||
package pp.mdga.client.gameState.turnState;
 | 
			
		||||
package pp.mdga.client.gamestate.turnstate;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
import pp.mdga.client.gameState.TurnState;
 | 
			
		||||
import pp.mdga.client.gamestate.TurnState;
 | 
			
		||||
import pp.mdga.message.client.AnimationEndMessage;
 | 
			
		||||
import pp.mdga.message.client.RequestDieMessage;
 | 
			
		||||
import pp.mdga.message.server.DieMessage;
 | 
			
		||||
import pp.mdga.message.server.NoTurnMessage;
 | 
			
		||||
import pp.mdga.notification.DiceNowNotification;
 | 
			
		||||
import pp.mdga.notification.RollDiceNotification;
 | 
			
		||||
 | 
			
		||||
public class RollDiceState extends TurnStates {
 | 
			
		||||
 | 
			
		||||
@@ -17,7 +21,7 @@ public RollDiceState(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void enter() {
 | 
			
		||||
 | 
			
		||||
        logic.addNotification(new DiceNowNotification());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
@@ -29,11 +33,27 @@ public TurnState getParent() {
 | 
			
		||||
        return parent;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void selectDice(){
 | 
			
		||||
        logic.send(new RequestDieMessage());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(DieMessage msg){
 | 
			
		||||
        logic.getGame().setDiceEyes(msg.getDiceEye());
 | 
			
		||||
        parent.setState(parent.getChoosePiece());
 | 
			
		||||
        logic.addNotification(new RollDiceNotification(logic.getGame().getPlayerById(logic.getOwnPlayerId()).getColor(), msg.getDiceEye(),false));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void selectAnimationEnd(){
 | 
			
		||||
        logic.send(new AnimationEndMessage());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
//    @Override
 | 
			
		||||
//    public void received(ChoosePieceStateMessage msg){
 | 
			
		||||
//        parent.setState(parent.getChoosePiece());
 | 
			
		||||
//    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(NoTurnMessage msg){
 | 
			
		||||
        parent.getParent().setState(parent.getParent().getWaiting());
 | 
			
		||||
@@ -1,8 +1,8 @@
 | 
			
		||||
package pp.mdga.client.gameState.turnState;
 | 
			
		||||
package pp.mdga.client.gamestate.turnstate;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
import pp.mdga.client.gameState.GameStates;
 | 
			
		||||
import pp.mdga.client.gamestate.GameStates;
 | 
			
		||||
 | 
			
		||||
public  abstract class TurnStates extends GameStates {
 | 
			
		||||
    public TurnStates(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
@@ -1,8 +1,8 @@
 | 
			
		||||
package pp.mdga.client.gameState.turnState.choosePieceState;
 | 
			
		||||
package pp.mdga.client.gamestate.turnstate.choosepiecestate;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
import pp.mdga.client.gameState.turnState.TurnStates;
 | 
			
		||||
import pp.mdga.client.gamestate.turnstate.TurnStates;
 | 
			
		||||
 | 
			
		||||
public abstract class ChoosePieceStates extends TurnStates {
 | 
			
		||||
    public ChoosePieceStates(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
@@ -1,12 +1,11 @@
 | 
			
		||||
package pp.mdga.client.gameState.turnState.choosePieceState;
 | 
			
		||||
package pp.mdga.client.gamestate.turnstate.choosepiecestate;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
import pp.mdga.client.gameState.turnState.ChoosePieceState;
 | 
			
		||||
import pp.mdga.client.gamestate.turnstate.ChoosePieceState;
 | 
			
		||||
import pp.mdga.game.Piece;
 | 
			
		||||
import pp.mdga.message.server.*;
 | 
			
		||||
import pp.mdga.message.server.StartPieceMessage;
 | 
			
		||||
import pp.mdga.notification.MovePieceNotification;
 | 
			
		||||
import pp.mdga.notification.SelectableMoveNotification;
 | 
			
		||||
import pp.mdga.notification.WaitMoveNotification;
 | 
			
		||||
 | 
			
		||||
@@ -1,8 +1,8 @@
 | 
			
		||||
package pp.mdga.client.gameState.turnState.choosePieceState;
 | 
			
		||||
package pp.mdga.client.gamestate.turnstate.choosepiecestate;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
import pp.mdga.client.gameState.turnState.ChoosePieceState;
 | 
			
		||||
import pp.mdga.client.gamestate.turnstate.ChoosePieceState;
 | 
			
		||||
import pp.mdga.game.Piece;
 | 
			
		||||
import pp.mdga.message.client.SelectedPiecesMessage;
 | 
			
		||||
import pp.mdga.message.server.MoveMessage;
 | 
			
		||||
@@ -31,24 +31,26 @@ public void exit() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setPossiblePieces(ArrayList<Piece> possiblePieces){
 | 
			
		||||
    public void setPossiblePieces(ArrayList<Piece> possiblePieces) {
 | 
			
		||||
        this.possiblePieces = possiblePieces;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void selectPiece(Piece piece){
 | 
			
		||||
    public void selectPiece(Piece piece) {
 | 
			
		||||
        ArrayList<Piece> pieces = new ArrayList<>();
 | 
			
		||||
        if(possiblePieces.contains(piece)){
 | 
			
		||||
            logic.send(new SelectedPiecesMessage(piece.getUuid()));
 | 
			
		||||
            pieces.add(piece);
 | 
			
		||||
            logic.send(new SelectedPiecesMessage(pieces));
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(MoveMessage msg){
 | 
			
		||||
    public void received(MoveMessage msg) {
 | 
			
		||||
        Piece piece = logic.getGame().getPieceThroughUUID(msg.getIdentifier());
 | 
			
		||||
        if(msg.isHomeMove()){
 | 
			
		||||
        if (msg.isHomeMove()) {
 | 
			
		||||
            logic.addNotification(new HomeMoveNotification(piece.getUuid(), msg.getTargetIndex()));
 | 
			
		||||
            logic.getGame().getBoard().getInfield()[logic.getGame().getBoard().getInfieldIndexOfPiece(piece)].clearOccupant();
 | 
			
		||||
            logic.getGame().getBoard().getPlayerData().get(piece.getColor()).setPieceInHome(msg.getTargetIndex(), piece);
 | 
			
		||||
            logic.getGame().getPlayerByColor(piece.getColor()).setPieceInHome(msg.getTargetIndex(), piece);
 | 
			
		||||
        } else {
 | 
			
		||||
            if (logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].isOccupied()) {
 | 
			
		||||
                throwPiece(logic.getGame().getBoard().getInfield()[msg.getTargetIndex()].getOccupant());
 | 
			
		||||
@@ -1,12 +1,14 @@
 | 
			
		||||
package pp.mdga.client.gameState.turnState.choosePieceState;
 | 
			
		||||
package pp.mdga.client.gamestate.turnstate.choosepiecestate;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
import pp.mdga.client.gameState.turnState.ChoosePieceState;
 | 
			
		||||
import pp.mdga.client.gamestate.turnstate.ChoosePieceState;
 | 
			
		||||
import pp.mdga.game.Piece;
 | 
			
		||||
import pp.mdga.message.client.SelectedPiecesMessage;
 | 
			
		||||
import pp.mdga.message.server.MoveMessage;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
 | 
			
		||||
public class StartPieceState extends ChoosePieceStates {
 | 
			
		||||
 | 
			
		||||
    private final ChoosePieceState parent;
 | 
			
		||||
@@ -30,8 +32,10 @@ public void exit() {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void selectPiece(Piece piece){
 | 
			
		||||
        ArrayList<Piece> pieces = new ArrayList<>();
 | 
			
		||||
        if(moveablePiece.equals(piece)){
 | 
			
		||||
            logic.send(new SelectedPiecesMessage(piece.getUuid()));
 | 
			
		||||
            pieces.add(piece);
 | 
			
		||||
            logic.send(new SelectedPiecesMessage(pieces));
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -1,13 +1,16 @@
 | 
			
		||||
package pp.mdga.client.gameState.turnState.choosePieceState;
 | 
			
		||||
package pp.mdga.client.gamestate.turnstate.choosepiecestate;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
import pp.mdga.client.gameState.turnState.ChoosePieceState;
 | 
			
		||||
import pp.mdga.client.gamestate.turnstate.ChoosePieceState;
 | 
			
		||||
import pp.mdga.game.Piece;
 | 
			
		||||
import pp.mdga.game.PieceState;
 | 
			
		||||
import pp.mdga.message.client.SelectedPiecesMessage;
 | 
			
		||||
import pp.mdga.message.server.MoveMessage;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
public class WaitingPieceState extends ChoosePieceStates {
 | 
			
		||||
 | 
			
		||||
    private final ChoosePieceState parent;
 | 
			
		||||
@@ -29,8 +32,10 @@ public void exit() {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void selectPiece(Piece piece){
 | 
			
		||||
        ArrayList<Piece> pieces = new ArrayList<>();
 | 
			
		||||
        if(moveablePiece.equals(piece)){
 | 
			
		||||
            logic.send(new SelectedPiecesMessage(piece.getUuid()));
 | 
			
		||||
            pieces.add(piece);
 | 
			
		||||
            logic.send(new SelectedPiecesMessage(pieces));
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -1,14 +1,15 @@
 | 
			
		||||
package pp.mdga.client.gameState.turnState.powerCardState;
 | 
			
		||||
package pp.mdga.client.gamestate.turnstate.powercardstate;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
import pp.mdga.client.gameState.turnState.PowerCardState;
 | 
			
		||||
import pp.mdga.client.gamestate.turnstate.PowerCardState;
 | 
			
		||||
import pp.mdga.game.BonusCard;
 | 
			
		||||
import pp.mdga.game.card.*;
 | 
			
		||||
import pp.mdga.message.client.NoPowerCardMessage;
 | 
			
		||||
import pp.mdga.message.client.SelectCardMessage;
 | 
			
		||||
import pp.mdga.message.server.DiceNowMessage;
 | 
			
		||||
import pp.mdga.message.server.PlayCardMessage;
 | 
			
		||||
import pp.mdga.message.server.PossibleCardMessage;
 | 
			
		||||
import pp.mdga.message.server.PossibleCardsMessage;
 | 
			
		||||
import pp.mdga.message.server.PossiblePieceMessage;
 | 
			
		||||
import pp.mdga.notification.SelectableCardsNotification;
 | 
			
		||||
 | 
			
		||||
@@ -21,7 +22,7 @@
 | 
			
		||||
public class ChoosePowerCardState extends PowerCardStates {
 | 
			
		||||
 | 
			
		||||
    private final PowerCardState parent;
 | 
			
		||||
    private ArrayList<BonusCard> possibleCards;
 | 
			
		||||
    private ArrayList<PowerCard> possibleCards = new ArrayList<>();
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Constructor
 | 
			
		||||
@@ -38,8 +39,6 @@ public ChoosePowerCardState(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public void enter() {
 | 
			
		||||
        possibleCards = new ArrayList<>();
 | 
			
		||||
        //TODO: logic.send(new RequestPossibleCardsMessage());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -47,7 +46,7 @@ public void enter() {
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public void exit() {
 | 
			
		||||
        possibleCards = null;
 | 
			
		||||
        possibleCards = new ArrayList<>();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -55,9 +54,15 @@ public void exit() {
 | 
			
		||||
     * @param msg possible cards message
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(PossibleCardMessage msg){
 | 
			
		||||
        possibleCards = (ArrayList<BonusCard>) msg.getPossibleCards();
 | 
			
		||||
        logic.addNotification(new SelectableCardsNotification(possibleCards));
 | 
			
		||||
    public void received(PossibleCardsMessage msg){
 | 
			
		||||
        possibleCards = (ArrayList<PowerCard>)msg.getPossibleCards();
 | 
			
		||||
        ArrayList<BonusCard> possibleBonusCards = new ArrayList<>();
 | 
			
		||||
        for (PowerCard card : possibleCards) {
 | 
			
		||||
            if (!possibleBonusCards.contains(card.getCard())) {
 | 
			
		||||
                possibleBonusCards.add(card.getCard());
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        logic.addNotification(new SelectableCardsNotification(possibleBonusCards));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -67,7 +72,7 @@ public void received(PossibleCardMessage msg){
 | 
			
		||||
    @Override
 | 
			
		||||
    public void selectCard(BonusCard card){
 | 
			
		||||
        if(card != null){
 | 
			
		||||
            logic.send(new SelectCardMessage(card));
 | 
			
		||||
            logic.send(new SelectCardMessage(logic.getGame().getPlayers().get(logic.getOwnPlayerId()).getPowerCardByType(card)));
 | 
			
		||||
        } else {
 | 
			
		||||
            logic.send(new NoPowerCardMessage());
 | 
			
		||||
        }
 | 
			
		||||
@@ -79,10 +84,9 @@ public void selectCard(BonusCard card){
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public void received(PlayCardMessage msg){
 | 
			
		||||
        if(msg.getCard().equals(BonusCard.TURBO)){
 | 
			
		||||
            logic.getGame().setDiceModifier(msg.getDiceModifier());
 | 
			
		||||
        } else {
 | 
			
		||||
            LOGGER.log(System.Logger.Level.ERROR, "Received card that is not turbo");
 | 
			
		||||
        if(msg.getCard().getCard().equals(BonusCard.TURBO)){
 | 
			
		||||
            parent.getParent().getPlayPowerCard().setPlayCard(msg);
 | 
			
		||||
            parent.getParent().setState(parent.getParent().getPlayPowerCard());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -1,8 +1,8 @@
 | 
			
		||||
package pp.mdga.client.gameState.turnState.powerCardState;
 | 
			
		||||
package pp.mdga.client.gamestate.turnstate.powercardstate;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
import pp.mdga.client.gameState.turnState.TurnStates;
 | 
			
		||||
import pp.mdga.client.gamestate.turnstate.TurnStates;
 | 
			
		||||
 | 
			
		||||
public abstract class PowerCardStates extends TurnStates {
 | 
			
		||||
    public PowerCardStates(ClientState parent, ClientGameLogic logic) {
 | 
			
		||||
@@ -1,8 +1,8 @@
 | 
			
		||||
package pp.mdga.client.gameState.turnState.powerCardState;
 | 
			
		||||
package pp.mdga.client.gamestate.turnstate.powercardstate;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
import pp.mdga.client.gameState.turnState.PowerCardState;
 | 
			
		||||
import pp.mdga.client.gamestate.turnstate.PowerCardState;
 | 
			
		||||
import pp.mdga.game.Piece;
 | 
			
		||||
import pp.mdga.message.client.RequestPlayCardMessage;
 | 
			
		||||
import pp.mdga.message.server.PlayCardMessage;
 | 
			
		||||
@@ -1,8 +1,8 @@
 | 
			
		||||
package pp.mdga.client.gameState.turnState.powerCardState;
 | 
			
		||||
package pp.mdga.client.gamestate.turnstate.powercardstate;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
import pp.mdga.client.gameState.turnState.PowerCardState;
 | 
			
		||||
import pp.mdga.client.gamestate.turnstate.PowerCardState;
 | 
			
		||||
import pp.mdga.game.Piece;
 | 
			
		||||
import pp.mdga.message.client.RequestPlayCardMessage;
 | 
			
		||||
import pp.mdga.message.server.PlayCardMessage;
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
package pp.mdga.client.settingsState;
 | 
			
		||||
package pp.mdga.client.settingsstate;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
package pp.mdga.client.settingsState;
 | 
			
		||||
package pp.mdga.client.settingsstate;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
package pp.mdga.client.settingsState;
 | 
			
		||||
package pp.mdga.client.settingsstate;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
package pp.mdga.client.settingsState;
 | 
			
		||||
package pp.mdga.client.settingsstate;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.client.ClientGameLogic;
 | 
			
		||||
import pp.mdga.client.ClientState;
 | 
			
		||||
@@ -2,31 +2,38 @@
 | 
			
		||||
 | 
			
		||||
import com.jme3.network.serializing.Serializable;
 | 
			
		||||
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * This class will be used to hold all Board relevant data.
 | 
			
		||||
 */
 | 
			
		||||
@Serializable
 | 
			
		||||
public class Board {
 | 
			
		||||
    private Map<Color, PlayerData> playerData = new HashMap<>();
 | 
			
		||||
    /**
 | 
			
		||||
     * The size of the board.
 | 
			
		||||
     */
 | 
			
		||||
    public static final int BOARD_SIZE = 40;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Create Board attributes.
 | 
			
		||||
     */
 | 
			
		||||
    private final Node[] infield;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This constructor is used to create a new board
 | 
			
		||||
     */
 | 
			
		||||
    public Board() {
 | 
			
		||||
        infield = new Node[40];
 | 
			
		||||
        for (int i = 0; i < 40; i++) {
 | 
			
		||||
            if (i % 10 == 0) {
 | 
			
		||||
                infield[i] = new StartNode(
 | 
			
		||||
                    i == 0 ? Color.AIRFORCE :
 | 
			
		||||
                        i == 10 ? Color.CYBER :
 | 
			
		||||
                            i == 20 ? Color.NAVY :
 | 
			
		||||
                                Color.ARMY
 | 
			
		||||
                );
 | 
			
		||||
            } else if (i == 4 || i == 14 || i == 24 || i == 34) {
 | 
			
		||||
        infield = new Node[BOARD_SIZE];
 | 
			
		||||
        initializeBoard();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Initializes the board by setting up the nodes.
 | 
			
		||||
     * Start nodes, bonus nodes, and regular nodes are created based on their positions.
 | 
			
		||||
     */
 | 
			
		||||
    private void initializeBoard() {
 | 
			
		||||
        for (int i = 0; i < BOARD_SIZE; i++) {
 | 
			
		||||
            if (isStartNode(i)) {
 | 
			
		||||
                infield[i] = createStartNode(i);
 | 
			
		||||
            } else if (isBonusNode(i)) {
 | 
			
		||||
                infield[i] = new BonusNode();
 | 
			
		||||
            } else {
 | 
			
		||||
                infield[i] = new Node(null);
 | 
			
		||||
@@ -35,23 +42,48 @@ public Board() {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method will be used to add the given color and playerData parameters to the playerData attribute of
 | 
			
		||||
     * Board class.
 | 
			
		||||
     * Checks if the given index is a start node.
 | 
			
		||||
     *
 | 
			
		||||
     * @param color      as the color of the player as a Color enumeration.
 | 
			
		||||
     * @param playerData as the playerData of the player as a PlayerData object.
 | 
			
		||||
     * @param i the index to check
 | 
			
		||||
     * @return true if the index is a start node, false otherwise
 | 
			
		||||
     */
 | 
			
		||||
    public void addPlayerData(Color color, PlayerData playerData) {
 | 
			
		||||
        this.playerData.put(color, playerData);
 | 
			
		||||
    private boolean isStartNode(int i) {
 | 
			
		||||
        return i % 10 == 0;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method returns the playerData
 | 
			
		||||
     * Checks if the given index is a bonus node.
 | 
			
		||||
     *
 | 
			
		||||
     * @return the playerData
 | 
			
		||||
     * @param i the index to check
 | 
			
		||||
     * @return true if the index is a bonus node, false otherwise
 | 
			
		||||
     */
 | 
			
		||||
    public Map<Color, PlayerData> getPlayerData() {
 | 
			
		||||
        return playerData;
 | 
			
		||||
    private boolean isBonusNode(int i) {
 | 
			
		||||
        return i % 10 == 4;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Creates a start node with the appropriate color based on the index.
 | 
			
		||||
     *
 | 
			
		||||
     * @param i the index of the start node
 | 
			
		||||
     * @return a new StartNode with the corresponding color
 | 
			
		||||
     */
 | 
			
		||||
    private StartNode createStartNode(int i) {
 | 
			
		||||
        return new StartNode(Color.getColor(i));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method returns the index of a specific piece on the board
 | 
			
		||||
     *
 | 
			
		||||
     * @param piece the piece to be searched for
 | 
			
		||||
     * @return the index of the piece
 | 
			
		||||
     */
 | 
			
		||||
    public int getInfieldIndexOfPiece(Piece piece) {
 | 
			
		||||
        for (int i = 0; i < infield.length; i++) {
 | 
			
		||||
            if (infield[i].getOccupant() == piece) {
 | 
			
		||||
                return i;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return -1;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -73,18 +105,8 @@ public void setPieceOnBoard(int index, Piece piece) {
 | 
			
		||||
        infield[index].setOccupant(piece);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method returns the index of a specific piece on the board
 | 
			
		||||
     *
 | 
			
		||||
     * @param piece the piece to be searched for
 | 
			
		||||
     * @return the index of the piece
 | 
			
		||||
     */
 | 
			
		||||
    public int getInfieldIndexOfPiece(Piece piece) {
 | 
			
		||||
        for (int i = 0; i < infield.length; i++) {
 | 
			
		||||
            if (infield[i].getOccupant() == piece) {
 | 
			
		||||
                return i;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return -1;
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toString() {
 | 
			
		||||
        return "Default Board";
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,8 +1,11 @@
 | 
			
		||||
package pp.mdga.game;
 | 
			
		||||
 | 
			
		||||
import com.jme3.network.serializing.Serializable;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Enum representing the different types of bonus cards.
 | 
			
		||||
 */
 | 
			
		||||
@Serializable
 | 
			
		||||
public enum BonusCard {
 | 
			
		||||
    /**
 | 
			
		||||
     * The hidden bonus card.
 | 
			
		||||
 
 | 
			
		||||
@@ -7,7 +7,10 @@
 | 
			
		||||
 */
 | 
			
		||||
@Serializable
 | 
			
		||||
public class BonusNode extends Node {
 | 
			
		||||
    BonusNode(){
 | 
			
		||||
    /**
 | 
			
		||||
     * Constructor.
 | 
			
		||||
     */
 | 
			
		||||
    BonusNode() {
 | 
			
		||||
        super(null);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -3,8 +3,8 @@
 | 
			
		||||
import com.jme3.network.serializing.Serializable;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * This enumeration will be used to show the four different TSK which can be picked from a player.
 | 
			
		||||
 * In Addition, the NONE color will be used to show a none color.
 | 
			
		||||
 * This enumeration represents the four different TSK colors that a player can choose.
 | 
			
		||||
 * Additionally, the NONE color indicates the absence of a color.
 | 
			
		||||
 */
 | 
			
		||||
@Serializable
 | 
			
		||||
public enum Color {
 | 
			
		||||
@@ -58,4 +58,19 @@ public Color next() {
 | 
			
		||||
 | 
			
		||||
        return colors[nextIndex];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method will be used to return the color of the given index.
 | 
			
		||||
     *
 | 
			
		||||
     * @param i as the index of the color as an Integer.
 | 
			
		||||
     * @return a Color enumeration.
 | 
			
		||||
     */
 | 
			
		||||
    public static Color getColor(int i) {
 | 
			
		||||
        for (Color color : Color.values()) {
 | 
			
		||||
            if (color.ordinal() == i) {
 | 
			
		||||
                return color;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,5 @@
 | 
			
		||||
package pp.mdga.game;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.Arrays;
 | 
			
		||||
import java.util.Iterator;
 | 
			
		||||
import java.util.random.RandomGenerator;
 | 
			
		||||
import java.util.random.RandomGeneratorFactory;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,14 @@
 | 
			
		||||
package pp.mdga.game;
 | 
			
		||||
 | 
			
		||||
import pp.mdga.game.card.PowerCard;
 | 
			
		||||
import pp.mdga.game.card.ShieldCard;
 | 
			
		||||
import pp.mdga.game.card.SwapCard;
 | 
			
		||||
import pp.mdga.game.card.TurboCard;
 | 
			
		||||
 | 
			
		||||
import java.util.*;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * The Game class represents the game state of the Ludo game.
 | 
			
		||||
 * The Game class represents the game state of the game.
 | 
			
		||||
 * It contains all the information needed to play the game.
 | 
			
		||||
 * The game state is updated by the game logic.
 | 
			
		||||
 */
 | 
			
		||||
@@ -14,57 +19,108 @@ public class Game {
 | 
			
		||||
    public static final int AMOUNT_OF_TURBO_CARDS = 16;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * The number of shield and swap cards available in the game.
 | 
			
		||||
     * The number of shield cards available in the game.
 | 
			
		||||
     */
 | 
			
		||||
    public static final int AMOUNT_OF_SHIELD_AND_SWAP_CARDS = 12;
 | 
			
		||||
    public static final int AMOUNT_OF_SHIELD_CARDS = 12;
 | 
			
		||||
 | 
			
		||||
    // The modifier applied to the dice roll.
 | 
			
		||||
    private int diceModifier = 1;
 | 
			
		||||
    /**
 | 
			
		||||
     * The number of swap cards available in the game.
 | 
			
		||||
     */
 | 
			
		||||
    public static final int AMOUNT_OF_SWAP_CARDS = 12;
 | 
			
		||||
 | 
			
		||||
    // The number of eyes shown on the dice.
 | 
			
		||||
    private int diceEyes;
 | 
			
		||||
 | 
			
		||||
    // A map of player IDs to Player objects.
 | 
			
		||||
    /**
 | 
			
		||||
     * A map of player IDs to Player objects.
 | 
			
		||||
     */
 | 
			
		||||
    private Map<Integer, Player> players = new HashMap<>();
 | 
			
		||||
 | 
			
		||||
    // The statistics of the game.
 | 
			
		||||
    /**
 | 
			
		||||
     * The statistics of the game.
 | 
			
		||||
     */
 | 
			
		||||
    private Statistic gameStatistics;
 | 
			
		||||
 | 
			
		||||
    // The pile of bonus cards available for drawing.
 | 
			
		||||
    private List<BonusCard> drawPile;
 | 
			
		||||
    /**
 | 
			
		||||
     * The pile of bonus cards available for drawing.
 | 
			
		||||
     */
 | 
			
		||||
    private List<PowerCard> drawPile = new ArrayList<>();
 | 
			
		||||
 | 
			
		||||
    // The pile of bonus cards that have been discarded.
 | 
			
		||||
    private List<BonusCard> discardPile = new ArrayList<>();
 | 
			
		||||
    /**
 | 
			
		||||
     * The pile of bonus cards that have been discarded.
 | 
			
		||||
     */
 | 
			
		||||
    private List<PowerCard> discardPile = new ArrayList<>();
 | 
			
		||||
 | 
			
		||||
    // The game board.
 | 
			
		||||
    /**
 | 
			
		||||
     * The game board.
 | 
			
		||||
     */
 | 
			
		||||
    private Board board;
 | 
			
		||||
 | 
			
		||||
    // The die used in the game.
 | 
			
		||||
    /**
 | 
			
		||||
     * The die used in the game.
 | 
			
		||||
     */
 | 
			
		||||
    private Die die;
 | 
			
		||||
 | 
			
		||||
    // The host of this game
 | 
			
		||||
    /**
 | 
			
		||||
     * The host of this game
 | 
			
		||||
     */
 | 
			
		||||
    private int host = -1;
 | 
			
		||||
 | 
			
		||||
    // The color of the active player.
 | 
			
		||||
    /**
 | 
			
		||||
     * The color of the active player.
 | 
			
		||||
     */
 | 
			
		||||
    private Color activeColor;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * The dice modifier.
 | 
			
		||||
     */
 | 
			
		||||
    private int diceModifier;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * The number of eyes on the dice.
 | 
			
		||||
     */
 | 
			
		||||
    private int diceEyes;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This constructor creates a new Game object.
 | 
			
		||||
     */
 | 
			
		||||
    public Game() {
 | 
			
		||||
        gameStatistics = new Statistic();
 | 
			
		||||
        drawPile = new ArrayList<>();
 | 
			
		||||
        for (int i = 0; i < AMOUNT_OF_TURBO_CARDS; i++) {
 | 
			
		||||
            drawPile.add(BonusCard.TURBO);
 | 
			
		||||
        }
 | 
			
		||||
        for (int i = 0; i < AMOUNT_OF_SHIELD_AND_SWAP_CARDS; i++) {
 | 
			
		||||
            drawPile.add(BonusCard.SWAP);
 | 
			
		||||
            drawPile.add(BonusCard.SHIELD);
 | 
			
		||||
        }
 | 
			
		||||
        initializeDrawPile();
 | 
			
		||||
        board = new Board();
 | 
			
		||||
        die = new Die();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method initializes the draw pile with the predefined number of bonus cards.
 | 
			
		||||
     */
 | 
			
		||||
    private void initializeDrawPile() {
 | 
			
		||||
//        this.addBonusCards(new TurboCard(), AMOUNT_OF_TURBO_CARDS);
 | 
			
		||||
        this.addBonusCards(new SwapCard(), AMOUNT_OF_SWAP_CARDS);
 | 
			
		||||
//        this.addBonusCards(new ShieldCard(), AMOUNT_OF_SHIELD_CARDS);
 | 
			
		||||
        Collections.shuffle(this.drawPile);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method will be used to remove the first card of the drawPile attribute of Game class.
 | 
			
		||||
     *
 | 
			
		||||
     * @return first card as a PowerCard enumeration.
 | 
			
		||||
     */
 | 
			
		||||
    public PowerCard draw() {
 | 
			
		||||
        if (!this.drawPile.isEmpty()) {
 | 
			
		||||
            return this.drawPile.remove(0);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method adds a number of bonus cards to the draw pile.
 | 
			
		||||
     *
 | 
			
		||||
     * @param card  the card to add
 | 
			
		||||
     * @param count the number of cards to add
 | 
			
		||||
     */
 | 
			
		||||
    private void addBonusCards(PowerCard card, int count) {
 | 
			
		||||
        drawPile.addAll(Collections.nCopies(count, card));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method adds a player to the game.
 | 
			
		||||
     *
 | 
			
		||||
@@ -99,7 +155,7 @@ public void updatePlayerActiveState(int id, boolean active) {
 | 
			
		||||
     * If yes it will return true, otherwise false.
 | 
			
		||||
     *
 | 
			
		||||
     * @param color as the color which should be checked if taken as a Color enumeration.
 | 
			
		||||
     * @return      true or false.
 | 
			
		||||
     * @return true or false.
 | 
			
		||||
     */
 | 
			
		||||
    public boolean isColorTaken(Color color) {
 | 
			
		||||
        for (Map.Entry<Integer, Player> entry : this.players.entrySet()) {
 | 
			
		||||
@@ -152,6 +208,15 @@ public Player getPlayerByColor(Color color) {
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method will be used to return all connected players as a list.
 | 
			
		||||
     *
 | 
			
		||||
     * @return players as a List of Player objects.
 | 
			
		||||
     */
 | 
			
		||||
    public List<Player> getPlayersAsList() {
 | 
			
		||||
        return new ArrayList<>(this.players.values());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method will be used to return the id of the active player depending on the activeColor attribute of Game
 | 
			
		||||
     * class.
 | 
			
		||||
@@ -166,7 +231,7 @@ public int getActivePlayerId() {
 | 
			
		||||
     * This method will be used to return the id of the Player defined by the given color parameter.
 | 
			
		||||
     *
 | 
			
		||||
     * @param color as the color of the player as a Color enumeration.
 | 
			
		||||
     * @return      the id of the player as an Integer.
 | 
			
		||||
     * @return the id of the player as an Integer.
 | 
			
		||||
     */
 | 
			
		||||
    public int getPlayerIdByColor(Color color) {
 | 
			
		||||
        for (Map.Entry<Integer, Player> entry : this.players.entrySet()) {
 | 
			
		||||
@@ -216,8 +281,8 @@ public boolean areAllReady() {
 | 
			
		||||
     * @return the piece specified by the UUID
 | 
			
		||||
     */
 | 
			
		||||
    public Piece getPieceThroughUUID(UUID pieceId) {
 | 
			
		||||
        for (var playerData : board.getPlayerData().values()) {
 | 
			
		||||
            for (var piece : playerData.getPieces()) {
 | 
			
		||||
        for (var player : this.getPlayers().values()) {
 | 
			
		||||
            for (var piece : player.getPieces()) {
 | 
			
		||||
                if (piece.getUuid().equals(pieceId)) {
 | 
			
		||||
                    return piece;
 | 
			
		||||
                }
 | 
			
		||||
@@ -235,24 +300,6 @@ public boolean isHost() {
 | 
			
		||||
        return this.host != -1;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method returns the dice modifier.
 | 
			
		||||
     *
 | 
			
		||||
     * @return the dice modifier
 | 
			
		||||
     */
 | 
			
		||||
    public int getDiceModifier() {
 | 
			
		||||
        return diceModifier;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method returns the dice eyes.
 | 
			
		||||
     *
 | 
			
		||||
     * @return the dice eyes
 | 
			
		||||
     */
 | 
			
		||||
    public int getDiceEyes() {
 | 
			
		||||
        return diceEyes;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method returns the players.
 | 
			
		||||
     *
 | 
			
		||||
@@ -272,21 +319,21 @@ public Statistic getGameStatistics() {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method returns the draw pile.
 | 
			
		||||
     * This method will be used to return drawPile attribute of Game class.
 | 
			
		||||
     *
 | 
			
		||||
     * @return the draw pile
 | 
			
		||||
     * @return drawPile as a List of PowerCard objects.
 | 
			
		||||
     */
 | 
			
		||||
    public List<BonusCard> getDrawPile() {
 | 
			
		||||
        return drawPile;
 | 
			
		||||
    public List<PowerCard> getDrawPile() {
 | 
			
		||||
        return this.drawPile;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method returns the discard pile.
 | 
			
		||||
     * This method will be used to return discardPile attribute of Game class.
 | 
			
		||||
     *
 | 
			
		||||
     * @return the discard pile
 | 
			
		||||
     * @return discardPile as a List of PowerCard objects.
 | 
			
		||||
     */
 | 
			
		||||
    public List<BonusCard> getDiscardPile() {
 | 
			
		||||
        return discardPile;
 | 
			
		||||
    public List<PowerCard> getDiscardPile() {
 | 
			
		||||
        return this.discardPile;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -325,24 +372,6 @@ public int getHost() {
 | 
			
		||||
        return this.host;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method sets the dice modifier.
 | 
			
		||||
     *
 | 
			
		||||
     * @param diceModifier the new dice modifier
 | 
			
		||||
     */
 | 
			
		||||
    public void setDiceModifier(int diceModifier) {
 | 
			
		||||
        this.diceModifier = diceModifier;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method sets the dice eyes.
 | 
			
		||||
     *
 | 
			
		||||
     * @param diceEyes the new dice eyes
 | 
			
		||||
     */
 | 
			
		||||
    public void setDiceEyes(int diceEyes) {
 | 
			
		||||
        this.diceEyes = diceEyes;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method sets the players.
 | 
			
		||||
     *
 | 
			
		||||
@@ -362,20 +391,22 @@ public void setGameStatistics(Statistic gameStatistics) {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method sets the draw pile.
 | 
			
		||||
     * This method will be used to set drawPile attribute of Game class to the given discardPile parameter.
 | 
			
		||||
     * It will be used to test cases.
 | 
			
		||||
     *
 | 
			
		||||
     * @param drawPile the new draw pile
 | 
			
		||||
     * @param drawPile the new value of drawPile attribute as a List of PowerCards.
 | 
			
		||||
     */
 | 
			
		||||
    public void setDrawPile(List<BonusCard> drawPile) {
 | 
			
		||||
    public void setDrawPile(List<PowerCard> drawPile) {
 | 
			
		||||
        this.drawPile = drawPile;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method sets the discard pile.
 | 
			
		||||
     * This method will be used to set discardPile attribute of Game class to the given discardPile parameter.
 | 
			
		||||
     * It will be used to test cases.
 | 
			
		||||
     *
 | 
			
		||||
     * @param discardPile the new discard pile
 | 
			
		||||
     * @param discardPile the new value of discardPile attribute as a List of PowerCards.
 | 
			
		||||
     */
 | 
			
		||||
    public void setDiscardPile(List<BonusCard> discardPile) {
 | 
			
		||||
    public void setDiscardPile(List<PowerCard> discardPile) {
 | 
			
		||||
        this.discardPile = discardPile;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -414,4 +445,40 @@ public void setDie(Die die) {
 | 
			
		||||
    public void setHost(int host) {
 | 
			
		||||
        this.host = host;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method will be used to get the dice eyes.
 | 
			
		||||
     *
 | 
			
		||||
     * @return the dice eyes
 | 
			
		||||
     */
 | 
			
		||||
    public int getDiceEyes() {
 | 
			
		||||
        return diceEyes;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method is used to get the dice modifier.
 | 
			
		||||
     *
 | 
			
		||||
     * @return the dice modifier
 | 
			
		||||
     */
 | 
			
		||||
    public int getDiceModifier() {
 | 
			
		||||
        return diceModifier;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method will be used to set the dice eyes.
 | 
			
		||||
     *
 | 
			
		||||
     * @param diceEyes the new dice eyes
 | 
			
		||||
     */
 | 
			
		||||
    public void setDiceEyes(int diceEyes) {
 | 
			
		||||
        this.diceEyes = diceEyes;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method is used to set the dice modifier.
 | 
			
		||||
     *
 | 
			
		||||
     * @param diceModifier the new dice modifier
 | 
			
		||||
     */
 | 
			
		||||
    public void setDiceModifier(int diceModifier) {
 | 
			
		||||
        this.diceModifier = diceModifier;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -7,6 +7,9 @@
 | 
			
		||||
 */
 | 
			
		||||
@Serializable
 | 
			
		||||
public class HomeNode extends Node {
 | 
			
		||||
    /**
 | 
			
		||||
     * Constructor.
 | 
			
		||||
     */
 | 
			
		||||
    public HomeNode() {
 | 
			
		||||
        super(null);
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -3,22 +3,33 @@
 | 
			
		||||
import com.jme3.network.serializing.Serializable;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * This class will be used the represent a Node on which the pieces can travel along
 | 
			
		||||
 * Represents a node on the board.
 | 
			
		||||
 */
 | 
			
		||||
@Serializable
 | 
			
		||||
public class Node {
 | 
			
		||||
    /**
 | 
			
		||||
     * The occupant of the node.
 | 
			
		||||
     */
 | 
			
		||||
    protected Piece occupant;
 | 
			
		||||
 | 
			
		||||
    public Node(Piece piece){
 | 
			
		||||
    /**
 | 
			
		||||
     * This constructor is used to create a new node object with a given occupant.
 | 
			
		||||
     *
 | 
			
		||||
     * @param piece as the occupant of the node.
 | 
			
		||||
     */
 | 
			
		||||
    public Node(Piece piece) {
 | 
			
		||||
        occupant = piece;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private Node(){
 | 
			
		||||
    /**
 | 
			
		||||
     * This constructor is used to create a new node object with a default occupant.
 | 
			
		||||
     */
 | 
			
		||||
    private Node() {
 | 
			
		||||
        occupant = new Piece(Color.AIRFORCE, PieceState.WAITING);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method is used to get an occupant of the Node.
 | 
			
		||||
     * This method is used to get an occupant of the node.
 | 
			
		||||
     *
 | 
			
		||||
     * @return the current occupant of the node
 | 
			
		||||
     */
 | 
			
		||||
@@ -27,7 +38,7 @@ public Piece getOccupant() {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method is used to set a new Occupant
 | 
			
		||||
     * This method is used to set a new occupant
 | 
			
		||||
     *
 | 
			
		||||
     * @param occupant the new occupant of the node
 | 
			
		||||
     */
 | 
			
		||||
@@ -58,9 +69,9 @@ public boolean isOccupied() {
 | 
			
		||||
     * This method will be used to check if the node is occupied by a piece of the given color.
 | 
			
		||||
     *
 | 
			
		||||
     * @param color as the color of the piece as a Color object.
 | 
			
		||||
     * @return      true or false.
 | 
			
		||||
     * @return true or false.
 | 
			
		||||
     */
 | 
			
		||||
    public boolean isOccupied(Color color) {
 | 
			
		||||
        return this.occupant != null && this.occupant.getColor() == color;
 | 
			
		||||
        return isOccupied() && this.occupant.getColor() == color;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -51,74 +51,117 @@ private Piece() {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method is used to get the color of the piece
 | 
			
		||||
     * Sets the shield state of the piece.
 | 
			
		||||
     *
 | 
			
		||||
     * @return the color of the piece
 | 
			
		||||
     * @param shield the new shield state
 | 
			
		||||
     */
 | 
			
		||||
    public void setShield(ShieldState shield) {
 | 
			
		||||
        this.shield = shield;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method is used to get the color of the piece
 | 
			
		||||
     * Gets the shield state of the piece.
 | 
			
		||||
     *
 | 
			
		||||
     * @return the color of the piece
 | 
			
		||||
     * @return the shield state
 | 
			
		||||
     */
 | 
			
		||||
    public ShieldState getShield() {
 | 
			
		||||
        return shield;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method is used to get the color of the piece
 | 
			
		||||
     * Sets the state of the piece.
 | 
			
		||||
     *
 | 
			
		||||
     * @param state the state of the piece
 | 
			
		||||
     * @param state the new state
 | 
			
		||||
     */
 | 
			
		||||
    public void setState(PieceState state) {
 | 
			
		||||
        this.state = state;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method is used to get the color of the piece
 | 
			
		||||
     * Gets the state of the piece.
 | 
			
		||||
     *
 | 
			
		||||
     * @return the color of the piece
 | 
			
		||||
     * @return the state
 | 
			
		||||
     */
 | 
			
		||||
    public PieceState getState() {
 | 
			
		||||
        return state;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method is used to get the color of the piece
 | 
			
		||||
     * Checks if the piece is shielded.
 | 
			
		||||
     *
 | 
			
		||||
     * @return the color of the piece
 | 
			
		||||
     * @return true if the piece is shielded, false otherwise
 | 
			
		||||
     */
 | 
			
		||||
    public boolean isShielded() {
 | 
			
		||||
        return shield == ShieldState.ACTIVE;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method is used to get the color of the piece
 | 
			
		||||
     * Checks if the shield of a piece is suppressed.
 | 
			
		||||
     *
 | 
			
		||||
     * @return the color of the piece
 | 
			
		||||
     * @return true if the shield is suppressed, false otherwise
 | 
			
		||||
     */
 | 
			
		||||
    public boolean isSuppressed() {
 | 
			
		||||
        return shield == ShieldState.SUPPRESSED;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method is used to get the color of the piece
 | 
			
		||||
     * Gets the color of the piece.
 | 
			
		||||
     *
 | 
			
		||||
     * @return the color of the piece
 | 
			
		||||
     * @return the color
 | 
			
		||||
     */
 | 
			
		||||
    public Color getColor() {
 | 
			
		||||
        return color;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method is used to get the color of the piece
 | 
			
		||||
     * Gets the unique identifier of the piece.
 | 
			
		||||
     *
 | 
			
		||||
     * @return the color of the piece
 | 
			
		||||
     * @return the UUID
 | 
			
		||||
     */
 | 
			
		||||
    public UUID getUuid() {
 | 
			
		||||
        return uuid;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method will return all necessary information of Piece class in a more readable way.
 | 
			
		||||
     *
 | 
			
		||||
     * @return information as a String.
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toString() {
 | 
			
		||||
        return "Piece with UUID: %s and color: %s with state: %s".formatted(this.uuid, color, state);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method will be used to create the hash code of this Piece class.
 | 
			
		||||
     *
 | 
			
		||||
     * @return hashCode as an Integer.
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public int hashCode() {
 | 
			
		||||
        return this.uuid.hashCode();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method will be used to check if the given obj parameter is equal to this object.
 | 
			
		||||
     * It will return false if the obj parameter is null or if the hash codes of both objects are not equal. Otherwise
 | 
			
		||||
     * it will return true.
 | 
			
		||||
     *
 | 
			
		||||
     * @param obj as the object which will be compared as an Object.
 | 
			
		||||
     * @return true or false.
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean equals(Object obj) {
 | 
			
		||||
        if (obj == null) {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (obj instanceof Piece) {
 | 
			
		||||
            Piece piece = (Piece) obj;
 | 
			
		||||
 | 
			
		||||
            return this.hashCode() == piece.hashCode();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -22,5 +22,5 @@ public enum PieceState {
 | 
			
		||||
    /**
 | 
			
		||||
     * The piece is finished.
 | 
			
		||||
     */
 | 
			
		||||
    HOMEFINISHED;
 | 
			
		||||
    HOMEFINISHED
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -2,11 +2,12 @@
 | 
			
		||||
 | 
			
		||||
import com.jme3.network.serializing.Serializable;
 | 
			
		||||
import pp.mdga.Resources;
 | 
			
		||||
import pp.mdga.game.card.PowerCard;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * This class will be used to handle general PlayerData
 | 
			
		||||
 * This class represents a player in the game.
 | 
			
		||||
 */
 | 
			
		||||
@Serializable
 | 
			
		||||
public class Player {
 | 
			
		||||
@@ -23,7 +24,7 @@ public class Player {
 | 
			
		||||
    /**
 | 
			
		||||
     * The hand cards of the player.
 | 
			
		||||
     */
 | 
			
		||||
    private ArrayList<BonusCard> handCards = new ArrayList<>();
 | 
			
		||||
    private ArrayList<PowerCard> handCards = new ArrayList<>();
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * The color of the player.
 | 
			
		||||
@@ -44,10 +45,29 @@ public class Player {
 | 
			
		||||
     * Node and piece attributes
 | 
			
		||||
     */
 | 
			
		||||
    private int startNodeIndex = -1;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * The home nodes of the player.
 | 
			
		||||
     */
 | 
			
		||||
    private HomeNode[] homeNodes = new HomeNode[Resources.MAX_PIECES];
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * The waiting area of the player.
 | 
			
		||||
     */
 | 
			
		||||
    private Piece[] waitingArea = new Piece[Resources.MAX_PIECES];
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * The pieces of the player.
 | 
			
		||||
     */
 | 
			
		||||
    private Piece[] pieces = new Piece[Resources.MAX_PIECES];
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Constructor.
 | 
			
		||||
     */
 | 
			
		||||
    public Player() {
 | 
			
		||||
        this("");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This constructor constructs a new Player object
 | 
			
		||||
     *
 | 
			
		||||
@@ -57,13 +77,6 @@ public Player(String name) {
 | 
			
		||||
        this.name = name;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Constructor.
 | 
			
		||||
     */
 | 
			
		||||
    public Player() {
 | 
			
		||||
        this("");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method will be used to initialize all nodes and pieces of the Player class.
 | 
			
		||||
     */
 | 
			
		||||
@@ -73,6 +86,7 @@ public void initialize() {
 | 
			
		||||
            this.pieces[index] = new Piece(this.color, PieceState.WAITING);
 | 
			
		||||
            this.waitingArea[index] = this.pieces[index];
 | 
			
		||||
        }
 | 
			
		||||
        startNodeIndex = color.ordinal() * 10;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -80,22 +94,17 @@ public void initialize() {
 | 
			
		||||
     *
 | 
			
		||||
     * @param card the card to be added to the players hand
 | 
			
		||||
     */
 | 
			
		||||
    public void addHandCard(BonusCard card) {
 | 
			
		||||
        handCards.add(card);
 | 
			
		||||
    public void addHandCard(PowerCard card) {
 | 
			
		||||
        this.handCards.add(card);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method returns a BonusCard to be removed from the players hand.
 | 
			
		||||
     * This method will be used to remove the given card parameter from the handCards attribute of Player card.
 | 
			
		||||
     *
 | 
			
		||||
     * @param card the cards type to be removed
 | 
			
		||||
     * @return the removed card or null if there is none of that card type
 | 
			
		||||
     * @param card as the card which should be removed from the handCards attribute as a PowerCard object.
 | 
			
		||||
     */
 | 
			
		||||
    public BonusCard removeHandCard(BonusCard card) {
 | 
			
		||||
        BonusCard cardToRemove = handCards.stream().filter(c -> c.equals(card)).findFirst().orElse(null);
 | 
			
		||||
        if (cardToRemove != null) {
 | 
			
		||||
            handCards.remove(cardToRemove);
 | 
			
		||||
        }
 | 
			
		||||
        return cardToRemove;
 | 
			
		||||
    public void removeHandCard(PowerCard card) {
 | 
			
		||||
        this.handCards.remove(card);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -120,7 +129,27 @@ public void addWaitingPiece(Piece piece) {
 | 
			
		||||
     * @return true or false.
 | 
			
		||||
     */
 | 
			
		||||
    public boolean isFinished() {
 | 
			
		||||
        return false;
 | 
			
		||||
        for (int i = 0; i < Resources.MAX_PIECES; i++) {
 | 
			
		||||
            if (this.pieces[i].getState() != PieceState.HOMEFINISHED) {
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method returns a PowerCard based on its Type.
 | 
			
		||||
     *
 | 
			
		||||
     * @param bonusCard the card Type to be matched
 | 
			
		||||
     * @return the first PowerCard of this type
 | 
			
		||||
     */
 | 
			
		||||
    public PowerCard getPowerCardByType(BonusCard bonusCard) {
 | 
			
		||||
        for (PowerCard card : this.handCards) {
 | 
			
		||||
            if(card.getCard().equals(bonusCard)) {
 | 
			
		||||
                return card;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -142,12 +171,12 @@ public Statistic getPlayerStatistic() {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method returns the current handCards of the player
 | 
			
		||||
     * This method will be used to return handCards attribute of Player class.
 | 
			
		||||
     *
 | 
			
		||||
     * @return the handCards of the player
 | 
			
		||||
     * @return handCards as a List of PowerCard objects.
 | 
			
		||||
     */
 | 
			
		||||
    public ArrayList<BonusCard> getHandCards() {
 | 
			
		||||
        return handCards;
 | 
			
		||||
    public ArrayList<PowerCard> getHandCards() {
 | 
			
		||||
        return this.handCards;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -248,4 +277,24 @@ public void setReady(boolean ready) {
 | 
			
		||||
    public void setActive(boolean active) {
 | 
			
		||||
        this.active = active;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method sets a piece at the given index in the home area
 | 
			
		||||
     *
 | 
			
		||||
     * @param index the index of the node
 | 
			
		||||
     * @param piece the piece to be set at the given index
 | 
			
		||||
     */
 | 
			
		||||
    public void setPieceInHome(int index, Piece piece) {
 | 
			
		||||
        this.homeNodes[index].setOccupant(piece);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * The string representation of the player
 | 
			
		||||
     *
 | 
			
		||||
     * @return the string representation of the player
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toString() {
 | 
			
		||||
        return "Player: " + name + " Color: " + color;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user