add copy methods to entities
This commit is contained in:
@@ -56,6 +56,32 @@ public abstract class Entity implements IDamageable, IHealable, IDefendable, IFi
|
||||
|
||||
protected Entity() {}
|
||||
|
||||
public Entity(Entity other) {
|
||||
this.Name = other.Name;
|
||||
this.MaxHealth = other.MaxHealth;
|
||||
this.Health = other.Health;
|
||||
this.Stamina = other.Stamina;
|
||||
this.MaxStamina = other.MaxStamina;
|
||||
this.Money = other.Money;
|
||||
this.BaseDamage = other.BaseDamage;
|
||||
this.State = other.State;
|
||||
|
||||
this.Weapon = other.Weapon == null ? null : new Weapon(other.Weapon.getName(), this, other.Weapon.GetPrice(), other.Weapon.GetHealth(), other.Weapon.GetMaxHealth(), other.Weapon.GetDamage());
|
||||
this.Shield = other.Shield == null ? null : new Shield(other.Shield.getName(), this, other.Shield.GetPrice(), other.Shield.GetHealth(), other.Shield.GetMaxHealth(), other.Shield.GetDefense());
|
||||
this.Costume = other.Costume == null ? null : new Costume(other.Costume.getName(), this, other.Costume.GetPrice(), other.Costume.GetHealth(), other.Costume.GetMaxHealth(), other.Costume.GetDefense());
|
||||
|
||||
this.Inventory = other.Inventory == null ? null : new ArrayList<>(other.Inventory);
|
||||
this.defencePowerUps = other.defencePowerUps == null ? null : new ArrayList<>(other.defencePowerUps);
|
||||
|
||||
this.DefenseBonus = other.DefenseBonus;
|
||||
this.IsDefending = other.IsDefending;
|
||||
this.HealAmount = other.HealAmount;
|
||||
this.HeavyAttackStamina = other.HeavyAttackStamina;
|
||||
this.SpecialAbilityStamina = other.SpecialAbilityStamina;
|
||||
}
|
||||
|
||||
public abstract Entity copy();
|
||||
|
||||
public int GetStamina() { return Stamina; }
|
||||
|
||||
public void ResetStamina() { Stamina = MaxStamina; }
|
||||
@@ -146,7 +172,7 @@ public abstract class Entity implements IDamageable, IHealable, IDefendable, IFi
|
||||
|
||||
@Override
|
||||
public void TakeDamage(int amount, AttackPowerUp[] powerUps) {
|
||||
if (!defencePowerUps.contains(DefencePowerUp.INVISIBLE)) return;
|
||||
if (defencePowerUps != null && !defencePowerUps.contains(DefencePowerUp.INVISIBLE)) return;
|
||||
|
||||
IDefender[] defenders = GetDefenders();
|
||||
|
||||
|
||||
@@ -26,6 +26,15 @@ public class Dragon extends Enemy {
|
||||
this("Dragon", 5000, 5000, 0, 100, EntityState.ALIVE, null, null, null, new ArrayList<>(){}, 50, false, 50, 500, 500, 1000);
|
||||
}
|
||||
|
||||
public Dragon (Dragon other) {
|
||||
super(other);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dragon copy() {
|
||||
return new Dragon(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void DropLoot(Player player) {
|
||||
Key.Owner = player;
|
||||
|
||||
@@ -36,6 +36,14 @@ public abstract class Enemy extends Entity {
|
||||
super();
|
||||
}
|
||||
|
||||
public Enemy(Enemy other) {
|
||||
super(other);
|
||||
this.Key = new KeyItem(other.Key.getName(), other.Key.Owner);
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract Enemy copy();
|
||||
|
||||
public void DropLoot(Player player) {
|
||||
Random random = new Random();
|
||||
|
||||
|
||||
@@ -25,6 +25,15 @@ public class Goblin extends Enemy {
|
||||
this("Goblin", 75, 75, 100, 10, EntityState.ALIVE, null, null, null, new ArrayList<>(), 5, false, 15, 100, 100, 50);
|
||||
}
|
||||
|
||||
public Goblin (Goblin other) {
|
||||
super(other);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Goblin copy() {
|
||||
return new Goblin(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SpecialAbility(Entity entity) {
|
||||
ModifyStamina(SpecialAbilityStamina, false);
|
||||
|
||||
@@ -29,6 +29,15 @@ public class Skeleton extends Enemy {
|
||||
this("Skeleton", 125, 125, 200, 15, EntityState.ALIVE, null, null, null, new ArrayList<>(), 5, false, 20, 100, 100, 100);
|
||||
}
|
||||
|
||||
public Skeleton (Skeleton other) {
|
||||
super(other);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Skeleton copy() {
|
||||
return new Skeleton(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<FightMoves> GetAvailableMoves() {
|
||||
if (GetState() == EntityState.FROZEN || GetState() == EntityState.DEAD) return new ArrayList<>(){};
|
||||
|
||||
@@ -25,6 +25,15 @@ public class Vampire extends Enemy {
|
||||
this("Vampire", 150, 150, 300, 20, EntityState.ALIVE, null, null, null, new ArrayList<>(), 8, false, 30, 100, 100, 150);
|
||||
}
|
||||
|
||||
public Vampire (Vampire other) {
|
||||
super(other);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vampire copy() {
|
||||
return new Vampire(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SpecialAbility(Entity entity) {
|
||||
int curHealth = entity.Health;
|
||||
|
||||
@@ -27,6 +27,15 @@ public class Assassin extends Player {
|
||||
this(name, 125, 125, 100, 15, EntityState.ALIVE, null, null, null, new ArrayList<>(), 5, false, 35, 100, 100, 1, 0);
|
||||
}
|
||||
|
||||
public Assassin(Assassin other) {
|
||||
super(other);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Assassin copy() {
|
||||
return new Assassin(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SpecialAbility(Entity entity) {
|
||||
ModifyStamina(SpecialAbilityStamina, false);
|
||||
|
||||
@@ -27,6 +27,15 @@ public class Knight extends Player {
|
||||
this(name, 150, 150, 100, 20, EntityState.ALIVE, null, null, null, new ArrayList<>(), 8, false, 30, 100, 100, 1, 0);
|
||||
}
|
||||
|
||||
public Knight(Knight other) {
|
||||
super(other);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Knight copy() {
|
||||
return new Knight(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SpecialAbility(Entity entity) {
|
||||
ModifyStamina(SpecialAbilityStamina, false);
|
||||
|
||||
@@ -29,6 +29,15 @@ public abstract class Player extends Entity {
|
||||
super();
|
||||
}
|
||||
|
||||
public Player(Player other) {
|
||||
super(other);
|
||||
this.Level = other.Level;
|
||||
this.LevelProgress = other.LevelProgress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract Player copy();
|
||||
|
||||
public void LevelUpTo(int level) {
|
||||
while (Level < level) {
|
||||
UnconditionalLevelUp();
|
||||
@@ -68,15 +77,15 @@ public abstract class Player extends Entity {
|
||||
int damage = GetDamage();
|
||||
|
||||
Damage(target, (int)(damage * 0.5), new AttackPowerUp[]{});
|
||||
ModifyStamina(MaxStamina/8, true);
|
||||
ModifyStamina(MaxStamina/8, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void HeavyAttack(IDamageable target) {
|
||||
int damage = GetDamage();
|
||||
ModifyStamina(HeavyAttackStamina, false);
|
||||
|
||||
Damage(target, damage, new AttackPowerUp[]{});
|
||||
ModifyStamina(HeavyAttackStamina, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -27,6 +27,15 @@ public class Wizard extends Player {
|
||||
this(name, 100, 100, 100, 15, EntityState.ALIVE, null, null, null, new ArrayList<>(), 5, false, 40, 100, 100, 1, 0);
|
||||
}
|
||||
|
||||
public Wizard(Wizard other) {
|
||||
super(other);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Wizard copy() {
|
||||
return new Wizard(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SpecialAbility(Entity entity) {
|
||||
ModifyStamina(SpecialAbilityStamina, false);
|
||||
|
||||
Reference in New Issue
Block a user