2 seperate highscore tables and final fixes
parent
936474c659
commit
9c3c0a7f89
|
@ -1,10 +1,10 @@
|
|||
2024-04-30: Selim: 172
|
||||
___: ___: 0
|
||||
___: ___: 0
|
||||
___: ___: 0
|
||||
___: ___: 0
|
||||
___: ___: 0
|
||||
___: ___: 0
|
||||
___: ___: 0
|
||||
___: ___: 0
|
||||
___: ___: 0
|
||||
2024-04-30 Selim 254
|
||||
2024-04-30 Enes 127
|
||||
2024-04-30 David 82
|
||||
___ ___ 0
|
||||
___ ___ 0
|
||||
___ ___ 0
|
||||
___ ___ 0
|
||||
___ ___ 0
|
||||
___ ___ 0
|
||||
___ ___ 0
|
||||
|
|
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
bin/ui/TUI.class
BIN
bin/ui/TUI.class
Binary file not shown.
|
@ -1,10 +1,10 @@
|
|||
2024-04-30: Selim: 172
|
||||
___: ___: 0
|
||||
___: ___: 0
|
||||
___: ___: 0
|
||||
___: ___: 0
|
||||
___: ___: 0
|
||||
___: ___: 0
|
||||
___: ___: 0
|
||||
___: ___: 0
|
||||
___: ___: 0
|
||||
2024-04-30 Selim 254
|
||||
2024-04-30 Enes 127
|
||||
2024-04-30 David 82
|
||||
___ ___ 0
|
||||
___ ___ 0
|
||||
___ ___ 0
|
||||
___ ___ 0
|
||||
___ ___ 0
|
||||
___ ___ 0
|
||||
___ ___ 0
|
||||
|
|
|
|
|
@ -153,10 +153,10 @@ public class Box {
|
|||
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
|
||||
if (counter[i] == 1 && counter[i + 1] == 1 && counter[i + 2] == 1 && counter[i + 3] == 1 && counter[i + 3] == 1)
|
||||
if (counter[i] == 1 && counter[i + 1] == 1 && counter[i + 2] == 1 && counter[i + 3] == 1
|
||||
&& counter[i + 3] == 1)
|
||||
categoryBigStreet = 40;
|
||||
|
||||
}
|
||||
|
@ -247,10 +247,17 @@ public class Box {
|
|||
if (setCategoryR2D2 == null && savedGamemode.equals("Special8"))
|
||||
res.add("R2D2: " + categoryR2D2);
|
||||
}
|
||||
|
||||
return res;
|
||||
|
||||
}
|
||||
|
||||
public boolean onlyOneOption() {
|
||||
|
||||
return getAllOptions().size() == 1;
|
||||
|
||||
}
|
||||
|
||||
public void selectOption(String option) {
|
||||
|
||||
if (option.equals("One"))
|
||||
|
@ -363,14 +370,17 @@ public class Box {
|
|||
|
||||
if (savedGamemode.equals("Special8")) {
|
||||
|
||||
if(nullCheckInt(setCategoryOne) + nullCheckInt(setCategoryTwo) + nullCheckInt(setCategoryThree) + nullCheckInt(setCategoryFour)
|
||||
+ nullCheckInt(setCategoryFive) + nullCheckInt(setCategorySix) + nullCheckInt(setCategorySeven) + nullCheckInt(setCategoryEight) >= 108){
|
||||
if (nullCheckInt(setCategoryOne) + nullCheckInt(setCategoryTwo) + nullCheckInt(setCategoryThree)
|
||||
+ nullCheckInt(setCategoryFour)
|
||||
+ nullCheckInt(setCategoryFive) + nullCheckInt(setCategorySix) + nullCheckInt(setCategorySeven)
|
||||
+ nullCheckInt(setCategoryEight) >= 108) {
|
||||
this.bonus = 35;
|
||||
}
|
||||
|
||||
} else
|
||||
|
||||
if(nullCheckInt(setCategoryOne) + nullCheckInt(setCategoryTwo) + nullCheckInt(setCategoryThree) + nullCheckInt(setCategoryFour)
|
||||
if (nullCheckInt(setCategoryOne) + nullCheckInt(setCategoryTwo) + nullCheckInt(setCategoryThree)
|
||||
+ nullCheckInt(setCategoryFour)
|
||||
+ nullCheckInt(setCategoryFive) + nullCheckInt(setCategorySix) >= 63) {
|
||||
this.bonus = 35;
|
||||
}
|
||||
|
@ -381,7 +391,8 @@ public class Box {
|
|||
|
||||
if (savedGamemode.equals("Special8"))
|
||||
return setCategoryOne + setCategoryTwo + setCategoryThree + setCategoryFour + setCategoryFive
|
||||
+ setCategorySix + setCategorySeven + setCategoryEight + nullCheckInt(bonus) + setCategoryTripleMatch
|
||||
+ setCategorySix + setCategorySeven + setCategoryEight + nullCheckInt(bonus)
|
||||
+ setCategoryTripleMatch
|
||||
+ setCategoryFourOfAKind
|
||||
+ setCategoryFullHouse + setCategorySmallStreet + setCategoryBigStreet + setCategoryYahtzee
|
||||
+ setCategoryChance + setCategoryStarWarsDay
|
||||
|
@ -455,33 +466,35 @@ public class Box {
|
|||
|
||||
if (savedGamemode.equals("Special8"))
|
||||
|
||||
this.upperBoxScore = nullCheckInt(setCategoryOne) + nullCheckInt(setCategoryTwo) + nullCheckInt(setCategoryThree) + nullCheckInt(setCategoryFour)
|
||||
+ nullCheckInt(setCategoryFive) + nullCheckInt(setCategorySix) + nullCheckInt(setCategorySeven) + nullCheckInt(setCategoryEight) + nullCheckInt(bonus);
|
||||
|
||||
|
||||
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)
|
||||
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);
|
||||
|
||||
|
||||
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);
|
||||
this.lowerBoxScore = nullCheckInt(setCategoryTripleMatch) + nullCheckInt(setCategoryFourOfAKind)
|
||||
+ nullCheckInt(setCategoryFullHouse) + nullCheckInt(setCategorySmallStreet)
|
||||
+ nullCheckInt(setCategoryBigStreet) + nullCheckInt(setCategoryYahtzee)
|
||||
+ nullCheckInt(setCategoryChance) + nullCheckInt(setCategoryStarWarsDay);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -68,6 +68,11 @@ public class YahtzeeGame {
|
|||
|
||||
}
|
||||
|
||||
public int getLockedInDiceAmount(int player) {
|
||||
|
||||
return players.get(player).hand.getLockedInDiceAmount();
|
||||
}
|
||||
|
||||
public void lockInDices(int player, String... dices) {
|
||||
|
||||
if (dices[0].equals("none"))
|
||||
|
@ -138,6 +143,12 @@ public class YahtzeeGame {
|
|||
|
||||
}
|
||||
|
||||
public boolean onlyOneOption(int player) {
|
||||
|
||||
return players.get(player).box.onlyOneOption();
|
||||
|
||||
}
|
||||
|
||||
public String selectedOptionsPrinted(int player) {
|
||||
|
||||
return players.get(player).box.selectedOptionsPrinted(player);
|
||||
|
@ -172,8 +183,29 @@ public class YahtzeeGame {
|
|||
|
||||
String highscores[][] = new String[10][3];
|
||||
Scanner sc = new Scanner(new File("src/csv/highscores.csv"));
|
||||
Scanner scSp = new Scanner(new File("src/csv/highscoresSpecial8.csv"));
|
||||
String mem[] = new String[3];
|
||||
|
||||
if (savedGamemode.equals("Special8"))
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
|
||||
if (scSp.hasNextLine()) {
|
||||
|
||||
mem = scSp.nextLine().split(" ");
|
||||
highscores[i][0] = mem[0];
|
||||
highscores[i][1] = mem[1];
|
||||
highscores[i][2] = mem[2];
|
||||
|
||||
} else {
|
||||
highscores[i][0] = "___";
|
||||
highscores[i][1] = "___";
|
||||
highscores[i][2] = "0";
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
|
||||
if (sc.hasNextLine()) {
|
||||
|
@ -192,6 +224,7 @@ public class YahtzeeGame {
|
|||
}
|
||||
|
||||
sc.close();
|
||||
scSp.close();
|
||||
return highscores;
|
||||
}
|
||||
|
||||
|
@ -405,16 +438,27 @@ public class YahtzeeGame {
|
|||
}
|
||||
|
||||
PrintWriter out = new PrintWriter(new FileWriter("src/csv/highscores.csv", false));
|
||||
PrintWriter outSp = new PrintWriter(new FileWriter("src/csv/highscoresSpecial8.csv", false));
|
||||
|
||||
if (savedGamemode.equals("Special8"))
|
||||
for (int i = 0; i < 10; i++) {
|
||||
|
||||
out.print(highscores[i][0] + ": " + highscores[i][1] + ": "
|
||||
outSp.print(highscores[i][0] + " " + highscores[i][1] + " "
|
||||
+ highscores[i][2]);
|
||||
|
||||
outSp.println();
|
||||
}
|
||||
else
|
||||
for (int i = 0; i < 10; i++) {
|
||||
|
||||
out.print(highscores[i][0] + " " + highscores[i][1] + " "
|
||||
+ highscores[i][2]);
|
||||
|
||||
out.println();
|
||||
}
|
||||
|
||||
out.close();
|
||||
outSp.close();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
|
@ -428,15 +472,16 @@ public class YahtzeeGame {
|
|||
|
||||
}
|
||||
|
||||
public String showHighscores() throws FileNotFoundException {
|
||||
public String showHighscores(String gamemode) throws FileNotFoundException {
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
this.savedGamemode = gamemode;
|
||||
|
||||
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");
|
||||
|
||||
}
|
||||
|
||||
|
@ -447,10 +492,15 @@ public class YahtzeeGame {
|
|||
public void deleteHighscores() throws IOException {
|
||||
|
||||
PrintWriter out = new PrintWriter(new FileWriter("src/csv/highscores.csv", false));
|
||||
PrintWriter outSp = new PrintWriter(new FileWriter("src/csv/highscoresSpecial8.csv", false));
|
||||
|
||||
if (savedGamemode.equals("Special8"))
|
||||
outSp.print("");
|
||||
else
|
||||
out.print("");
|
||||
|
||||
out.close();
|
||||
outSp.close();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -17,14 +17,17 @@ public class TUI {
|
|||
|
||||
YahtzeeGame game = new YahtzeeGame() {
|
||||
};
|
||||
System.out.println("\nMain menu:\n");
|
||||
System.out.println("\nMain menu:");
|
||||
System.out.println(">Play");
|
||||
System.out.println(">Highscores");
|
||||
choice = sc.nextLine();
|
||||
|
||||
if (choice.equals("Highscores")) {
|
||||
System.out.println(game.showHighscores());
|
||||
System.out.println(">Return");
|
||||
System.out.println("\nChoose your gamemode:");
|
||||
System.out.println(">Normal");
|
||||
System.out.println(">Special8");
|
||||
System.out.println("\n" + game.showHighscores(sc.nextLine()));
|
||||
System.out.println("\n>Return");
|
||||
System.out.println(">Delete");
|
||||
choice = sc.nextLine();
|
||||
if (choice.equals("Return")) {
|
||||
|
@ -72,20 +75,24 @@ public class TUI {
|
|||
if (game.gameOver(i))
|
||||
continue;
|
||||
|
||||
System.out.println("\nIts your turn " + game.getPlayerName(i));
|
||||
System.out.println("\n\n\nIts your turn " + game.getPlayerName(i));
|
||||
System.out.println("\nThis is your Yahtzee Box: ");
|
||||
System.out.println("\n" + game.selectedOptionsPrinted(i) + "\n");
|
||||
|
||||
while (!game.allDicesLockedIn(i) && !game.noMoreRolls(i)) {
|
||||
|
||||
if (game.getLockedInDiceAmount(i) != 4)
|
||||
System.out.println("Rolling dices... ");
|
||||
else
|
||||
System.out.println("Rolling the last dice...");
|
||||
|
||||
game.rollDices(i);
|
||||
|
||||
System.out.println("Free dices: " + game.getFreeDiceNumbers(i));
|
||||
System.out.println("Locked in dices: " + game.getLockedInDiceNumbers(i));
|
||||
|
||||
if (game.autoLockInDices(i)) {
|
||||
System.out.println("\nNo rolls left auto locking dices....\n");
|
||||
System.out.println("\nNo rolls left => auto locking dices...\n");
|
||||
}
|
||||
if (!game.noMoreRolls(i)) {
|
||||
System.out.println(
|
||||
|
@ -94,9 +101,9 @@ public class TUI {
|
|||
|
||||
game.lockInDices(i, choice.split(" "));
|
||||
|
||||
if ((game.getLeftRolls(i)) != 1)
|
||||
if ((game.getLeftRolls(i)) != 1 && !game.allDicesLockedIn(i))
|
||||
System.out.println("\n" + game.getLeftRolls(i) + " rolls left");
|
||||
else if ((game.getLeftRolls(i)) == 1)
|
||||
else if ((game.getLeftRolls(i)) == 1 && !game.allDicesLockedIn(i))
|
||||
System.out.println("\n" + game.getLeftRolls(i) + " roll left");
|
||||
}
|
||||
}
|
||||
|
@ -104,22 +111,27 @@ 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("\n" + game.optionsPrinted(i));
|
||||
|
||||
if (game.onlyOneOption(i)) {
|
||||
game.selectOption(i, game.getAllOptions(i).get(0).split(":")[0]);
|
||||
System.out.println("Only one option possible => auto selecting option...");
|
||||
} else {
|
||||
System.out.println("Which option you want to select?: ");
|
||||
game.selectOption(i, sc.nextLine());
|
||||
|
||||
}
|
||||
if (game.gameOver(i)) {
|
||||
System.out.println(
|
||||
"Your game is over, here is your total score: " + game.returnTotalPoints(i));
|
||||
"\n\nYour game is over, here is your total score: " + game.returnTotalPoints(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("The game is over, " + game.getWinnerMessage());
|
||||
System.out.println("\n\nThe game is over, " + game.getWinnerMessage());
|
||||
System.out.println("Saving all highscores to the highscore table...");
|
||||
game.saveAllPlayersHighscores();
|
||||
System.out.println(
|
||||
"If you want to stop the programm type: 'stop', otherwise you will return to the main menu:");
|
||||
"\nIf you want to stop the programm type: 'stop', otherwise you will return to the main menu:");
|
||||
choice = sc.nextLine();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue