Beside category choices everything should work

main
selim 2024-04-30 00:45:27 +02:00
parent 7657f010a9
commit d99f72daea
6 changed files with 42 additions and 17 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -27,6 +27,7 @@ public class Hand {
if (this.dices.get(i).getDiceNumber() == dice) {
this.dices.remove(i);
this.lockedInDices.add(new Dice(savedGamemode, dice));
return;
}
}
@ -40,6 +41,21 @@ public class Hand {
}
}
public void autoLockInDices() {
int mem = this.dices.size();
if (leftRolls == 0) {
for (int i = 0; i < mem; i++) {
lockInDice(dices.get(0).getDiceNumber());
}
System.out.println("No rolls left, auto locking in all left dices...");
}
}
public int getLockedInDiceAmount() {
if (lockedInDices != null)
@ -57,11 +73,6 @@ public class Hand {
leftRolls--;
if (this.leftRolls == 1)
for (int i = 0; i < this.dices.size(); i++) {
lockInDice(this.dices.get(i).getDiceNumber());
}
}
public ArrayList<Integer> getAllDiceNumbers() {

View File

@ -76,6 +76,12 @@ public class YahtzeeGame {
}
public void autoLockInDices(int player) {
players.get(player).hand.autoLockInDices();
}
public boolean allDicesLockedIn(int player) {
return players.get(player).hand.getLockedInDiceAmount() == 5;
@ -157,13 +163,17 @@ public class YahtzeeGame {
String highscores[][] = new String[10][3];
Scanner sc = new Scanner(new File("src/csv/highscores.csv"));
String mem[] = new String[3];
for (int i = 0; i < 10; i++) {
if (sc.hasNextLine()) {
highscores[i][0] = sc.next();
highscores[i][1] = sc.next();
highscores[i][2] = sc.nextLine();
mem = sc.nextLine().split(" ");
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] = "___";

View File

@ -84,20 +84,24 @@ public class TUI {
System.out.println("Free dices: " + game.getFreeDiceNumbers(i));
System.out.println("Locked in dices: " + game.getLockedInDiceNumbers(i));
System.out.println(
"Type in which free dices you want to keep \n(seperated by space, type 'none' if you dont want to keep any): ");
choice = sc.nextLine();
game.lockInDices(i, choice.split(" "));
if ((game.getLeftRolls(i)) != 1)
System.out.println("\n" + game.getLeftRolls(i) + " rolls left");
else
System.out.println("\n" + game.getLeftRolls(i) + " roll left");
game.autoLockInDices(i);
if (!game.noMoreRolls(i)) {
System.out.println(
"Type in which free dices you want to keep \n(seperated by space, type 'none' if you dont want to keep any): ");
choice = sc.nextLine();
game.lockInDices(i, choice.split(" "));
if ((game.getLeftRolls(i)) != 1)
System.out.println("\n" + game.getLeftRolls(i) + " rolls left");
else if ((game.getLeftRolls(i)) == 1)
System.out.println("\n" + game.getLeftRolls(i) + " roll left");
}
}
System.out.println("\n\nLocked in dices: " + game.getLockedInDiceNumbers(i));
System.out.println("Done locking in... Here are your options: ");
System.out.println("Locked in dices: " + game.getLockedInDiceNumbers(i));
System.out.println(game.optionsPrinted(i));
System.out.println("Which option you want to select?: ");
game.selectOption(i, sc.nextLine());