From c3a33b4402e526ce6a28a770f22ba26635004a7b Mon Sep 17 00:00:00 2001 From: Johannes Schmelz Date: Thu, 21 Nov 2024 15:30:34 +0100 Subject: [PATCH] added house prices and color to buildingfields --- .../monopoly/model/fields/BoardManager.java | 44 +++++++++---------- .../model/fields/BuildingProperty.java | 43 +++++++++++++++--- .../pp/monopoly/model/fields/FieldColor.java | 37 ++++++++++++++++ 3 files changed, 96 insertions(+), 28 deletions(-) create mode 100644 Projekte/monopoly/model/src/main/java/pp/monopoly/model/fields/FieldColor.java diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/model/fields/BoardManager.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/model/fields/BoardManager.java index 0cb7c0c..769a148 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/model/fields/BoardManager.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/model/fields/BoardManager.java @@ -26,45 +26,45 @@ public class BoardManager { ArrayList fields = new ArrayList<>(); fields.add(new GoField()); - fields.add(new BuildingProperty("Gym", 1, 600, 20)); + fields.add(new BuildingProperty("Gym", 1, 600, 20, 500, FieldColor.BROWN)); fields.add(new EventField("Hausfeier", 2)); - fields.add(new BuildingProperty("Sportplatz", 3, 600, 40)); + fields.add(new BuildingProperty("Sportplatz", 3, 600, 40, 500, FieldColor.BROWN)); fields.add(new FineField("Diszi", 4, 2000)); fields.add(new GateField("Südtor", 5)); - fields.add(new BuildingProperty("Studium+", 6, 1000, 60)); + fields.add(new BuildingProperty("Studium+", 6, 1000, 60, 500, FieldColor.BLUE_LIGHT)); fields.add(new EventField("Üvas", 7)); - fields.add(new BuildingProperty("PhysikHörsaal", 8, 1000, 60)); - fields.add(new BuildingProperty("Audimax", 9, 1200, 80)); + fields.add(new BuildingProperty("PhysikHörsaal", 8, 1000, 60, 500, FieldColor.BLUE_LIGHT)); + fields.add(new BuildingProperty("Audimax", 9, 1200, 80, 500, FieldColor.BLUE_LIGHT)); fields.add(new GulagField()); - fields.add(new BuildingProperty("99er", 11, 1400, 100)); + fields.add(new BuildingProperty("99er", 11, 1400, 100, 1000, FieldColor.PINK)); fields.add(new FoodField("Brandl", 12)); - fields.add(new BuildingProperty("12er", 13, 1400, 100)); - fields.add(new BuildingProperty("23er", 14, 1600, 120)); + fields.add(new BuildingProperty("12er", 13, 1400, 100, 1000, FieldColor.PINK)); + fields.add(new BuildingProperty("23er", 14, 1600, 120, 1000, FieldColor.PINK)); fields.add(new GateField("HauptWache", 15)); - fields.add(new BuildingProperty("Schwimmhalle", 16, 1800, 140)); - fields.add(new BuildingProperty("CISM-Bahn", 17, 1800, 140)); + fields.add(new BuildingProperty("Schwimmhalle", 16, 1800, 140, 1000, FieldColor.ORANGE)); + fields.add(new BuildingProperty("CISM-Bahn", 17, 1800, 140, 1000, FieldColor.ORANGE)); fields.add(new EventField("Marine-Welcome-Party", 18)); - fields.add(new BuildingProperty("Kletterturm", 19, 2000, 160)); + fields.add(new BuildingProperty("Kletterturm", 19, 2000, 160, 1000, FieldColor.ORANGE)); fields.add(new TestStreckeField()); - fields.add(new BuildingProperty("StudFBer C", 21, 2200, 180)); + fields.add(new BuildingProperty("StudFBer C", 21, 2200, 180, 1500, FieldColor.RED)); fields.add(new EventField("Üvas", 22)); - fields.add(new BuildingProperty("StudFBer B", 23, 2200, 180)); - fields.add(new BuildingProperty("StudFBer A", 24, 2400, 200)); + fields.add(new BuildingProperty("StudFBer B", 23, 2200, 180, 1500, FieldColor.RED)); + fields.add(new BuildingProperty("StudFBer A", 24, 2400, 200, 1500, FieldColor.RED)); fields.add(new GateField("Nordtor", 25)); - fields.add(new BuildingProperty("Cascada", 26, 2600, 220)); - fields.add(new BuildingProperty("Fakultätsgebäude", 27, 2600, 220)); + fields.add(new BuildingProperty("Cascada", 26, 2600, 220, 1500, FieldColor.YELLOW)); + fields.add(new BuildingProperty("Fakultätsgebäude", 27, 2600, 220, 1500, FieldColor.YELLOW)); fields.add(new FoodField("Truppenküche", 28)); - fields.add(new BuildingProperty("Prüfungsamt", 29, 2800, 240)); + fields.add(new BuildingProperty("Prüfungsamt", 29, 2800, 240, 1500, FieldColor.YELLOW)); fields.add(new WacheField()); - fields.add(new BuildingProperty("Feuerwehr", 31, 3000, 260)); - fields.add(new BuildingProperty("SanZ", 32, 300, 260)); + fields.add(new BuildingProperty("Feuerwehr", 31, 3000, 260, 2000, FieldColor.GREEN)); + fields.add(new BuildingProperty("SanZ", 32, 300, 260, 2000, FieldColor.GREEN)); fields.add(new EventField("Maibock", 33)); - fields.add(new BuildingProperty("Rechenzentrum", 34, 3200, 280)); + fields.add(new BuildingProperty("Rechenzentrum", 34, 3200, 280, 2000, FieldColor.GREEN)); fields.add(new GateField("Osttor", 35)); fields.add(new EventField("Üvas", 36)); - fields.add(new BuildingProperty("2er", 37, 3500, 350)); + fields.add(new BuildingProperty("2er", 37, 3500, 350, 2000, FieldColor.BLUE_DARK)); fields.add(new FineField("EZM", 38, 1000)); - fields.add(new BuildingProperty("20er", 39, 4000, 500)); + fields.add(new BuildingProperty("20er", 39, 4000, 500, 2000, FieldColor.BLUE_DARK)); return fields; } diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/model/fields/BuildingProperty.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/model/fields/BuildingProperty.java index ae73cb8..9967c7f 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/model/fields/BuildingProperty.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/model/fields/BuildingProperty.java @@ -1,30 +1,42 @@ package pp.monopoly.model.fields; +import java.util.ArrayList; +import java.util.List; + import pp.monopoly.game.server.Player; public class BuildingProperty extends PropertyField { private int houses; private boolean hotel = false; + private final int housePrice; + private final FieldColor color; + private final int rentFactor1 = 5; + private final int rentFactor2 = 15; + private final int rentFactor3 = 40; + private final int rentFactor4 = 55; + private final int rentFactorHotel = 70; - BuildingProperty(String name, int id, int price, int rent) { + BuildingProperty(String name, int id, int price, int rent, int housePrice, FieldColor color) { super(name, id, price, rent); + this.housePrice = housePrice; + this.color = color; } @Override public int calcRent() { if (hotel) { - return (int) Math.round(rent*70/10)*10; + return (int) Math.round(rent*rentFactorHotel/10)*10; } switch (houses) { case 1: - return (int) Math.round(rent*5/10)*10; + return (int) Math.round(rent*rentFactor1/10)*10; case 2: - return (int) Math.round(rent*15/10)*10; + return (int) Math.round(rent*rentFactor2/10)*10; case 3: - return (int) Math.round(rent*40/10)*10; + return (int) Math.round(rent*rentFactor3/10)*10; case 4: - return (int) Math.round(rent*55/10)*10; + return (int) Math.round(rent*rentFactor4/10)*10; default: return rent; @@ -67,4 +79,23 @@ public class BuildingProperty extends PropertyField { public void accept(Player player) { player.visit(this); } + + public List getAllRent() { + List list = new ArrayList<>(); + list.add(rent); + list.add((int) Math.round(rent*rentFactor1/10)*10); + list.add((int) Math.round(rent*rentFactor2/10)*10); + list.add((int) Math.round(rent*rentFactor3/10)*10); + list.add((int) Math.round(rent*rentFactor4/10)*10); + list.add((int) Math.round(rent*rentFactorHotel/10)*10); + return list; + } + + public FieldColor getColor() { + return color; + } + + public int getHousePrice() { + return housePrice; + } } diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/model/fields/FieldColor.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/model/fields/FieldColor.java new file mode 100644 index 0000000..3102e25 --- /dev/null +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/model/fields/FieldColor.java @@ -0,0 +1,37 @@ +package pp.monopoly.model.fields; + +import com.jme3.math.ColorRGBA; + +/** + * Enum representing eight distinct colors for properties in the game. + */ +enum FieldColor { + BROWN(new ColorRGBA(148 / 255f, 86 / 255f, 57 / 255f, 1)), + GREEN(new ColorRGBA(30 / 255f, 179 / 255f, 90 / 255f, 1)), + YELLOW(new ColorRGBA(252 / 255f, 241 / 255f, 1 / 255f, 1)), + BLUE_LIGHT(new ColorRGBA(170 / 255f, 223 / 255f, 246 / 255f, 1)), + PINK(new ColorRGBA(214 / 255f, 60 / 255f, 153 / 255f, 1)), + ORANGE(new ColorRGBA(244 / 255f, 147 / 255f, 32 / 255f, 1)), + RED(new ColorRGBA(232 / 255f, 27 / 255f, 30 / 255f, 1)), + BLUE_DARK(new ColorRGBA(2 / 255f, 112 / 255f, 191 / 255f, 1)); + + private final ColorRGBA color; + + /** + * Constructs a FieldColor with the specified ColorRGBA value. + * + * @param color the ColorRGBA value associated with the field color + */ + FieldColor(ColorRGBA color) { + this.color = color; + } + + /** + * Gets the ColorRGBA value of the field color. + * + * @return the ColorRGBA value + */ + public ColorRGBA getColor() { + return color; + } +}