Spiel ändern
parent
375b322573
commit
7c8d8e8e65
|
@ -56,7 +56,7 @@ public class Spiel {
|
||||||
// Method to set the score for a specific category
|
// Method to set the score for a specific category
|
||||||
public void setKategorieScore(int categoryIndex, int score) {
|
public void setKategorieScore(int categoryIndex, int score) {
|
||||||
// Set the value of the category at the specified index
|
// 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
|
kategorie[categoryIndex].setValue(score); // Set the value of the category
|
||||||
scores[categoryIndex] = score; // Store the score in the scores array
|
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
|
// 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 score = 0;
|
||||||
int[] diceValues = getWürfelValues();
|
int[] diceValues = getWürfelValues();
|
||||||
|
@ -150,12 +150,14 @@ public class Spiel {
|
||||||
|
|
||||||
private int countDiceValue(int[] diceValues, int value) {
|
private int countDiceValue(int[] diceValues, int value) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
int sum = 0;
|
||||||
for (int diceValue : diceValues) {
|
for (int diceValue : diceValues) {
|
||||||
if (diceValue == value) {
|
if (diceValue == value) {
|
||||||
count++;
|
count++;
|
||||||
|
sum+= diceValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return count;
|
return sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -279,17 +281,26 @@ public class Spiel {
|
||||||
values[diceValue - 1]++;
|
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;
|
return values[0] >= 1 && values[7] >= 1 && values[1] >= 2 && values[3] >= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public int calculateTotalScore(Würfel würfel) {
|
public int calculateTotalScore(int categoryIndex) {
|
||||||
int totalScore = 0;
|
|
||||||
for (int categoryIndex = 1; categoryIndex <= 17; categoryIndex++) {
|
|
||||||
totalScore += calculateKategorieScore(categoryIndex, würfel);
|
// for (int i = categoryIndex; i <= categoryIndex; i++) {
|
||||||
}
|
// totalScore += calculateKategorieScore(categoryIndex);
|
||||||
|
// }
|
||||||
|
|
||||||
|
int categoryScore = calculateKategorieScore(categoryIndex);
|
||||||
|
int totalScore = categoryScore;
|
||||||
|
|
||||||
if (totalScore >= 108) {
|
if (totalScore >= 108) {
|
||||||
totalScore += BONUS;
|
totalScore += BONUS;
|
||||||
}
|
}
|
||||||
|
@ -346,10 +357,7 @@ public class Spiel {
|
||||||
return winner; // Einen Gewinner zurückbringen
|
return winner; // Einen Gewinner zurückbringen
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void addHighscore(String highscore) {
|
public void addHighscore(String highscore) {
|
||||||
highscores.add(highscore);
|
highscores.add(highscore);
|
||||||
|
|
Loading…
Reference in New Issue