diff --git a/bin/csv/highscores.csv b/bin/csv/highscores.csv index 8b13789..e69de29 100644 --- a/bin/csv/highscores.csv +++ b/bin/csv/highscores.csv @@ -1 +0,0 @@ - diff --git a/bin/domain/Box.class b/bin/domain/Box.class index bb0735c..6bf0fb6 100644 Binary files a/bin/domain/Box.class and b/bin/domain/Box.class differ diff --git a/bin/facade/YahtzeeGame.class b/bin/facade/YahtzeeGame.class index 1b610c7..6f05a14 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 33b0eb2..b139d48 100644 Binary files a/bin/ui/TUI.class and b/bin/ui/TUI.class differ diff --git a/src/csv/highscores.csv b/src/csv/highscores.csv index 8b13789..e69de29 100644 --- a/src/csv/highscores.csv +++ b/src/csv/highscores.csv @@ -1 +0,0 @@ - diff --git a/src/domain/Box.java b/src/domain/Box.java index 24d1743..492bb46 100644 --- a/src/domain/Box.java +++ b/src/domain/Box.java @@ -56,37 +56,37 @@ public class Box { if (diceNumbers.get(i) == 1) this.categoryOne += diceNumbers.get(i); } - else if (diceNumbers.contains(2)) + if (diceNumbers.contains(2)) for (int i = 0; i < diceNumbers.size(); i++) { if (diceNumbers.get(i) == 2) this.categoryTwo += diceNumbers.get(i); } - else if (diceNumbers.contains(3)) + if (diceNumbers.contains(3)) for (int i = 0; i < diceNumbers.size(); i++) { if (diceNumbers.get(i) == 3) this.categoryThree += diceNumbers.get(i); } - else if (diceNumbers.contains(4)) + if (diceNumbers.contains(4)) for (int i = 0; i < diceNumbers.size(); i++) { if (diceNumbers.get(i) == 4) this.categoryFour += diceNumbers.get(i); } - else if (diceNumbers.contains(5)) + if (diceNumbers.contains(5)) for (int i = 0; i < diceNumbers.size(); i++) { if (diceNumbers.get(i) == 5) this.categoryFive += diceNumbers.get(i); } - else if (diceNumbers.contains(6)) + if (diceNumbers.contains(6)) for (int i = 0; i < diceNumbers.size(); i++) { if (diceNumbers.get(i) == 6) this.categorySix += diceNumbers.get(i); } - else if (diceNumbers.contains(7)) + if (diceNumbers.contains(7)) for (int i = 0; i < diceNumbers.size(); i++) { if (diceNumbers.get(i) == 7) this.categorySeven += diceNumbers.get(i); } - else if (diceNumbers.contains(8)) + if (diceNumbers.contains(8)) for (int i = 0; i < diceNumbers.size(); i++) { if (diceNumbers.get(i) == 8) this.categoryEight += diceNumbers.get(i); @@ -138,14 +138,14 @@ public class Box { for (int i = 0; i < 6; i++) { - if (counter[i] == 1 && counter[i + 1] == 1 && counter[i + 2] == 1) + if (counter[i] >= 1 && counter[i + 1] >= 1 && counter[i + 2] >= 1) categorySmallStreet = 30; } for (int i = 0; i < 5; i++) { - if (counter[i] == 1 && counter[i + 1] == 1 && counter[i + 2] == 1 && counter[i + 3] == 1) + if (counter[i] >= 1 && counter[i + 1] >= 1 && counter[i + 2] >= 1 && counter[i + 3] >= 1) categoryBigStreet = 40; } @@ -340,11 +340,19 @@ public class Box { public int returnTotalPoints() { - return setCategoryOne + setCategoryTwo + setCategoryThree + setCategoryFour + setCategoryFive - + setCategorySix + setCategorySeven + setCategoryEight + setCategoryTripleMatch + setCategoryFourOfAKind - + setCategoryFullHouse + setCategorySmallStreet + setCategoryBigStreet + setCategoryYahtzee - + setCategoryChance - + setCategoryR2D2; + if (savedGamemode.equals("Special8")) + return setCategoryOne + setCategoryTwo + setCategoryThree + setCategoryFour + setCategoryFive + + setCategorySix + setCategorySeven + setCategoryEight + setCategoryTripleMatch + + setCategoryFourOfAKind + + setCategoryFullHouse + setCategorySmallStreet + setCategoryBigStreet + setCategoryYahtzee + + setCategoryChance + + setCategoryR2D2; + else + + return setCategoryOne + setCategoryTwo + setCategoryThree + setCategoryFour + setCategoryFive + + setCategorySix + setCategoryTripleMatch + setCategoryFourOfAKind + + setCategoryFullHouse + setCategorySmallStreet + setCategoryBigStreet + setCategoryYahtzee + + setCategoryChance; } diff --git a/src/facade/YahtzeeGame.java b/src/facade/YahtzeeGame.java index 3f1f7af..f44051b 100644 --- a/src/facade/YahtzeeGame.java +++ b/src/facade/YahtzeeGame.java @@ -100,9 +100,14 @@ public class YahtzeeGame { } - public ArrayList getAllOptionsEvaluated(int player) { + public void evaluateAllOptions(int player) { + + players.get(player).box.evaluateBoxOptions(players.get(player).hand.getLockedInDiceNumbers()); + + } + + public ArrayList getAllOptions(int player) { - players.get(player).box.evaluateBoxOptions(players.get(player).hand.getAllDiceNumbers()); return players.get(player).box.getAllOptions(); } @@ -119,9 +124,9 @@ public class YahtzeeGame { StringBuilder sb = new StringBuilder(); - for (int i = 0; i < getAllOptionsEvaluated(player).size(); i++) { + for (int i = 0; i < getAllOptions(player).size(); i++) { - sb.append(getAllOptionsEvaluated(player).get(i) + "\n"); + sb.append(getAllOptions(player).get(i) + "\n"); } @@ -173,7 +178,7 @@ public class YahtzeeGame { 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] = "___"; @@ -398,10 +403,10 @@ public class YahtzeeGame { PrintWriter out = new PrintWriter(new FileWriter("src/csv/highscores.csv", false)); for (int i = 0; i < 10; i++) { - for (int s = 0; s < 3; s++) { - out.print((i + 1) + ": " + LocalDate.now() + ": " + players.get(player).name + ": " - + returnTotalPoints(player)); - } + + out.print(LocalDate.now() + ": " + players.get(player).name + ": " + + returnTotalPoints(player)); + out.println(); } @@ -426,8 +431,8 @@ public class YahtzeeGame { for (int i = 0; i < 10; i++) { sb.append((i + 1) + ": " + refreshHighscoreList()[i][0]); - sb.append(": " + refreshHighscoreList()[i][1]); - sb.append(": " + refreshHighscoreList()[i][2] + "\n"); + sb.append(" " + refreshHighscoreList()[i][1]); + sb.append(" " + refreshHighscoreList()[i][2] + "\n"); } @@ -439,7 +444,7 @@ public class YahtzeeGame { PrintWriter out = new PrintWriter(new FileWriter("src/csv/highscores.csv", false)); - out.println(""); + out.print(""); out.close(); diff --git a/src/ui/TUI.java b/src/ui/TUI.java index 7d452dd..b02bcb9 100644 --- a/src/ui/TUI.java +++ b/src/ui/TUI.java @@ -102,6 +102,7 @@ public class TUI { System.out.println("\n\nLocked in dices: " + game.getLockedInDiceNumbers(i)); System.out.println("Done locking in... Here are your options: "); + game.evaluateAllOptions(i); System.out.println(game.optionsPrinted(i)); System.out.println("Which option you want to select?: "); game.selectOption(i, sc.nextLine());