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