diff --git a/bin/facade/YahtzeeGame.class b/bin/facade/YahtzeeGame.class index 9836209..48bd58a 100644 Binary files a/bin/facade/YahtzeeGame.class and b/bin/facade/YahtzeeGame.class differ diff --git a/bin/ui/TUI.class b/bin/ui/TUI.class index eb2cafb..0f845fa 100644 Binary files a/bin/ui/TUI.class and b/bin/ui/TUI.class differ diff --git a/src/domain/Player.java b/src/domain/Player.java index 96bfdac..ad39041 100644 --- a/src/domain/Player.java +++ b/src/domain/Player.java @@ -22,4 +22,5 @@ public class Player { } + } diff --git a/src/facade/YahtzeeGame.java b/src/facade/YahtzeeGame.java index 5e09331..369c3b1 100644 --- a/src/facade/YahtzeeGame.java +++ b/src/facade/YahtzeeGame.java @@ -1,6 +1,5 @@ package facade; -import java.io.FileNotFoundException; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; @@ -10,6 +9,8 @@ import java.util.Scanner; import domain.Player; + + public class YahtzeeGame { public int playerCount; @@ -17,19 +18,33 @@ public class YahtzeeGame { public String savedGamemode; - public YahtzeeGame(int playerCount, String gamemode, String... names) { + public YahtzeeGame() { + } + + public void setPlayercount(int playerCount){ this.playerCount = playerCount; - this.savedGamemode = gamemode; - + + } + public void setPlayerNames(String... names){ for (int i = 0; i < this.playerCount; i++) { this.players.add(new Player(names[i], this.savedGamemode)); } + } - + + public String getPlayerName(int player){ + return players.get(player).name; + } + + public void setGamemode(String gamemode){ + this.savedGamemode = gamemode; + + } + public void rollDices(int player) { players.get(player).hand.rollDices(); @@ -87,6 +102,17 @@ public class YahtzeeGame { } + public boolean gameOverAll(){ + int counter = 0; + + for(int i = 0; iPlay"); + System.out.println(">Highscores"); + choice = sc.nextLine(); - if(High) + if(choice.equals("Highscores")){ + System.out.println(game.showHighscores()); + System.out.println(">Return"); + System.out.println(">Delete"); + choice = sc.nextLine(); + if(choice.equals("Return")) + break; + else if(choice.equals("Delete")){ + System.out.println("Are you sure you want to delete the Highscore file?\nAs a confirmation type: 'I AM SURE': "); + choice = sc.nextLine(); + if(choice.equals("I AM SURE")){ + game.deleteHighscores(); + System.out.println("Highscore file got deleted...\nReturning to the main menu..."); + } + else{ + System.out.println("Highscore file not deleted...\nReturning to the main menu..."); + } + + } + } + + + else if(choice.equals("Play")){ + + System.out.println("Choose your gamemode: "); + System.out.println(">Normal"); + System.out.println(">StarWarsDay"); + System.out.println(">Special8"); + game.setGamemode(sc.nextLine()); + System.out.println("Amount of players: "); + System.out.println(">1-6"); + game.setPlayercount(sc.nextInt()); + System.out.println("Type in the player names, lock in each name with Enter: "); + System.out.println(">ex. Lucas [Enter] William [Enter] Lena [Enter]"); + + String playerNames[] = new String[game.playerCount]; + for(int i = 0; i < game.playerCount; i++){ + playerNames[i] = sc.nextLine(); + } + + game.setPlayerNames(playerNames); + + while (!game.gameOverAll()) { + + for(int i = 0; i