Some bugs need to be solved
parent
df415b4042
commit
7657f010a9
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.
|
@ -265,7 +265,7 @@ public class Box {
|
|||
else if (option.equals("categoryBigStreet"))
|
||||
setCategoryBigStreet = categoryBigStreet;
|
||||
else if (option.equals("categoryYahtzee")) {
|
||||
if (setCategoryYahtzee > 0) {
|
||||
if (setCategoryYahtzee != null) {
|
||||
setCategoryYahtzee += 50;
|
||||
if (counter[0] == 5)
|
||||
setCategoryOne = 5;
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package domain;
|
||||
|
||||
import java.lang.Math;
|
||||
|
||||
public class Dice {
|
||||
|
||||
private int diceNumber;
|
||||
|
@ -8,9 +10,9 @@ public class Dice {
|
|||
public Dice(String gamemode) {
|
||||
this.savedGamemode = gamemode;
|
||||
if (gamemode.equals("Normal") || gamemode.equals("StarWarsDay"))
|
||||
this.diceNumber = (int) Math.random() * 6 + 1;
|
||||
this.diceNumber = ((int) (Math.random() * 6)) + 1;
|
||||
else if (gamemode.equals("Special8"))
|
||||
this.diceNumber = (int) Math.random() * 8 + 1;
|
||||
this.diceNumber = ((int) (Math.random() * 8)) + 1;
|
||||
}
|
||||
|
||||
public Dice(String gamemode, int diceNumber) {
|
||||
|
@ -21,9 +23,9 @@ public class Dice {
|
|||
public void rerollDice() {
|
||||
|
||||
if (this.savedGamemode.equals("Normal") || this.savedGamemode.equals("StarWarsDay"))
|
||||
this.diceNumber = (int) Math.random() * 6 + 1;
|
||||
this.diceNumber = ((int) (Math.random() * 6)) + 1;
|
||||
else if (this.savedGamemode.equals("Special8"))
|
||||
this.diceNumber = (int) Math.random() * 8 + 1;
|
||||
this.diceNumber = ((int) (Math.random() * 8)) + 1;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -5,15 +5,15 @@ import java.util.ArrayList;
|
|||
public class Hand {
|
||||
|
||||
private ArrayList<Dice> dices = new ArrayList<>(5);
|
||||
private ArrayList<Dice> lockedInDices;
|
||||
private int leftRolls = 2;
|
||||
private ArrayList<Dice> lockedInDices = new ArrayList<>();
|
||||
private int leftRolls = 3;
|
||||
private String savedGamemode;
|
||||
|
||||
public Hand(String gamemode) {
|
||||
|
||||
this.savedGamemode = gamemode;
|
||||
|
||||
for (int i = 0; i < dices.size(); i++) {
|
||||
for (int i = 0; i < 5; i++) {
|
||||
|
||||
dices.add(i, new Dice(gamemode));
|
||||
|
||||
|
@ -56,6 +56,12 @@ 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() {
|
||||
|
|
|
@ -17,7 +17,7 @@ public class TUI {
|
|||
|
||||
YahtzeeGame game = new YahtzeeGame() {
|
||||
};
|
||||
System.out.println("Main menu:\n");
|
||||
System.out.println("\nMain menu:\n");
|
||||
System.out.println(">Play");
|
||||
System.out.println(">Highscores");
|
||||
choice = sc.nextLine();
|
||||
|
@ -32,11 +32,11 @@ public class TUI {
|
|||
|
||||
else if (choice.equals("Delete")) {
|
||||
System.out.println(
|
||||
"Are you sure you want to delete the Highscore file?\nAs a confirmation type: 'I AM SURE': ");
|
||||
"\nAre you sure you want to delete the Highscore file?\nAs a confirmation type: 'I AM SURE': ");
|
||||
choice = sc.nextLine();
|
||||
if (choice.equals("I AM SURE")) {
|
||||
game.deleteHighscores();
|
||||
System.out.println("Highscore file got deleted...\nReturning to the main menu...");
|
||||
System.out.println("\nHighscore file got deleted...\nReturning to the main menu...");
|
||||
} else {
|
||||
System.out.println("Highscore file not deleted...\nReturning to the main menu...");
|
||||
}
|
||||
|
@ -47,18 +47,19 @@ public class TUI {
|
|||
|
||||
else if (choice.equals("Play")) {
|
||||
|
||||
System.out.println("Choose your gamemode: ");
|
||||
System.out.println("\nChoose your gamemode: ");
|
||||
System.out.println(">Normal");
|
||||
System.out.println(">StarWarsDay");
|
||||
System.out.println(">Special8");
|
||||
game.setGamemode(sc.nextLine());
|
||||
System.out.println("Amount of players: ");
|
||||
System.out.println("\nAmount of players: ");
|
||||
System.out.println(">1-6");
|
||||
game.setPlayercount(sc.nextInt());
|
||||
System.out.println("Type in the player names, lock in each name with Enter: ");
|
||||
game.setPlayercount(Integer.parseInt(sc.nextLine()));
|
||||
System.out.println("\nType in the player names, lock in each name with Enter: ");
|
||||
System.out.println(">ex. Lucas [Enter] William [Enter] Lena [Enter]");
|
||||
|
||||
String playerNames[] = new String[game.playerCount];
|
||||
|
||||
for (int i = 0; i < game.playerCount; i++) {
|
||||
playerNames[i] = sc.nextLine();
|
||||
}
|
||||
|
@ -72,26 +73,31 @@ public class TUI {
|
|||
if (game.gameOver(i))
|
||||
continue;
|
||||
|
||||
System.out.println("Its your turn " + game.getPlayerName(i));
|
||||
System.out.println("This is your Yahtzee Box: ");
|
||||
System.out.println(game.selectedOptionsPrinted(i) + "\n");
|
||||
System.out.println("\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)) {
|
||||
while (!game.allDicesLockedIn(i) && !game.noMoreRolls(i)) {
|
||||
|
||||
System.out.println("Rolling dices... ");
|
||||
game.rollDices(i);
|
||||
|
||||
System.out.println("Your dices: ");
|
||||
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(" "));
|
||||
game.rollDices(i);
|
||||
System.out.println(game.getLeftRolls(i) + " rolls left");
|
||||
System.out.println("Rerolling dices... ");
|
||||
|
||||
if ((game.getLeftRolls(i)) != 1)
|
||||
System.out.println("\n" + game.getLeftRolls(i) + " rolls left");
|
||||
else
|
||||
System.out.println("\n" + game.getLeftRolls(i) + " roll left");
|
||||
|
||||
}
|
||||
|
||||
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());
|
||||
|
|
Loading…
Reference in New Issue