diff --git a/bin/domain/Hand.class b/bin/domain/Hand.class index 8767774..6ae2bdc 100644 Binary files a/bin/domain/Hand.class and b/bin/domain/Hand.class differ diff --git a/bin/facade/YahtzeeGame.class b/bin/facade/YahtzeeGame.class index 530daef..1b610c7 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 fe70f11..33b0eb2 100644 Binary files a/bin/ui/TUI.class and b/bin/ui/TUI.class differ diff --git a/src/domain/Hand.java b/src/domain/Hand.java index 310a672..b394453 100644 --- a/src/domain/Hand.java +++ b/src/domain/Hand.java @@ -27,6 +27,7 @@ public class Hand { if (this.dices.get(i).getDiceNumber() == dice) { this.dices.remove(i); this.lockedInDices.add(new Dice(savedGamemode, dice)); + return; } } @@ -40,6 +41,21 @@ public class Hand { } } + public void autoLockInDices() { + + int mem = this.dices.size(); + + if (leftRolls == 0) { + + for (int i = 0; i < mem; i++) { + lockInDice(dices.get(0).getDiceNumber()); + } + + System.out.println("No rolls left, auto locking in all left dices..."); + } + + } + public int getLockedInDiceAmount() { if (lockedInDices != null) @@ -57,11 +73,6 @@ public class Hand { leftRolls--; - if (this.leftRolls == 1) - for (int i = 0; i < this.dices.size(); i++) { - lockInDice(this.dices.get(i).getDiceNumber()); - } - } public ArrayList getAllDiceNumbers() { diff --git a/src/facade/YahtzeeGame.java b/src/facade/YahtzeeGame.java index 3278e7f..3f1f7af 100644 --- a/src/facade/YahtzeeGame.java +++ b/src/facade/YahtzeeGame.java @@ -76,6 +76,12 @@ public class YahtzeeGame { } + public void autoLockInDices(int player) { + + players.get(player).hand.autoLockInDices(); + + } + public boolean allDicesLockedIn(int player) { return players.get(player).hand.getLockedInDiceAmount() == 5; @@ -157,13 +163,17 @@ public class YahtzeeGame { String highscores[][] = new String[10][3]; Scanner sc = new Scanner(new File("src/csv/highscores.csv")); + String mem[] = new String[3]; for (int i = 0; i < 10; i++) { if (sc.hasNextLine()) { - highscores[i][0] = sc.next(); - highscores[i][1] = sc.next(); - highscores[i][2] = sc.nextLine(); + + mem = sc.nextLine().split(" "); + highscores[i][0] = mem[0]; + highscores[i][1] = mem[1]; + highscores[i][2] = mem[2]; + System.out.println("test"); } else { highscores[i][0] = "___"; highscores[i][1] = "___"; diff --git a/src/ui/TUI.java b/src/ui/TUI.java index d773683..7d452dd 100644 --- a/src/ui/TUI.java +++ b/src/ui/TUI.java @@ -84,20 +84,24 @@ public class TUI { System.out.println("Free dices: " + game.getFreeDiceNumbers(i)); System.out.println("Locked in dices: " + game.getLockedInDiceNumbers(i)); - System.out.println( - "Type in which free dices you want to keep \n(seperated by space, type 'none' if you dont want to keep any): "); - choice = sc.nextLine(); - game.lockInDices(i, choice.split(" ")); - if ((game.getLeftRolls(i)) != 1) - System.out.println("\n" + game.getLeftRolls(i) + " rolls left"); - else - System.out.println("\n" + game.getLeftRolls(i) + " roll left"); + game.autoLockInDices(i); + if (!game.noMoreRolls(i)) { + System.out.println( + "Type in which free dices you want to keep \n(seperated by space, type 'none' if you dont want to keep any): "); + choice = sc.nextLine(); + game.lockInDices(i, choice.split(" ")); + + if ((game.getLeftRolls(i)) != 1) + System.out.println("\n" + game.getLeftRolls(i) + " rolls left"); + else if ((game.getLeftRolls(i)) == 1) + System.out.println("\n" + game.getLeftRolls(i) + " roll left"); + } } + System.out.println("\n\nLocked in dices: " + game.getLockedInDiceNumbers(i)); System.out.println("Done locking in... Here are your options: "); - System.out.println("Locked in dices: " + game.getLockedInDiceNumbers(i)); System.out.println(game.optionsPrinted(i)); System.out.println("Which option you want to select?: "); game.selectOption(i, sc.nextLine());