category star wars day fix

main
s.eser 2024-04-30 11:01:16 +02:00
parent c992825659
commit dd752e9064
11 changed files with 29 additions and 17 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -30,6 +30,7 @@ public class Box {
private int categoryBigStreet; private int categoryBigStreet;
private int categoryYahtzee; private int categoryYahtzee;
private int categoryChance; private int categoryChance;
private int categoryStarWarsDay;
private int categoryR2D2; private int categoryR2D2;
private Integer setCategoryTripleMatch; private Integer setCategoryTripleMatch;
@ -39,6 +40,7 @@ public class Box {
private Integer setCategoryBigStreet; private Integer setCategoryBigStreet;
private Integer setCategoryYahtzee; private Integer setCategoryYahtzee;
private Integer setCategoryChance; private Integer setCategoryChance;
private Integer setCategoryStarWarsDay;
private Integer setCategoryR2D2; private Integer setCategoryR2D2;
private int counter[] = new int[8]; private int counter[] = new int[8];
@ -119,6 +121,7 @@ public class Box {
sumOfAllNumbers += diceNumbers.get(i); sumOfAllNumbers += diceNumbers.get(i);
} }
categoryStarWarsDay = (counter[3]*4) + (counter[4]*5);
categoryChance = sumOfAllNumbers; categoryChance = sumOfAllNumbers;
for (int i = 0; i < counter.length; i++) { for (int i = 0; i < counter.length; i++) {
@ -195,6 +198,8 @@ public class Box {
res.add("categoryYahtzee: " + categoryYahtzee); res.add("categoryYahtzee: " + categoryYahtzee);
if (categoryChance > 0 && (setCategoryChance == null)) if (categoryChance > 0 && (setCategoryChance == null))
res.add("categoryChance: " + categoryChance); res.add("categoryChance: " + categoryChance);
if (categoryStarWarsDay > 0 && (setCategoryStarWarsDay == null))
res.add("categoryStarWarsDays: " + categoryStarWarsDay);
if (categoryR2D2 > 0 && (setCategoryR2D2 == null)) if (categoryR2D2 > 0 && (setCategoryR2D2 == null))
res.add("categoryR2D2: " + categoryR2D2); res.add("categoryR2D2: " + categoryR2D2);
@ -229,6 +234,8 @@ public class Box {
res.add("categoryYahtzee: " + categoryYahtzee); res.add("categoryYahtzee: " + categoryYahtzee);
if (setCategoryChance == null) if (setCategoryChance == null)
res.add("categoryChance: " + categoryChance); res.add("categoryChance: " + categoryChance);
if (setCategoryStarWarsDay == null)
res.add("categoryStarWarsDay: " + categoryStarWarsDay);
if (setCategoryR2D2 == null && savedGamemode.equals("Special8")) if (setCategoryR2D2 == null && savedGamemode.equals("Special8"))
res.add("categoryR2D2: " + categoryR2D2); res.add("categoryR2D2: " + categoryR2D2);
} }
@ -288,6 +295,8 @@ public class Box {
} else if (option.equals("categoryChance")) } else if (option.equals("categoryChance"))
setCategoryChance = categoryChance; setCategoryChance = categoryChance;
else if (option.equals("categoryStarWarsDay"))
setCategoryStarWarsDay = categoryStarWarsDay;
else if (option.equals("categoryR2D2")) else if (option.equals("categoryR2D2"))
setCategoryR2D2 = categoryR2D2; setCategoryR2D2 = categoryR2D2;
@ -295,7 +304,7 @@ public class Box {
public void resetOptions() { public void resetOptions() {
categoryOne = categoryTwo = categoryThree = categoryFour = categoryFive = categorySix = categorySeven = categoryEight = categoryTripleMatch = categoryFourOfAKind = categoryFullHouse = categorySmallStreet = categoryBigStreet = categoryYahtzee = categoryChance = categoryR2D2 = 0; categoryOne = categoryTwo = categoryThree = categoryFour = categoryFive = categorySix = categorySeven = categoryEight = categoryTripleMatch = categoryFourOfAKind = categoryFullHouse = categorySmallStreet = categoryBigStreet = categoryYahtzee = categoryChance = categoryStarWarsDay = categoryR2D2 = 0;
Arrays.fill(counter, 0); Arrays.fill(counter, 0);
@ -319,6 +328,7 @@ public class Box {
setCategoryBigStreet != null && setCategoryBigStreet != null &&
setCategoryYahtzee != null && setCategoryYahtzee != null &&
setCategoryChance != null && setCategoryChance != null &&
setCategoryStarWarsDay != null &&
setCategoryR2D2 != null; setCategoryR2D2 != null;
else else
@ -334,7 +344,8 @@ public class Box {
setCategorySmallStreet != null && setCategorySmallStreet != null &&
setCategoryBigStreet != null && setCategoryBigStreet != null &&
setCategoryYahtzee != null && setCategoryYahtzee != null &&
setCategoryChance != null; setCategoryChance != null &&
setCategoryStarWarsDay != null;
} }
@ -345,14 +356,14 @@ public class Box {
+ setCategorySix + setCategorySeven + setCategoryEight + setCategoryTripleMatch + setCategorySix + setCategorySeven + setCategoryEight + setCategoryTripleMatch
+ setCategoryFourOfAKind + setCategoryFourOfAKind
+ setCategoryFullHouse + setCategorySmallStreet + setCategoryBigStreet + setCategoryYahtzee + setCategoryFullHouse + setCategorySmallStreet + setCategoryBigStreet + setCategoryYahtzee
+ setCategoryChance + setCategoryChance + setCategoryStarWarsDay
+ setCategoryR2D2; + setCategoryR2D2;
else else
return setCategoryOne + setCategoryTwo + setCategoryThree + setCategoryFour + setCategoryFive return setCategoryOne + setCategoryTwo + setCategoryThree + setCategoryFour + setCategoryFive
+ setCategorySix + setCategoryTripleMatch + setCategoryFourOfAKind + setCategorySix + setCategoryTripleMatch + setCategoryFourOfAKind
+ setCategoryFullHouse + setCategorySmallStreet + setCategoryBigStreet + setCategoryYahtzee + setCategoryFullHouse + setCategorySmallStreet + setCategoryBigStreet + setCategoryYahtzee
+ setCategoryChance; + setCategoryChance + setCategoryStarWarsDay;
} }
@ -377,6 +388,7 @@ public class Box {
sb.append("categoryBigStreet: " + nullCheck(setCategoryBigStreet) + "\n"); sb.append("categoryBigStreet: " + nullCheck(setCategoryBigStreet) + "\n");
sb.append("categoryYahtzee: " + nullCheck(setCategoryYahtzee) + "\n"); sb.append("categoryYahtzee: " + nullCheck(setCategoryYahtzee) + "\n");
sb.append("categoryChance: " + nullCheck(setCategoryChance) + "\n"); sb.append("categoryChance: " + nullCheck(setCategoryChance) + "\n");
sb.append("categoryStarWarsDay: " + nullCheck(setCategoryStarWarsDay) + "\n");
sb.append("categoryR2D2: " + nullCheck(setCategoryR2D2) + "\n"); sb.append("categoryR2D2: " + nullCheck(setCategoryR2D2) + "\n");
} else { } else {
sb.append("categoryOne: " + nullCheck(setCategoryOne) + "\n"); sb.append("categoryOne: " + nullCheck(setCategoryOne) + "\n");
@ -393,6 +405,7 @@ public class Box {
sb.append("categoryBigStreet: " + nullCheck(setCategoryBigStreet) + "\n"); sb.append("categoryBigStreet: " + nullCheck(setCategoryBigStreet) + "\n");
sb.append("categoryYahtzee: " + nullCheck(setCategoryYahtzee) + "\n"); sb.append("categoryYahtzee: " + nullCheck(setCategoryYahtzee) + "\n");
sb.append("categoryChance: " + nullCheck(setCategoryChance) + "\n"); sb.append("categoryChance: " + nullCheck(setCategoryChance) + "\n");
sb.append("categoryStarWarsDay: " + nullCheck(setCategoryStarWarsDay) + "\n");
} }
return sb.toString(); return sb.toString();

View File

@ -9,7 +9,7 @@ public class Dice {
public Dice(String gamemode) { public Dice(String gamemode) {
this.savedGamemode = gamemode; this.savedGamemode = gamemode;
if (gamemode.equals("Normal") || gamemode.equals("StarWarsDay")) if (gamemode.equals("Normal"))
this.diceNumber = ((int) (Math.random() * 6)) + 1; this.diceNumber = ((int) (Math.random() * 6)) + 1;
else if (gamemode.equals("Special8")) else if (gamemode.equals("Special8"))
this.diceNumber = ((int) (Math.random() * 8)) + 1; this.diceNumber = ((int) (Math.random() * 8)) + 1;
@ -22,7 +22,7 @@ public class Dice {
public void rerollDice() { public void rerollDice() {
if (this.savedGamemode.equals("Normal") || this.savedGamemode.equals("StarWarsDay")) if (this.savedGamemode.equals("Normal"))
this.diceNumber = ((int) (Math.random() * 6)) + 1; this.diceNumber = ((int) (Math.random() * 6)) + 1;
else if (this.savedGamemode.equals("Special8")) else if (this.savedGamemode.equals("Special8"))
this.diceNumber = ((int) (Math.random() * 8)) + 1; this.diceNumber = ((int) (Math.random() * 8)) + 1;

View File

@ -207,7 +207,7 @@ public class YahtzeeGame {
try { try {
if (returnTotalPoints(player) > Integer.parseInt(highscores[0][2])) { if (returnTotalPoints(player) >= Integer.parseInt(highscores[0][2])) {
for (int i = 2; i >= 0; i--) { for (int i = 2; i >= 0; i--) {
highscoreMem1 = highscores[0][i]; highscoreMem1 = highscores[0][i];
@ -236,7 +236,7 @@ public class YahtzeeGame {
highscores[9][i] = highscoreMem1; highscores[9][i] = highscoreMem1;
} }
} else if (returnTotalPoints(player) > Integer.parseInt(highscores[1][2])) { } else if (returnTotalPoints(player) >= Integer.parseInt(highscores[1][2])) {
for (int i = 2; i >= 0; i--) { for (int i = 2; i >= 0; i--) {
highscoreMem2 = highscores[1][i]; highscoreMem2 = highscores[1][i];
@ -262,7 +262,7 @@ public class YahtzeeGame {
highscores[8][i] = highscoreMem2; highscores[8][i] = highscoreMem2;
highscores[9][i] = highscoreMem1; highscores[9][i] = highscoreMem1;
} }
} else if (returnTotalPoints(player) > Integer.parseInt(highscores[2][2])) { } else if (returnTotalPoints(player) >= Integer.parseInt(highscores[2][2])) {
for (int i = 2; i >= 0; i--) { for (int i = 2; i >= 0; i--) {
highscoreMem1 = highscores[2][i]; highscoreMem1 = highscores[2][i];
@ -286,7 +286,7 @@ public class YahtzeeGame {
highscores[8][i] = highscoreMem2; highscores[8][i] = highscoreMem2;
highscores[9][i] = highscoreMem1; highscores[9][i] = highscoreMem1;
} }
} else if (returnTotalPoints(player) > Integer.parseInt(highscores[3][2])) { } else if (returnTotalPoints(player) >= Integer.parseInt(highscores[3][2])) {
for (int i = 2; i >= 0; i--) { for (int i = 2; i >= 0; i--) {
highscoreMem2 = highscores[3][i]; highscoreMem2 = highscores[3][i];
@ -308,7 +308,7 @@ public class YahtzeeGame {
highscores[8][i] = highscoreMem2; highscores[8][i] = highscoreMem2;
highscores[9][i] = highscoreMem1; highscores[9][i] = highscoreMem1;
} }
} else if (returnTotalPoints(player) > Integer.parseInt(highscores[4][2])) { } else if (returnTotalPoints(player) >= Integer.parseInt(highscores[4][2])) {
for (int i = 2; i >= 0; i--) { for (int i = 2; i >= 0; i--) {
highscoreMem1 = highscores[4][i]; highscoreMem1 = highscores[4][i];
@ -328,7 +328,7 @@ public class YahtzeeGame {
highscores[8][i] = highscoreMem2; highscores[8][i] = highscoreMem2;
highscores[9][i] = highscoreMem1; highscores[9][i] = highscoreMem1;
} }
} else if (returnTotalPoints(player) > Integer.parseInt(highscores[5][2])) { } else if (returnTotalPoints(player) >= Integer.parseInt(highscores[5][2])) {
for (int i = 2; i >= 0; i--) { for (int i = 2; i >= 0; i--) {
highscoreMem2 = highscores[5][i]; highscoreMem2 = highscores[5][i];
@ -346,7 +346,7 @@ public class YahtzeeGame {
highscores[8][i] = highscoreMem2; highscores[8][i] = highscoreMem2;
highscores[9][i] = highscoreMem1; highscores[9][i] = highscoreMem1;
} }
} else if (returnTotalPoints(player) > Integer.parseInt(highscores[6][2])) { } else if (returnTotalPoints(player) >= Integer.parseInt(highscores[6][2])) {
for (int i = 2; i >= 0; i--) { for (int i = 2; i >= 0; i--) {
highscoreMem1 = highscores[6][i]; highscoreMem1 = highscores[6][i];
@ -362,7 +362,7 @@ public class YahtzeeGame {
highscores[8][i] = highscoreMem2; highscores[8][i] = highscoreMem2;
highscores[9][i] = highscoreMem1; highscores[9][i] = highscoreMem1;
} }
} else if (returnTotalPoints(player) > Integer.parseInt(highscores[7][2])) { } else if (returnTotalPoints(player) >= Integer.parseInt(highscores[7][2])) {
for (int i = 2; i >= 0; i--) { for (int i = 2; i >= 0; i--) {
highscoreMem2 = highscores[7][i]; highscoreMem2 = highscores[7][i];
@ -376,7 +376,7 @@ public class YahtzeeGame {
highscores[8][i] = highscoreMem2; highscores[8][i] = highscoreMem2;
highscores[9][i] = highscoreMem1; highscores[9][i] = highscoreMem1;
} }
} else if (returnTotalPoints(player) > Integer.parseInt(highscores[8][2])) { } else if (returnTotalPoints(player) >= Integer.parseInt(highscores[8][2])) {
for (int i = 2; i >= 0; i--) { for (int i = 2; i >= 0; i--) {
highscoreMem1 = highscores[8][i]; highscoreMem1 = highscores[8][i];
@ -388,7 +388,7 @@ public class YahtzeeGame {
highscores[8][i] = "" + LocalDate.now(); highscores[8][i] = "" + LocalDate.now();
highscores[9][i] = highscoreMem1; highscores[9][i] = highscoreMem1;
} }
} else if (returnTotalPoints(player) > Integer.parseInt(highscores[9][2])) { } else if (returnTotalPoints(player) >= Integer.parseInt(highscores[9][2])) {
for (int i = 2; i >= 0; i--) { for (int i = 2; i >= 0; i--) {
if (i == 2) if (i == 2)

View File

@ -49,7 +49,6 @@ public class TUI {
System.out.println("\nChoose your gamemode: "); System.out.println("\nChoose your gamemode: ");
System.out.println(">Normal"); System.out.println(">Normal");
System.out.println(">StarWarsDay");
System.out.println(">Special8"); System.out.println(">Special8");
game.setGamemode(sc.nextLine()); game.setGamemode(sc.nextLine());
System.out.println("\nAmount of players: "); System.out.println("\nAmount of players: ");