fix cards INVENTORS iconValue
This commit is contained in:
@@ -45,35 +45,27 @@ public class Tribe {
|
||||
|
||||
// Metodo per ottenere lo sconto in cibo in base a quanti gatherer abbiamo nella tribù
|
||||
public int gathererDiscount() {
|
||||
int discount = 0;
|
||||
for (CharacterCard c : characters) {
|
||||
if (c.getCharacterType() == CharacterType.GATHERER) {
|
||||
discount += 3; // i gatherers prendono sempre 3 cibi
|
||||
}
|
||||
}
|
||||
return discount;
|
||||
long gatherers = characters.stream()
|
||||
.filter(c -> c.getCharacterType() == CharacterType.GATHERER)
|
||||
.count();
|
||||
|
||||
return (int) gatherers * 3;
|
||||
}
|
||||
|
||||
// Metodo per ottenere lo sconto totale sugli edifici grazie ai builder nella tribù
|
||||
public int buildersDiscount() {
|
||||
int discount = 0;
|
||||
for (CharacterCard c : characters) {
|
||||
if (c.getCharacterType() == CharacterType.BUILDER) {
|
||||
discount += c.getIconValue(); // con getIconValue intendo lo sconto del costruttore
|
||||
}
|
||||
}
|
||||
return discount;
|
||||
return characters.stream()
|
||||
.filter(c -> c.getCharacterType() == CharacterType.BUILDER)
|
||||
.mapToInt(CharacterCard::getIconValue)
|
||||
.sum();
|
||||
}
|
||||
|
||||
// Metodo che conta quante stelle degli sciamani abbiamo in totale nella tribù
|
||||
public int shamansIcons() {
|
||||
int totalIcons = 0;
|
||||
for (CharacterCard c : characters) {
|
||||
if (c.getCharacterType() == CharacterType.SHAMAN) {
|
||||
totalIcons += c.getIconValue();
|
||||
}
|
||||
}
|
||||
return totalIcons;
|
||||
return characters.stream()
|
||||
.filter(c -> c.getCharacterType() == CharacterType.SHAMAN)
|
||||
.mapToInt(CharacterCard::getIconValue)
|
||||
.sum();
|
||||
}
|
||||
|
||||
// Metodo che restituisce il numero di artisti nella tribù
|
||||
@@ -88,13 +80,10 @@ public class Tribe {
|
||||
|
||||
// Metodo universale per contare le carte di un certo tipo all'interno della tribù
|
||||
public int countCharactersByType(CharacterType typeToCount) {
|
||||
int count = 0;
|
||||
for (CharacterCard c : characters) {
|
||||
if (c.getCharacterType() == typeToCount) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
long count = characters.stream()
|
||||
.filter(c -> c.getCharacterType() == typeToCount)
|
||||
.count();
|
||||
return (int) count;
|
||||
}
|
||||
|
||||
// Metodo che ritorna il numero totale di cibi ottenuti dopo aver pescato il cacciatore col cosciotto
|
||||
|
||||
Reference in New Issue
Block a user