added house prices and color to buildingfields

This commit is contained in:
Johannes Schmelz 2024-11-21 15:30:34 +01:00
parent e12f00aad6
commit c3a33b4402
3 changed files with 96 additions and 28 deletions

View File

@ -26,45 +26,45 @@ public class BoardManager {
ArrayList<Field> 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;
}

View File

@ -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<Integer> getAllRent() {
List<Integer> 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;
}
}

View File

@ -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;
}
}