2024-04-29 21:06:04 +02:00
|
|
|
package tui;
|
|
|
|
|
|
|
|
import fassade.KniffelSystem;
|
|
|
|
|
|
|
|
import java.util.Scanner;
|
|
|
|
|
|
|
|
public class TUI {
|
|
|
|
static KniffelSystem gameSystem;
|
|
|
|
static Scanner sc = new Scanner(System.in);
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
System.out.println("Welcome to the PR2 Kniffel game!");
|
2024-04-30 12:46:42 +02:00
|
|
|
|
|
|
|
// while (true){
|
|
|
|
// mainMenuOutput();
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// DEV:
|
|
|
|
gameSystem = new KniffelSystem();
|
|
|
|
gameLoop();
|
2024-04-29 21:06:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private static int mainMenuOutput(){
|
|
|
|
System.out.println("What do you want to do?");
|
|
|
|
System.out.println("1 - Play");
|
2024-04-30 12:46:42 +02:00
|
|
|
System.out.println("2 - See leaderboard");
|
2024-04-29 21:06:04 +02:00
|
|
|
System.out.println("3 - Exit");
|
|
|
|
System.out.print("> ");
|
|
|
|
String mainMenuUserInput = sc.nextLine().toLowerCase();
|
|
|
|
|
|
|
|
|
|
|
|
if ((mainMenuUserInput.equals("1"))
|
|
|
|
|| (mainMenuUserInput.equals("play"))){
|
|
|
|
mainMenuPlay();
|
|
|
|
System.out.println("play"); // TEST
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else if ((mainMenuUserInput.equals("2"))
|
2024-04-30 12:46:42 +02:00
|
|
|
|| (mainMenuUserInput.equals("see leaderboard"))
|
2024-04-29 21:06:04 +02:00
|
|
|
|| (mainMenuUserInput.equals("see"))
|
2024-04-30 12:46:42 +02:00
|
|
|
|| (mainMenuUserInput.equals("leaderboard"))){
|
|
|
|
System.out.println("leaderboard"); // TEST
|
|
|
|
mainMenuLeaderBoard();
|
2024-04-29 21:06:04 +02:00
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
System.out.println("exit"); // TEST
|
|
|
|
mainMenuExit();
|
|
|
|
return 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private static void mainMenuPlay(){
|
|
|
|
gameSystem = new KniffelSystem();
|
|
|
|
|
|
|
|
System.out.println("How many players are you? (1-6)");
|
|
|
|
System.out.print("> ");
|
|
|
|
String mainMenuPlayAmountPlayersInput = sc.nextLine().toLowerCase();
|
|
|
|
|
|
|
|
int amountPlayers = Integer.parseInt(mainMenuPlayAmountPlayersInput);
|
2024-04-30 12:46:42 +02:00
|
|
|
|
2024-04-29 21:06:04 +02:00
|
|
|
for (int i = 0; i < amountPlayers; i++){
|
|
|
|
System.out.printf("Player %d: ", i + 1);
|
|
|
|
System.out.println("Enter your name: ");
|
|
|
|
System.out.print("> ");
|
|
|
|
String playerName = sc.nextLine();
|
|
|
|
|
|
|
|
String coloredPlayerName = gameSystem.addPlayer(i+1, playerName);
|
|
|
|
System.out.printf("Welcome %s! \n\n", coloredPlayerName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-04-30 12:46:42 +02:00
|
|
|
private static void gameLoop(){
|
|
|
|
gameSystem.createTestPlayers(6);
|
|
|
|
String[] playerStrings = gameSystem.getAllPlayerStrings();
|
|
|
|
|
|
|
|
for (String player : playerStrings){
|
|
|
|
System.out.println(player);
|
|
|
|
}
|
|
|
|
|
|
|
|
gameSystem.rollDice(40);
|
|
|
|
}
|
2024-04-29 21:06:04 +02:00
|
|
|
|
2024-04-30 12:46:42 +02:00
|
|
|
private static void mainMenuLeaderBoard(){
|
|
|
|
gameSystem = new KniffelSystem(); // Scorboard System
|
|
|
|
System.out.println(gameSystem.LeaderBaordData()); // TODO
|
2024-04-29 21:06:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private static void mainMenuExit(){
|
|
|
|
System.out.println("Do you really want to exit? (Y/n)");
|
|
|
|
System.out.print("> ");
|
|
|
|
String mainMenuExitUserInput = sc.nextLine().toLowerCase();
|
|
|
|
|
|
|
|
if ((mainMenuExitUserInput.equals("y"))
|
|
|
|
|| (mainMenuExitUserInput.equals("yes"))
|
|
|
|
|| mainMenuExitUserInput.isBlank()){
|
|
|
|
System.out.print("Exiting, see you next time!");
|
|
|
|
System.exit(0);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
System.out.println("Returning to main menu");
|
|
|
|
System.out.println();
|
|
|
|
mainMenuOutput();
|
|
|
|
}
|
|
|
|
|
|
|
|
System.out.printf("|%s| \nIs blank? %b\n", mainMenuExitUserInput, mainMenuExitUserInput.isBlank()); // TEST
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|