Fix: character list in player
This commit is contained in:
@@ -2,7 +2,8 @@ package it.polimi.ingsw.gc14.Model.Cards.TribeCards;
|
||||
|
||||
import it.polimi.ingsw.gc14.Model.Cards.TribeCard;
|
||||
|
||||
public abstract class Character extends TribeCard {
|
||||
|
||||
public abstract class Character extends TribeCard implements Cloneable {
|
||||
private CharacterType type;
|
||||
public CharacterType getType() {
|
||||
return type;
|
||||
@@ -17,5 +18,7 @@ public abstract class Character extends TribeCard {
|
||||
public String toString() {
|
||||
return super.toString()+" "+type.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract Character clone();
|
||||
}
|
||||
|
||||
@@ -12,14 +12,20 @@ public class Artist extends Character {
|
||||
public Artist(int Era) {
|
||||
super(Era, CharacterType.ARTIST);
|
||||
}
|
||||
|
||||
public Artist(Artist copy){
|
||||
this(copy.getEra());
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Artist clone() {
|
||||
public Character clone() {
|
||||
return new Artist(getEra());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -21,11 +21,17 @@ public class Builder extends Character
|
||||
}
|
||||
this.reductionValue = reductionValue;
|
||||
}
|
||||
public Builder(Builder copy)
|
||||
{
|
||||
this(copy.getEra(),copy.getReductionValue());
|
||||
}
|
||||
@Override
|
||||
public String toString() { return super.toString()+" Reduction Value: " + String.valueOf(reductionValue); }
|
||||
|
||||
@Override
|
||||
public Builder clone() {
|
||||
return new Builder(getEra(),reductionValue);
|
||||
public Character clone() {
|
||||
return new Builder(this);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -18,7 +18,8 @@ public class Gatherers extends Character {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Gatherers clone() {
|
||||
public Character clone() {
|
||||
return new Gatherers(getEra());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,7 +30,8 @@ public class Hunter extends Character {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Hunter clone() {
|
||||
return new Hunter(getEra(),icon);
|
||||
public Character clone() {
|
||||
return new Hunter(getEra(), getIcon());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,7 +31,8 @@ public class Inventor extends Character {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Inventor clone() {
|
||||
public Character clone() {
|
||||
return new Inventor(getEra(),icon);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters;
|
||||
|
||||
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;
|
||||
|
||||
@@ -30,7 +31,8 @@ public class Shaman extends Character {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Shaman clone() {
|
||||
return new Shaman(getEra(),icon);
|
||||
public Character clone() {
|
||||
return new Shaman(getEra(), getIcon());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ 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 java.util.ArrayList;
|
||||
|
||||
@@ -15,8 +16,12 @@ public class Player {
|
||||
}
|
||||
|
||||
private ArrayList <Character> CharacterCards;
|
||||
public ArrayList <TribeCard> getCharacterCards() {
|
||||
return CharacterCards.clone();
|
||||
public ArrayList <Character> getCharacterCards() {
|
||||
ArrayList <Character> copy = new ArrayList <>();
|
||||
for(Character character:CharacterCards){
|
||||
copy.add(character.clone());
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
private ArrayList <BuildingCard> BuildingCards;
|
||||
@@ -51,13 +56,6 @@ public class Player {
|
||||
this.UserName = UserName;
|
||||
}
|
||||
|
||||
public void setTribeCards(ArrayList <TribeCard> TribeCards){
|
||||
this.TribeCards = TribeCards;
|
||||
}
|
||||
|
||||
public void setBuildingCards(ArrayList <BuildingCard> BuildingCards){
|
||||
this.BuildingCards = BuildingCards;
|
||||
}
|
||||
|
||||
public void addFood(int Value){
|
||||
this.FoodValue += Value;
|
||||
@@ -87,7 +85,7 @@ public class Player {
|
||||
// Constructors
|
||||
public Player(String UserName){
|
||||
this.UserName = UserName;
|
||||
this.TribeCards = new ArrayList<TribeCard>();
|
||||
this.CharacterCards = new ArrayList<Character>();
|
||||
this.BuildingCards = new ArrayList<BuildingCard>();
|
||||
this.FoodValue = 0;
|
||||
this.PrestigeValue = 0;
|
||||
|
||||
Reference in New Issue
Block a user