mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2025-08-06 02:35:38 +02:00
Gui
This commit is contained in:
@@ -7,6 +7,13 @@
|
||||
|
||||
package pp.monopoly.game.client;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.System.Logger;
|
||||
import java.lang.System.Logger.Level;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import pp.monopoly.message.client.ClientMessage;
|
||||
import pp.monopoly.message.server.BuyPropertyResponse;
|
||||
import pp.monopoly.message.server.DiceResult;
|
||||
@@ -20,8 +27,8 @@ import pp.monopoly.message.server.TimeOutWarning;
|
||||
import pp.monopoly.message.server.TradeReply;
|
||||
import pp.monopoly.message.server.TradeRequest;
|
||||
import pp.monopoly.message.server.ViewAssetsResponse;
|
||||
import pp.monopoly.model.IntPoint;
|
||||
import pp.monopoly.model.Board;
|
||||
import pp.monopoly.model.IntPoint;
|
||||
import pp.monopoly.notification.ClientStateEvent;
|
||||
import pp.monopoly.notification.GameEvent;
|
||||
import pp.monopoly.notification.GameEventBroker;
|
||||
|
@@ -7,13 +7,9 @@
|
||||
|
||||
package pp.monopoly.game.client;
|
||||
|
||||
import pp.monopoly.MonopolyConfig;
|
||||
import pp.monopoly.model.IntPoint;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import pp.monopoly.MonopolyConfig;
|
||||
|
||||
/**
|
||||
* Class providing access to the Monopoly client configuration.
|
||||
|
@@ -12,6 +12,10 @@ import pp.monopoly.model.fields.PropertyField;
|
||||
import java.lang.System.Logger;
|
||||
import java.lang.System.Logger.Level;
|
||||
|
||||
import pp.monopoly.MonopolyConfig;
|
||||
import pp.monopoly.message.client.ClientInterpreter;
|
||||
import pp.monopoly.message.server.ServerMessage;
|
||||
|
||||
/**
|
||||
* Controls the server-side game logic for Monopoly.
|
||||
* Manages game states, player interactions, and message handling.
|
||||
|
@@ -7,15 +7,16 @@
|
||||
|
||||
package pp.monopoly.model;
|
||||
|
||||
import pp.monopoly.notification.GameEvent;
|
||||
import pp.monopoly.notification.GameEventBroker;
|
||||
import pp.monopoly.notification.ItemAddedEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import pp.monopoly.notification.GameEvent;
|
||||
import pp.monopoly.notification.GameEventBroker;
|
||||
import pp.monopoly.notification.ItemAddedEvent;
|
||||
import pp.monopoly.notification.ItemRemovedEvent;
|
||||
|
||||
/**
|
||||
* Represents a rectangular map that holds figures and registers houses, hotels
|
||||
* It also supports event notification for game state changes such as item addition or removal.
|
||||
@@ -65,7 +66,7 @@ public class Board {
|
||||
*/
|
||||
private void addItem(Item item) {
|
||||
items.add(item);
|
||||
notifyListeners(new ItemAddedEvent(item, this));
|
||||
notifyListeners((GameEvent) new ItemAddedEvent(item, null));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,7 +76,7 @@ public class Board {
|
||||
*/
|
||||
public void remove(Item item) {
|
||||
items.remove(item);
|
||||
notifyListeners(new ItemAddedEvent(item, this));
|
||||
notifyListeners((GameEvent) new ItemRemovedEvent(item, null)); // Falls es ein entsprechendes ItemRemovedEvent gibt
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -7,10 +7,10 @@
|
||||
|
||||
package pp.monopoly.model;
|
||||
|
||||
import com.jme3.network.serializing.Serializable;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import com.jme3.network.serializing.Serializable;
|
||||
|
||||
/**
|
||||
* Represents a point in the two-dimensional plane with integer coordinates.
|
||||
*/
|
||||
|
@@ -1,29 +1,41 @@
|
||||
////////////////////////////////////////
|
||||
// Programming project code
|
||||
// UniBw M, 2022, 2023, 2024
|
||||
// www.unibw.de/inf2
|
||||
// (c) Mark Minas (mark.minas@unibw.de)
|
||||
////////////////////////////////////////
|
||||
|
||||
package pp.monopoly.notification;
|
||||
|
||||
import pp.monopoly.model.Item;
|
||||
import pp.monopoly.model.Board;
|
||||
import pp.monopoly.model.Item;
|
||||
|
||||
/**
|
||||
* Event when an item is added to a map.
|
||||
*
|
||||
* @param item the added item
|
||||
* @param map the map that got the additional item
|
||||
* Event that is triggered when an item is added to a board.
|
||||
*/
|
||||
public record ItemAddedEvent(Item item, Board map) implements GameEvent {
|
||||
public class ItemAddedEvent {
|
||||
private final Item item;
|
||||
private final Board board;
|
||||
|
||||
/**
|
||||
* Notifies the game event listener of this event.
|
||||
* Constructs a new ItemAddedEvent.
|
||||
*
|
||||
* @param listener the game event listener
|
||||
* @param item the item that was added
|
||||
* @param board the board to which the item was added
|
||||
*/
|
||||
@Override
|
||||
public void notifyListener(GameEventListener listener) {
|
||||
listener.receivedEvent(this);
|
||||
public ItemAddedEvent(Item item, Board board) {
|
||||
this.item = item;
|
||||
this.board = board;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the item that was added.
|
||||
*
|
||||
* @return the added item
|
||||
*/
|
||||
public Item getItem() {
|
||||
return item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the board to which the item was added.
|
||||
*
|
||||
* @return the board
|
||||
*/
|
||||
public Board getBoard() {
|
||||
return board;
|
||||
}
|
||||
}
|
||||
|
@@ -7,22 +7,30 @@
|
||||
|
||||
package pp.monopoly.notification;
|
||||
|
||||
import pp.monopoly.model.Item;
|
||||
import pp.monopoly.model.Board;
|
||||
import pp.monopoly.model.Item;
|
||||
|
||||
/**
|
||||
* Event when an item gets removed.
|
||||
*
|
||||
* @param item the destroyed item
|
||||
*/
|
||||
public record ItemRemovedEvent(Item item, Board map) implements GameEvent {
|
||||
/**
|
||||
* Notifies the game event listener of this event.
|
||||
*
|
||||
* @param listener the game event listener
|
||||
*/
|
||||
@Override
|
||||
public void notifyListener(GameEventListener listener) {
|
||||
listener.receivedEvent(this);
|
||||
public class ItemRemovedEvent {
|
||||
private final Item item;
|
||||
private final Board board;
|
||||
|
||||
public ItemRemovedEvent(Item item, Board board) {
|
||||
this.item = item;
|
||||
this.board = board;
|
||||
}
|
||||
|
||||
public Item getItem() {
|
||||
return item;
|
||||
}
|
||||
|
||||
public Board getBoard() {
|
||||
return board;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -58,4 +58,4 @@ public enum Sound {
|
||||
* UC-sound-11: Sound effect for button click.
|
||||
*/
|
||||
BUTTON;
|
||||
}
|
||||
}
|
@@ -1,26 +1,25 @@
|
||||
////////////////////////////////////////
|
||||
// Programming project code
|
||||
// UniBw M, 2022, 2023, 2024
|
||||
// www.unibw.de/inf2
|
||||
// (c) Mark Minas (mark.minas@unibw.de)
|
||||
////////////////////////////////////////
|
||||
|
||||
package pp.monopoly.notification;
|
||||
|
||||
/**
|
||||
* Event when an item is added to a map.
|
||||
* Event when a sound needs to be played.
|
||||
*
|
||||
* @param sound the sound to be played
|
||||
* @param soundFileName the sound file to be played
|
||||
*/
|
||||
public record SoundEvent(Sound sound) implements GameEvent {
|
||||
public class SoundEvent implements GameEvent {
|
||||
private final String soundFileName;
|
||||
|
||||
public SoundEvent(Sound sound) {
|
||||
this.soundFileName = sound.getFileName(); // Angenommen, Sound hat eine Methode getFileName()
|
||||
}
|
||||
|
||||
public String getSoundFileName() {
|
||||
return soundFileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notifies the game event listener of this event.
|
||||
*
|
||||
* @param listener the game event listener
|
||||
*/
|
||||
@Override
|
||||
public void notifyListener(GameEventListener listener) {
|
||||
listener.receivedEvent(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -40,3 +40,4 @@ dialog.question=Question
|
||||
port.must.be.integer=Port must be an integer number
|
||||
map.doesnt.fit=The map doesn't fit to this game
|
||||
client.server-start=Start server
|
||||
menu.settings=Open Settings
|
||||
|
Reference in New Issue
Block a user