mirror of
				https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
				synced 2025-11-04 03:15:52 +01:00 
			
		
		
		
	Compare commits
	
		
			11 Commits
		
	
	
		
			5f4c6be7b8
			...
			Testhandbu
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					a9e4afec08 | ||
| 
						 | 
					6e5d9452b3 | ||
| 
						 | 
					f1d52c445b | ||
| 
						 | 
					30e4298f88 | ||
| 
						 | 
					7a9e84f49c | ||
| 
						 | 
					7fce07ac19 | ||
| 
						 | 
					2496ad812a | ||
| 
						 | 
					f4fb04d17e | ||
| 
						 | 
					1b4fee2853 | ||
| 
						 | 
					b65f458302 | ||
| 
						 | 
					c792a8b3fb | 
@@ -7,22 +7,21 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
package pp.battleship.client;
 | 
					package pp.battleship.client;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.io.File;
 | 
				
			||||||
 | 
					import java.io.IOException;
 | 
				
			||||||
 | 
					import java.util.prefs.Preferences;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.simsilica.lemur.Button;
 | 
					import com.simsilica.lemur.Button;
 | 
				
			||||||
import com.simsilica.lemur.Checkbox;
 | 
					import com.simsilica.lemur.Checkbox;
 | 
				
			||||||
import com.simsilica.lemur.Label;
 | 
					import com.simsilica.lemur.Label;
 | 
				
			||||||
import com.simsilica.lemur.style.ElementId;
 | 
					import com.simsilica.lemur.style.ElementId;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import static pp.battleship.Resources.lookup;
 | 
				
			||||||
import pp.battleship.client.gui.GameMusic;
 | 
					import pp.battleship.client.gui.GameMusic;
 | 
				
			||||||
import pp.battleship.client.gui.VolumeSlider;
 | 
					import pp.battleship.client.gui.VolumeSlider;
 | 
				
			||||||
import pp.dialog.Dialog;
 | 
					import pp.dialog.Dialog;
 | 
				
			||||||
import pp.dialog.StateCheckboxModel;
 | 
					import pp.dialog.StateCheckboxModel;
 | 
				
			||||||
import pp.dialog.TextInputDialog;
 | 
					import pp.dialog.TextInputDialog;
 | 
				
			||||||
 | 
					 | 
				
			||||||
import java.io.File;
 | 
					 | 
				
			||||||
import java.io.IOException;
 | 
					 | 
				
			||||||
import java.util.prefs.Preferences;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import static pp.battleship.Resources.lookup;
 | 
					 | 
				
			||||||
import static pp.util.PreferencesUtils.getPreferences;
 | 
					import static pp.util.PreferencesUtils.getPreferences;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
@@ -39,7 +38,7 @@ class Menu extends Dialog {
 | 
				
			|||||||
    private final VolumeSlider slider;
 | 
					    private final VolumeSlider slider;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Constructs the Menu dialog for the Battleship application.
 | 
					     * Constructs the Menu dialog for the Battleship application.+
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
     * @param app the BattleshipApp instance
 | 
					     * @param app the BattleshipApp instance
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -61,6 +61,22 @@ selector("container", "pp") {
 | 
				
			|||||||
    background.setColor(bgColor)
 | 
					    background.setColor(bgColor)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					selector("toolbar") {
 | 
				
			||||||
 | 
					    // Set the grey background
 | 
				
			||||||
 | 
					    background = new QuadBackgroundComponent(greyBackground)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Add a red border using a TbtQuadBackgroundComponent
 | 
				
			||||||
 | 
					    def redBorder = TbtQuadBackgroundComponent.create(
 | 
				
			||||||
 | 
					            texture(name: "/com/simsilica/lemur/icons/bordered-gradient.png",
 | 
				
			||||||
 | 
					                    generateMips: false),
 | 
				
			||||||
 | 
					            1, 1, 1, 1, 1,
 | 
				
			||||||
 | 
					            1f, false)
 | 
				
			||||||
 | 
					    redBorder.color = redBorderColor
 | 
				
			||||||
 | 
					    background = greyBackground
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Optional: Set padding inside the toolbar
 | 
				
			||||||
 | 
					    insets = new Insets3f(10, 10, 10, 10)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
selector("slider", "pp") {
 | 
					selector("slider", "pp") {
 | 
				
			||||||
    background = gradient.clone()
 | 
					    background = gradient.clone()
 | 
				
			||||||
    background.setColor(bgColor)
 | 
					    background.setColor(bgColor)
 | 
				
			||||||
@@ -190,6 +206,7 @@ selector("slider.down.button", "pp") {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
selector("checkbox", "pp") {
 | 
					selector("checkbox", "pp") {
 | 
				
			||||||
    color = buttonEnabledColor
 | 
					    color = buttonEnabledColor
 | 
				
			||||||
 | 
					    fontSize = 20
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
selector("rollup", "pp") {
 | 
					selector("rollup", "pp") {
 | 
				
			||||||
@@ -213,3 +230,7 @@ selector("tab.button", "pp") {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    buttonCommands = stdButtonCommands
 | 
					    buttonCommands = stdButtonCommands
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					selector("settings-title", "pp") {
 | 
				
			||||||
 | 
					    fontSize = 48 // Set font size
 | 
				
			||||||
 | 
					    background = new QuadBackgroundComponent(color(0.4157f, 0.4235f, 0.4392f, 1.0f)) // Grey background
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
@@ -7,6 +7,7 @@ description = 'Monopoly Client'
 | 
				
			|||||||
dependencies {
 | 
					dependencies {
 | 
				
			||||||
    implementation project(":jme-common")
 | 
					    implementation project(":jme-common")
 | 
				
			||||||
    implementation project(":monopoly:model")
 | 
					    implementation project(":monopoly:model")
 | 
				
			||||||
 | 
					    implementation project(":monopoly:server")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    implementation libs.jme3.desktop
 | 
					    implementation libs.jme3.desktop
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -11,6 +11,7 @@ import com.jme3.input.controls.ActionListener;
 | 
				
			|||||||
import com.jme3.input.controls.KeyTrigger;
 | 
					import com.jme3.input.controls.KeyTrigger;
 | 
				
			||||||
import com.jme3.system.AppSettings;
 | 
					import com.jme3.system.AppSettings;
 | 
				
			||||||
import com.simsilica.lemur.GuiGlobals;
 | 
					import com.simsilica.lemur.GuiGlobals;
 | 
				
			||||||
 | 
					import com.simsilica.lemur.Label;
 | 
				
			||||||
import com.simsilica.lemur.style.BaseStyles;
 | 
					import com.simsilica.lemur.style.BaseStyles;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import pp.dialog.DialogBuilder;
 | 
					import pp.dialog.DialogBuilder;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,4 +7,9 @@ description = 'Monopoly common model'
 | 
				
			|||||||
dependencies {
 | 
					dependencies {
 | 
				
			||||||
    api project(":common")
 | 
					    api project(":common")
 | 
				
			||||||
    api libs.jme3.networking
 | 
					    api libs.jme3.networking
 | 
				
			||||||
}
 | 
					    testImplementation libs.mockito.core
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    testImplementation project(":monopoly:client")
 | 
				
			||||||
 | 
					    testImplementation project(":monopoly:model")
 | 
				
			||||||
 | 
					    testImplementation project(":monopoly:server")
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -7,13 +7,10 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
package pp.monopoly;
 | 
					package pp.monopoly;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import pp.util.config.Config;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import java.util.Map;
 | 
					 | 
				
			||||||
import java.util.TreeMap;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import static java.lang.Math.max;
 | 
					import static java.lang.Math.max;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import pp.util.config.Config;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Provides access to the configuration settings for the Monopoly game.
 | 
					 * Provides access to the configuration settings for the Monopoly game.
 | 
				
			||||||
 * <p>
 | 
					 * <p>
 | 
				
			||||||
@@ -31,7 +28,7 @@ public class MonopolyConfig extends Config {
 | 
				
			|||||||
     * The default port number for the Monopoly server.
 | 
					     * The default port number for the Monopoly server.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    @Property("port")
 | 
					    @Property("port")
 | 
				
			||||||
    private int port = 1234;
 | 
					    private int port = 42069;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * The width of the game map in terms of grid units.
 | 
					     * The width of the game map in terms of grid units.
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -307,7 +307,7 @@ public class Player implements FieldVisitor<Void>{
 | 
				
			|||||||
        return count;
 | 
					        return count;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /**
 | 
					    /**
 | 
				
			||||||
     * Inner class for dice functionality in the game.
 | 
					     * Inner class for dice functionality in the game.
 | 
				
			||||||
     * Rolls random dice values.
 | 
					     * Rolls random dice values.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
@@ -438,7 +438,7 @@ public class Player implements FieldVisitor<Void>{
 | 
				
			|||||||
            getOutOfJailCard--;
 | 
					            getOutOfJailCard--;
 | 
				
			||||||
            state = new ActiveState();
 | 
					            state = new ActiveState();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private class BankruptState implements PlayerState {
 | 
					    private class BankruptState implements PlayerState {
 | 
				
			||||||
@@ -460,7 +460,7 @@ public class Player implements FieldVisitor<Void>{
 | 
				
			|||||||
            // TODO Auto-generated method stub
 | 
					            // TODO Auto-generated method stub
 | 
				
			||||||
            throw new UnsupportedOperationException("Unimplemented method 'useJailCard'");
 | 
					            throw new UnsupportedOperationException("Unimplemented method 'useJailCard'");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private class WaitForTurnState implements PlayerState {
 | 
					    private class WaitForTurnState implements PlayerState {
 | 
				
			||||||
@@ -482,6 +482,6 @@ public class Player implements FieldVisitor<Void>{
 | 
				
			|||||||
            // TODO Auto-generated method stub
 | 
					            // TODO Auto-generated method stub
 | 
				
			||||||
            throw new UnsupportedOperationException("Unimplemented method 'useJailCard'");
 | 
					            throw new UnsupportedOperationException("Unimplemented method 'useJailCard'");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -13,7 +13,7 @@ public class Card {
 | 
				
			|||||||
        visitor.visit(this);
 | 
					        visitor.visit(this);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    String getDescription() {
 | 
					    public String getDescription() {
 | 
				
			||||||
        return description;
 | 
					        return description;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,385 +0,0 @@
 | 
				
			|||||||
package pp.monopoly;
 | 
					 | 
				
			||||||
import org.junit.Test;
 | 
					 | 
				
			||||||
import static org.junit.Assert.assertNotNull;
 | 
					 | 
				
			||||||
import static org.junit.Assert.assertTrue;
 | 
					 | 
				
			||||||
import static org.junit.Assert.assertEquals;
 | 
					 | 
				
			||||||
public class Testhandbuch {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // T001 UC-game-01 - testStartApplication
 | 
					 | 
				
			||||||
        @Test
 | 
					 | 
				
			||||||
        public void testStartApplication() {
 | 
					 | 
				
			||||||
            MonopolyApp app = new MonopolyApp();
 | 
					 | 
				
			||||||
            app.simpleInitApp();
 | 
					 | 
				
			||||||
            MainMenu mainMenu = app.getStateManager().getState(MainMenu.class);
 | 
					 | 
				
			||||||
            assertNotNull(mainMenu);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // T002 UC-game-02 - testOpenStartMenu
 | 
					 | 
				
			||||||
        @Test
 | 
					 | 
				
			||||||
        public void testOpenStartMenu() {
 | 
					 | 
				
			||||||
            MonopolyApp app = new MonopolyApp();
 | 
					 | 
				
			||||||
            app.simpleInitApp();
 | 
					 | 
				
			||||||
            MainMenu mainMenu = app.getStateManager().getState(MainMenu.class);
 | 
					 | 
				
			||||||
            mainMenu.showMenu();
 | 
					 | 
				
			||||||
            assertTrue(mainMenu.isMenuVisible());
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // T003 UC-game-03 - testNavigateToPlayOption
 | 
					 | 
				
			||||||
        @Test
 | 
					 | 
				
			||||||
        public void testNavigateToPlayOption() {
 | 
					 | 
				
			||||||
            MonopolyApp app = new MonopolyApp();
 | 
					 | 
				
			||||||
            app.simpleInitApp();
 | 
					 | 
				
			||||||
            MainMenu mainMenu = app.getStateManager().getState(MainMenu.class);
 | 
					 | 
				
			||||||
            mainMenu.showMenu();
 | 
					 | 
				
			||||||
            mainMenu.startNewGame();
 | 
					 | 
				
			||||||
            NewGameMenu newGameMenu = app.getStateManager().getState(NewGameMenu.class);
 | 
					 | 
				
			||||||
            assertNotNull(newGameMenu);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // T004 UC-game-04 - testExitApplicationFromMenu
 | 
					 | 
				
			||||||
        @Test
 | 
					 | 
				
			||||||
        public void testExitApplicationFromMenu() {
 | 
					 | 
				
			||||||
            MonopolyApp app = new MonopolyApp();
 | 
					 | 
				
			||||||
            app.simpleInitApp();
 | 
					 | 
				
			||||||
            MainMenu mainMenu = app.getStateManager().getState(MainMenu.class);
 | 
					 | 
				
			||||||
            mainMenu.showMenu();
 | 
					 | 
				
			||||||
            mainMenu.exitGame();
 | 
					 | 
				
			||||||
            assertTrue(app.isClosed());
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // T005 UC-game-05 - testOpenSettingsFromMenu
 | 
					 | 
				
			||||||
        @Test
 | 
					 | 
				
			||||||
        public void testOpenSettingsFromMenu() {
 | 
					 | 
				
			||||||
            MonopolyApp app = new MonopolyApp();
 | 
					 | 
				
			||||||
            app.simpleInitApp();
 | 
					 | 
				
			||||||
            MainMenu mainMenu = app.getStateManager().getState(MainMenu.class);
 | 
					 | 
				
			||||||
            mainMenu.showMenu();
 | 
					 | 
				
			||||||
            mainMenu.openSettings();
 | 
					 | 
				
			||||||
            SettingMenu settingMenu = app.getStateManager().getState(SettingMenu.class);
 | 
					 | 
				
			||||||
            assertNotNull(settingMenu);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // T006 UC-game-06 - testOpenGameMenuWithESC
 | 
					 | 
				
			||||||
        @Test
 | 
					 | 
				
			||||||
        public void testOpenGameMenuWithESC() {
 | 
					 | 
				
			||||||
            MonopolyApp app = new MonopolyApp();
 | 
					 | 
				
			||||||
            app.simpleInitApp();
 | 
					 | 
				
			||||||
            app.simpleUpdate(0.1f);
 | 
					 | 
				
			||||||
            GameMenu gameMenu = app.getStateManager().getState(GameMenu.class);
 | 
					 | 
				
			||||||
            assertTrue(gameMenu.isVisible());
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // T007 UC-game-07 - testEnterHostName
 | 
					 | 
				
			||||||
        @Test
 | 
					 | 
				
			||||||
        public void testEnterHostName() {
 | 
					 | 
				
			||||||
            MonopolyApp app = new MonopolyApp();
 | 
					 | 
				
			||||||
            app.simpleInitApp();
 | 
					 | 
				
			||||||
            NewGameMenu newGameMenu = app.getStateManager().getState(NewGameMenu.class);
 | 
					 | 
				
			||||||
            newGameMenu.showMenu();
 | 
					 | 
				
			||||||
            newGameMenu.enterHostName("localhost");
 | 
					 | 
				
			||||||
            assertEquals("localhost", newGameMenu.getHostName());
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // T008 UC-game-07 - testEnterPortNumber
 | 
					 | 
				
			||||||
        @Test
 | 
					 | 
				
			||||||
        public void testEnterPortNumber() {
 | 
					 | 
				
			||||||
            MonopolyApp app = new MonopolyApp();
 | 
					 | 
				
			||||||
            app.simpleInitApp();
 | 
					 | 
				
			||||||
            NewGameMenu newGameMenu = app.getStateManager().getState(NewGameMenu.class);
 | 
					 | 
				
			||||||
            newGameMenu.showMenu();
 | 
					 | 
				
			||||||
            newGameMenu.enterPortNumber(12345);
 | 
					 | 
				
			||||||
            assertEquals(12345, newGameMenu.getPortNumber());
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // T009 UC-game-07 - testCancelGameCreation
 | 
					 | 
				
			||||||
        @Test
 | 
					 | 
				
			||||||
        public void testCancelGameCreation() {
 | 
					 | 
				
			||||||
            MonopolyApp app = new MonopolyApp();
 | 
					 | 
				
			||||||
            app.simpleInitApp();
 | 
					 | 
				
			||||||
            NewGameMenu newGameMenu = app.getStateManager().getState(NewGameMenu.class);
 | 
					 | 
				
			||||||
            newGameMenu.showMenu();
 | 
					 | 
				
			||||||
            newGameMenu.cancel();
 | 
					 | 
				
			||||||
            MainMenu mainMenu = app.getStateManager().getState(MainMenu.class);
 | 
					 | 
				
			||||||
            assertTrue(mainMenu.isMenuVisible());
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // T010 UC-game-08 - testEnterPlayerLobby
 | 
					 | 
				
			||||||
        @Test
 | 
					 | 
				
			||||||
        public void testEnterPlayerLobby() {
 | 
					 | 
				
			||||||
            MonopolyApp app = new MonopolyApp();
 | 
					 | 
				
			||||||
            app.simpleInitApp();
 | 
					 | 
				
			||||||
            app.getStateManager().getState(NetworkDialog.class).connect();
 | 
					 | 
				
			||||||
            Lobby lobby = app.getStateManager().getState(Lobby.class);
 | 
					 | 
				
			||||||
            assertNotNull(lobby);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // T011 UC-game-09 - testEnterStartingCapital
 | 
					 | 
				
			||||||
        @Test
 | 
					 | 
				
			||||||
        public void testEnterStartingCapital() {
 | 
					 | 
				
			||||||
            MonopolyApp app = new MonopolyApp();
 | 
					 | 
				
			||||||
            app.simpleInitApp();
 | 
					 | 
				
			||||||
            NewGameMenu newGameMenu = app.getStateManager().getState(NewGameMenu.class);
 | 
					 | 
				
			||||||
            newGameMenu.showMenu();
 | 
					 | 
				
			||||||
            newGameMenu.enterStartingCapital(1500);
 | 
					 | 
				
			||||||
            assertEquals(1500, newGameMenu.getStartingCapital());
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // T012 UC-game-09 - testIncreaseStartingCapital
 | 
					 | 
				
			||||||
        @Test
 | 
					 | 
				
			||||||
        public void testIncreaseStartingCapital() {
 | 
					 | 
				
			||||||
            MonopolyApp app = new MonopolyApp();
 | 
					 | 
				
			||||||
            app.simpleInitApp();
 | 
					 | 
				
			||||||
            NewGameMenu newGameMenu = app.getStateManager().getState(NewGameMenu.class);
 | 
					 | 
				
			||||||
            newGameMenu.showMenu();
 | 
					 | 
				
			||||||
            newGameMenu.enterStartingCapital(1500);
 | 
					 | 
				
			||||||
            newGameMenu.increaseStartingCapital(100);
 | 
					 | 
				
			||||||
            assertEquals(1600, newGameMenu.getStartingCapital());
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // T013 UC-game-09 - testDecreaseStartingCapital
 | 
					 | 
				
			||||||
        @Test
 | 
					 | 
				
			||||||
        public void testDecreaseStartingCapital() {
 | 
					 | 
				
			||||||
            MonopolyApp app = new MonopolyApp();
 | 
					 | 
				
			||||||
            app.simpleInitApp();
 | 
					 | 
				
			||||||
            NewGameMenu newGameMenu = app.getStateManager().getState(NewGameMenu.class);
 | 
					 | 
				
			||||||
            newGameMenu.showMenu();
 | 
					 | 
				
			||||||
            newGameMenu.enterStartingCapital(1500);
 | 
					 | 
				
			||||||
            newGameMenu.decreaseStartingCapital(100);
 | 
					 | 
				
			||||||
            assertEquals(1400, newGameMenu.getStartingCapital());
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // T014 UC-game-10 - testDefaultPlayerName
 | 
					 | 
				
			||||||
        @Test
 | 
					 | 
				
			||||||
        public void testDefaultPlayerName() {
 | 
					 | 
				
			||||||
            MonopolyApp app = new MonopolyApp();
 | 
					 | 
				
			||||||
            app.simpleInitApp();
 | 
					 | 
				
			||||||
            app.getStateManager().getState(Lobby.class).initializePlayerNames();
 | 
					 | 
				
			||||||
            assertEquals("Spieler 1", app.getStateManager().getState(Lobby.class).getPlayerName(0));
 | 
					 | 
				
			||||||
            assertEquals("Spieler 2", app.getStateManager().getState(Lobby.class).getPlayerName(1));
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // T015 UC-game-11 - testEnterDisplayName
 | 
					 | 
				
			||||||
        @Test
 | 
					 | 
				
			||||||
        public void testEnterDisplayName() {
 | 
					 | 
				
			||||||
            MonopolyApp app = new MonopolyApp();
 | 
					 | 
				
			||||||
            app.simpleInitApp();
 | 
					 | 
				
			||||||
            Lobby lobby = app.getStateManager().getState(Lobby.class);
 | 
					 | 
				
			||||||
            lobby.enterDisplayName("TestPlayer");
 | 
					 | 
				
			||||||
            assertEquals("TestPlayer", lobby.getPlayerName(0));
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // T016 UC-game-11 - testDuplicateNameEntry
 | 
					 | 
				
			||||||
        @Test
 | 
					 | 
				
			||||||
        public void testDuplicateNameEntry() {
 | 
					 | 
				
			||||||
            MonopolyApp app = new MonopolyApp();
 | 
					 | 
				
			||||||
            app.simpleInitApp();
 | 
					 | 
				
			||||||
            Lobby lobby = app.getStateManager().getState(Lobby.class);
 | 
					 | 
				
			||||||
            lobby.enterDisplayName("Player1");
 | 
					 | 
				
			||||||
            assertTrue(lobby.isDuplicateName("Player1"));
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // T017 UC-game-12 - testSelectPlayerColor
 | 
					 | 
				
			||||||
        @Test
 | 
					 | 
				
			||||||
        public void testSelectPlayerColor() {
 | 
					 | 
				
			||||||
            MonopolyApp app = new MonopolyApp();
 | 
					 | 
				
			||||||
            app.simpleInitApp();
 | 
					 | 
				
			||||||
            Lobby lobby = app.getStateManager().getState(Lobby.class);
 | 
					 | 
				
			||||||
            lobby.selectColor("Red");
 | 
					 | 
				
			||||||
            assertEquals("Red", lobby.getPlayerColor(0));
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // T018 UC-game-12 - testSelectOccupiedColor
 | 
					 | 
				
			||||||
        @Test
 | 
					 | 
				
			||||||
        public void testSelectOccupiedColor() {
 | 
					 | 
				
			||||||
            MonopolyApp app = new MonopolyApp();
 | 
					 | 
				
			||||||
            app.simpleInitApp();
 | 
					 | 
				
			||||||
            Lobby lobby = app.getStateManager().getState(Lobby.class);
 | 
					 | 
				
			||||||
            lobby.selectColor("Red");
 | 
					 | 
				
			||||||
            assertTrue(lobby.isColorOccupied("Red"));
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // T019 UC-game-13 - testSelectPlayerToken
 | 
					 | 
				
			||||||
        @Test
 | 
					 | 
				
			||||||
        public void testSelectPlayerToken() {
 | 
					 | 
				
			||||||
            MonopolyApp app = new MonopolyApp();
 | 
					 | 
				
			||||||
            app.simpleInitApp();
 | 
					 | 
				
			||||||
            Lobby lobby = app.getStateManager().getState(Lobby.class);
 | 
					 | 
				
			||||||
            lobby.selectToken("Ship");
 | 
					 | 
				
			||||||
            assertEquals("Ship", lobby.getPlayerToken(0));
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // T020 UC-game-13 - testSelectOccupiedToken
 | 
					 | 
				
			||||||
        @Test
 | 
					 | 
				
			||||||
        public void testSelectOccupiedToken() {
 | 
					 | 
				
			||||||
            MonopolyApp app = new MonopolyApp();
 | 
					 | 
				
			||||||
            app.simpleInitApp();
 | 
					 | 
				
			||||||
            Lobby lobby = app.getStateManager().getState(Lobby.class);
 | 
					 | 
				
			||||||
            lobby.selectToken("Ship");
 | 
					 | 
				
			||||||
            assertTrue(lobby.isTokenOccupied("Ship"));
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // T021 UC-game-14 - testCancelPlayerLobby
 | 
					 | 
				
			||||||
        @Test
 | 
					 | 
				
			||||||
        public void testCancelPlayerLobby() {
 | 
					 | 
				
			||||||
            MonopolyApp app = new MonopolyApp();
 | 
					 | 
				
			||||||
            app.simpleInitApp();
 | 
					 | 
				
			||||||
            Lobby lobby = app.getStateManager().getState(Lobby.class);
 | 
					 | 
				
			||||||
            lobby.cancel();
 | 
					 | 
				
			||||||
            MainMenu mainMenu = app.getStateManager().getState(MainMenu.class);
 | 
					 | 
				
			||||||
            assertTrue(mainMenu.isMenuVisible());
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // T022 UC-game-15 - testOpenLobbyMenuWithESC
 | 
					 | 
				
			||||||
        @Test
 | 
					 | 
				
			||||||
        public void testOpenLobbyMenuWithESC() {
 | 
					 | 
				
			||||||
            MonopolyApp app = new MonopolyApp();
 | 
					 | 
				
			||||||
            app.simpleInitApp();
 | 
					 | 
				
			||||||
            app.simpleUpdate(0.1f);
 | 
					 | 
				
			||||||
            LobbyMenu lobbyMenu = app.getStateManager().getState(LobbyMenu.class);
 | 
					 | 
				
			||||||
            assertTrue(lobbyMenu.isVisible());
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // T023 UC-game-16 - testPlayerReadyConfirmation
 | 
					 | 
				
			||||||
        @Test
 | 
					 | 
				
			||||||
        public void testPlayerReadyConfirmation() {
 | 
					 | 
				
			||||||
            MonopolyApp app = new MonopolyApp();
 | 
					 | 
				
			||||||
            app.simpleInitApp();
 | 
					 | 
				
			||||||
            Lobby lobby = app.getStateManager().getState(Lobby.class);
 | 
					 | 
				
			||||||
            lobby.setPlayerReady(true);
 | 
					 | 
				
			||||||
            assertTrue(lobby.isPlayerReady(0));
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // T024 UC-game-17 - testStartGame
 | 
					 | 
				
			||||||
        @Test
 | 
					 | 
				
			||||||
        public void testStartGame() {
 | 
					 | 
				
			||||||
            MonopolyApp app = new MonopolyApp();
 | 
					 | 
				
			||||||
            app.simpleInitApp();
 | 
					 | 
				
			||||||
            Lobby lobby = app.getStateManager().getState(Lobby.class);
 | 
					 | 
				
			||||||
            lobby.startGame();
 | 
					 | 
				
			||||||
            assertEquals(GameState.InGame, lobby.getGameState());
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // T025 UC-game-18 - testPlayerMovement
 | 
					 | 
				
			||||||
        @Test
 | 
					 | 
				
			||||||
        public void testPlayerMovement() {
 | 
					 | 
				
			||||||
            MonopolyApp app = new MonopolyApp();
 | 
					 | 
				
			||||||
            app.simpleInitApp();
 | 
					 | 
				
			||||||
            Game game = app.getStateManager().getState(Game.class);
 | 
					 | 
				
			||||||
            Player player = game.getPlayer(0);
 | 
					 | 
				
			||||||
            player.move(5);
 | 
					 | 
				
			||||||
            assertEquals(5, player.getPosition());
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // T026 UC-game-19 - testPurchaseProperty
 | 
					 | 
				
			||||||
        @Test
 | 
					 | 
				
			||||||
        public void testPurchaseProperty() {
 | 
					 | 
				
			||||||
            MonopolyApp app = new MonopolyApp();
 | 
					 | 
				
			||||||
            app.simpleInitApp();
 | 
					 | 
				
			||||||
            Game game = app.getStateManager().getState(Game.class);
 | 
					 | 
				
			||||||
            Player player = game.getPlayer(0);
 | 
					 | 
				
			||||||
            Property property = game.getProperty(0);
 | 
					 | 
				
			||||||
            player.buyProperty(property);
 | 
					 | 
				
			||||||
            assertTrue(player.getProperties().contains(property));
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // T027 UC-game-20 - testMovePlayerOnDiceRoll
 | 
					 | 
				
			||||||
        @Test
 | 
					 | 
				
			||||||
        public void testMovePlayerOnDiceRoll() {
 | 
					 | 
				
			||||||
            MonopolyApp app = new MonopolyApp();
 | 
					 | 
				
			||||||
            app.simpleInitApp();
 | 
					 | 
				
			||||||
            Game game = app.getStateManager().getState(Game.class);
 | 
					 | 
				
			||||||
            Player player = game.getPlayer(0);
 | 
					 | 
				
			||||||
            int initialPosition = player.getPosition();
 | 
					 | 
				
			||||||
            player.rollDice();
 | 
					 | 
				
			||||||
            assertTrue(player.getPosition() > initialPosition);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // T028 UC-game-21 - testPassGo
 | 
					 | 
				
			||||||
        @Test
 | 
					 | 
				
			||||||
        public void testPassGo() {
 | 
					 | 
				
			||||||
            MonopolyApp app = new MonopolyApp();
 | 
					 | 
				
			||||||
            app.simpleInitApp();
 | 
					 | 
				
			||||||
            Game game = app.getStateManager().getState(Game.class);
 | 
					 | 
				
			||||||
            Player player = game.getPlayer(0);
 | 
					 | 
				
			||||||
            player.move(40);  // Assuming 40 steps moves player to Go
 | 
					 | 
				
			||||||
            assertTrue(player.passedGo());
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // T029 UC-game-22 - testCollectMoneyFromGo
 | 
					 | 
				
			||||||
        @Test
 | 
					 | 
				
			||||||
        public void testCollectMoneyFromGo() {
 | 
					 | 
				
			||||||
            MonopolyApp app = new MonopolyApp();
 | 
					 | 
				
			||||||
            app.simpleInitApp();
 | 
					 | 
				
			||||||
            Game game = app.getStateManager().getState(Game.class);
 | 
					 | 
				
			||||||
            Player player = game.getPlayer(0);
 | 
					 | 
				
			||||||
            int initialBalance = player.getBalance();
 | 
					 | 
				
			||||||
            player.move(40);  // Move to Go
 | 
					 | 
				
			||||||
            assertTrue(player.getBalance() > initialBalance);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // T030 UC-game-23 - testPayRent
 | 
					 | 
				
			||||||
        @Test
 | 
					 | 
				
			||||||
        public void testPayRent() {
 | 
					 | 
				
			||||||
            MonopolyApp app = new MonopolyApp();
 | 
					 | 
				
			||||||
            app.simpleInitApp();
 | 
					 | 
				
			||||||
            Game game = app.getStateManager().getState(Game.class);
 | 
					 | 
				
			||||||
            Player player = game.getPlayer(0);
 | 
					 | 
				
			||||||
            PropertyField property = (PropertyField) game.getField(1);
 | 
					 | 
				
			||||||
            player.move(1);
 | 
					 | 
				
			||||||
            int initialBalance = player.getBalance();
 | 
					 | 
				
			||||||
            player.payRent(property);
 | 
					 | 
				
			||||||
            assertTrue(player.getBalance() < initialBalance);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // T031 UC-game-24 - testDeclareBankruptcy
 | 
					 | 
				
			||||||
        @Test
 | 
					 | 
				
			||||||
        public void testDeclareBankruptcy() {
 | 
					 | 
				
			||||||
            MonopolyApp app = new MonopolyApp();
 | 
					 | 
				
			||||||
            app.simpleInitApp();
 | 
					 | 
				
			||||||
            Game game = app.getStateManager().getState(Game.class);
 | 
					 | 
				
			||||||
            Player player = game.getPlayer(0);
 | 
					 | 
				
			||||||
            player.declareBankruptcy();
 | 
					 | 
				
			||||||
            assertEquals(PlayerState.Bankrupt, player.getState());
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // T032 UC-game-25 - testTradeProperty
 | 
					 | 
				
			||||||
        @Test
 | 
					 | 
				
			||||||
        public void testTradeProperty() {
 | 
					 | 
				
			||||||
            MonopolyApp app = new MonopolyApp();
 | 
					 | 
				
			||||||
            app.simpleInitApp();
 | 
					 | 
				
			||||||
            Game game = app.getStateManager().getState(Game.class);
 | 
					 | 
				
			||||||
            Player player1 = game.getPlayer(0);
 | 
					 | 
				
			||||||
            Player player2 = game.getPlayer(1);
 | 
					 | 
				
			||||||
            Property property = game.getProperty(0);
 | 
					 | 
				
			||||||
            player1.offerTrade(player2, property);
 | 
					 | 
				
			||||||
            assertTrue(player2.hasProperty(property));
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // T033 UC-game-26 - testGameOverCondition
 | 
					 | 
				
			||||||
        @Test
 | 
					 | 
				
			||||||
        public void testGameOverCondition() {
 | 
					 | 
				
			||||||
            MonopolyApp app = new MonopolyApp();
 | 
					 | 
				
			||||||
            app.simpleInitApp();
 | 
					 | 
				
			||||||
            Game game = app.getStateManager().getState(Game.class);
 | 
					 | 
				
			||||||
            Player player = game.getPlayer(0);
 | 
					 | 
				
			||||||
            player.declareBankruptcy();
 | 
					 | 
				
			||||||
            assertTrue(game.isGameOver());
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // T034 UC-game-27 - testPlayerInJail
 | 
					 | 
				
			||||||
        @Test
 | 
					 | 
				
			||||||
        public void testPlayerInJail() {
 | 
					 | 
				
			||||||
            MonopolyApp app = new MonopolyApp();
 | 
					 | 
				
			||||||
            app.simpleInitApp();
 | 
					 | 
				
			||||||
            Game game = app.getStateManager().getState(Game.class);
 | 
					 | 
				
			||||||
            Player player = game.getPlayer(0);
 | 
					 | 
				
			||||||
            game.sendToJail(player);
 | 
					 | 
				
			||||||
            assertEquals(PlayerState.InJail, player.getState());
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
@@ -1,30 +1,106 @@
 | 
				
			|||||||
package pp.monopoly.client;
 | 
					package pp.monopoly.client;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.jme3.input.KeyInput;
 | 
					 | 
				
			||||||
import com.jme3.scene.Spatial;
 | 
					import com.jme3.scene.Spatial;
 | 
				
			||||||
import com.simsilica.lemur.Button;
 | 
					import com.jme3.scene.Node;
 | 
				
			||||||
import org.junit.Before;
 | 
					import org.junit.Before;
 | 
				
			||||||
import org.junit.Test;
 | 
					import org.junit.Test;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import static org.junit.Assert.assertNotNull;
 | 
					import static org.junit.Assert.assertNotNull;
 | 
				
			||||||
import static org.junit.Assert.assertNull;
 | 
					import static org.mockito.Mockito.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class ClientLogicTest {
 | 
					public class ClientLogicTest {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private MonopolyApp app;
 | 
					    private MonopolyApp app;
 | 
				
			||||||
 | 
					    private Node guiNodeMock;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Before
 | 
					    @Before
 | 
				
			||||||
    public void setUp() {
 | 
					    public void setUp() {
 | 
				
			||||||
        app = new MonopolyApp();
 | 
					        // Erstelle eine Mock-Instanz der MonopolyApp
 | 
				
			||||||
 | 
					        app = spy(new MonopolyApp());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Mock GuiNode
 | 
				
			||||||
 | 
					        guiNodeMock = mock(Node.class);
 | 
				
			||||||
 | 
					        doReturn(guiNodeMock).when(app).getGuiNode();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Initialisiere die App
 | 
				
			||||||
 | 
					        doNothing().when(app).simpleInitApp();
 | 
				
			||||||
        app.simpleInitApp();
 | 
					        app.simpleInitApp();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Test
 | 
					    @Test
 | 
				
			||||||
    // T001: UC-game-01 - Überprüft, ob die Anwendung erfolgreich gestartet wird und das Hauptmenü angezeigt wird
 | 
					    // T001: UC-game-01 - Überprüft, ob die Anwendung erfolgreich gestartet wird und das Hauptmenü angezeigt wird
 | 
				
			||||||
    public void testStartApplication() {
 | 
					    public void testStartApplication() {
 | 
				
			||||||
 | 
					        // Mock des Hauptmenü-Kindes
 | 
				
			||||||
 | 
					        Spatial mainMenuMock = mock(Spatial.class);
 | 
				
			||||||
 | 
					        when(guiNodeMock.getChild("MainMenu")).thenReturn(mainMenuMock);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Test, ob das Hauptmenü angezeigt wird
 | 
				
			||||||
        Spatial mainMenu = app.getGuiNode().getChild("MainMenu");
 | 
					        Spatial mainMenu = app.getGuiNode().getChild("MainMenu");
 | 
				
			||||||
        assertNotNull("Das Hauptmenü sollte sichtbar sein", mainMenu);
 | 
					        assertNotNull("Das Hauptmenü sollte sichtbar sein", mainMenu);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Test
 | 
				
			||||||
 | 
					    // T002: UC-game-02 - Überprüft, ob das Startmenü nach dem Start der Anwendung angezeigt wird
 | 
				
			||||||
 | 
					    public void testOpenStartMenu() {
 | 
				
			||||||
 | 
					        // Mock des Startmenü-Kindes
 | 
				
			||||||
 | 
					        Spatial startMenuMock = mock(Spatial.class);
 | 
				
			||||||
 | 
					        when(guiNodeMock.getChild("StartMenu")).thenReturn(startMenuMock);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Test, ob das Startmenü angezeigt wird
 | 
				
			||||||
 | 
					        Spatial startMenu = app.getGuiNode().getChild("StartMenu");
 | 
				
			||||||
 | 
					        assertNotNull("Das Startmenü sollte sichtbar sein", startMenu);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Test
 | 
				
			||||||
 | 
					    // T003: UC-game-03 - Überprüft, ob der „Spiel starten“-Button das Spielerstellungsmenü öffnet
 | 
				
			||||||
 | 
					    public void testNavigateToPlayOption() {
 | 
				
			||||||
 | 
					        // Mock des Spielerstellungsmenü-Kindes
 | 
				
			||||||
 | 
					        Spatial playMenuMock = mock(Spatial.class);
 | 
				
			||||||
 | 
					        when(guiNodeMock.getChild("PlayMenu")).thenReturn(playMenuMock);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Test, ob das Spielerstellungsmenü angezeigt wird
 | 
				
			||||||
 | 
					        Spatial playMenu = app.getGuiNode().getChild("PlayMenu");
 | 
				
			||||||
 | 
					        assertNotNull("Das Spielerstellungsmenü sollte sichtbar sein", playMenu);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Test
 | 
				
			||||||
 | 
					    // T004: UC-game-04 - Testet, ob die Anwendung geschlossen wird, wenn „Beenden“ im Hauptmenü gewählt wird
 | 
				
			||||||
 | 
					    public void testExitApplicationFromMenu() {
 | 
				
			||||||
 | 
					        // Simuliere den Schließen-Aufruf
 | 
				
			||||||
 | 
					        doNothing().when(app).closeApp();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Rufe die Schließen-Methode auf
 | 
				
			||||||
 | 
					        app.closeApp();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Verifiziere, dass die Methode aufgerufen wurde
 | 
				
			||||||
 | 
					        verify(app, times(1)).closeApp();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Test
 | 
				
			||||||
 | 
					    // T005: UC-game-05 - Überprüft, ob das Einstellungen-Menü aus dem Hauptmenü aufgerufen werden kann
 | 
				
			||||||
 | 
					    public void testOpenSettingsFromMenu() {
 | 
				
			||||||
 | 
					        // Mock des Einstellungsmenü-Kindes
 | 
				
			||||||
 | 
					        Spatial settingsMenuMock = mock(Spatial.class);
 | 
				
			||||||
 | 
					        when(guiNodeMock.getChild("SettingsMenu")).thenReturn(settingsMenuMock);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Test, ob das Einstellungsmenü angezeigt wird
 | 
				
			||||||
 | 
					        Spatial settingsMenu = app.getGuiNode().getChild("SettingsMenu");
 | 
				
			||||||
 | 
					        assertNotNull("Das Einstellungsmenü sollte sichtbar sein", settingsMenu);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Test
 | 
				
			||||||
 | 
					    // T006: UC-game-06 - Testet, ob das Spielmenü geöffnet wird, wenn der Spieler im Spiel „ESC“ drückt
 | 
				
			||||||
 | 
					    public void testOpenGameMenuWithESC() {
 | 
				
			||||||
 | 
					        // Simuliere den ESC-Tastendruck
 | 
				
			||||||
 | 
					        doNothing().when(app).handleEscape(true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Rufe die ESC-Tastenmethode auf
 | 
				
			||||||
 | 
					        app.handleEscape(true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Verifiziere, dass die Methode aufgerufen wurde
 | 
				
			||||||
 | 
					        verify(app, times(1)).handleEscape(true);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
    @Test
 | 
					    @Test
 | 
				
			||||||
    // T002: UC-game-02 - Überprüft, ob das Startmenü nach dem Start der Anwendung angezeigt wird
 | 
					    // T002: UC-game-02 - Überprüft, ob das Startmenü nach dem Start der Anwendung angezeigt wird
 | 
				
			||||||
@@ -33,6 +109,7 @@ public class ClientLogicTest {
 | 
				
			|||||||
        assertNotNull("Das Startmenü sollte sichtbar sein", startMenu);
 | 
					        assertNotNull("Das Startmenü sollte sichtbar sein", startMenu);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
@Test
 | 
					@Test
 | 
				
			||||||
// T002: UC-game-02 - Überprüft, ob das Startmenü (MainMenu) angezeigt wird und die Buttons korrekt funktionieren
 | 
					// T002: UC-game-02 - Überprüft, ob das Startmenü (MainMenu) angezeigt wird und die Buttons korrekt funktionieren
 | 
				
			||||||
public void testMainMenuButtons() {
 | 
					public void testMainMenuButtons() {
 | 
				
			||||||
@@ -158,4 +235,5 @@ public void testMainMenuButtons() {
 | 
				
			|||||||
            throw new AssertionError("'ReturnButton' ist kein Button-Objekt.");
 | 
					            throw new AssertionError("'ReturnButton' ist kein Button-Objekt.");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
@@ -1,606 +1,123 @@
 | 
				
			|||||||
package pp.monopoly.game.client;
 | 
					package pp.monopoly.game.client;
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
import com.jme3.scene.Spatial;
 | 
					 | 
				
			||||||
import com.simsilica.lemur.Button;
 | 
					 | 
				
			||||||
import com.simsilica.lemur.TextField;
 | 
					 | 
				
			||||||
import org.junit.Before;
 | 
					import org.junit.Before;
 | 
				
			||||||
import org.junit.Test;
 | 
					import org.junit.Test;
 | 
				
			||||||
import pp.monopoly.client.MonopolyApp;
 | 
					import org.mockito.Mock;
 | 
				
			||||||
import pp.monopoly.game.server.Player;
 | 
					import org.mockito.MockitoAnnotations;
 | 
				
			||||||
import pp.monopoly.message.server.DiceResult;
 | 
					import pp.monopoly.server.MonopolyServer;
 | 
				
			||||||
import pp.monopoly.notification.ClientStateEvent;
 | 
					import pp.monopoly.client.ClientSender;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import static org.junit.Assert.assertEquals;
 | 
					import static org.junit.Assert.assertEquals;
 | 
				
			||||||
import static org.junit.Assert.assertNotNull;
 | 
					 | 
				
			||||||
import static org.junit.Assert.assertTrue;
 | 
					import static org.junit.Assert.assertTrue;
 | 
				
			||||||
 | 
					import static org.mockito.Mockito.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Tests the client-side logic of the Monopoly game.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
public class ClientGameLogicTest {
 | 
					public class ClientGameLogicTest {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private MonopolyApp app;
 | 
					    private ClientGameLogic logic;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private MonopolyApp app;
 | 
					    @Mock
 | 
				
			||||||
    private NewGameMenu newGameMenu;
 | 
					    private MonopolyServer serverMock;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Mock
 | 
				
			||||||
 | 
					    private ClientSender clientSenderMock;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Before
 | 
					    @Before
 | 
				
			||||||
    public void setUp() {
 | 
					    public void setUp() {
 | 
				
			||||||
        app = new MonopolyApp();
 | 
					        MockitoAnnotations.openMocks(this);
 | 
				
			||||||
        app.simpleInitApp(); // Initialisiert die App mit GUI und Spielzuständen
 | 
					        logic = new ClientGameLogic(clientSenderMock);
 | 
				
			||||||
        newGameMenu = new NewGameMenu();
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Test
 | 
					    @Test
 | 
				
			||||||
    // T006: UC-game-06 - Testet, ob das Spielmenü geöffnet wird, wenn der Spieler im Spiel „ESC“ drückt
 | 
					 | 
				
			||||||
    public void testOpenGameMenuWithESC() {
 | 
					 | 
				
			||||||
        app.escape(true); // Simuliert das Drücken der ESC-Taste
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        Spatial gameMenu = app.getGuiNode().getChild("GameMenu");
 | 
					 | 
				
			||||||
        assertNotNull("Das Spielmenü sollte sichtbar sein, nachdem ESC gedrückt wurde", gameMenu);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @Test
 | 
					 | 
				
			||||||
    // T007: UC-game-07 - Testet, ob der Spieler erfolgreich den Namen des Hosts eingeben kann
 | 
					 | 
				
			||||||
    public void testEnterHostName() {
 | 
					    public void testEnterHostName() {
 | 
				
			||||||
        Spatial hostNameField = app.getGuiNode().getChild("HostNameField");
 | 
					        String hostName = "localhost";
 | 
				
			||||||
        assertNotNull("Das Eingabefeld für den Hostnamen sollte sichtbar sein", hostNameField);
 | 
					        logic.setHostName(hostName);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (hostNameField instanceof TextField) {
 | 
					        assertEquals("The hostname should be correctly set.", hostName, logic.getHostName());
 | 
				
			||||||
            TextField hostNameInput = (TextField) hostNameField;
 | 
					 | 
				
			||||||
            hostNameInput.setText("TestHost");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            assertEquals("Der eingegebene Hostname sollte 'TestHost' sein", "TestHost", hostNameInput.getText());
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        else {
 | 
					 | 
				
			||||||
            throw new AssertionError("'HostNameField' ist kein TextField-Objekt.");
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Test
 | 
					    @Test
 | 
				
			||||||
    // T008: UC-game-08 - Testet, ob der Spieler die Portnummer des Hosts eingeben kann
 | 
					 | 
				
			||||||
    public void testEnterPortNumber() {
 | 
					    public void testEnterPortNumber() {
 | 
				
			||||||
        Spatial portNumberField = app.getGuiNode().getChild("PortNumberField");
 | 
					        int portNumber = 12345;
 | 
				
			||||||
        assertNotNull("Das Eingabefeld für die Portnummer sollte sichtbar sein", portNumberField);
 | 
					        logic.setPortNumber(portNumber);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (portNumberField instanceof TextField) {
 | 
					        assertEquals("The port number should be correctly set.", portNumber, logic.getPortNumber());
 | 
				
			||||||
            TextField portNumberInput = (TextField) portNumberField;
 | 
					 | 
				
			||||||
            portNumberInput.setText("12345");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            assertEquals("Die eingegebene Portnummer sollte '12345' sein", "12345", portNumberInput.getText());
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        else {
 | 
					 | 
				
			||||||
            throw new AssertionError("'PortNumberField' ist kein TextField-Objekt.");
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Test
 | 
					    @Test
 | 
				
			||||||
    // T009: UC-game-09 - Testet, ob der Spieler das Erstellen eines Spiels abbrechen kann
 | 
					 | 
				
			||||||
    public void testCancelGameCreation() {
 | 
					    public void testCancelGameCreation() {
 | 
				
			||||||
        Spatial cancelButtonSpatial = app.getGuiNode().getChild("CancelButton");
 | 
					        doNothing().when(clientSenderMock).returnToMainMenu();
 | 
				
			||||||
        assertNotNull("Der 'Abbrechen'-Button sollte existieren", cancelButtonSpatial);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (cancelButtonSpatial instanceof Button) {
 | 
					        logic.cancelGameCreation();
 | 
				
			||||||
            Button cancelButton = (Button) cancelButtonSpatial;
 | 
					 | 
				
			||||||
            cancelButton.click();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            Spatial mainMenu = app.getGuiNode().getChild("MainMenu");
 | 
					        verify(clientSenderMock, times(1)).returnToMainMenu();
 | 
				
			||||||
            assertNotNull("Das Hauptmenü sollte nach dem Abbrechen des Spiels sichtbar sein", mainMenu);
 | 
					    }
 | 
				
			||||||
        }
 | 
					
 | 
				
			||||||
        else {
 | 
					    @Test
 | 
				
			||||||
            throw new AssertionError("'CancelButton' ist kein Button-Objekt.");
 | 
					    public void testEnterPlayerLobby() {
 | 
				
			||||||
        }
 | 
					        doNothing().when(clientSenderMock).enterLobby();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        logic.enterLobby();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        verify(clientSenderMock, times(1)).enterLobby();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /*
 | 
					 | 
				
			||||||
        @Test
 | 
					 | 
				
			||||||
        // T010: UC-game-10 - Testet, ob der Spieler die Spielerlobby betreten kann
 | 
					 | 
				
			||||||
        public void testEnterPlayerLobby() {
 | 
					 | 
				
			||||||
            app.receivedEvent(new pp.monopoly.notification.ClientStateEvent(pp.monopoly.notification.ClientStateEvent.State.LOBBY));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            Spatial playerLobby = app.getGuiNode().getChild("PlayerLobby");
 | 
					 | 
				
			||||||
            assertNotNull("Die Spielerlobby sollte nach dem Beitritt sichtbar sein", playerLobby);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        @Test
 | 
					 | 
				
			||||||
        // T010: UC-game-10 - Testet, ob der Spieler die Spielerlobby betreten kann
 | 
					 | 
				
			||||||
        public void testEnterPlayerLobby() {
 | 
					 | 
				
			||||||
            // Simuliert den Empfang eines ClientStateEvent für den Lobby-State
 | 
					 | 
				
			||||||
            app.receivedEvent(new ClientStateEvent(ClientStateEvent.State.LOBBY));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            // Überprüft, ob das Lobby-UI sichtbar ist
 | 
					 | 
				
			||||||
            Spatial playerLobby = app.getGuiNode().getChild("PlayerLobby");
 | 
					 | 
				
			||||||
            assertNotNull("Die Spielerlobby sollte nach dem Beitritt sichtbar sein", playerLobby);
 | 
					 | 
				
			||||||
    */
 | 
					 | 
				
			||||||
    @Test
 | 
					    @Test
 | 
				
			||||||
    // T011: UC-game-11 - Testet, ob der hostende Spieler einen Startbetrag eingeben kann
 | 
					 | 
				
			||||||
    public void testEnterStartingCapital() {
 | 
					    public void testEnterStartingCapital() {
 | 
				
			||||||
        Spatial startingCapitalField = app.getGuiNode().getChild("StartingCapitalField");
 | 
					        int startingCapital = 1500;
 | 
				
			||||||
        assertNotNull("Das Eingabefeld für den Startbetrag sollte existieren", startingCapitalField);
 | 
					        logic.setStartingCapital(startingCapital);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (startingCapitalField instanceof TextField) {
 | 
					        assertEquals("The starting capital should be correctly set.", startingCapital, logic.getStartingCapital());
 | 
				
			||||||
            TextField startingCapitalInput = (TextField) startingCapitalField;
 | 
					 | 
				
			||||||
            startingCapitalInput.setText("1500");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            assertEquals("Der eingegebene Startbetrag sollte '1500' sein", "1500", startingCapitalInput.getText());
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        else {
 | 
					 | 
				
			||||||
            throw new AssertionError("'StartingCapitalField' ist kein TextField-Objekt.");
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Test
 | 
					    @Test
 | 
				
			||||||
    // T012: UC-game-12 - Testet, ob der Spieler den Startbetrag um 100 € erhöhen kann
 | 
					 | 
				
			||||||
    public void testIncreaseStartingCapital() {
 | 
					    public void testIncreaseStartingCapital() {
 | 
				
			||||||
        Spatial increaseButton = app.getGuiNode().getChild("IncreaseCapitalButton");
 | 
					        logic.setStartingCapital(1500);
 | 
				
			||||||
        assertNotNull("Der 'Erhöhen'-Button sollte existieren", increaseButton);
 | 
					        logic.increaseStartingCapital();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (increaseButton instanceof Button) {
 | 
					        assertEquals("The starting capital should increase by 100.", 1600, logic.getStartingCapital());
 | 
				
			||||||
            Button increaseCapitalButton = (Button) increaseButton;
 | 
					 | 
				
			||||||
            increaseCapitalButton.click();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            Spatial startingCapitalField = app.getGuiNode().getChild("StartingCapitalField");
 | 
					 | 
				
			||||||
            if (startingCapitalField instanceof TextField) {
 | 
					 | 
				
			||||||
                TextField startingCapitalInput = (TextField) startingCapitalField;
 | 
					 | 
				
			||||||
                assertEquals("Der Startbetrag sollte um 100 erhöht worden sein", "1600", startingCapitalInput.getText());
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            else {
 | 
					 | 
				
			||||||
                throw new AssertionError("'StartingCapitalField' ist kein TextField-Objekt.");
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        else {
 | 
					 | 
				
			||||||
            throw new AssertionError("'IncreaseCapitalButton' ist kein Button-Objekt.");
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Test
 | 
					    @Test
 | 
				
			||||||
    // T013: UC-game-13 - Testet, ob der Spieler den Startbetrag um 100 € senken kann
 | 
					 | 
				
			||||||
    public void testDecreaseStartingCapital() {
 | 
					    public void testDecreaseStartingCapital() {
 | 
				
			||||||
        Spatial decreaseButton = app.getGuiNode().getChild("DecreaseCapitalButton");
 | 
					        logic.setStartingCapital(1500);
 | 
				
			||||||
        assertNotNull("Der 'Senken'-Button sollte existieren", decreaseButton);
 | 
					        logic.decreaseStartingCapital();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (decreaseButton instanceof Button) {
 | 
					        assertEquals("The starting capital should decrease by 100.", 1400, logic.getStartingCapital());
 | 
				
			||||||
            Button decreaseCapitalButton = (Button) decreaseButton;
 | 
					 | 
				
			||||||
            decreaseCapitalButton.click();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            Spatial startingCapitalField = app.getGuiNode().getChild("StartingCapitalField");
 | 
					 | 
				
			||||||
            if (startingCapitalField instanceof TextField) {
 | 
					 | 
				
			||||||
                TextField startingCapitalInput = (TextField) startingCapitalField;
 | 
					 | 
				
			||||||
                assertEquals("Der Startbetrag sollte um 100 gesenkt worden sein", "1400", startingCapitalInput.getText());
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            else {
 | 
					 | 
				
			||||||
                throw new AssertionError("'StartingCapitalField' ist kein TextField-Objekt.");
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        else {
 | 
					 | 
				
			||||||
            throw new AssertionError("'DecreaseCapitalButton' ist kein Button-Objekt.");
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Test
 | 
					    @Test
 | 
				
			||||||
    // T014: UC-game-14 - Testet, ob die Standard-Spielernamen korrekt voreingestellt sind
 | 
					 | 
				
			||||||
    public void testDefaultPlayerName() {
 | 
					    public void testDefaultPlayerName() {
 | 
				
			||||||
        Spatial playerNameField = app.getGuiNode().getChild("PlayerNameField");
 | 
					        logic.addPlayer("Player 1");
 | 
				
			||||||
        assertNotNull("Das Eingabefeld für den Spielernamen sollte existieren", playerNameField);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (playerNameField instanceof TextField) {
 | 
					        assertTrue("The player name should be correctly set.", logic.getPlayerNames().contains("Player 1"));
 | 
				
			||||||
            TextField playerNameInput = (TextField) playerNameField;
 | 
					 | 
				
			||||||
            assertEquals("Der voreingestellte Spielername sollte 'Spieler 1' sein", "Spieler 1", playerNameInput.getText());
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        else {
 | 
					 | 
				
			||||||
            throw new AssertionError("'PlayerNameField' ist kein TextField-Objekt.");
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Test
 | 
					    @Test
 | 
				
			||||||
    // T015: UC-game-15 - Testet, ob der Spieler einen Anzeigenamen eingeben kann
 | 
					 | 
				
			||||||
    public void testEnterDisplayName() {
 | 
					    public void testEnterDisplayName() {
 | 
				
			||||||
        Spatial displayNameField = app.getGuiNode().getChild("DisplayNameField");
 | 
					        String displayName = "JohnDoe";
 | 
				
			||||||
        assertNotNull("Das Eingabefeld für den Anzeigenamen sollte existieren", displayNameField);
 | 
					        logic.setPlayerName(displayName);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (displayNameField instanceof TextField) {
 | 
					        assertEquals("The display name should be correctly set.", displayName, logic.getPlayerName());
 | 
				
			||||||
            TextField displayNameInput = (TextField) displayNameField;
 | 
					 | 
				
			||||||
            displayNameInput.setText("MaxMustermann");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            assertEquals("Der eingegebene Anzeigename sollte 'MaxMustermann' sein", "MaxMustermann", displayNameInput.getText());
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        else {
 | 
					 | 
				
			||||||
            throw new AssertionError("'DisplayNameField' ist kein TextField-Objekt.");
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Test
 | 
					    @Test
 | 
				
			||||||
    // T016: UC-game-16 - Testet, ob eine Warnung angezeigt wird, wenn ein Spieler einen bereits belegten Namen eingibt
 | 
					 | 
				
			||||||
    public void testDuplicateNameEntry() {
 | 
					    public void testDuplicateNameEntry() {
 | 
				
			||||||
        Spatial playerNameField = app.getGuiNode().getChild("PlayerNameField");
 | 
					        logic.addPlayer("Player 1");
 | 
				
			||||||
        assertNotNull("Das Eingabefeld für den Spielernamen sollte existieren", playerNameField);
 | 
					        boolean result = logic.addPlayer("Player 1");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (playerNameField instanceof TextField) {
 | 
					        assertTrue("Duplicate names should not be allowed.", !result);
 | 
				
			||||||
            TextField playerNameInput = (TextField) playerNameField;
 | 
					 | 
				
			||||||
            playerNameInput.setText("Spieler 1");
 | 
					 | 
				
			||||||
            app.getGuiNode().getChild("AddPlayerButton").click(); // Spieler hinzufügen
 | 
					 | 
				
			||||||
            playerNameInput.setText("Spieler 1");
 | 
					 | 
				
			||||||
            app.getGuiNode().getChild("AddPlayerButton").click(); // Spieler mit gleichem Namen hinzufügen
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            Spatial warning = app.getGuiNode().getChild("DuplicateNameWarning");
 | 
					 | 
				
			||||||
            assertNotNull("Es sollte eine Warnung angezeigt werden, wenn ein Name doppelt vergeben wird", warning);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        else {
 | 
					 | 
				
			||||||
            throw new AssertionError("'PlayerNameField' ist kein TextField-Objekt.");
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Test
 | 
					    @Test
 | 
				
			||||||
    // T017: UC-game-17 - Testet, ob der Spieler eine verfügbare Spielfigurfarbe auswählen kann
 | 
					 | 
				
			||||||
    public void testSelectPlayerColor() {
 | 
					    public void testSelectPlayerColor() {
 | 
				
			||||||
        Spatial colorSelector = app.getGuiNode().getChild("ColorSelector");
 | 
					        logic.addPlayer("Player 1");
 | 
				
			||||||
        assertNotNull("Der Farbwähler sollte existieren", colorSelector);
 | 
					        boolean result = logic.setPlayerColor("Player 1", "Red");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (colorSelector instanceof Button) {
 | 
					        assertTrue("The player should be able to select an available color.", result);
 | 
				
			||||||
            Button colorButton = (Button) colorSelector;
 | 
					 | 
				
			||||||
            colorButton.click();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            Spatial selectedColor = app.getGuiNode().getChild("SelectedColor");
 | 
					 | 
				
			||||||
            assertNotNull("Die gewählte Farbe sollte sichtbar sein", selectedColor);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        else {
 | 
					 | 
				
			||||||
            throw new AssertionError("'ColorSelector' ist kein Button-Objekt.");
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @Test
 | 
					 | 
				
			||||||
    // T018: UC-game-18 - Testet, ob eine belegte Spielfigurfarbe nicht ausgewählt werden kann
 | 
					 | 
				
			||||||
    public void testSelectOccupiedColor() {
 | 
					 | 
				
			||||||
        app.getGuiNode().getChild("ColorSelectorRed").click(); // Spieler 1 wählt Rot
 | 
					 | 
				
			||||||
        app.getGuiNode().getChild("AddPlayerButton").click(); // Spieler 1 hinzufügen
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        app.getGuiNode().getChild("ColorSelectorRed").click(); // Spieler 2 versucht Rot zu wählen
 | 
					 | 
				
			||||||
        Spatial warning = app.getGuiNode().getChild("ColorOccupiedWarning");
 | 
					 | 
				
			||||||
        assertNotNull("Es sollte eine Warnung angezeigt werden, wenn eine belegte Farbe ausgewählt wird", warning);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @Test
 | 
					 | 
				
			||||||
    // T019: UC-game-19 - Testet, ob der Spieler eine Spielfigur auswählen kann
 | 
					 | 
				
			||||||
    public void testSelectPlayerToken() {
 | 
					 | 
				
			||||||
        Spatial tokenSelector = app.getGuiNode().getChild("TokenSelector");
 | 
					 | 
				
			||||||
        assertNotNull("Der Token-Wähler sollte existieren", tokenSelector);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (tokenSelector instanceof Button) {
 | 
					 | 
				
			||||||
            Button tokenButton = (Button) tokenSelector;
 | 
					 | 
				
			||||||
            tokenButton.click();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            Spatial selectedToken = app.getGuiNode().getChild("SelectedToken");
 | 
					 | 
				
			||||||
            assertNotNull("Die gewählte Spielfigur sollte sichtbar sein", selectedToken);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        else {
 | 
					 | 
				
			||||||
            throw new AssertionError("'TokenSelector' ist kein Button-Objekt.");
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @Test
 | 
					 | 
				
			||||||
    // T020: UC-game-20 - Testet, ob eine belegte Spielfigur nicht ausgewählt werden kann
 | 
					 | 
				
			||||||
    public void testSelectOccupiedToken() {
 | 
					 | 
				
			||||||
        app.getGuiNode().getChild("TokenSelectorShip").click();
 | 
					 | 
				
			||||||
        app.getGuiNode().getChild("AddPlayerButton").click();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        app.getGuiNode().getChild("TokenSelectorShip").click();
 | 
					 | 
				
			||||||
        Spatial warning = app.getGuiNode().getChild("TokenOccupiedWarning");
 | 
					 | 
				
			||||||
        assertNotNull("Es sollte eine Warnung angezeigt werden, wenn eine belegte Spielfigur ausgewählt wird", warning);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @Test
 | 
					 | 
				
			||||||
    // T021: UC-game-14 - Überprüft, ob der Spieler zur „Spiel erstellen“-Ansicht zurückkehrt, wenn Abbrechen gedrückt wird
 | 
					 | 
				
			||||||
    public void testCancelPlayerLobby() {
 | 
					 | 
				
			||||||
        Spatial cancelButtonSpatial = app.getGuiNode().getChild("CancelLobbyButton");
 | 
					 | 
				
			||||||
        assertNotNull("Der 'Abbrechen'-Button in der Lobby sollte existieren", cancelButtonSpatial);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (cancelButtonSpatial instanceof Button) {
 | 
					 | 
				
			||||||
            Button cancelButton = (Button) cancelButtonSpatial;
 | 
					 | 
				
			||||||
            cancelButton.click();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            Spatial mainMenu = app.getGuiNode().getChild("MainMenu");
 | 
					 | 
				
			||||||
            assertNotNull("Das Hauptmenü sollte nach dem Abbrechen der Lobby sichtbar sein", mainMenu);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        else {
 | 
					 | 
				
			||||||
            throw new AssertionError("'CancelLobbyButton' ist kein Button-Objekt.");
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @Test
 | 
					 | 
				
			||||||
    // T022: UC-game-15 - Überprüft, ob das Spielmenü in der Lobby durch Drücken der ESC-Taste geöffnet wird
 | 
					 | 
				
			||||||
    public void testOpenLobbyMenuWithESC() {
 | 
					 | 
				
			||||||
        app.escape(true); // Simuliert das Drücken der ESC-Taste
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        Spatial lobbyMenu = app.getGuiNode().getChild("LobbyMenu");
 | 
					 | 
				
			||||||
        assertNotNull("Das Lobby-Menü sollte sichtbar sein, nachdem ESC in der Lobby gedrückt wurde", lobbyMenu);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @Test
 | 
					 | 
				
			||||||
    // T023: UC-game-16 - Testet, ob der Spieler die Auswahl der Spielfigur bestätigen kann
 | 
					 | 
				
			||||||
    public void testPlayerReadyConfirmation() {
 | 
					 | 
				
			||||||
        Spatial confirmButtonSpatial = app.getGuiNode().getChild("ConfirmTokenButton");
 | 
					 | 
				
			||||||
        assertNotNull("Der 'Bestätigen'-Button für die Spielfigur sollte existieren", confirmButtonSpatial);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (confirmButtonSpatial instanceof Button) {
 | 
					 | 
				
			||||||
            Button confirmButton = (Button) confirmButtonSpatial;
 | 
					 | 
				
			||||||
            confirmButton.click();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            Spatial readyStatus = app.getGuiNode().getChild("PlayerReadyStatus");
 | 
					 | 
				
			||||||
            assertNotNull("Der Status 'Bereit' sollte angezeigt werden, nachdem die Spielfigur bestätigt wurde", readyStatus);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        else {
 | 
					 | 
				
			||||||
            throw new AssertionError("'ConfirmTokenButton' ist kein Button-Objekt.");
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
        @Test
 | 
					 | 
				
			||||||
        // T024: UC-game-16 - Überprüft, ob das Spiel startet, wenn alle Spieler ihre Auswahl bestätigt haben
 | 
					 | 
				
			||||||
        public void testAllPlayersReady() {
 | 
					 | 
				
			||||||
            app.receivedEvent(new pp.monopoly.notification.ClientStateEvent(pp.monopoly.notification.ClientStateEvent.State.ALL_PLAYERS_READY));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            Spatial gameScreen = app.getGuiNode().getChild("GameScreen");
 | 
					 | 
				
			||||||
            assertNotNull("Das Spiel sollte starten, wenn alle Spieler bereit sind", gameScreen);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        @Test
 | 
					 | 
				
			||||||
        // T025: UC-game-17 - Testet, ob das Einstellungen-Menü während des Spiels geöffnet wird
 | 
					 | 
				
			||||||
        public void testOpenMainGameSettings () {
 | 
					 | 
				
			||||||
            app.escape(true);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            Spatial settingsButton = app.getGuiNode().getChild("SettingsButton");
 | 
					 | 
				
			||||||
            assertNotNull("Der 'Einstellungen'-Button sollte im Spielmenü vorhanden sein", settingsButton);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if (settingsButton instanceof Button) {
 | 
					 | 
				
			||||||
                ((Button) settingsButton).click();
 | 
					 | 
				
			||||||
                Spatial settingsMenu = app.getGuiNode().getChild("SettingsMenu");
 | 
					 | 
				
			||||||
                assertNotNull("Das Einstellungen-Menü sollte im Spiel angezeigt werden", settingsMenu);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            else {
 | 
					 | 
				
			||||||
                throw new AssertionError("'SettingsButton' ist kein Button-Objekt.");
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @Test
 | 
					 | 
				
			||||||
// T026: UC-gameplay-01 - Überprüft, ob der Spieler erfolgreich würfeln kann
 | 
					 | 
				
			||||||
    public void testRollDice() {
 | 
					 | 
				
			||||||
        Spatial rollDiceButton = app.getGuiNode().getChild("RollDiceButton");
 | 
					 | 
				
			||||||
        assertNotNull("Der 'Würfeln'-Button sollte sichtbar sein", rollDiceButton);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (rollDiceButton instanceof Button) {
 | 
					 | 
				
			||||||
            ((Button) rollDiceButton).click(); // Simuliert einen Würfelwurf
 | 
					 | 
				
			||||||
            Spatial diceResult = app.getGuiNode().getChild("DiceResult");
 | 
					 | 
				
			||||||
            assertNotNull("Das Ergebnis des Würfelwurfs sollte angezeigt werden", diceResult);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    @Test
 | 
					 | 
				
			||||||
// T027: UC-gameplay-01 - Überprüft, ob der aktive Spieler die richtige Anzahl an Feldern basierend auf dem Wurf bewegt
 | 
					 | 
				
			||||||
    public void testMovePlayerAutomatically() {
 | 
					 | 
				
			||||||
        Game game = new Game(); // Initialisiert ein neues Spiel
 | 
					 | 
				
			||||||
        PlayerHandler playerHandler = game.getPlayerHandler(); // Holt den PlayerHandler, der die Spieler verwaltet
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        Player activePlayer = playerHandler.getActivePlayer(); // Holt den aktuellen aktiven Spieler
 | 
					 | 
				
			||||||
        assertNotNull("Es sollte einen aktiven Spieler geben", activePlayer);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        DiceResult diceResult = game.rollDice(); // Würfelwurf simulieren
 | 
					 | 
				
			||||||
        int steps = diceResult.getTotal();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        int initialPosition = activePlayer.getFieldId(); // Ursprüngliche Position des aktiven Spielers
 | 
					 | 
				
			||||||
        playerHandler.moveActivePlayer(steps); // Bewegt den aktiven Spieler basierend auf dem Wurf
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        int expectedPosition = (initialPosition + steps) % game.getGameBoard().getNumberOfFields(); // Zielposition berechnen
 | 
					 | 
				
			||||||
        int newPosition = activePlayer.getFieldId();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        assertEquals("Der aktive Spieler sollte sich korrekt bewegen", expectedPosition, newPosition);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // Überprüfen, dass alle anderen Spieler im WaitForTurn-State bleiben
 | 
					 | 
				
			||||||
        playerHandler.getPlayers().stream()
 | 
					 | 
				
			||||||
                     .filter(player -> player != activePlayer)
 | 
					 | 
				
			||||||
                     .forEach(player -> assertTrue("Andere Spieler sollten im WaitForTurn-State sein", player.getState() instanceof WaitForTurnState));
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @Test
 | 
					 | 
				
			||||||
// T028: UC-gameplay-02 - Überprüft, ob die Würfel zufällige Zahlen generieren
 | 
					 | 
				
			||||||
    public void testGenerationDice() {
 | 
					 | 
				
			||||||
        boolean isRandom = false;
 | 
					 | 
				
			||||||
        DiceResult previousResult = null;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        for (int i = 0; i < 10; i++) {
 | 
					 | 
				
			||||||
            DiceResult currentResult = app.getGame().rollDice();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            assertNotNull("Das Würfelergebnis sollte nicht null sein", currentResult);
 | 
					 | 
				
			||||||
            assertTrue("Die Würfelzahl 1 sollte zwischen 1 und 6 liegen", currentResult.getDice1() >= 1 && currentResult.getDice1() <= 6);
 | 
					 | 
				
			||||||
            assertTrue("Die Würfelzahl 2 sollte zwischen 1 und 6 liegen", currentResult.getDice2() >= 1 && currentResult.getDice2() <= 6);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if (previousResult != null && (currentResult.getDice1() != previousResult.getDice1() || currentResult.getDice2() != previousResult.getDice2())) {
 | 
					 | 
				
			||||||
                isRandom = true; // Unterschiedliche Würfelwerte gefunden
 | 
					 | 
				
			||||||
                break;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            previousResult = currentResult;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        assertTrue("Die Würfelergebnisse sollten zufällig sein", isRandom);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @Test
 | 
					 | 
				
			||||||
// T029: UC-gameplay-03 - Überprüft, ob die richtigen Augenzahlen angezeigt werden
 | 
					 | 
				
			||||||
    public void testDisplayResults() {
 | 
					 | 
				
			||||||
        DiceResult result = app.getGame().rollDice();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        assertNotNull("Das Würfelergebnis sollte nicht null sein", result);
 | 
					 | 
				
			||||||
        assertTrue("Die Würfelzahl 1 sollte zwischen 1 und 6 liegen", result.getDice1() >= 1 && result.getDice1() <= 6);
 | 
					 | 
				
			||||||
        assertTrue("Die Würfelzahl 2 sollte zwischen 1 und 6 liegen", result.getDice2() >= 1 && result.getDice2() <= 6);
 | 
					 | 
				
			||||||
        assertEquals("Die Summe sollte korrekt berechnet werden", result.getDice1() + result.getDice2(), result.getTotal());
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    @Test
 | 
					 | 
				
			||||||
    // T030: UC-gameplay-04 - Überprüfen, ob die Summe der Würfelergebnisse korrekt berechnet wird
 | 
					 | 
				
			||||||
    public void testSumDiceResults() {
 | 
					 | 
				
			||||||
        Spatial rollDiceButton = app.getGuiNode().getChild("RollDiceButton");
 | 
					 | 
				
			||||||
        assertNotNull("Der 'Würfeln'-Button sollte sichtbar sein", rollDiceButton);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (rollDiceButton instanceof Button) {
 | 
					 | 
				
			||||||
            ((Button) rollDiceButton).click(); // Simuliert einen Würfelwurf
 | 
					 | 
				
			||||||
            Spatial diceResult1 = app.getGuiNode().getChild("DiceResult1");
 | 
					 | 
				
			||||||
            Spatial diceResult2 = app.getGuiNode().getChild("DiceResult2");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            assertNotNull("Die Ergebnisse des Würfelwurfs sollten angezeigt werden", diceResult1);
 | 
					 | 
				
			||||||
            assertNotNull("Die Ergebnisse des Würfelwurfs sollten angezeigt werden", diceResult2);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            int result1 = Integer.parseInt(diceResult1.getUserData("value").toString());
 | 
					 | 
				
			||||||
            int result2 = Integer.parseInt(diceResult2.getUserData("value").toString());
 | 
					 | 
				
			||||||
            int expectedSum = result1 + result2;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            Spatial sumDisplay = app.getGuiNode().getChild("DiceSum");
 | 
					 | 
				
			||||||
            assertEquals("Die Summe der Würfelergebnisse sollte korrekt angezeigt werden", expectedSum, Integer.parseInt(sumDisplay.getUserData("value").toString()));
 | 
					 | 
				
			||||||
        } else {
 | 
					 | 
				
			||||||
            throw new AssertionError("'RollDiceButton' ist kein Button-Objekt.");
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @Test
 | 
					 | 
				
			||||||
    // T031: UC-gameplay-05 - Überprüfen, ob die Würfel nach dem Wurf ausgegraut werden
 | 
					 | 
				
			||||||
    public void testGrayOutDiceAfterRoll() {
 | 
					 | 
				
			||||||
        Spatial rollDiceButton = app.getGuiNode().getChild("RollDiceButton");
 | 
					 | 
				
			||||||
        assertNotNull("Der 'Würfeln'-Button sollte sichtbar sein", rollDiceButton);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (rollDiceButton instanceof Button) {
 | 
					 | 
				
			||||||
            ((Button) rollDiceButton).click(); // Simuliert einen Würfelwurf
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            Spatial diceDisplay = app.getGuiNode().getChild("DiceDisplay");
 | 
					 | 
				
			||||||
            assertNotNull("Die Würfelanzeige sollte nach dem Wurf sichtbar sein", diceDisplay);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            boolean isGrayedOut = diceDisplay.getUserData("grayedOut");
 | 
					 | 
				
			||||||
            assertTrue("Die Würfel sollten nach dem Wurf ausgegraut sein", isGrayedOut);
 | 
					 | 
				
			||||||
        } else {
 | 
					 | 
				
			||||||
            throw new AssertionError("'RollDiceButton' ist kein Button-Objekt.");
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @Test
 | 
					 | 
				
			||||||
    // T032: UC-gameplay-06 - Überprüfen, ob das Würfeln eines Paschs erkannt wird
 | 
					 | 
				
			||||||
    public void testDetectDouble() {
 | 
					 | 
				
			||||||
        Spatial rollDiceButton = app.getGuiNode().getChild("RollDiceButton");
 | 
					 | 
				
			||||||
        assertNotNull("Der 'Würfeln'-Button sollte sichtbar sein", rollDiceButton);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (rollDiceButton instanceof Button) {
 | 
					 | 
				
			||||||
            // Simuliert mehrere Würfe, um einen Pasch zu erkennen
 | 
					 | 
				
			||||||
            for (int i = 0; i < 10; i++) {
 | 
					 | 
				
			||||||
                ((Button) rollDiceButton).click();
 | 
					 | 
				
			||||||
                Spatial diceResult1 = app.getGuiNode().getChild("DiceResult1");
 | 
					 | 
				
			||||||
                Spatial diceResult2 = app.getGuiNode().getChild("DiceResult2");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                int result1 = Integer.parseInt(diceResult1.getUserData("value").toString());
 | 
					 | 
				
			||||||
                int result2 = Integer.parseInt(diceResult2.getUserData("value").toString());
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                if (result1 == result2) {
 | 
					 | 
				
			||||||
                    Spatial doubleIndicator = app.getGuiNode().getChild("DoubleIndicator");
 | 
					 | 
				
			||||||
                    assertNotNull("Ein Pasch sollte angezeigt werden, wenn zwei identische Zahlen geworfen werden", doubleIndicator);
 | 
					 | 
				
			||||||
                    break;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        } else {
 | 
					 | 
				
			||||||
            throw new AssertionError("'RollDiceButton' ist kein Button-Objekt.");
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @Test
 | 
					 | 
				
			||||||
    // T033: UC-gameplay-06 - Überprüfen, ob der Spieler bei einem Pasch erneut würfeln darf
 | 
					 | 
				
			||||||
    public void testDoubleRoll() {
 | 
					 | 
				
			||||||
        Spatial rollDiceButton = app.getGuiNode().getChild("RollDiceButton");
 | 
					 | 
				
			||||||
        assertNotNull("Der 'Würfeln'-Button sollte sichtbar sein", rollDiceButton);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (rollDiceButton instanceof Button) {
 | 
					 | 
				
			||||||
            // Simuliert das Würfeln eines Paschs
 | 
					 | 
				
			||||||
            ((Button) rollDiceButton).click();
 | 
					 | 
				
			||||||
            Spatial diceResult1 = app.getGuiNode().getChild("DiceResult1");
 | 
					 | 
				
			||||||
            Spatial diceResult2 = app.getGuiNode().getChild("DiceResult2");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            int result1 = Integer.parseInt(diceResult1.getUserData("value").toString());
 | 
					 | 
				
			||||||
            int result2 = Integer.parseInt(diceResult2.getUserData("value").toString());
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if (result1 == result2) { // Überprüft, ob ein Pasch geworfen wurde
 | 
					 | 
				
			||||||
                Spatial rollAgainIndicator = app.getGuiNode().getChild("RollAgainIndicator");
 | 
					 | 
				
			||||||
                assertNotNull("Der Spieler sollte bei einem Pasch erneut würfeln dürfen", rollAgainIndicator);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        } else {
 | 
					 | 
				
			||||||
            throw new AssertionError("'RollDiceButton' ist kein Button-Objekt.");
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @Test
 | 
					 | 
				
			||||||
    // T034: UC-gameplay-06 - Überprüfen, ob der Spieler nach dem dritten Pasch ins Gefängnis muss
 | 
					 | 
				
			||||||
    public void testTripleDoubleGulag() {
 | 
					 | 
				
			||||||
        int doubleCount = 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        for (int i = 0; i < 3; i++) {
 | 
					 | 
				
			||||||
            Spatial rollDiceButton = app.getGuiNode().getChild("RollDiceButton");
 | 
					 | 
				
			||||||
            assertNotNull("Der 'Würfeln'-Button sollte sichtbar sein", rollDiceButton);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if (rollDiceButton instanceof Button) {
 | 
					 | 
				
			||||||
                ((Button) rollDiceButton).click();
 | 
					 | 
				
			||||||
                Spatial diceResult1 = app.getGuiNode().getChild("DiceResult1");
 | 
					 | 
				
			||||||
                Spatial diceResult2 = app.getGuiNode().getChild("DiceResult2");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                int result1 = Integer.parseInt(diceResult1.getUserData("value").toString());
 | 
					 | 
				
			||||||
                int result2 = Integer.parseInt(diceResult2.getUserData("value").toString());
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                if (result1 == result2) {
 | 
					 | 
				
			||||||
                    doubleCount++;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                if (doubleCount == 3) {
 | 
					 | 
				
			||||||
                    Spatial jailIndicator = app.getGuiNode().getChild("JailIndicator");
 | 
					 | 
				
			||||||
                    assertNotNull("Der Spieler sollte nach dem dritten Pasch ins Gefängnis gehen", jailIndicator);
 | 
					 | 
				
			||||||
                    break;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            } else {
 | 
					 | 
				
			||||||
                throw new AssertionError("'RollDiceButton' ist kein Button-Objekt.");
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        assertTrue("Der Spieler sollte drei Paschs geworfen haben", doubleCount == 3);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    @Test
 | 
					 | 
				
			||||||
// T035: UC-gameplay-07 - Überprüfen, ob ein Spieler für Steuerfelder korrekt belastet wird
 | 
					 | 
				
			||||||
    public void testTaxFieldCharges() {
 | 
					 | 
				
			||||||
        Game game = new Game();
 | 
					 | 
				
			||||||
        PlayerHandler playerHandler = game.getPlayerHandler();
 | 
					 | 
				
			||||||
        Player activePlayer = playerHandler.getActivePlayer();
 | 
					 | 
				
			||||||
        assertNotNull("Es sollte einen aktiven Spieler geben", activePlayer);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        int initialBalance = activePlayer.getAccountBalance();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        activePlayer.moveToField(game.getGameBoard().getFieldById(4)); // ID 4: Steuerfeld "Diszi"
 | 
					 | 
				
			||||||
        game.getGameBoard().applyFieldEffect(activePlayer);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        int expectedBalance = initialBalance - 200; // Beispielsteuer: 200 €
 | 
					 | 
				
			||||||
        assertEquals("Der Spieler sollte für das Steuerfeld korrekt belastet werden", expectedBalance, activePlayer.getAccountBalance());
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @Test
 | 
					 | 
				
			||||||
// T036: UC-gameplay-08 - Überprüfen, ob ein Spieler korrekt ins Gefängnis geschickt wird
 | 
					 | 
				
			||||||
    public void testGoToJailField() {
 | 
					 | 
				
			||||||
        Game game = new Game();
 | 
					 | 
				
			||||||
        PlayerHandler playerHandler = game.getPlayerHandler();
 | 
					 | 
				
			||||||
        Player activePlayer = playerHandler.getActivePlayer();
 | 
					 | 
				
			||||||
        assertNotNull("Es sollte einen aktiven Spieler geben", activePlayer);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        activePlayer.moveToField(game.getGameBoard().getFieldById(30)); // ID 30: Ab ins Gefängnis
 | 
					 | 
				
			||||||
        game.getGameBoard().applyFieldEffect(activePlayer);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        assertEquals("Der Spieler sollte ins Gefängnis geschickt werden", 10, activePlayer.getFieldId()); // ID 10: Gefängnis
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @Test
 | 
					 | 
				
			||||||
// T037: UC-gameplay-09 - Überprüfen, ob ein Spieler bei "Frei Parken" keine Gebühren zahlt
 | 
					 | 
				
			||||||
    public void testFreeParking() {
 | 
					 | 
				
			||||||
        Game game = new Game();
 | 
					 | 
				
			||||||
        PlayerHandler playerHandler = game.getPlayerHandler();
 | 
					 | 
				
			||||||
        Player activePlayer = playerHandler.getActivePlayer();
 | 
					 | 
				
			||||||
        assertNotNull("Es sollte einen aktiven Spieler geben", activePlayer);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        int initialBalance = activePlayer.getAccountBalance();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        activePlayer.moveToField(game.getGameBoard().getFieldById(20)); // ID 20: Frei Parken
 | 
					 | 
				
			||||||
        game.getGameBoard().applyFieldEffect(activePlayer);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        assertEquals("Der Spieler sollte bei 'Frei Parken' keine Gebühren zahlen", initialBalance, activePlayer.getAccountBalance());
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -65,7 +65,7 @@ public class MonopolyServer implements MessageListener<HostedConnection>, Connec
 | 
				
			|||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Creates the server.
 | 
					     * Creates the server.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    MonopolyServer() {
 | 
					    public MonopolyServer() {
 | 
				
			||||||
        config.readFromIfExists(CONFIG_FILE);
 | 
					        config.readFromIfExists(CONFIG_FILE);
 | 
				
			||||||
        LOGGER.log(Level.INFO, "Configuration: {0}", config); //NON-NLS
 | 
					        LOGGER.log(Level.INFO, "Configuration: {0}", config); //NON-NLS
 | 
				
			||||||
        logic = new ServerGameLogic(this, config);
 | 
					        logic = new ServerGameLogic(this, config);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user