refactor PlayerColor

fixed default playermodel selection
This commit is contained in:
Johannes Schmelz
2024-12-03 12:07:09 +01:00
parent 09ea8a046e
commit 1f37eb9962
4 changed files with 46 additions and 90 deletions

View File

@@ -90,7 +90,7 @@ public class Player implements FieldVisitor<Void>{
return figure;
}
public PlayerColor getColor() {
public static PlayerColor getColor(int id) {
switch ((id%6)+1) {
case 1: return PlayerColor.CYAN;
case 2: return PlayerColor.YELLOW;

View File

@@ -6,22 +6,24 @@ import com.jme3.math.ColorRGBA;
* Enum representing six distinct colors for players in the game.
*/
public enum PlayerColor {
CYAN(new ColorRGBA(1 / 255f, 190 / 255f, 254 / 255f, 1)),
YELLOW(new ColorRGBA(255 / 255f, 255 / 255f, 0 / 255f, 1)),
RED(new ColorRGBA(255 / 255f, 0 / 255f, 0 / 255f, 1)),
PINK(new ColorRGBA(255 / 255f, 77 / 255f, 166 / 255f, 1)),
GREEN(new ColorRGBA(0 / 255f, 204 / 255f, 0 / 255f, 1)),
PURPLE(new ColorRGBA(143 / 255f, 0 / 255f, 255 / 255f, 1));
CYAN(new ColorRGBA(1 / 255f, 190 / 255f, 254 / 255f, 1), "Cyan"),
YELLOW(new ColorRGBA(255 / 255f, 255 / 255f, 0 / 255f, 1), "Gelb"),
RED(new ColorRGBA(255 / 255f, 0 / 255f, 0 / 255f, 1), "Rot"),
PINK(new ColorRGBA(255 / 255f, 77 / 255f, 166 / 255f, 1), "Pink"),
GREEN(new ColorRGBA(0 / 255f, 204 / 255f, 0 / 255f, 1), "Grün"),
PURPLE(new ColorRGBA(143 / 255f, 0 / 255f, 255 / 255f, 1), "Lila");
private final ColorRGBA color;
private final String colorName;
/**
* Constructs a PlayerColor with the specified ColorRGBA value.
*
* @param color the ColorRGBA value associated with the player color
*/
PlayerColor(ColorRGBA color) {
PlayerColor(ColorRGBA color, String colorName) {
this.color = color;
this.colorName = colorName;
}
/**
@@ -32,4 +34,13 @@ public enum PlayerColor {
public ColorRGBA getColor() {
return color;
}
/**
* Gets the Name of the Color
*
* @return a String with re corresponing name
*/
public String getColorName() {
return colorName;
}
}