added Fields

This commit is contained in:
Johannes Schmelz 2024-11-12 22:35:41 +01:00
parent 65c85aacf0
commit 81731247c7
10 changed files with 241 additions and 0 deletions

View File

@ -0,0 +1,59 @@
package pp.monopoly.model.fields;
import pp.monopoly.game.server.Player;
public class BuildingProperty extends PropertyField {
private int houses;
private boolean hotel = false;
BuildingProperty(String name, int id, int price, int rent) {
super(name, id, price, rent);
}
@Override
protected int calcRent() {
if(!hotel) {
return rent*houses;
} else {
return rent*6;
}
}
public boolean buildHouse() {
if (houses < 4) {
houses++;
return true;
}
return false;
}
public boolean buildHotel() {
if (hotel) {
return false;
}
hotel = true;
return true;
}
public boolean removeHouse() {
if (houses == 0) {
return false;
}
houses--;
return true;
}
public boolean removeHotel() {
if (!hotel) {
return false;
}
hotel = false;
return true;
}
@Override
public void accept(Player player) {
player.visit(this);
}
}

View File

@ -0,0 +1,23 @@
package pp.monopoly.model.fields;
import pp.monopoly.game.server.Player;
import pp.monopoly.model.card.Card;
import pp.monopoly.model.card.DeckHelper;
public class EventField extends Field{
public EventField(int id) {
super("EreignissFeld", id);
}
@Override
public void accept(Player player) {
player.visit(this);
}
public Card drawCard() {
return DeckHelper.drawCard();
}
}

View File

@ -0,0 +1,19 @@
package pp.monopoly.model.fields;
import pp.monopoly.game.server.Player;
abstract class Field {
protected final String name;
protected final int id;
protected Field(String name, int id) {
this.name = name;
this.id= id;
}
public abstract void accept(Player player);
public int getId() {
return id;
}
}

View File

@ -0,0 +1,21 @@
package pp.monopoly.model.fields;
import pp.monopoly.game.server.Player;
public class FoodField extends PropertyField {
public FoodField(String name, int id) {
super(name, id, 1500,0);
}
@Override
protected int calcRent() {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'calcRent'");
}
@Override
public void accept(Player player) {
player.visit(this);
}
}

View File

@ -0,0 +1,21 @@
package pp.monopoly.model.fields;
import pp.monopoly.game.server.Player;
public class GateField extends PropertyField{
GateField(String name, int id) {
super(name, id, 2000, 25);
}
@Override
protected int calcRent() {
return rent;
}
@Override
public void accept(Player player) {
player.visit(this);
}
}

View File

@ -0,0 +1,15 @@
package pp.monopoly.model.fields;
import pp.monopoly.game.server.Player;
public class GoField extends Field{
public GoField() {
super("Monatsgehalt", 0);
}
@Override
public void accept(Player player) {
player.visit(this);
}
}

View File

@ -0,0 +1,18 @@
package pp.monopoly.model.fields;
import pp.monopoly.game.server.Player;
public class GulagField extends Field{
private int bailCost = 500;
GulagField() {
super("Gulag", 10);
}
@Override
public void accept(Player player) {
player.visit(this);
}
}

View File

@ -0,0 +1,25 @@
package pp.monopoly.model.fields;
import pp.monopoly.game.server.Player;
public abstract class PropertyField extends Field {
private final int price;
protected final int rent;
private Player owner;
private boolean mortaged = false;
protected PropertyField(String name, int id, int price, int rent) {
super(name, id);
this.price = price;
this.rent = rent;
}
protected abstract int calcRent();
public int getPrice() {
return price;
}
}

View File

@ -0,0 +1,24 @@
package pp.monopoly.model.fields;
import pp.monopoly.game.server.Player;
public class TestStreckeField extends Field{
private int money;
TestStreckeField() {
super("Teststrecke", 20);
}
@Override
public void accept(Player player) {
player.visit(this);
}
public void addMoney(int amount) {
money += amount;
}
public int collectMoney() {
return money = 0;
}
}

View File

@ -0,0 +1,16 @@
package pp.monopoly.model.fields;
import pp.monopoly.game.server.Player;
public class WacheField extends Field{
public WacheField() {
super("Wache", 30);
}
@Override
public void accept(Player player) {
player.visit(this);
}
}