Logic Player Completely changed
This commit is contained in:
@@ -2,10 +2,13 @@ package it.polimi.ingsw.gc14.Model;
|
||||
|
||||
import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
|
||||
import it.polimi.ingsw.gc14.Model.Cards.TribeCard;
|
||||
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Character;
|
||||
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.CharacterType;
|
||||
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import static java.lang.Math.abs;
|
||||
|
||||
@@ -16,20 +19,20 @@ public class Player {
|
||||
return UserName;
|
||||
}
|
||||
|
||||
private ArrayList <Character> CharacterCards;
|
||||
public ArrayList <Character> getCharacterCards() {
|
||||
ArrayList <Character> copy = new ArrayList <>();
|
||||
ArrayList<Character> temp = new ArrayList <>();
|
||||
temp.addAll(artists);
|
||||
temp.addAll(builders);
|
||||
temp.addAll(gatherers);
|
||||
temp.addAll(inventors);
|
||||
temp.addAll(shamans);
|
||||
temp.addAll(hunters);
|
||||
for(Character character:CharacterCards){
|
||||
copy.add(character.clone());
|
||||
}
|
||||
return copy;
|
||||
public int getTotCharacters() {
|
||||
return Arrays.stream(CharacterType.values())
|
||||
.mapToInt(this::getNType)
|
||||
.sum();
|
||||
}
|
||||
public int getNType(CharacterType type) {
|
||||
return switch (type) {
|
||||
case ARTIST -> artists.size();
|
||||
case INVENTOR -> inventors.size();
|
||||
case HUNTER -> hunters.size();
|
||||
case BUILDER -> builders.size();
|
||||
case SHAMAN -> shamans.size();
|
||||
case GATHERERS -> gatherers.size();
|
||||
};
|
||||
}
|
||||
|
||||
private ArrayList <BuildingCard> BuildingCards;
|
||||
@@ -71,9 +74,7 @@ public class Player {
|
||||
this.FoodValue += Value;
|
||||
}
|
||||
|
||||
// TODO, chiedere prof (throws IllegalArgument)
|
||||
public Boolean removeFood(int Value){
|
||||
// Value = abs(Value); chiedere prof
|
||||
if(Value > this.FoodValue){
|
||||
return false;
|
||||
}
|
||||
@@ -95,8 +96,15 @@ public class Player {
|
||||
// Constructors
|
||||
public Player(String UserName){
|
||||
this.UserName = UserName;
|
||||
this.CharacterCards = new ArrayList<Character>();
|
||||
this.BuildingCards = new ArrayList<BuildingCard>();
|
||||
|
||||
this.inventors = new ArrayList <>();
|
||||
this.builders = new ArrayList <>();
|
||||
this.gatherers = new ArrayList <>();
|
||||
this.shamans = new ArrayList <>();
|
||||
this.hunters = new ArrayList <>();
|
||||
this.artists = new ArrayList<>();
|
||||
|
||||
this.BuildingCards = new ArrayList<>();
|
||||
this.FoodValue = 0;
|
||||
this.PrestigeValue = 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user