From 25305760c5dfcda6dbe5594379baa12d4bc2ff46 Mon Sep 17 00:00:00 2001 From: Johannes Schmelz Date: Tue, 12 Nov 2024 22:32:55 +0100 Subject: [PATCH] added Player --- .../java/pp/monopoly/game/server/Player.java | 115 +++++++++++++++++- 1 file changed, 113 insertions(+), 2 deletions(-) diff --git a/Projekte/monopoly/model/src/main/java/pp/monopoly/game/server/Player.java b/Projekte/monopoly/model/src/main/java/pp/monopoly/game/server/Player.java index 67b6791..c4f240a 100644 --- a/Projekte/monopoly/model/src/main/java/pp/monopoly/game/server/Player.java +++ b/Projekte/monopoly/model/src/main/java/pp/monopoly/game/server/Player.java @@ -7,9 +7,120 @@ package pp.monopoly.game.server; +import java.util.List; + +import com.jme3.math.ColorRGBA; + +import pp.monopoly.model.FieldVisitor; +import pp.monopoly.model.Figure; +import pp.monopoly.model.fields.BuildingProperty; +import pp.monopoly.model.fields.EventField; +import pp.monopoly.model.fields.FoodField; +import pp.monopoly.model.fields.GateField; +import pp.monopoly.model.fields.GoField; +import pp.monopoly.model.fields.GulagField; +import pp.monopoly.model.fields.PropertyField; +import pp.monopoly.model.fields.TestStreckeField; +import pp.monopoly.model.fields.WacheField; + /** * Class representing a player */ -public class Player { - +public class Player implements FieldVisitor{ + private String name; + private ColorRGBA color; + private int accountBalance = 0; + private Figure figure; + private List properties; + private int getOutOfJailCard; + private int fieldID; + + Player(String name, ColorRGBA color) { + this.name = name; + this.color = color; + figure = new Figure(); + } + + public int move(int steps){ + return fieldID += steps; + } + + public void buyProperty(PropertyField property) { + properties.add(property); + } + + public void sellProperty(PropertyField property) { + properties.remove(property); + } + + public void payRent(int amount) { + accountBalance -= amount; + } + + public void earnMoney(int amount) { + accountBalance += amount; + } + + public String getName() { + return name; + } + + public void addJailCard() { + getOutOfJailCard++; + } + + public void removeJailCard() { + if (getOutOfJailCard ==0) { + throw new IllegalStateException("Has no JailCard to remove"); + } + getOutOfJailCard--; + } + + @Override + public Void visit(BuildingProperty field) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'visit'"); + } + + @Override + public Void visit(FoodField field) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'visit'"); + } + + @Override + public Void visit(GateField field) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'visit'"); + } + + @Override + public Void visit(GulagField field) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'visit'"); + } + + @Override + public Void visit(TestStreckeField field) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'visit'"); + } + + @Override + public Void visit(EventField field) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'visit'"); + } + + @Override + public Void visit(WacheField field) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'visit'"); + } + + @Override + public Void visit(GoField field) { + accountBalance += 4000; + return null; + } }