From 3de31de9f7edd9cd802e5519a5913543aea317f4 Mon Sep 17 00:00:00 2001 From: Johannes Schmelz Date: Sat, 23 Nov 2024 12:46:20 +0100 Subject: [PATCH] bind playercolor to join order --- .../java/pp/monopoly/game/server/Player.java | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 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 a8701cb..7208209 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 @@ -31,7 +31,6 @@ import pp.monopoly.model.fields.WacheField; public class Player implements FieldVisitor{ private final int id; private String name; - private PlayerColor color; private int accountBalance = 0; private Figure figure; private List properties; @@ -63,6 +62,20 @@ public class Player implements FieldVisitor{ 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{ 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