2024-04-29 21:06:04 +02:00
|
|
|
package fassade;
|
|
|
|
|
|
|
|
import domain.Game;
|
|
|
|
import domain.Player;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.Random;
|
|
|
|
|
|
|
|
public class KniffelSystem {
|
|
|
|
ArrayList<String> playerColors;
|
|
|
|
Game game;
|
|
|
|
public KniffelSystem(){
|
|
|
|
game = new Game();
|
|
|
|
playerColors = new ArrayList<>(Arrays.asList(
|
|
|
|
"\u001B[31m", // Quelle 2 Anfang
|
|
|
|
"\u001B[32m", //
|
|
|
|
"\u001B[34m", //
|
|
|
|
"\u001B[33m", //
|
|
|
|
"\u001B[36m")); // Quelle 2 Ende
|
|
|
|
}
|
|
|
|
|
2024-04-29 21:17:51 +02:00
|
|
|
|
2024-04-29 21:06:04 +02:00
|
|
|
public String scorebaordData(){
|
|
|
|
return "Scoreboard - TODO";
|
|
|
|
}
|
|
|
|
|
2024-04-29 21:17:51 +02:00
|
|
|
|
2024-04-29 21:06:04 +02:00
|
|
|
public String addPlayer(int playerNumber, String name) {
|
|
|
|
String playerColor = colorPicker(playerNumber);
|
|
|
|
Player playerToAdd = new Player(playerNumber, name, playerColor, 0);
|
|
|
|
game.addPlayer(playerToAdd);
|
|
|
|
|
|
|
|
return changePlayerNameColor(name, playerColor);
|
|
|
|
}
|
|
|
|
|
2024-04-29 21:17:51 +02:00
|
|
|
|
2024-04-29 21:06:04 +02:00
|
|
|
private String changePlayerNameColor(String name, String color){
|
|
|
|
String ANSI_RESET = "\u001B[0m";
|
|
|
|
|
|
|
|
return String.format(color + name + ANSI_RESET);
|
|
|
|
}
|
|
|
|
|
2024-04-29 21:17:51 +02:00
|
|
|
|
2024-04-29 21:06:04 +02:00
|
|
|
private String colorPicker(int playerNumber){
|
|
|
|
if (playerNumber == 1){
|
|
|
|
return "\u001B[35m"; // Quelle 2
|
|
|
|
}
|
|
|
|
|
|
|
|
Random rand = new Random(); // Quelle 1 Anfang
|
|
|
|
int randomIndex = rand.nextInt(playerColors.size()); //
|
|
|
|
return playerColors.remove(randomIndex); // Quelle 1 Ende
|
|
|
|
}
|
|
|
|
}
|