Spiel ändern

main
danai 2024-05-07 15:00:31 +02:00
parent 375b322573
commit 7c8d8e8e65
1 changed files with 20 additions and 12 deletions

View File

@ -56,7 +56,7 @@ public class Spiel {
// Method to set the score for a specific category
public void setKategorieScore(int categoryIndex, int score) {
// Set the value of the category at the specified index
kategorie[categoryIndex] = kategorie[categoryIndex];
kategorie[categoryIndex] = Kategorie.values()[categoryIndex];
kategorie[categoryIndex].setValue(score); // Set the value of the category
scores[categoryIndex] = score; // Store the score in the scores array
}
@ -82,7 +82,7 @@ public class Spiel {
// Method to calculate the score for a specific category
public int calculateKategorieScore(int categoryIndex, Würfel würfel) {
public int calculateKategorieScore(int categoryIndex) {
int score = 0;
int[] diceValues = getWürfelValues();
@ -150,12 +150,14 @@ public class Spiel {
private int countDiceValue(int[] diceValues, int value) {
int count = 0;
int sum = 0;
for (int diceValue : diceValues) {
if (diceValue == value) {
count++;
sum+= diceValue;
}
}
return count;
return sum;
}
@ -279,17 +281,26 @@ public class Spiel {
values[diceValue - 1]++;
}
}
// Überprüfen, ob die spezielle R2D2-Kombination erfüllt ist
// Dazu müssen 1 und 8 jeweils mindestens einmal vorkommen,
// während 2 und 4 jeweils mindestens zweimal vorkommen müssen
return values[0] >= 1 && values[7] >= 1 && values[1] >= 2 && values[3] >= 2;
}
public int calculateTotalScore(Würfel würfel) {
int totalScore = 0;
for (int categoryIndex = 1; categoryIndex <= 17; categoryIndex++) {
totalScore += calculateKategorieScore(categoryIndex, würfel);
}
public int calculateTotalScore(int categoryIndex) {
// for (int i = categoryIndex; i <= categoryIndex; i++) {
// totalScore += calculateKategorieScore(categoryIndex);
// }
int categoryScore = calculateKategorieScore(categoryIndex);
int totalScore = categoryScore;
if (totalScore >= 108) {
totalScore += BONUS;
}
@ -346,10 +357,7 @@ public class Spiel {
return winner; // Einen Gewinner zurückbringen
}
public void addHighscore(String highscore) {
highscores.add(highscore);