First final version

main
selim 2024-04-30 01:44:50 +02:00
parent d99f72daea
commit b0d4e94f2f
8 changed files with 40 additions and 28 deletions

View File

@ -1 +0,0 @@
1

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1 +0,0 @@
1

View File

@ -56,37 +56,37 @@ public class Box {
if (diceNumbers.get(i) == 1) if (diceNumbers.get(i) == 1)
this.categoryOne += diceNumbers.get(i); this.categoryOne += diceNumbers.get(i);
} }
else if (diceNumbers.contains(2)) if (diceNumbers.contains(2))
for (int i = 0; i < diceNumbers.size(); i++) { for (int i = 0; i < diceNumbers.size(); i++) {
if (diceNumbers.get(i) == 2) if (diceNumbers.get(i) == 2)
this.categoryTwo += diceNumbers.get(i); this.categoryTwo += diceNumbers.get(i);
} }
else if (diceNumbers.contains(3)) if (diceNumbers.contains(3))
for (int i = 0; i < diceNumbers.size(); i++) { for (int i = 0; i < diceNumbers.size(); i++) {
if (diceNumbers.get(i) == 3) if (diceNumbers.get(i) == 3)
this.categoryThree += diceNumbers.get(i); this.categoryThree += diceNumbers.get(i);
} }
else if (diceNumbers.contains(4)) if (diceNumbers.contains(4))
for (int i = 0; i < diceNumbers.size(); i++) { for (int i = 0; i < diceNumbers.size(); i++) {
if (diceNumbers.get(i) == 4) if (diceNumbers.get(i) == 4)
this.categoryFour += diceNumbers.get(i); this.categoryFour += diceNumbers.get(i);
} }
else if (diceNumbers.contains(5)) if (diceNumbers.contains(5))
for (int i = 0; i < diceNumbers.size(); i++) { for (int i = 0; i < diceNumbers.size(); i++) {
if (diceNumbers.get(i) == 5) if (diceNumbers.get(i) == 5)
this.categoryFive += diceNumbers.get(i); this.categoryFive += diceNumbers.get(i);
} }
else if (diceNumbers.contains(6)) if (diceNumbers.contains(6))
for (int i = 0; i < diceNumbers.size(); i++) { for (int i = 0; i < diceNumbers.size(); i++) {
if (diceNumbers.get(i) == 6) if (diceNumbers.get(i) == 6)
this.categorySix += diceNumbers.get(i); this.categorySix += diceNumbers.get(i);
} }
else if (diceNumbers.contains(7)) if (diceNumbers.contains(7))
for (int i = 0; i < diceNumbers.size(); i++) { for (int i = 0; i < diceNumbers.size(); i++) {
if (diceNumbers.get(i) == 7) if (diceNumbers.get(i) == 7)
this.categorySeven += diceNumbers.get(i); this.categorySeven += diceNumbers.get(i);
} }
else if (diceNumbers.contains(8)) if (diceNumbers.contains(8))
for (int i = 0; i < diceNumbers.size(); i++) { for (int i = 0; i < diceNumbers.size(); i++) {
if (diceNumbers.get(i) == 8) if (diceNumbers.get(i) == 8)
this.categoryEight += diceNumbers.get(i); this.categoryEight += diceNumbers.get(i);
@ -138,14 +138,14 @@ public class Box {
for (int i = 0; i < 6; i++) { 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; categorySmallStreet = 30;
} }
for (int i = 0; i < 5; i++) { 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; categoryBigStreet = 40;
} }
@ -340,11 +340,19 @@ public class Box {
public int returnTotalPoints() { public int returnTotalPoints() {
if (savedGamemode.equals("Special8"))
return setCategoryOne + setCategoryTwo + setCategoryThree + setCategoryFour + setCategoryFive return setCategoryOne + setCategoryTwo + setCategoryThree + setCategoryFour + setCategoryFive
+ setCategorySix + setCategorySeven + setCategoryEight + setCategoryTripleMatch + setCategoryFourOfAKind + setCategorySix + setCategorySeven + setCategoryEight + setCategoryTripleMatch
+ setCategoryFourOfAKind
+ setCategoryFullHouse + setCategorySmallStreet + setCategoryBigStreet + setCategoryYahtzee + setCategoryFullHouse + setCategorySmallStreet + setCategoryBigStreet + setCategoryYahtzee
+ setCategoryChance + setCategoryChance
+ setCategoryR2D2; + setCategoryR2D2;
else
return setCategoryOne + setCategoryTwo + setCategoryThree + setCategoryFour + setCategoryFive
+ setCategorySix + setCategoryTripleMatch + setCategoryFourOfAKind
+ setCategoryFullHouse + setCategorySmallStreet + setCategoryBigStreet + setCategoryYahtzee
+ setCategoryChance;
} }

View File

@ -100,9 +100,14 @@ public class YahtzeeGame {
} }
public ArrayList<String> getAllOptionsEvaluated(int player) { public void evaluateAllOptions(int player) {
players.get(player).box.evaluateBoxOptions(players.get(player).hand.getLockedInDiceNumbers());
}
public ArrayList<String> getAllOptions(int player) {
players.get(player).box.evaluateBoxOptions(players.get(player).hand.getAllDiceNumbers());
return players.get(player).box.getAllOptions(); return players.get(player).box.getAllOptions();
} }
@ -119,9 +124,9 @@ public class YahtzeeGame {
StringBuilder sb = new StringBuilder(); 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][0] = mem[0];
highscores[i][1] = mem[1]; highscores[i][1] = mem[1];
highscores[i][2] = mem[2]; highscores[i][2] = mem[2];
System.out.println("test");
} else { } else {
highscores[i][0] = "___"; highscores[i][0] = "___";
highscores[i][1] = "___"; highscores[i][1] = "___";
@ -398,10 +403,10 @@ public class YahtzeeGame {
PrintWriter out = new PrintWriter(new FileWriter("src/csv/highscores.csv", false)); PrintWriter out = new PrintWriter(new FileWriter("src/csv/highscores.csv", false));
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
for (int s = 0; s < 3; s++) {
out.print((i + 1) + ": " + LocalDate.now() + ": " + players.get(player).name + ": " out.print(LocalDate.now() + ": " + players.get(player).name + ": "
+ returnTotalPoints(player)); + returnTotalPoints(player));
}
out.println(); out.println();
} }
@ -426,8 +431,8 @@ public class YahtzeeGame {
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
sb.append((i + 1) + ": " + refreshHighscoreList()[i][0]); sb.append((i + 1) + ": " + refreshHighscoreList()[i][0]);
sb.append(": " + refreshHighscoreList()[i][1]); sb.append(" " + refreshHighscoreList()[i][1]);
sb.append(": " + refreshHighscoreList()[i][2] + "\n"); sb.append(" " + refreshHighscoreList()[i][2] + "\n");
} }
@ -439,7 +444,7 @@ public class YahtzeeGame {
PrintWriter out = new PrintWriter(new FileWriter("src/csv/highscores.csv", false)); PrintWriter out = new PrintWriter(new FileWriter("src/csv/highscores.csv", false));
out.println(""); out.print("");
out.close(); out.close();

View File

@ -102,6 +102,7 @@ public class TUI {
System.out.println("\n\nLocked in dices: " + game.getLockedInDiceNumbers(i)); System.out.println("\n\nLocked in dices: " + game.getLockedInDiceNumbers(i));
System.out.println("Done locking in... Here are your options: "); System.out.println("Done locking in... Here are your options: ");
game.evaluateAllOptions(i);
System.out.println(game.optionsPrinted(i)); System.out.println(game.optionsPrinted(i));
System.out.println("Which option you want to select?: "); System.out.println("Which option you want to select?: ");
game.selectOption(i, sc.nextLine()); game.selectOption(i, sc.nextLine());