final version

main
s.eser 2024-04-30 12:32:29 +02:00
parent 4acfb7cb72
commit e2d9e58c35
6 changed files with 165 additions and 85 deletions

View File

@ -0,0 +1,10 @@
2024-04-30: Selim: 172
___: ___: 0
___: ___: 0
___: ___: 0
___: ___: 0
___: ___: 0
___: ___: 0
___: ___: 0
___: ___: 0
___: ___: 0
1 2024-04-30: Selim: 172
1 2024-04-30: Selim: 172
2 ___: ___: 0
3 ___: ___: 0
4 ___: ___: 0
5 ___: ___: 0
6 ___: ___: 0
7 ___: ___: 0
8 ___: ___: 0
9 ___: ___: 0
10 ___: ___: 0

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,10 @@
2024-04-30: Selim: 172
___: ___: 0
___: ___: 0
___: ___: 0
___: ___: 0
___: ___: 0
___: ___: 0
___: ___: 0
___: ___: 0
___: ___: 0
1 2024-04-30: Selim: 172
1 2024-04-30: Selim: 172
2 ___: ___: 0
3 ___: ___: 0
4 ___: ___: 0
5 ___: ___: 0
6 ___: ___: 0
7 ___: ___: 0
8 ___: ___: 0
9 ___: ___: 0
10 ___: ___: 0

View File

@ -23,6 +23,8 @@ public class Box {
private Integer setCategorySeven; private Integer setCategorySeven;
private Integer setCategoryEight; private Integer setCategoryEight;
private Integer upperBoxScore;
private int categoryTripleMatch; private int categoryTripleMatch;
private int categoryFourOfAKind; private int categoryFourOfAKind;
private int categoryFullHouse; private int categoryFullHouse;
@ -43,6 +45,10 @@ public class Box {
private Integer setCategoryStarWarsDay; private Integer setCategoryStarWarsDay;
private Integer setCategoryR2D2; private Integer setCategoryR2D2;
private Integer lowerBoxScore;
private Integer totalScore;
private Integer bonus; private Integer bonus;
private int counter[] = new int[8]; private int counter[] = new int[8];
private String savedGamemode; private String savedGamemode;
@ -171,75 +177,75 @@ public class Box {
ArrayList<String> res = new ArrayList<>(); ArrayList<String> res = new ArrayList<>();
if (categoryOne > 0 && (setCategoryOne == null)) if (categoryOne > 0 && (setCategoryOne == null))
res.add("categoryOne: " + categoryOne); res.add("One: " + categoryOne);
if (categoryTwo > 0 && (setCategoryTwo == null)) if (categoryTwo > 0 && (setCategoryTwo == null))
res.add("categoryTwo: " + categoryTwo); res.add("Two: " + categoryTwo);
if (categoryThree > 0 && (setCategoryThree == null)) if (categoryThree > 0 && (setCategoryThree == null))
res.add("categoryThree: " + categoryThree); res.add("Three: " + categoryThree);
if (categoryFour > 0 && (setCategoryFour == null)) if (categoryFour > 0 && (setCategoryFour == null))
res.add("categoryFour: " + categoryFour); res.add("Four: " + categoryFour);
if (categoryFive > 0 && (setCategoryFive == null)) if (categoryFive > 0 && (setCategoryFive == null))
res.add("categoryFive: " + categoryFive); res.add("Five: " + categoryFive);
if (categorySix > 0 && (setCategorySix == null)) if (categorySix > 0 && (setCategorySix == null))
res.add("categorySix: " + categorySix); res.add("Six: " + categorySix);
if (categorySeven > 0 && (setCategorySeven == null)) if (categorySeven > 0 && (setCategorySeven == null))
res.add("categorySeven: " + categorySeven); res.add("Seven: " + categorySeven);
if (categoryEight > 0 && (setCategoryEight == null)) if (categoryEight > 0 && (setCategoryEight == null))
res.add("categoryEight: " + categoryEight); res.add("Eight: " + categoryEight);
if (categoryTripleMatch > 0 && (setCategoryTripleMatch == null)) if (categoryTripleMatch > 0 && (setCategoryTripleMatch == null))
res.add("categoryTripleMatch: " + categoryTripleMatch); res.add("TripleMatch: " + categoryTripleMatch);
if (categoryFourOfAKind > 0 && (setCategoryFourOfAKind == null)) if (categoryFourOfAKind > 0 && (setCategoryFourOfAKind == null))
res.add("categoryFourOfAKind: " + categoryFourOfAKind); res.add("FourOfAKind: " + categoryFourOfAKind);
if (categoryFullHouse > 0 && (setCategoryFullHouse == null)) if (categoryFullHouse > 0 && (setCategoryFullHouse == null))
res.add("categoryFullHouse: " + categoryFullHouse); res.add("FullHouse: " + categoryFullHouse);
if (categorySmallStreet > 0 && (setCategorySmallStreet == null)) if (categorySmallStreet > 0 && (setCategorySmallStreet == null))
res.add("categorySmallStreet: " + categorySmallStreet); res.add("SmallStreet: " + categorySmallStreet);
if (categoryBigStreet > 0 && (setCategoryBigStreet == null)) if (categoryBigStreet > 0 && (setCategoryBigStreet == null))
res.add("categoryBigStreet: " + categoryBigStreet); res.add("BigStreet: " + categoryBigStreet);
if (categoryYahtzee > 0) if (categoryYahtzee > 0)
res.add("categoryYahtzee: " + categoryYahtzee); res.add("Yahtzee: " + categoryYahtzee);
if (categoryChance > 0 && (setCategoryChance == null)) if (categoryChance > 0 && (setCategoryChance == null))
res.add("categoryChance: " + categoryChance); res.add("Chance: " + categoryChance);
if (categoryStarWarsDay > 0 && (setCategoryStarWarsDay == null)) if (categoryStarWarsDay > 0 && (setCategoryStarWarsDay == null))
res.add("categoryStarWarsDay: " + categoryStarWarsDay); res.add("StarWarsDay: " + categoryStarWarsDay);
if (categoryR2D2 > 0 && (setCategoryR2D2 == null)) if (categoryR2D2 > 0 && (setCategoryR2D2 == null))
res.add("categoryR2D2: " + categoryR2D2); res.add("R2D2: " + categoryR2D2);
if (res.isEmpty()) { if (res.isEmpty()) {
if (setCategoryOne == null) if (setCategoryOne == null)
res.add("categoryOne: " + categoryOne); res.add("One: " + categoryOne);
if (setCategoryTwo == null) if (setCategoryTwo == null)
res.add("categoryTwo: " + categoryTwo); res.add("Two: " + categoryTwo);
if (setCategoryThree == null) if (setCategoryThree == null)
res.add("categoryThree: " + categoryThree); res.add("Three: " + categoryThree);
if (setCategoryFour == null) if (setCategoryFour == null)
res.add("categoryFour: " + categoryFour); res.add("Four: " + categoryFour);
if (setCategoryFive == null) if (setCategoryFive == null)
res.add("categoryFive: " + categoryFive); res.add("Five: " + categoryFive);
if (setCategorySix == null) if (setCategorySix == null)
res.add("categorySix: " + categorySix); res.add("Six: " + categorySix);
if (setCategorySeven == null && savedGamemode.equals("Special8")) if (setCategorySeven == null && savedGamemode.equals("Special8"))
res.add("categorySeven: " + categorySeven); res.add("Seven: " + categorySeven);
if (setCategoryEight == null && savedGamemode.equals("Special8")) if (setCategoryEight == null && savedGamemode.equals("Special8"))
res.add("categoryEight: " + categoryEight); res.add("Eight: " + categoryEight);
if (setCategoryTripleMatch == null) if (setCategoryTripleMatch == null)
res.add("categoryTrippleMatch: " + categoryTripleMatch); res.add("TripleMatch: " + categoryTripleMatch);
if (setCategoryFourOfAKind == null) if (setCategoryFourOfAKind == null)
res.add("categoryFourOfAKind: " + categoryFourOfAKind); res.add("FourOfAKind: " + categoryFourOfAKind);
if (setCategoryFullHouse == null) if (setCategoryFullHouse == null)
res.add("categoryFullHouse: " + categoryFullHouse); res.add("FullHouse: " + categoryFullHouse);
if (setCategorySmallStreet == null) if (setCategorySmallStreet == null)
res.add("categorySmallStreet: " + categorySmallStreet); res.add("SmallStreet: " + categorySmallStreet);
if (setCategoryBigStreet == null) if (setCategoryBigStreet == null)
res.add("categoryBigStreet: " + categoryBigStreet); res.add("BigStreet: " + categoryBigStreet);
if (setCategoryYahtzee == null) if (setCategoryYahtzee == null)
res.add("categoryYahtzee: " + categoryYahtzee); res.add("Yahtzee: " + categoryYahtzee);
if (setCategoryChance == null) if (setCategoryChance == null)
res.add("categoryChance: " + categoryChance); res.add("Chance: " + categoryChance);
if (setCategoryStarWarsDay == null) if (setCategoryStarWarsDay == null)
res.add("categoryStarWarsDay: " + categoryStarWarsDay); res.add("StarWarsDay: " + categoryStarWarsDay);
if (setCategoryR2D2 == null && savedGamemode.equals("Special8")) if (setCategoryR2D2 == null && savedGamemode.equals("Special8"))
res.add("categoryR2D2: " + categoryR2D2); res.add("R2D2: " + categoryR2D2);
} }
return res; return res;
@ -247,33 +253,33 @@ public class Box {
public void selectOption(String option) { public void selectOption(String option) {
if (option.equals("categoryOne")) if (option.equals("One"))
setCategoryOne = categoryOne; setCategoryOne = categoryOne;
else if (option.equals("categoryTwo")) else if (option.equals("Two"))
setCategoryTwo = categoryTwo; setCategoryTwo = categoryTwo;
else if (option.equals("categoryThree")) else if (option.equals("Three"))
setCategoryThree = categoryThree; setCategoryThree = categoryThree;
else if (option.equals("categoryFour")) else if (option.equals("Four"))
setCategoryFour = categoryFour; setCategoryFour = categoryFour;
else if (option.equals("categoryFive")) else if (option.equals("Five"))
setCategoryFive = categoryFive; setCategoryFive = categoryFive;
else if (option.equals("categorySix")) else if (option.equals("Six"))
setCategorySix = categorySix; setCategorySix = categorySix;
else if (option.equals("categorySeven")) else if (option.equals("Seven"))
setCategorySeven = categorySeven; setCategorySeven = categorySeven;
else if (option.equals("categoryEight")) else if (option.equals("Eight"))
setCategoryEight = categoryEight; setCategoryEight = categoryEight;
else if (option.equals("categoryTripleMatch")) else if (option.equals("TripleMatch"))
setCategoryTripleMatch = categoryTripleMatch; setCategoryTripleMatch = categoryTripleMatch;
else if (option.equals("categoryFourOfAKind")) else if (option.equals("FourOfAKind"))
setCategoryFourOfAKind = categoryFourOfAKind; setCategoryFourOfAKind = categoryFourOfAKind;
else if (option.equals("categoryFullHouse")) else if (option.equals("FullHouse"))
setCategoryFullHouse = categoryFullHouse; setCategoryFullHouse = categoryFullHouse;
else if (option.equals("categorySmallStreet")) else if (option.equals("SmallStreet"))
setCategorySmallStreet = categorySmallStreet; setCategorySmallStreet = categorySmallStreet;
else if (option.equals("categoryBigStreet")) else if (option.equals("BigStreet"))
setCategoryBigStreet = categoryBigStreet; setCategoryBigStreet = categoryBigStreet;
else if (option.equals("categoryYahtzee")) { else if (option.equals("Yahtzee")) {
if (setCategoryYahtzee != null) { if (setCategoryYahtzee != null) {
setCategoryYahtzee += 50; setCategoryYahtzee += 50;
if (counter[0] == 5) if (counter[0] == 5)
@ -297,9 +303,11 @@ public class Box {
} else if (option.equals("categoryChance")) } else if (option.equals("categoryChance"))
setCategoryChance = categoryChance; setCategoryChance = categoryChance;
else if (option.equals("categoryStarWarsDay")) else if (option.equals("Chance"))
setCategoryChance = categoryChance;
else if (option.equals("StarWarsDay"))
setCategoryStarWarsDay = categoryStarWarsDay; setCategoryStarWarsDay = categoryStarWarsDay;
else if (option.equals("categoryR2D2")) else if (option.equals("R2D2"))
setCategoryR2D2 = categoryR2D2; setCategoryR2D2 = categoryR2D2;
} }
@ -392,47 +400,96 @@ public class Box {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
if (savedGamemode.equals("Special8")) { if (savedGamemode.equals("Special8")) {
sb.append("categoryOne: " + nullCheck(setCategoryOne) + "\n");
sb.append("categoryTwo: " + nullCheck(setCategoryTwo) + "\n");
sb.append("categoryThree: " + nullCheck(setCategoryThree) + "\n");
sb.append("categoryFour: " + nullCheck(setCategoryFour) + "\n");
sb.append("categoryFive: " + nullCheck(setCategoryFive) + "\n");
sb.append("categorySix: " + nullCheck(setCategorySix) + "\n");
sb.append("categorySeven: " + nullCheck(setCategorySeven) + "\n");
sb.append("categoryEight: " + nullCheck(setCategoryEight) + "\n");
sb.append("\nbonus: " + nullCheck(bonus) + "\n");
sb.append("\n--------------------------\n\n"); sb.append("\n--------------------------\n\n");
sb.append("categoryTripleMatch: " + nullCheck(setCategoryTripleMatch) + "\n"); sb.append("One: " + nullCheck(setCategoryOne) + "\n");
sb.append("categoryFourOfAKind: " + nullCheck(setCategoryFourOfAKind) + "\n"); sb.append("Two: " + nullCheck(setCategoryTwo) + "\n");
sb.append("categoryFullHouse: " + nullCheck(setCategoryFullHouse) + "\n"); sb.append("Three: " + nullCheck(setCategoryThree) + "\n");
sb.append("categorySmallStreet: " + nullCheck(setCategorySmallStreet) + "\n"); sb.append("Four: " + nullCheck(setCategoryFour) + "\n");
sb.append("categoryBigStreet: " + nullCheck(setCategoryBigStreet) + "\n"); sb.append("Five: " + nullCheck(setCategoryFive) + "\n");
sb.append("categoryYahtzee: " + nullCheck(setCategoryYahtzee) + "\n"); sb.append("Six: " + nullCheck(setCategorySix) + "\n");
sb.append("categoryChance: " + nullCheck(setCategoryChance) + "\n"); sb.append("Seven: " + nullCheck(setCategorySeven) + "\n");
sb.append("categoryStarWarsDay: " + nullCheck(setCategoryStarWarsDay) + "\n"); sb.append("Eight: " + nullCheck(setCategoryEight) + "\n");
sb.append("categoryR2D2: " + nullCheck(setCategoryR2D2) + "\n"); sb.append("\nbonus: " + nullCheck(bonus) + "\n");
sb.append("\ntotal upper box: " + nullCheck(upperBoxScore) + "\n");
sb.append("\n--------------------------\n\n");
sb.append("TripleMatch: " + nullCheck(setCategoryTripleMatch) + "\n");
sb.append("FourOfAKind: " + nullCheck(setCategoryFourOfAKind) + "\n");
sb.append("FullHouse: " + nullCheck(setCategoryFullHouse) + "\n");
sb.append("SmallStreet: " + nullCheck(setCategorySmallStreet) + "\n");
sb.append("BigStreet: " + nullCheck(setCategoryBigStreet) + "\n");
sb.append("Yahtzee: " + nullCheck(setCategoryYahtzee) + "\n");
sb.append("Chance: " + nullCheck(setCategoryChance) + "\n");
sb.append("StarWarsDay: " + nullCheck(setCategoryStarWarsDay) + "\n");
sb.append("R2D2: " + nullCheck(setCategoryR2D2) + "\n");
sb.append("\ntotal lower box: " + nullCheck(lowerBoxScore) + "\n");
sb.append("\n--------------------------\n\n");
sb.append("\ntotal score: " + nullCheck(totalScore) + "\n");
} else { } else {
sb.append("categoryOne: " + nullCheck(setCategoryOne) + "\n");
sb.append("categoryTwo: " + nullCheck(setCategoryTwo) + "\n");
sb.append("categoryThree: " + nullCheck(setCategoryThree) + "\n");
sb.append("categoryFour: " + nullCheck(setCategoryFour) + "\n");
sb.append("categoryFive: " + nullCheck(setCategoryFive) + "\n");
sb.append("categorySix: " + nullCheck(setCategorySix) + "\n");
sb.append("\nbonus: " + nullCheck(bonus) + "\n");
sb.append("\n--------------------------\n\n"); sb.append("\n--------------------------\n\n");
sb.append("categoryTripleMatch: " + nullCheck(setCategoryTripleMatch) + "\n"); sb.append("One: " + nullCheck(setCategoryOne) + "\n");
sb.append("categoryFourOfAKind: " + nullCheck(setCategoryFourOfAKind) + "\n"); sb.append("Two: " + nullCheck(setCategoryTwo) + "\n");
sb.append("categoryFullHouse: " + nullCheck(setCategoryFullHouse) + "\n"); sb.append("Three: " + nullCheck(setCategoryThree) + "\n");
sb.append("categorySmallStreet: " + nullCheck(setCategorySmallStreet) + "\n"); sb.append("Four: " + nullCheck(setCategoryFour) + "\n");
sb.append("categoryBigStreet: " + nullCheck(setCategoryBigStreet) + "\n"); sb.append("Five: " + nullCheck(setCategoryFive) + "\n");
sb.append("categoryYahtzee: " + nullCheck(setCategoryYahtzee) + "\n"); sb.append("Six: " + nullCheck(setCategorySix) + "\n");
sb.append("categoryChance: " + nullCheck(setCategoryChance) + "\n"); sb.append("\nbonus: " + nullCheck(bonus) + "\n");
sb.append("categoryStarWarsDay: " + nullCheck(setCategoryStarWarsDay) + "\n"); sb.append("\ntotal upper box: " + nullCheck(upperBoxScore) + "\n");
sb.append("\n--------------------------\n\n");
sb.append("TripleMatch: " + nullCheck(setCategoryTripleMatch) + "\n");
sb.append("FourOfAKind: " + nullCheck(setCategoryFourOfAKind) + "\n");
sb.append("FullHouse: " + nullCheck(setCategoryFullHouse) + "\n");
sb.append("SmallStreet: " + nullCheck(setCategorySmallStreet) + "\n");
sb.append("BigStreet: " + nullCheck(setCategoryBigStreet) + "\n");
sb.append("Yahtzee: " + nullCheck(setCategoryYahtzee) + "\n");
sb.append("Chance: " + nullCheck(setCategoryChance) + "\n");
sb.append("StarWarsDay: " + nullCheck(setCategoryStarWarsDay) + "\n");
sb.append("\ntotal lower box: " + nullCheck(lowerBoxScore) + "\n");
sb.append("\n--------------------------\n\n");
sb.append("\ntotal score: " + nullCheck(totalScore) + "\n");
} }
return sb.toString(); return sb.toString();
} }
public void updateUpperBoxScore(){
if(savedGamemode.equals("Special8"))
this.upperBoxScore = nullCheckInt(setCategoryOne) + nullCheckInt(setCategoryTwo) + nullCheckInt(setCategoryThree) + nullCheckInt(setCategoryFour)
+ nullCheckInt(setCategoryFive) + nullCheckInt(setCategorySix) + nullCheckInt(setCategorySeven) + nullCheckInt(setCategoryEight) + nullCheckInt(bonus);
else
this.upperBoxScore = nullCheckInt(setCategoryOne) + nullCheckInt(setCategoryTwo) + nullCheckInt(setCategoryThree) + nullCheckInt(setCategoryFour)
+ nullCheckInt(setCategoryFive) + nullCheckInt(setCategorySix) + nullCheckInt(bonus);
}
public void updateLowerBoxScore(){
if(savedGamemode.equals("Special8"))
this.lowerBoxScore = nullCheckInt(setCategoryTripleMatch) + nullCheckInt(setCategoryFourOfAKind) + nullCheckInt(setCategoryFullHouse) + nullCheckInt(setCategorySmallStreet)
+ nullCheckInt(setCategoryBigStreet) + nullCheckInt(setCategoryYahtzee) + nullCheckInt(setCategoryChance) + nullCheckInt(setCategoryStarWarsDay) + nullCheckInt(setCategoryR2D2);
else
this.lowerBoxScore = nullCheckInt(setCategoryTripleMatch) + nullCheckInt(setCategoryFourOfAKind) + nullCheckInt(setCategoryFullHouse) + nullCheckInt(setCategorySmallStreet)
+ nullCheckInt(setCategoryBigStreet) + nullCheckInt(setCategoryYahtzee) + nullCheckInt(setCategoryChance) + nullCheckInt(setCategoryStarWarsDay);
}
public void updateTotalScore(){
this.totalScore = nullCheckInt(upperBoxScore) + nullCheckInt(lowerBoxScore);
}
public String nullCheck(Integer i) { public String nullCheck(Integer i) {
if (i == null) if (i == null)

View File

@ -118,6 +118,9 @@ public class YahtzeeGame {
players.get(player).box.resetOptions(); players.get(player).box.resetOptions();
players.get(player).getNewHand(); players.get(player).getNewHand();
players.get(player).box.updateBonus(); players.get(player).box.updateBonus();
players.get(player).box.updateUpperBoxScore();
players.get(player).box.updateLowerBoxScore();
players.get(player).box.updateTotalScore();
} }
@ -405,8 +408,8 @@ public class YahtzeeGame {
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
out.print(LocalDate.now() + ": " + players.get(player).name + ": " out.print(highscores[i][0] + ": " + highscores[i][1] + ": "
+ returnTotalPoints(player)); + highscores[i][2]);
out.println(); out.println();
} }