bind playercolor to join order

This commit is contained in:
Johannes Schmelz 2024-11-23 12:46:20 +01:00
parent 7252259ab3
commit 3de31de9f7

View File

@ -31,7 +31,6 @@ import pp.monopoly.model.fields.WacheField;
public class Player implements FieldVisitor<Void>{
private final int id;
private String name;
private PlayerColor color;
private int accountBalance = 0;
private Figure figure;
private List<PropertyField> properties;
@ -63,6 +62,20 @@ public class Player implements FieldVisitor<Void>{
this.handler = handler;
}
public PlayerColor getColor() {
switch ((id%6)+1) {
case 1: return PlayerColor.BLUE;
case 2: return PlayerColor.GREEN_DARK;
case 3: return PlayerColor.GREEN_LIGHT;
case 4: return PlayerColor.PINK;
case 5: return PlayerColor.RED;
case 6: return PlayerColor.YELLOW;
default:
return null;
}
}
/**
* Set the name of the Player
* @param name the new name
@ -71,14 +84,6 @@ public class Player implements FieldVisitor<Void>{
this.name = name;
}
/**
* Set the PlayerColor
* @param color the color to be set to
*/
void setColor(PlayerColor color) {
this.color = color;
}
/**
* Returns this players id
* @return th eid of this player