9 Commits

Author SHA1 Message Date
Simon Wilkening
4cdd7c0cab Upload Vostellung_PP_Gruppe2_Monopoly 2024-12-19 10:24:04 +00:00
Filip Szepielewicz
e66487776d Delete ClientGameLogicTest.java 2024-12-13 13:50:30 +00:00
Filip Szepielewicz
97397e3053 Delete ClientLogicTest.java 2024-12-13 13:49:04 +00:00
Johannes Schmelz
be568fd8f2 completed documentation 2024-12-12 18:17:21 +01:00
Johannes Schmelz
83aaae9fa6 Merge branch 'gui' into 'main'
Gui

See merge request progproj/gruppen-ht24/Gruppe-02!21
2024-12-12 16:51:29 +00:00
Johannes Schmelz
10e30d9bd9 Merge branch 'main' into 'gui'
# Conflicts:
#   Projekte/monopoly/client/src/main/java/pp/monopoly/client/gui/popups/EventCardPopup.java
2024-12-12 16:50:21 +00:00
Johannes Schmelz
249110f83c Merge remote-tracking branch 'origin/gui' 2024-12-09 14:13:44 +01:00
Johannes Schmelz
a686671c15 Merge branch 'reworkedGui' into 'main'
refactor Worlds and client States

See merge request progproj/gruppen-ht24/Gruppe-02!18
2024-12-08 01:18:35 +00:00
Johannes Schmelz
e102d22f14 refactor Worlds and client States 2024-12-08 01:18:35 +00:00
31 changed files with 336 additions and 380 deletions

Binary file not shown.

View File

@@ -17,8 +17,12 @@ public class CameraController implements GameEventListener{
* Enum representing the camera mode for the CameraController.
*/
public enum CameraMode {
/** Mode to focus on the current player */
FOCUS_CURRENT_PLAYER,
/** Mode to focus on the own player */
FOCUS_SELF,
/** Mode for free camera movement */
FREECAM
}

View File

@@ -318,6 +318,7 @@ public class LobbyMenu extends Dialog {
figure = selector.getSelectedItem();
break;
}
System.out.println("FIGUR:::::"+figure);
}
/**

Binary file not shown.

Before

Width:  |  Height:  |  Size: 132 KiB

After

Width:  |  Height:  |  Size: 105 KiB

View File

@@ -117,6 +117,11 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
state.entry();
}
/**
* Returns the player handler containing information about all players in the game.
*
* @return the player handler
*/
public PlayerHandler getPlayerHandler() {
return playerHandler;
}
@@ -130,6 +135,11 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
return board;
}
/**
* Returns the trade handler containing information about trades in the game.
*
* @return the trade handler
*/
public TradeHandler getTradeHandler() {
return tradeHandler;
}
@@ -208,6 +218,11 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
state.update(delta);
}
/**
* Returns if it is the player's turn.
*
* @return true if it is the player's turn, false otherwise
*/
public boolean isTurn() {
return state.isTurn();
}

View File

@@ -111,6 +111,8 @@ public class Player implements FieldVisitor<Void> {
/**
* Returns the color of the player
*
* @param id the id of the player
* @return the color of the player
*/
public static PlayerColor getColor(int id) {
@@ -472,6 +474,10 @@ public class Player implements FieldVisitor<Void> {
return null;
}
/**
* Returns the properties owned by the player
* @return the properties owned by the player
*/
public List<PropertyField> getPropertyFields() {
List<PropertyField> properties = new ArrayList<>();

View File

@@ -6,16 +6,39 @@ import com.jme3.math.ColorRGBA;
* Enum representing six distinct colors for players in the game.
*/
public enum PlayerColor {
/**
* Representing the color cyan.
*/
CYAN(new ColorRGBA(69 / 255f, 205 / 255f, 205 / 255f, 1), "Cyan"),
/**
* Representing the color yellow.
*/
YELLOW(new ColorRGBA(225 / 255f, 201 / 255f, 44 / 255f, 1), "Yellow"),
/**
* Representing the color red.
*/
RED(new ColorRGBA(255 / 255f, 33 / 255f, 33 / 255f, 1), "Red"),
/**
* Representing the color pink.
*/
PINK(new ColorRGBA(196 / 255f, 73 / 255f, 240 / 255f, 1), "Pink"),
/**
* Representing the color green.
*/
GREEN(new ColorRGBA(61 / 255f, 227 / 255f, 58 / 255f, 1), "Green"),
/**
* Representing the color purple.
*/
PURPLE(new ColorRGBA(60 / 255f, 74 / 255f, 223 / 255f, 1), "Purple");
/** The corresponding ColorRGBA color */
private final ColorRGBA color;
/** The name of the color */
private final String colorName;
/**

View File

@@ -8,6 +8,9 @@ import com.jme3.network.serializing.Serializable;
@Serializable
public class BuyPropertyRequest extends ServerMessage{
/**
* Constructor for the BuyPropertyRequest.
*/
public BuyPropertyRequest(){}
@Override

View File

@@ -2,6 +2,9 @@ package pp.monopoly.message.server;
import com.jme3.network.serializing.Serializable;
/**
* Message for drawing a card from the chance or community chest deck.
*/
@Serializable
public class EventDrawCard extends ServerMessage{
private String cardDescription;
@@ -11,6 +14,11 @@ public class EventDrawCard extends ServerMessage{
*/
private EventDrawCard() { /* empty */ }
/**
* Creates a new EventDrawCard message.
*
* @param cardDescription the description of the card that was drawn
*/
public EventDrawCard(String cardDescription) {
this.cardDescription = cardDescription;
}
@@ -20,6 +28,11 @@ public class EventDrawCard extends ServerMessage{
interpreter.received(this);
}
/**
* Returns the description of the card that was drawn.
*
* @return the description of the card that was drawn
*/
public String getCardDescription() {
return cardDescription;
}

View File

@@ -4,6 +4,9 @@ import com.jme3.network.serializing.Serializable;
import pp.monopoly.game.server.PlayerHandler;
/**
* Message that is sent from the server to the client to signal the start of the game.
*/
@Serializable
public class GameStart extends ServerMessage{

View File

@@ -29,12 +29,12 @@ public class Figure implements Item{
}
/**
* Constructs a new Figure with the specified length, position, and rotation.
* Creates a new Figure with the specified position and rotation.
*
* @param length the length of the Figure
* @param x the x-coordinate of the Figure's initial position
* @param z the z-coordinate of the Figure's initial position
* @param rot the rotation of the Figure
* @param position the position of the Figure
* @param rot the rotation of the Figure
* @param type the type of the figure
* @param id the id of the figure
*/
public Figure(Vector3f position, Rotation rot, String type, int id) {
this.position = calculateFieldPosition(0);

View File

@@ -2,6 +2,9 @@ package pp.monopoly.model;
import com.jme3.math.Vector3f;
/**
* A class representing a hotel in the Monopoly game.
*/
public class Hotel implements Item{
/**
* The ID of the field the hotel is on.

View File

@@ -37,6 +37,7 @@ public class House implements Item{
* Creates a new house with the given stage.
*
* @param stage the stage of the house
* @param fieldID the field ID of the house
*/
public House(int stage, int fieldID) {
this.stage = stage;
@@ -124,6 +125,11 @@ public class House implements Item{
return Rotation.NORTH;
}
/**
* Returns the alignment of the building on the field.
*
* @return the alignment of the building on the field
*/
public Quaternion getAlignment() {
Quaternion rotation = new Quaternion();
if (fieldID >= 1 && fieldID <= 10) {

View File

@@ -12,6 +12,9 @@ import com.jme3.network.serializing.Serializable;
@Serializable
public class LimitedLinkedList<E> extends LinkedList<E> {
/**
* The maximum number of elements this list can hold.
*/
private int maxSize;
/**

View File

@@ -29,6 +29,6 @@ public interface Visitor<T> {
* @param house the House element to visit
* @return the result of visiting the house element
*/
T visit(House figure);
T visit(House house);
}

View File

@@ -73,6 +73,11 @@ public class BoardManager {
return fields;
}
/**
* Method to find the Field by its name
* @param name the name of the Field to find
* @return the Field with the given name
*/
public Field getFieldByName(String name) {
for (Field field : board) {
if (field.getName().equals(name)) {
@@ -102,10 +107,19 @@ public class BoardManager {
else throw new NoSuchElementException();
}
/**
* Returns the Monopoly board with its fields in a list
* @return the Monopoly board
*/
public List<Field> getBoard() {
return board;
}
/**
* Returns a list of the PropertyFields in the source list
* @param source the list of indices of fields
* @return the list of PropertyFields
*/
public List<PropertyField> getPropertyFields(List<Integer> source) {
List<PropertyField> properties = new ArrayList<>();
for (Integer i : source) {
@@ -114,6 +128,12 @@ public class BoardManager {
return properties;
}
/**
* Checks if a House or Hotel can be built on the given Property.
*
* @param field the Property to check
* @return true if a house or hotel can be built on the property, false otherwise
*/
public boolean canBuild(BuildingProperty field) {
if (field == null) {
return false; // Null check for safety
@@ -200,10 +220,3 @@ public class BoardManager {
}
}
/* TODO:
- Häuser beim bau eines Hotels entfernen
- Alle texturen schwarz
*
*/

View File

@@ -7,24 +7,47 @@ import com.jme3.network.serializing.Serializable;
import pp.monopoly.game.server.Player;
/**
* Represents a building property field in the Monopoly game.
* Contains attributes related to ownership, price, rent, and mortgage status.
*/
@Serializable
public class BuildingProperty extends PropertyField {
/** Number of houses on the field 1-4 for houses and 5 for a hotel */
private int houses;
/** Price for building a house on the field */
private final int housePrice;
/** Color of the field */
private final FieldColor color;
/** The factor rent increses by with one house */
private final int rentFactor1 = 5;
/** The factor rent increses by with two houses */
private final int rentFactor2 = 15;
/** The factor rent increses by with three houses */
private final int rentFactor3 = 40;
/** The factor rent increses by with four houses */
private final int rentFactor4 = 55;
/** The factor rent increses by with a hotel */
private final int rentFactorHotel = 70;
/** No-arg constructor for serialization */
private BuildingProperty(){
super("", 0, 0, 0);
this.housePrice = 0;
this.color = null;
}
/**
* Constructs a BuildingProperty with the specified name, ID, price, rent, house price, and color.
*
* @param name the name of the property
* @param id the unique identifier for the property
* @param price the purchase price of the property
* @param rent the base rent for the property
* @param housePrice the price for building a house on the field
* @param color the color of the field
*/
BuildingProperty(String name, int id, int price, int rent, int housePrice, FieldColor color) {
super(name, id, price, rent);
this.housePrice = housePrice;
@@ -49,6 +72,12 @@ public class BuildingProperty extends PropertyField {
}
}
/**
* Builds a house on the field.
* If the field already has 4 houses, the method returns false.
*
* @return true if the house was built, false if the field already has 4 houses
*/
public boolean build() {
if (houses < 5) {
houses++;
@@ -57,6 +86,12 @@ public class BuildingProperty extends PropertyField {
return false;
}
/**
* Sells a house on the field.
* If the field has no houses, the method returns false.
*
* @return true if the house was sold, false if the field has no houses
*/
public boolean sell() {
if (houses == 0) {
return false;
@@ -70,6 +105,10 @@ public class BuildingProperty extends PropertyField {
player.visit(this);
}
/**
* Returns the rent for the field with 0-5 houses.
* @return a list of the rent for the field with 0-5 houses
*/
public List<Integer> getAllRent() {
List<Integer> list = new ArrayList<>();
list.add(rent);
@@ -81,18 +120,38 @@ public class BuildingProperty extends PropertyField {
return list;
}
/**
* Returns the color of the field.
*
* @return the color of the field
*/
public FieldColor getColor() {
return color;
}
/**
* Returns the number of houses on the field.
*
* @return the number of houses on the field
*/
public int getHousePrice() {
return housePrice;
}
/**
* Returns the number of houses on the field.
*
* @return the number of houses on the field
*/
public int getHouses() {
return houses;
}
/**
* Returns the number of hotels on the field.
*
* @return the number of hotels on the field
*/
public int getHotel() {
return (houses == 5)? 1:0;
}

View File

@@ -5,13 +5,24 @@ import com.jme3.network.serializing.Serializable;
import pp.monopoly.game.server.Player;
/**
* EventField class is a subclass of Field and represents a field that triggers an event when a player lands on it.
*/
@Serializable
public class EventField extends Field{
/**
* Empty constructor for serialization.
*/
private EventField() {
super("", 0);
}
/**
* Constructor for EventField.
* @param name The name of the field.
* @param id The id of the field.
*/
EventField(String name, int id) {
super(name, id);
}

View File

@@ -4,27 +4,52 @@ import com.jme3.network.serializing.Serializable;
import pp.monopoly.game.server.Player;
/**
* Abstract class for all fields on the board.
*/
@Serializable
public abstract class Field {
/** Name of the field */
protected final String name;
/** ID of the field */
protected final int id;
/**
* Empty constructor for serialization.
*/
private Field() {
this.name = "";
this.id = 0;
}
/**
* Constructor for the field.
* @param name Name of the field.
* @param id ID of the field.
*/
protected Field(String name, int id) {
this.name = name;
this.id= id;
}
/**
* Abstract method for the field. Supports the visitor pattern.
* @param player Player that lands on the field.
*/
public abstract void accept(Player player);
/**
* Returns the id of the field.
* @return id of the field.
*/
public int getId() {
return id;
}
/**
* Returns the name of the field.
* @return name of the field.
*/
public String getName() {
return name;
}

View File

@@ -6,17 +6,55 @@ import com.jme3.math.ColorRGBA;
* Enum representing eight distinct colors for properties in the game.
*/
public enum FieldColor {
/**
* Representing the FieldColor BROWN.
*/
BROWN(new ColorRGBA(148 / 255f, 86 / 255f, 57 / 255f, 1)),
/**
* Representing the FieldColor GREEN.
*/
GREEN(new ColorRGBA(30 / 255f, 179 / 255f, 90 / 255f, 1)),
/**
* Representing the FieldColor YELLOW.
*/
YELLOW(new ColorRGBA(252 / 255f, 241 / 255f, 1 / 255f, 1)),
/**
* Representing the FieldColor BLUE_LIGHT.
*/
BLUE_LIGHT(new ColorRGBA(170 / 255f, 223 / 255f, 246 / 255f, 1)),
/**
* Representing the FieldColor PINK.
*/
PINK(new ColorRGBA(214 / 255f, 60 / 255f, 153 / 255f, 1)),
/**
* Representing the FieldColor ORANGE.
*/
ORANGE(new ColorRGBA(244 / 255f, 147 / 255f, 32 / 255f, 1)),
/**
* Representing the FieldColor RED.
*/
RED(new ColorRGBA(232 / 255f, 27 / 255f, 30 / 255f, 1)),
/**
* Representing the FieldColor BLUE_DARK.
*/
BLUE_DARK(new ColorRGBA(2 / 255f, 112 / 255f, 191 / 255f, 1));
/**
* The ColorRGBA value associated with the field color.
*/
private final ColorRGBA color;
/**
* Constructs a FieldColor with a null ColorRGBA value for serialization.
*/
private FieldColor() {
this.color = null;
}

View File

@@ -4,21 +4,35 @@ import com.jme3.network.serializing.Serializable;
import pp.monopoly.game.server.Player;
/**
* Represents a field where the player has to pay a fine.
*/
@Serializable
public class FineField extends Field{
/** The fine the player has to pay. */
private final int fine;
/** Empty constructor for deserialization. */
private FineField() {
super("", 0);
this.fine = 0;
}
/**
* Creates a new fine field.
* @param name the name of the field
* @param id the id of the field
* @param fine the fine the player has to pay
*/
FineField(String name, int id, int fine) {
super(name, id);
this.fine = fine;
}
/**
* Returns the fine the player has to pay.
* @return the fine the player has to pay
*/
public int getFine() {
return fine;
}

View File

@@ -4,13 +4,25 @@ import com.jme3.network.serializing.Serializable;
import pp.monopoly.game.server.Player;
/**
* Represents a food field on the board.
*/
@Serializable
public class FoodField extends PropertyField {
/**
* Empty constructor used for serialization.
*/
private FoodField() {
super("", 0, 0, 0);
}
/**
* Constructor for the FoodField.
*
* @param name The name of the field.
* @param id The id of the field.
*/
FoodField(String name, int id) {
super(name, id, 1500,0);
}

View File

@@ -3,13 +3,26 @@ package pp.monopoly.model.fields;
import com.jme3.network.serializing.Serializable;
import pp.monopoly.game.server.Player;
/**
* GateField class is a subclass of PropertyField class and represents a field
* on the board that is a gate. It has a name, id, rent and price.
*/
@Serializable
public class GateField extends PropertyField{
/**
* No-argument constructor for serialization.
*/
private GateField() {
super("", 0, 0, 0);
}
/**
* Constructor for the GateField class.
* @param name the name of the field
* @param id the id of the field
*/
GateField(String name, int id) {
super(name, id, 2000, 250);
}

View File

@@ -3,9 +3,17 @@ package pp.monopoly.model.fields;
import com.jme3.network.serializing.Serializable;
import pp.monopoly.game.server.Player;
/**
* GoField class extends Field class and represents the Go field on the board.
* It is the first field on the board and the player receives a monthly salary when he passes it.
*/
@Serializable
public class GoField extends Field{
/**
* Constructor for the GoField class.
* It sets the name of the field to "Monatsgehalt" and the index to 0.
*/
GoField() {
super("Monatsgehalt", 0);
}

View File

@@ -3,11 +3,18 @@ package pp.monopoly.model.fields;
import com.jme3.network.serializing.Serializable;
import pp.monopoly.game.server.Player;
/*
* Represents the Gulag field on the board. This is the place a player goes to when they are sent to jail.
*/
@Serializable
public class GulagField extends Field{
/** Cost to bail out of jail */
private int bailCost = 500;
/**
* Constructor for the Gulag field.
*/
GulagField() {
super("Gulag", 10);
}
@@ -17,6 +24,11 @@ public class GulagField extends Field{
player.visit(this);
}
/**
* Gets the cost to bail out of jail.
*
* @return the cost to bail out of jail
*/
public int getBailCost() {
return bailCost;
}

View File

@@ -11,11 +11,16 @@ import pp.monopoly.game.server.Player;
@Serializable
public abstract class PropertyField extends Field {
/** Prive of the property */
private final int price;
/** Base rent of the property */
protected final int rent;
/** Owner of the property */
private Player owner;
/** Mortgage status of the property */
private boolean mortgaged = false;
/** No-argument constructor required for serialization. */
private PropertyField() {
super("", 0);
this.price = 0;

View File

@@ -4,10 +4,19 @@ import com.jme3.network.serializing.Serializable;
import pp.monopoly.game.server.Player;
/**
* A field that represents the Teststrecke field on the board.
*/
@Serializable
public class TestStreckeField extends Field{
/**
* The amount of money on the field.
*/
private int money;
/**
* Creates a new TestStreckeField.
*/
TestStreckeField() {
super("Teststrecke", 20);
}
@@ -17,10 +26,20 @@ public class TestStreckeField extends Field{
player.visit(this);
}
/**
* Adds money to the field.
*
* @param amount the amount of money to add
*/
public void addMoney(int amount) {
money += amount;
}
/**
* Collects the money from the field and resets the money to 0.
*
* @return the amount of money collected
*/
public int collectMoney() {
int tmp = money;
money = 0;

View File

@@ -4,9 +4,16 @@ import com.jme3.network.serializing.Serializable;
import pp.monopoly.game.server.Player;
/**
* Field representing the police station. If a player lands on this field, he
* has to move to the jail.
*/
@Serializable
public class WacheField extends Field{
/**
* Constructor for the WacheField.
*/
WacheField() {
super("Wache", 30);
}

View File

@@ -1,239 +0,0 @@
package pp.monopoly.client;
import com.jme3.scene.Spatial;
import com.jme3.scene.Node;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertNotNull;
import static org.mockito.Mockito.*;
public class ClientLogicTest {
private MonopolyApp app;
private Node guiNodeMock;
@Before
public void setUp() {
// 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();
}
@Test
// T001: UC-game-01 - Überprüft, ob die Anwendung erfolgreich gestartet wird und das Hauptmenü angezeigt wird
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");
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).escape(true);
// Rufe die ESC-Tastenmethode auf
app.escape(true);
// Verifiziere, dass die Methode aufgerufen wurde
verify(app, times(1)).escape(true);
}
}
/*
@Test
// T002: UC-game-02 - Überprüft, ob das Startmenü nach dem Start der Anwendung angezeigt wird
public void testOpenStartMenu() {
Spatial startMenu = app.getGuiNode().getChild("StartMenu");
assertNotNull("Das Startmenü sollte sichtbar sein", startMenu);
}
*/
/*
@Test
// T002: UC-game-02 - Überprüft, ob das Startmenü (MainMenu) angezeigt wird und die Buttons korrekt funktionieren
public void testMainMenuButtons() {
Spatial mainMenu = app.getGuiNode().getChild("MainMenu");
assertNotNull("Das Hauptmenü (MainMenu) sollte sichtbar sein", mainMenu);
Spatial playButtonSpatial = app.getGuiNode().getChild("PlayButton");
assertNotNull("Der 'Spielen'-Button sollte existieren", playButtonSpatial);
Spatial settingsButtonSpatial = app.getGuiNode().getChild("SettingsButton");
assertNotNull("Der 'Einstellungen'-Button sollte existieren", settingsButtonSpatial);
Spatial exitButtonSpatial = app.getGuiNode().getChild("ExitButton");
assertNotNull("Der 'Spiel beenden'-Button sollte existieren", exitButtonSpatial);
// Optional: Überprüfung der Funktionalität (Simulation von Button-Klicks)
if (playButtonSpatial instanceof Button) {
Button playButton = (Button) playButtonSpatial;
playButton.click();
Spatial newGameMenu = app.getGuiNode().getChild("NewGameMenu");
assertNotNull("Das Spielerstellungsmenü sollte nach dem Klicken auf 'Spielen' sichtbar sein", newGameMenu);
} else {
throw new AssertionError("'PlayButton' ist kein Button-Objekt.");
}
if (settingsButtonSpatial instanceof Button) {
Button settingsButton = (Button) settingsButtonSpatial;
settingsButton.click();
Spatial settingsMenu = app.getGuiNode().getChild("SettingsMenu");
assertNotNull("Das Einstellungsmenü sollte nach dem Klicken auf 'Einstellungen' sichtbar sein", settingsMenu);
} else {
throw new AssertionError("'SettingsButton' ist kein Button-Objekt.");
}
if (exitButtonSpatial instanceof Button) {
Button exitButton = (Button) exitButtonSpatial;
exitButton.click();
Spatial mainMenuAfterExit = app.getGuiNode().getChild("MainMenu");
assertNull("Das Hauptmenü sollte nach dem Klicken auf 'Spiel beenden' nicht mehr sichtbar sein", mainMenuAfterExit);
} else {
throw new AssertionError("'ExitButton' ist kein Button-Objekt.");
}
}
@Test
// T003: UC-game-03 - Überprüft, ob der „Spiel starten“-Button das Spielerstellungsmenü öffnet
public void testNavigateToPlayOption() {
Spatial startGameButtonSpatial = app.getGuiNode().getChild("StartGameButton");
assertNotNull("Der 'Spiel starten'-Button sollte existieren", startGameButtonSpatial);
if (startGameButtonSpatial instanceof Button) {
Button startGameButton = (Button) startGameButtonSpatial;
startGameButton.click();
Spatial newGameMenu = app.getGuiNode().getChild("NewGameMenu");
assertNotNull("Das Spielerstellungsmenü sollte sichtbar sein", newGameMenu);
} else {
throw new AssertionError("'StartGameButton' ist kein Button-Objekt.");
}
}
@Test
// T004: UC-game-04 - Testet, ob die Anwendung geschlossen wird, wenn „Beenden“ im Hauptmenü gewählt wird
public void testExitApplicationFromMenu() {
Spatial exitButtonSpatial = app.getGuiNode().getChild("ExitButton");
assertNotNull("Der 'Beenden'-Button sollte existieren", exitButtonSpatial);
if (exitButtonSpatial instanceof Button) {
Button exitButton = (Button) exitButtonSpatial;
exitButton.click();
Spatial mainMenuAfterExit = app.getGuiNode().getChild("MainMenu");
assertNull("Das Hauptmenü sollte nach dem Beenden nicht mehr sichtbar sein", mainMenuAfterExit);
} else {
throw new AssertionError("'ExitButton' ist kein Button-Objekt.");
}
}
@Test
// T005: UC-game-05 - Überprüft, ob das Einstellungen-Menü aus dem Hauptmenü aufgerufen werden kann
public void testOpenSettingsFromMenu() {
Spatial settingsButtonSpatial = app.getGuiNode().getChild("SettingsButton");
assertNotNull("Der 'Einstellungen'-Button sollte existieren", settingsButtonSpatial);
if (settingsButtonSpatial instanceof Button) {
Button settingsButton = (Button) settingsButtonSpatial;
settingsButton.click();
Spatial settingsMenu = app.getGuiNode().getChild("SettingsMenu");
assertNotNull("Das Einstellungsmenü sollte sichtbar sein", settingsMenu);
} else {
throw new AssertionError("'SettingsButton' ist kein Button-Objekt.");
}
}
@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 nach Drücken von ESC sichtbar sein", gameMenu);
app.escape(false); // Simuliert das Loslassen der ESC-Taste
}
@Test
// T083: UC-menu-05 - Überprüfen, ob der Spieler erfolgreich ins Spiel zurückkehren kann
public void testReturnToGame() {
Spatial returnButtonSpatial = app.getGuiNode().getChild("ReturnButton");
assertNotNull("Der 'Zurück'-Button sollte existieren", returnButtonSpatial);
if (returnButtonSpatial instanceof Button) {
Button returnButton = (Button) returnButtonSpatial;
returnButton.click();
Spatial gameScene = app.getGuiNode().getChild("GameScene");
assertNotNull("Die Spielszene sollte nach dem Klick auf 'Zurück' sichtbar sein", gameScene);
} else {
throw new AssertionError("'ReturnButton' ist kein Button-Objekt.");
}
}
}
*/

View File

@@ -1,123 +0,0 @@
package pp.monopoly.game.client;
/*
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import pp.monopoly.server.MonopolyServer;
import pp.monopoly.client.ClientSender;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.*;
/**
* Tests the client-side logic of the Monopoly game.
*/
/*
public class ClientGameLogicTest {
private ClientGameLogic logic;
@Mock
private MonopolyServer serverMock;
@Mock
private ClientSender clientSenderMock;
@Before
public void setUp() {
MockitoAnnotations.openMocks(this);
logic = new ClientGameLogic(clientSenderMock);
}
@Test
public void testEnterHostName() {
String hostName = "localhost";
logic.setHostName(hostName);
assertEquals("The hostname should be correctly set.", hostName, logic.getHostName());
}
@Test
public void testEnterPortNumber() {
int portNumber = 12345;
logic.setPortNumber(portNumber);
assertEquals("The port number should be correctly set.", portNumber, logic.getPortNumber());
}
@Test
public void testCancelGameCreation() {
doNothing().when(clientSenderMock).returnToMainMenu();
logic.cancelGameCreation();
verify(clientSenderMock, times(1)).returnToMainMenu();
}
@Test
public void testEnterPlayerLobby() {
doNothing().when(clientSenderMock).enterLobby();
logic.enterLobby();
verify(clientSenderMock, times(1)).enterLobby();
}
@Test
public void testEnterStartingCapital() {
int startingCapital = 1500;
logic.setStartingCapital(startingCapital);
assertEquals("The starting capital should be correctly set.", startingCapital, logic.getStartingCapital());
}
@Test
public void testIncreaseStartingCapital() {
logic.setStartingCapital(1500);
logic.increaseStartingCapital();
assertEquals("The starting capital should increase by 100.", 1600, logic.getStartingCapital());
}
@Test
public void testDecreaseStartingCapital() {
logic.setStartingCapital(1500);
logic.decreaseStartingCapital();
assertEquals("The starting capital should decrease by 100.", 1400, logic.getStartingCapital());
}
@Test
public void testDefaultPlayerName() {
logic.addPlayer("Player 1");
assertTrue("The player name should be correctly set.", logic.getPlayerNames().contains("Player 1"));
}
@Test
public void testEnterDisplayName() {
String displayName = "JohnDoe";
logic.setPlayerName(displayName);
assertEquals("The display name should be correctly set.", displayName, logic.getPlayerName());
}
@Test
public void testDuplicateNameEntry() {
logic.addPlayer("Player 1");
boolean result = logic.addPlayer("Player 1");
assertTrue("Duplicate names should not be allowed.", !result);
}
@Test
public void testSelectPlayerColor() {
logic.addPlayer("Player 1");
boolean result = logic.setPlayerColor("Player 1", "Red");
assertTrue("The player should be able to select an available color.", result);
}
}
*/

View File

@@ -96,6 +96,8 @@ public class MonopolyServer implements MessageListener<HostedConnection>, Connec
/**
* Starts the Monopolys server.
*
* @param args the command line arguments
*/
public static void main(String[] args) {
new MonopolyServer().run();