added Player

This commit is contained in:
Johannes Schmelz 2024-11-12 22:32:55 +01:00
parent 29a56f42a8
commit 25305760c5

View File

@ -7,9 +7,120 @@
package pp.monopoly.game.server; 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 * Class representing a player
*/ */
public class Player { public class Player implements FieldVisitor<Void>{
private String name;
private ColorRGBA color;
private int accountBalance = 0;
private Figure figure;
private List<PropertyField> 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;
}
} }