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