Gamelib/src/main/java/uulm/teamname/marvelous/gamelibrary/ai/Piece.java

92 lines
2.8 KiB
Java

package uulm.teamname.marvelous.gamelibrary.ai;
import uulm.teamname.marvelous.gamelibrary.entities.*;
import java.util.Arrays;
import java.util.HashSet;
class Piece {
public final PieceType type;
public EntityID id;
public Stat hp;
public Stat mp;
public Stat ap;
public HashSet<StoneType> inventory;
public StoneType stone;
public Piece(PieceType type) {
this.type = type;
this.id = null;
this.hp = null;
this.mp = null;
this.ap = null;
this.inventory = null;
this.stone = null;
}
public Piece(PieceType type, EntityID id) {
this.type = type;
this.id = id;
this.hp = null;
this.mp = null;
this.ap = null;
this.inventory = null;
this.stone = null;
}
public Piece(PieceType type, EntityID id, int hp, int maxHP) {
this.type = type;
this.id = id;
this.hp = new Stat(StatType.HP, hp, maxHP);
this.mp = null;
this.ap = null;
this.inventory = null;
this.stone = null;
}
public Piece(PieceType type, EntityID id, StoneType stone) {
this.type = type;
this.id = id;
this.hp = null;
this.mp = null;
this.ap = null;
this.inventory = null;
this.stone = stone;
}
public Piece(PieceType type, EntityID id, int hp, int maxHP, int mp, int maxMP, int ap, int maxAP, StoneType[] inventory) {
this.type = type;
this.id = id;
this.hp = new Stat(StatType.HP, hp, maxHP);
this.mp = new Stat(StatType.MP, mp, maxMP);
this.ap = new Stat(StatType.AP, ap, maxAP);
this.inventory = new HashSet<>(Arrays.asList(inventory));
this.stone = null;
}
private Piece(PieceType type, EntityID id, int hp, int maxHP, int mp, int maxMP, int ap, int maxAP, StoneType[] inventory, StoneType stone) {
this.type = type;
this.id = id;
this.hp = new Stat(StatType.HP, hp, maxHP);
this.mp = new Stat(StatType.MP, mp, maxMP);
this.ap = new Stat(StatType.AP, ap, maxAP);
this.inventory = new HashSet<>(Arrays.asList(inventory));
this.stone = stone;
}
public Piece clone() {
Piece clone = new Piece(type);
clone.id = this.id != null ? this.id.clone() : null;
clone.hp = this.hp != null ? new Stat(StatType.HP, this.hp.getValue(), this.hp.getMax()) : null;
clone.mp = this.mp != null ? new Stat(StatType.MP, this.mp.getValue(), this.mp.getMax()) : null;
clone.ap = this.ap != null ? new Stat(StatType.AP, this.ap.getValue(), this.ap.getMax()) : null;
clone.inventory = this.inventory != null ? (HashSet<StoneType>)this.inventory.clone() : null;
clone.stone = this.stone;
return clone;
}
}