mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2025-01-18 19:33:40 +01:00
completed documentation
This commit is contained in:
parent
83aaae9fa6
commit
be568fd8f2
@ -17,8 +17,12 @@ public class CameraController implements GameEventListener{
|
|||||||
* Enum representing the camera mode for the CameraController.
|
* Enum representing the camera mode for the CameraController.
|
||||||
*/
|
*/
|
||||||
public enum CameraMode {
|
public enum CameraMode {
|
||||||
|
|
||||||
|
/** Mode to focus on the current player */
|
||||||
FOCUS_CURRENT_PLAYER,
|
FOCUS_CURRENT_PLAYER,
|
||||||
|
/** Mode to focus on the own player */
|
||||||
FOCUS_SELF,
|
FOCUS_SELF,
|
||||||
|
/** Mode for free camera movement */
|
||||||
FREECAM
|
FREECAM
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,6 +117,11 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
|
|||||||
state.entry();
|
state.entry();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the player handler containing information about all players in the game.
|
||||||
|
*
|
||||||
|
* @return the player handler
|
||||||
|
*/
|
||||||
public PlayerHandler getPlayerHandler() {
|
public PlayerHandler getPlayerHandler() {
|
||||||
return playerHandler;
|
return playerHandler;
|
||||||
}
|
}
|
||||||
@ -130,6 +135,11 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
|
|||||||
return board;
|
return board;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the trade handler containing information about trades in the game.
|
||||||
|
*
|
||||||
|
* @return the trade handler
|
||||||
|
*/
|
||||||
public TradeHandler getTradeHandler() {
|
public TradeHandler getTradeHandler() {
|
||||||
return tradeHandler;
|
return tradeHandler;
|
||||||
}
|
}
|
||||||
@ -208,6 +218,11 @@ public class ClientGameLogic implements ServerInterpreter, GameEventBroker {
|
|||||||
state.update(delta);
|
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() {
|
public boolean isTurn() {
|
||||||
return state.isTurn();
|
return state.isTurn();
|
||||||
}
|
}
|
||||||
|
@ -111,6 +111,8 @@ public class Player implements FieldVisitor<Void> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the color of the player
|
* Returns the color of the player
|
||||||
|
*
|
||||||
|
* @param id the id of the player
|
||||||
* @return the color of the player
|
* @return the color of the player
|
||||||
*/
|
*/
|
||||||
public static PlayerColor getColor(int id) {
|
public static PlayerColor getColor(int id) {
|
||||||
@ -472,6 +474,10 @@ public class Player implements FieldVisitor<Void> {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the properties owned by the player
|
||||||
|
* @return the properties owned by the player
|
||||||
|
*/
|
||||||
public List<PropertyField> getPropertyFields() {
|
public List<PropertyField> getPropertyFields() {
|
||||||
List<PropertyField> properties = new ArrayList<>();
|
List<PropertyField> properties = new ArrayList<>();
|
||||||
|
|
||||||
|
@ -6,16 +6,39 @@ import com.jme3.math.ColorRGBA;
|
|||||||
* Enum representing six distinct colors for players in the game.
|
* Enum representing six distinct colors for players in the game.
|
||||||
*/
|
*/
|
||||||
public enum PlayerColor {
|
public enum PlayerColor {
|
||||||
|
/**
|
||||||
|
* Representing the color cyan.
|
||||||
|
*/
|
||||||
CYAN(new ColorRGBA(69 / 255f, 205 / 255f, 205 / 255f, 1), "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"),
|
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"),
|
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"),
|
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"),
|
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");
|
PURPLE(new ColorRGBA(60 / 255f, 74 / 255f, 223 / 255f, 1), "Purple");
|
||||||
|
|
||||||
|
/** The corresponding ColorRGBA color */
|
||||||
|
|
||||||
private final ColorRGBA color;
|
private final ColorRGBA color;
|
||||||
|
/** The name of the color */
|
||||||
private final String colorName;
|
private final String colorName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -8,6 +8,9 @@ import com.jme3.network.serializing.Serializable;
|
|||||||
@Serializable
|
@Serializable
|
||||||
public class BuyPropertyRequest extends ServerMessage{
|
public class BuyPropertyRequest extends ServerMessage{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for the BuyPropertyRequest.
|
||||||
|
*/
|
||||||
public BuyPropertyRequest(){}
|
public BuyPropertyRequest(){}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2,6 +2,9 @@ package pp.monopoly.message.server;
|
|||||||
|
|
||||||
import com.jme3.network.serializing.Serializable;
|
import com.jme3.network.serializing.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Message for drawing a card from the chance or community chest deck.
|
||||||
|
*/
|
||||||
@Serializable
|
@Serializable
|
||||||
public class EventDrawCard extends ServerMessage{
|
public class EventDrawCard extends ServerMessage{
|
||||||
private String cardDescription;
|
private String cardDescription;
|
||||||
@ -11,6 +14,11 @@ public class EventDrawCard extends ServerMessage{
|
|||||||
*/
|
*/
|
||||||
private EventDrawCard() { /* empty */ }
|
private EventDrawCard() { /* empty */ }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new EventDrawCard message.
|
||||||
|
*
|
||||||
|
* @param cardDescription the description of the card that was drawn
|
||||||
|
*/
|
||||||
public EventDrawCard(String cardDescription) {
|
public EventDrawCard(String cardDescription) {
|
||||||
this.cardDescription = cardDescription;
|
this.cardDescription = cardDescription;
|
||||||
}
|
}
|
||||||
@ -20,6 +28,11 @@ public class EventDrawCard extends ServerMessage{
|
|||||||
interpreter.received(this);
|
interpreter.received(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the description of the card that was drawn.
|
||||||
|
*
|
||||||
|
* @return the description of the card that was drawn
|
||||||
|
*/
|
||||||
public String getCardDescription() {
|
public String getCardDescription() {
|
||||||
return cardDescription;
|
return cardDescription;
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,9 @@ import com.jme3.network.serializing.Serializable;
|
|||||||
|
|
||||||
import pp.monopoly.game.server.PlayerHandler;
|
import pp.monopoly.game.server.PlayerHandler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Message that is sent from the server to the client to signal the start of the game.
|
||||||
|
*/
|
||||||
@Serializable
|
@Serializable
|
||||||
public class GameStart extends ServerMessage{
|
public class GameStart extends ServerMessage{
|
||||||
|
|
||||||
|
@ -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 position the position of the Figure
|
||||||
* @param x the x-coordinate of the Figure's initial position
|
* @param rot the rotation of the Figure
|
||||||
* @param z the z-coordinate of the Figure's initial position
|
* @param type the type of the figure
|
||||||
* @param rot the rotation of the Figure
|
* @param id the id of the figure
|
||||||
*/
|
*/
|
||||||
public Figure(Vector3f position, Rotation rot, String type, int id) {
|
public Figure(Vector3f position, Rotation rot, String type, int id) {
|
||||||
this.position = calculateFieldPosition(0);
|
this.position = calculateFieldPosition(0);
|
||||||
|
@ -2,6 +2,9 @@ package pp.monopoly.model;
|
|||||||
|
|
||||||
import com.jme3.math.Vector3f;
|
import com.jme3.math.Vector3f;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A class representing a hotel in the Monopoly game.
|
||||||
|
*/
|
||||||
public class Hotel implements Item{
|
public class Hotel implements Item{
|
||||||
/**
|
/**
|
||||||
* The ID of the field the hotel is on.
|
* The ID of the field the hotel is on.
|
||||||
|
@ -37,6 +37,7 @@ public class House implements Item{
|
|||||||
* Creates a new house with the given stage.
|
* Creates a new house with the given stage.
|
||||||
*
|
*
|
||||||
* @param stage the stage of the house
|
* @param stage the stage of the house
|
||||||
|
* @param fieldID the field ID of the house
|
||||||
*/
|
*/
|
||||||
public House(int stage, int fieldID) {
|
public House(int stage, int fieldID) {
|
||||||
this.stage = stage;
|
this.stage = stage;
|
||||||
@ -124,6 +125,11 @@ public class House implements Item{
|
|||||||
return Rotation.NORTH;
|
return Rotation.NORTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the alignment of the building on the field.
|
||||||
|
*
|
||||||
|
* @return the alignment of the building on the field
|
||||||
|
*/
|
||||||
public Quaternion getAlignment() {
|
public Quaternion getAlignment() {
|
||||||
Quaternion rotation = new Quaternion();
|
Quaternion rotation = new Quaternion();
|
||||||
if (fieldID >= 1 && fieldID <= 10) {
|
if (fieldID >= 1 && fieldID <= 10) {
|
||||||
|
@ -12,6 +12,9 @@ import com.jme3.network.serializing.Serializable;
|
|||||||
@Serializable
|
@Serializable
|
||||||
public class LimitedLinkedList<E> extends LinkedList<E> {
|
public class LimitedLinkedList<E> extends LinkedList<E> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The maximum number of elements this list can hold.
|
||||||
|
*/
|
||||||
private int maxSize;
|
private int maxSize;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -29,6 +29,6 @@ public interface Visitor<T> {
|
|||||||
* @param house the House element to visit
|
* @param house the House element to visit
|
||||||
* @return the result of visiting the house element
|
* @return the result of visiting the house element
|
||||||
*/
|
*/
|
||||||
T visit(House figure);
|
T visit(House house);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -73,6 +73,11 @@ public class BoardManager {
|
|||||||
return fields;
|
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) {
|
public Field getFieldByName(String name) {
|
||||||
for (Field field : board) {
|
for (Field field : board) {
|
||||||
if (field.getName().equals(name)) {
|
if (field.getName().equals(name)) {
|
||||||
@ -102,10 +107,19 @@ public class BoardManager {
|
|||||||
else throw new NoSuchElementException();
|
else throw new NoSuchElementException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the Monopoly board with its fields in a list
|
||||||
|
* @return the Monopoly board
|
||||||
|
*/
|
||||||
public List<Field> getBoard() {
|
public List<Field> getBoard() {
|
||||||
return board;
|
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) {
|
public List<PropertyField> getPropertyFields(List<Integer> source) {
|
||||||
List<PropertyField> properties = new ArrayList<>();
|
List<PropertyField> properties = new ArrayList<>();
|
||||||
for (Integer i : source) {
|
for (Integer i : source) {
|
||||||
@ -114,6 +128,12 @@ public class BoardManager {
|
|||||||
return properties;
|
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) {
|
public boolean canBuild(BuildingProperty field) {
|
||||||
if (field == null) {
|
if (field == null) {
|
||||||
return false; // Null check for safety
|
return false; // Null check for safety
|
||||||
@ -200,10 +220,3 @@ public class BoardManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO:
|
|
||||||
- Häuser beim bau eines Hotels entfernen
|
|
||||||
- Alle texturen schwarz
|
|
||||||
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
@ -7,24 +7,47 @@ import com.jme3.network.serializing.Serializable;
|
|||||||
|
|
||||||
import pp.monopoly.game.server.Player;
|
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
|
@Serializable
|
||||||
public class BuildingProperty extends PropertyField {
|
public class BuildingProperty extends PropertyField {
|
||||||
|
|
||||||
|
/** Number of houses on the field 1-4 for houses and 5 for a hotel */
|
||||||
private int houses;
|
private int houses;
|
||||||
|
/** Price for building a house on the field */
|
||||||
private final int housePrice;
|
private final int housePrice;
|
||||||
|
/** Color of the field */
|
||||||
private final FieldColor color;
|
private final FieldColor color;
|
||||||
|
/** The factor rent increses by with one house */
|
||||||
private final int rentFactor1 = 5;
|
private final int rentFactor1 = 5;
|
||||||
|
/** The factor rent increses by with two houses */
|
||||||
private final int rentFactor2 = 15;
|
private final int rentFactor2 = 15;
|
||||||
|
/** The factor rent increses by with three houses */
|
||||||
private final int rentFactor3 = 40;
|
private final int rentFactor3 = 40;
|
||||||
|
/** The factor rent increses by with four houses */
|
||||||
private final int rentFactor4 = 55;
|
private final int rentFactor4 = 55;
|
||||||
|
/** The factor rent increses by with a hotel */
|
||||||
private final int rentFactorHotel = 70;
|
private final int rentFactorHotel = 70;
|
||||||
|
|
||||||
|
/** No-arg constructor for serialization */
|
||||||
private BuildingProperty(){
|
private BuildingProperty(){
|
||||||
super("", 0, 0, 0);
|
super("", 0, 0, 0);
|
||||||
this.housePrice = 0;
|
this.housePrice = 0;
|
||||||
this.color = null;
|
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) {
|
BuildingProperty(String name, int id, int price, int rent, int housePrice, FieldColor color) {
|
||||||
super(name, id, price, rent);
|
super(name, id, price, rent);
|
||||||
this.housePrice = housePrice;
|
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() {
|
public boolean build() {
|
||||||
if (houses < 5) {
|
if (houses < 5) {
|
||||||
houses++;
|
houses++;
|
||||||
@ -57,6 +86,12 @@ public class BuildingProperty extends PropertyField {
|
|||||||
return false;
|
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() {
|
public boolean sell() {
|
||||||
if (houses == 0) {
|
if (houses == 0) {
|
||||||
return false;
|
return false;
|
||||||
@ -70,6 +105,10 @@ public class BuildingProperty extends PropertyField {
|
|||||||
player.visit(this);
|
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() {
|
public List<Integer> getAllRent() {
|
||||||
List<Integer> list = new ArrayList<>();
|
List<Integer> list = new ArrayList<>();
|
||||||
list.add(rent);
|
list.add(rent);
|
||||||
@ -81,18 +120,38 @@ public class BuildingProperty extends PropertyField {
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the color of the field.
|
||||||
|
*
|
||||||
|
* @return the color of the field
|
||||||
|
*/
|
||||||
public FieldColor getColor() {
|
public FieldColor getColor() {
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the number of houses on the field.
|
||||||
|
*
|
||||||
|
* @return the number of houses on the field
|
||||||
|
*/
|
||||||
public int getHousePrice() {
|
public int getHousePrice() {
|
||||||
return housePrice;
|
return housePrice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the number of houses on the field.
|
||||||
|
*
|
||||||
|
* @return the number of houses on the field
|
||||||
|
*/
|
||||||
public int getHouses() {
|
public int getHouses() {
|
||||||
return houses;
|
return houses;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the number of hotels on the field.
|
||||||
|
*
|
||||||
|
* @return the number of hotels on the field
|
||||||
|
*/
|
||||||
public int getHotel() {
|
public int getHotel() {
|
||||||
return (houses == 5)? 1:0;
|
return (houses == 5)? 1:0;
|
||||||
}
|
}
|
||||||
|
@ -5,13 +5,24 @@ import com.jme3.network.serializing.Serializable;
|
|||||||
|
|
||||||
import pp.monopoly.game.server.Player;
|
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
|
@Serializable
|
||||||
public class EventField extends Field{
|
public class EventField extends Field{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Empty constructor for serialization.
|
||||||
|
*/
|
||||||
private EventField() {
|
private EventField() {
|
||||||
super("", 0);
|
super("", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for EventField.
|
||||||
|
* @param name The name of the field.
|
||||||
|
* @param id The id of the field.
|
||||||
|
*/
|
||||||
EventField(String name, int id) {
|
EventField(String name, int id) {
|
||||||
super(name, id);
|
super(name, id);
|
||||||
}
|
}
|
||||||
|
@ -4,27 +4,52 @@ import com.jme3.network.serializing.Serializable;
|
|||||||
|
|
||||||
import pp.monopoly.game.server.Player;
|
import pp.monopoly.game.server.Player;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Abstract class for all fields on the board.
|
||||||
|
*/
|
||||||
@Serializable
|
@Serializable
|
||||||
public abstract class Field {
|
public abstract class Field {
|
||||||
|
/** Name of the field */
|
||||||
protected final String name;
|
protected final String name;
|
||||||
|
/** ID of the field */
|
||||||
protected final int id;
|
protected final int id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Empty constructor for serialization.
|
||||||
|
*/
|
||||||
private Field() {
|
private Field() {
|
||||||
this.name = "";
|
this.name = "";
|
||||||
this.id = 0;
|
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) {
|
protected Field(String name, int id) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.id= id;
|
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);
|
public abstract void accept(Player player);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the id of the field.
|
||||||
|
* @return id of the field.
|
||||||
|
*/
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the name of the field.
|
||||||
|
* @return name of the field.
|
||||||
|
*/
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
@ -6,17 +6,55 @@ import com.jme3.math.ColorRGBA;
|
|||||||
* Enum representing eight distinct colors for properties in the game.
|
* Enum representing eight distinct colors for properties in the game.
|
||||||
*/
|
*/
|
||||||
public enum FieldColor {
|
public enum FieldColor {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Representing the FieldColor BROWN.
|
||||||
|
*/
|
||||||
BROWN(new ColorRGBA(148 / 255f, 86 / 255f, 57 / 255f, 1)),
|
BROWN(new ColorRGBA(148 / 255f, 86 / 255f, 57 / 255f, 1)),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Representing the FieldColor GREEN.
|
||||||
|
*/
|
||||||
GREEN(new ColorRGBA(30 / 255f, 179 / 255f, 90 / 255f, 1)),
|
GREEN(new ColorRGBA(30 / 255f, 179 / 255f, 90 / 255f, 1)),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Representing the FieldColor YELLOW.
|
||||||
|
*/
|
||||||
YELLOW(new ColorRGBA(252 / 255f, 241 / 255f, 1 / 255f, 1)),
|
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)),
|
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)),
|
PINK(new ColorRGBA(214 / 255f, 60 / 255f, 153 / 255f, 1)),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Representing the FieldColor ORANGE.
|
||||||
|
*/
|
||||||
ORANGE(new ColorRGBA(244 / 255f, 147 / 255f, 32 / 255f, 1)),
|
ORANGE(new ColorRGBA(244 / 255f, 147 / 255f, 32 / 255f, 1)),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Representing the FieldColor RED.
|
||||||
|
*/
|
||||||
RED(new ColorRGBA(232 / 255f, 27 / 255f, 30 / 255f, 1)),
|
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));
|
BLUE_DARK(new ColorRGBA(2 / 255f, 112 / 255f, 191 / 255f, 1));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The ColorRGBA value associated with the field color.
|
||||||
|
*/
|
||||||
private final ColorRGBA color;
|
private final ColorRGBA color;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a FieldColor with a null ColorRGBA value for serialization.
|
||||||
|
*/
|
||||||
private FieldColor() {
|
private FieldColor() {
|
||||||
this.color = null;
|
this.color = null;
|
||||||
}
|
}
|
||||||
|
@ -4,21 +4,35 @@ import com.jme3.network.serializing.Serializable;
|
|||||||
|
|
||||||
import pp.monopoly.game.server.Player;
|
import pp.monopoly.game.server.Player;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a field where the player has to pay a fine.
|
||||||
|
*/
|
||||||
@Serializable
|
@Serializable
|
||||||
public class FineField extends Field{
|
public class FineField extends Field{
|
||||||
|
/** The fine the player has to pay. */
|
||||||
private final int fine;
|
private final int fine;
|
||||||
|
|
||||||
|
/** Empty constructor for deserialization. */
|
||||||
private FineField() {
|
private FineField() {
|
||||||
super("", 0);
|
super("", 0);
|
||||||
this.fine = 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) {
|
FineField(String name, int id, int fine) {
|
||||||
super(name, id);
|
super(name, id);
|
||||||
this.fine = fine;
|
this.fine = fine;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the fine the player has to pay.
|
||||||
|
* @return the fine the player has to pay
|
||||||
|
*/
|
||||||
public int getFine() {
|
public int getFine() {
|
||||||
return fine;
|
return fine;
|
||||||
}
|
}
|
||||||
|
@ -4,13 +4,25 @@ import com.jme3.network.serializing.Serializable;
|
|||||||
|
|
||||||
import pp.monopoly.game.server.Player;
|
import pp.monopoly.game.server.Player;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a food field on the board.
|
||||||
|
*/
|
||||||
@Serializable
|
@Serializable
|
||||||
public class FoodField extends PropertyField {
|
public class FoodField extends PropertyField {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Empty constructor used for serialization.
|
||||||
|
*/
|
||||||
private FoodField() {
|
private FoodField() {
|
||||||
super("", 0, 0, 0);
|
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) {
|
FoodField(String name, int id) {
|
||||||
super(name, id, 1500,0);
|
super(name, id, 1500,0);
|
||||||
}
|
}
|
||||||
|
@ -3,13 +3,26 @@ package pp.monopoly.model.fields;
|
|||||||
import com.jme3.network.serializing.Serializable;
|
import com.jme3.network.serializing.Serializable;
|
||||||
|
|
||||||
import pp.monopoly.game.server.Player;
|
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
|
@Serializable
|
||||||
public class GateField extends PropertyField{
|
public class GateField extends PropertyField{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* No-argument constructor for serialization.
|
||||||
|
*/
|
||||||
private GateField() {
|
private GateField() {
|
||||||
super("", 0, 0, 0);
|
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) {
|
GateField(String name, int id) {
|
||||||
super(name, id, 2000, 250);
|
super(name, id, 2000, 250);
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,17 @@ package pp.monopoly.model.fields;
|
|||||||
import com.jme3.network.serializing.Serializable;
|
import com.jme3.network.serializing.Serializable;
|
||||||
|
|
||||||
import pp.monopoly.game.server.Player;
|
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
|
@Serializable
|
||||||
public class GoField extends Field{
|
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() {
|
GoField() {
|
||||||
super("Monatsgehalt", 0);
|
super("Monatsgehalt", 0);
|
||||||
}
|
}
|
||||||
|
@ -3,11 +3,18 @@ package pp.monopoly.model.fields;
|
|||||||
import com.jme3.network.serializing.Serializable;
|
import com.jme3.network.serializing.Serializable;
|
||||||
|
|
||||||
import pp.monopoly.game.server.Player;
|
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
|
@Serializable
|
||||||
public class GulagField extends Field{
|
public class GulagField extends Field{
|
||||||
|
|
||||||
|
/** Cost to bail out of jail */
|
||||||
private int bailCost = 500;
|
private int bailCost = 500;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for the Gulag field.
|
||||||
|
*/
|
||||||
GulagField() {
|
GulagField() {
|
||||||
super("Gulag", 10);
|
super("Gulag", 10);
|
||||||
}
|
}
|
||||||
@ -17,6 +24,11 @@ public class GulagField extends Field{
|
|||||||
player.visit(this);
|
player.visit(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the cost to bail out of jail.
|
||||||
|
*
|
||||||
|
* @return the cost to bail out of jail
|
||||||
|
*/
|
||||||
public int getBailCost() {
|
public int getBailCost() {
|
||||||
return bailCost;
|
return bailCost;
|
||||||
}
|
}
|
||||||
|
@ -11,11 +11,16 @@ import pp.monopoly.game.server.Player;
|
|||||||
@Serializable
|
@Serializable
|
||||||
public abstract class PropertyField extends Field {
|
public abstract class PropertyField extends Field {
|
||||||
|
|
||||||
|
/** Prive of the property */
|
||||||
private final int price;
|
private final int price;
|
||||||
|
/** Base rent of the property */
|
||||||
protected final int rent;
|
protected final int rent;
|
||||||
|
/** Owner of the property */
|
||||||
private Player owner;
|
private Player owner;
|
||||||
|
/** Mortgage status of the property */
|
||||||
private boolean mortgaged = false;
|
private boolean mortgaged = false;
|
||||||
|
|
||||||
|
/** No-argument constructor required for serialization. */
|
||||||
private PropertyField() {
|
private PropertyField() {
|
||||||
super("", 0);
|
super("", 0);
|
||||||
this.price = 0;
|
this.price = 0;
|
||||||
|
@ -4,10 +4,19 @@ import com.jme3.network.serializing.Serializable;
|
|||||||
|
|
||||||
import pp.monopoly.game.server.Player;
|
import pp.monopoly.game.server.Player;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A field that represents the Teststrecke field on the board.
|
||||||
|
*/
|
||||||
@Serializable
|
@Serializable
|
||||||
public class TestStreckeField extends Field{
|
public class TestStreckeField extends Field{
|
||||||
|
/**
|
||||||
|
* The amount of money on the field.
|
||||||
|
*/
|
||||||
private int money;
|
private int money;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new TestStreckeField.
|
||||||
|
*/
|
||||||
TestStreckeField() {
|
TestStreckeField() {
|
||||||
super("Teststrecke", 20);
|
super("Teststrecke", 20);
|
||||||
}
|
}
|
||||||
@ -17,10 +26,20 @@ public class TestStreckeField extends Field{
|
|||||||
player.visit(this);
|
player.visit(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds money to the field.
|
||||||
|
*
|
||||||
|
* @param amount the amount of money to add
|
||||||
|
*/
|
||||||
public void addMoney(int amount) {
|
public void addMoney(int amount) {
|
||||||
money += amount;
|
money += amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collects the money from the field and resets the money to 0.
|
||||||
|
*
|
||||||
|
* @return the amount of money collected
|
||||||
|
*/
|
||||||
public int collectMoney() {
|
public int collectMoney() {
|
||||||
int tmp = money;
|
int tmp = money;
|
||||||
money = 0;
|
money = 0;
|
||||||
|
@ -4,9 +4,16 @@ import com.jme3.network.serializing.Serializable;
|
|||||||
|
|
||||||
import pp.monopoly.game.server.Player;
|
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
|
@Serializable
|
||||||
public class WacheField extends Field{
|
public class WacheField extends Field{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for the WacheField.
|
||||||
|
*/
|
||||||
WacheField() {
|
WacheField() {
|
||||||
super("Wache", 30);
|
super("Wache", 30);
|
||||||
}
|
}
|
||||||
|
@ -96,6 +96,8 @@ public class MonopolyServer implements MessageListener<HostedConnection>, Connec
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts the Monopolys server.
|
* Starts the Monopolys server.
|
||||||
|
*
|
||||||
|
* @param args the command line arguments
|
||||||
*/
|
*/
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
new MonopolyServer().run();
|
new MonopolyServer().run();
|
||||||
|
Loading…
Reference in New Issue
Block a user