Fassade edit
parent
99f9aab7e3
commit
c194baa303
|
@ -4,6 +4,7 @@ import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
import domain.Kategorie;
|
||||||
import domain.Spiel;
|
import domain.Spiel;
|
||||||
import domain.Spieler;
|
import domain.Spieler;
|
||||||
import domain.Würfel;
|
import domain.Würfel;
|
||||||
|
@ -13,12 +14,12 @@ public class KniffelSpiel {
|
||||||
private Spiel spiel;
|
private Spiel spiel;
|
||||||
private Scanner scanner;
|
private Scanner scanner;
|
||||||
private Würfel würfel;
|
private Würfel würfel;
|
||||||
|
private int numPlayers;
|
||||||
|
|
||||||
public KniffelSpiel() {
|
public KniffelSpiel() {
|
||||||
System.out.println("Willkommen zum Star Wars Day Kniffel!");
|
System.out.println("Willkommen zum Star Wars Day Kniffel!");
|
||||||
this.scanner = new Scanner(System.in);
|
this.scanner = new Scanner(System.in);
|
||||||
int numPlayers;
|
|
||||||
int numSides;
|
int numSides;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
@ -40,29 +41,39 @@ public class KniffelSpiel {
|
||||||
System.out.print("Enter player " + player.getNumber() + " name: ");
|
System.out.print("Enter player " + player.getNumber() + " name: ");
|
||||||
player.setName(scanner.nextLine());
|
player.setName(scanner.nextLine());
|
||||||
}
|
}
|
||||||
|
spiel.setCurrentPlayerIndex(0);
|
||||||
playGame();
|
playGame();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void playGame() {
|
private void playGame() {
|
||||||
int numPlayers = spiel.getSpieler().size();
|
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
||||||
spiel.nextPlayer();
|
|
||||||
|
for (Spieler player : spiel.getSpieler()) {
|
||||||
|
System.out.println("Player " + player.getNumber() + " of " + numPlayers + "'s turn:");
|
||||||
|
rollAndRerollDice();
|
||||||
|
displayCategories();
|
||||||
|
askUserForCategory();
|
||||||
|
displayScore();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*spiel.nextPlayer();
|
||||||
|
|
||||||
int currentPlayerIndex = spiel.getCurrentPlayerIndex();
|
int currentPlayerIndex = spiel.getCurrentPlayerIndex();
|
||||||
Spieler currentPlayer = spiel.getSpieler().get(currentPlayerIndex);
|
|
||||||
|
|
||||||
System.out.println("Player " + currentPlayer.getNumber() + " of " + numPlayers + "'s turn:");
|
int playerNumber = spiel.getCurrentPlayerIndex() + 1;
|
||||||
|
|
||||||
|
System.out.println("Player " + playerNumber + " of " + numPlayers + "'s turn:");
|
||||||
|
|
||||||
rollAndRerollDice();
|
rollAndRerollDice();
|
||||||
displayCategories();
|
displayCategories();
|
||||||
askUserForCategory();
|
askUserForCategory();*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
displayScore();
|
|
||||||
if (isGameFinished()) {
|
if (isGameFinished()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -79,7 +90,7 @@ public class KniffelSpiel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void rollAndRerollDice() {
|
public void rollAndRerollDice() {
|
||||||
// Бросаем все кубики в первый раз
|
// Alle Würfel beim ersten Mal werfen
|
||||||
spiel.rollWürfel();
|
spiel.rollWürfel();
|
||||||
displayDiceValues();
|
displayDiceValues();
|
||||||
|
|
||||||
|
@ -90,7 +101,7 @@ public class KniffelSpiel {
|
||||||
System.out.println("Do you want to keep some dice for the next roll? (y/n): ");
|
System.out.println("Do you want to keep some dice for the next roll? (y/n): ");
|
||||||
String answer = scanner.nextLine().toLowerCase();
|
String answer = scanner.nextLine().toLowerCase();
|
||||||
if (answer.equals("y")) {
|
if (answer.equals("y")) {
|
||||||
// Сохраняем выбранные кубики и перебрасываем остальные
|
// Speicher die ausgewählten Würfel und würfel die restlichen Würfel erneut
|
||||||
spiel.rerollWürfel();
|
spiel.rerollWürfel();
|
||||||
displayDiceValues();
|
displayDiceValues();
|
||||||
currentRoll++;
|
currentRoll++;
|
||||||
|
@ -121,7 +132,6 @@ public class KniffelSpiel {
|
||||||
int score = calculateCategoryScore(categoryIndex, würfel);
|
int score = calculateCategoryScore(categoryIndex, würfel);
|
||||||
spiel.setKategorieScore(categoryIndex, score);
|
spiel.setKategorieScore(categoryIndex, score);
|
||||||
|
|
||||||
// Здесь добавьте код для присвоения результата игроку
|
|
||||||
int playerIndex = spiel.getCurrentPlayerIndex();
|
int playerIndex = spiel.getCurrentPlayerIndex();
|
||||||
spiel.getSpieler().get(playerIndex).setScoreForCategory(categoryIndex, score);
|
spiel.getSpieler().get(playerIndex).setScoreForCategory(categoryIndex, score);
|
||||||
|
|
||||||
|
@ -138,10 +148,16 @@ public class KniffelSpiel {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isGameFinished() {
|
private boolean isGameFinished() {
|
||||||
// implement game finish condition here
|
Kategorie[] categories = spiel.getKategorie();
|
||||||
|
for (Spieler player : spiel.getSpieler()) {
|
||||||
|
if (!player.hasUnusedCategories(categories)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void displayFinalScore() {
|
private void displayFinalScore() {
|
||||||
System.out.println("Final score: " + spiel.calculateTotalScore(würfel));
|
System.out.println("Final score: " + spiel.calculateTotalScore(würfel));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue