Initial commit of tui

main
selim 2024-04-28 15:17:13 +02:00
parent 8cadbcd55c
commit 0081a61c11
8 changed files with 75 additions and 16 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
bin/ui/TUI.class 100644

Binary file not shown.

View File

@ -49,7 +49,7 @@ public class Box {
this.savedGamemode = gamemode;
}
public void evaluateUpperBoxOptions(ArrayList<Integer> diceNumbers) {
private void evaluateUpperBoxOptions(ArrayList<Integer> diceNumbers) {
if (diceNumbers.contains(1))
for (int i = 0; i < diceNumbers.size(); i++) {
@ -93,7 +93,7 @@ public class Box {
}
}
public void evaluateLowerBoxOptions(ArrayList<Integer> diceNumbers) {
private void evaluateLowerBoxOptions(ArrayList<Integer> diceNumbers) {
int sumOfAllNumbers = 0;
for (int i = 0; i < diceNumbers.size(); i++) {

View File

@ -1,13 +1,11 @@
package domain;
import java.time.LocalDate;
public class Player {
String name;
Hand hand;
Box box;
String savedGamemode;
public String name;
public Hand hand;
public Box box;
public String savedGamemode;
public Player(String name, String gamemode) {
@ -24,12 +22,4 @@ public class Player {
}
public String getHighscore() {
if (box.gameOver())
return "date: " + LocalDate.now().toString() + "\n" + name + ": " + box.returnTotalPoints();
else
return "";
}
}

View File

@ -23,4 +23,68 @@ public class YahtzeeGame {
}
}
public void rollDices(int player) {
players.get(player - 1).hand.rollDices();
}
public ArrayList<Integer> getAllDiceNumbers(int player) {
return players.get(player - 1).hand.getAllDiceNumbers();
}
public ArrayList<Integer> getFreeDiceNumbers(int player) {
return players.get(player - 1).hand.getFreeDiceNumbers();
}
public ArrayList<Integer> getLockedInDiceNumbers(int player) {
return players.get(player - 1).hand.getLockedInDiceNumbers();
}
public void lockInDices(int player, int... dices) {
players.get(player - 1).hand.lockInDices(dices);
}
public int getLeftRolls(int player) {
return players.get(player - 1).hand.getLeftRolls();
}
public ArrayList<String> getAllOptionsEvaluated(int player) {
players.get(player - 1).box.evaluateBoxOptions(players.get(player - 1).hand.getAllDiceNumbers());
return players.get(player - 1).box.getAllOptions();
}
public void selectOption(int player, String selectedOption) {
players.get(player - 1).box.selectOption(selectedOption);
players.get(player - 1).box.resetOptions();
players.get(player - 1).getNewHand();
}
public boolean gameOver(int player) {
return players.get(player - 1).box.gameOver();
}
public int returnTotalPoints(int player) {
if (players.get(player - 1).box.gameOver())
return players.get(player - 1).box.returnTotalPoints();
else
return 0;
}
}

5
src/ui/TUI.java 100644
View File

@ -0,0 +1,5 @@
package ui;
public class TUI {
}