add Dragon.java Enemy.java Goblin.java Skeleton.java Vampire.java
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
package org.project.entity.enemies;
|
||||
|
||||
import org.project.abilities.InfernoBreath;
|
||||
import org.project.item.armors.Armor;
|
||||
import org.project.item.armors.DragonArmor;
|
||||
import org.project.item.weapons.Sword;
|
||||
|
||||
public class Dragon extends Enemy {
|
||||
|
||||
private static final String NAME = "Dragon";
|
||||
private static final int MAX_HP = 300;
|
||||
private static final int MAX_MP = 150;
|
||||
private static final int XP_REWARD = 500;
|
||||
private static final int BASE_DAMAGE = 30;
|
||||
|
||||
private final Armor personalArmor = new DragonArmor();
|
||||
|
||||
public Dragon() {
|
||||
|
||||
super(
|
||||
NAME,
|
||||
MAX_HP,
|
||||
MAX_MP,
|
||||
XP_REWARD,
|
||||
BASE_DAMAGE,
|
||||
null,
|
||||
new Sword(),
|
||||
new InfernoBreath()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Armor getPersonalArmor() {
|
||||
return personalArmor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Dragon{" +
|
||||
"MAX_HP : 300 | " +
|
||||
"MAX_MP : 150 | " +
|
||||
"XP_REWARD : 500 | " +
|
||||
"BASE_DAMAGE : 30 | " +
|
||||
"personalArmor = " + personalArmor +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -1,34 +1,322 @@
|
||||
package org.project.entity.enemies;
|
||||
|
||||
import org.project.abilities.SpecialAbility;
|
||||
import org.project.entity.Entity;
|
||||
import org.project.entity.players.Player;
|
||||
import org.project.item.armors.Armor;
|
||||
import org.project.item.weapons.Weapon;
|
||||
import org.project.managers.SpecialAbilityManager;
|
||||
import org.project.managers.StatusEffectManager;
|
||||
import org.project.weaponEffects.StatusEffect;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public abstract class Enemy {
|
||||
Weapon weapon;
|
||||
public abstract class Enemy implements Entity {
|
||||
|
||||
// =========================================================
|
||||
// BASIC INFO
|
||||
// =========================================================
|
||||
|
||||
private final String name;
|
||||
|
||||
// =========================================================
|
||||
// STATS
|
||||
// =========================================================
|
||||
|
||||
private int xpReward;
|
||||
|
||||
private int maxHp;
|
||||
private int hp;
|
||||
|
||||
private int maxMp;
|
||||
private int mp;
|
||||
|
||||
public Enemy(int hp, int mp, Weapon weapon) {
|
||||
this.hp = hp;
|
||||
this.mp = mp;
|
||||
private int baseDamage;
|
||||
|
||||
// =========================================================
|
||||
// EQUIPMENT
|
||||
// =========================================================
|
||||
|
||||
private Armor armor;
|
||||
private Weapon weapon;
|
||||
|
||||
// =========================================================
|
||||
// ABILITIES
|
||||
// =========================================================
|
||||
|
||||
private final SpecialAbility specialAbility;
|
||||
|
||||
private final StatusEffectManager effectManager;
|
||||
private final SpecialAbilityManager abilityManager;
|
||||
|
||||
// =========================================================
|
||||
// STATES
|
||||
// =========================================================
|
||||
|
||||
private boolean defending;
|
||||
private boolean frozen;
|
||||
private boolean stunned;
|
||||
private boolean live;
|
||||
|
||||
// =========================================================
|
||||
// CONSTRUCTOR
|
||||
// =========================================================
|
||||
|
||||
public Enemy(
|
||||
String name,
|
||||
int maxHp,
|
||||
int maxMp,
|
||||
int xpReward,
|
||||
int baseDamage,
|
||||
Armor armor,
|
||||
Weapon weapon,
|
||||
SpecialAbility specialAbility
|
||||
) {
|
||||
|
||||
this.name = name;
|
||||
|
||||
this.maxHp = maxHp;
|
||||
this.hp = maxHp;
|
||||
|
||||
this.maxMp = maxMp;
|
||||
this.mp = maxMp;
|
||||
|
||||
this.xpReward = xpReward;
|
||||
|
||||
this.baseDamage = baseDamage;
|
||||
|
||||
this.armor = armor;
|
||||
this.weapon = weapon;
|
||||
|
||||
this.specialAbility = specialAbility;
|
||||
|
||||
this.effectManager = new StatusEffectManager();
|
||||
this.abilityManager = new SpecialAbilityManager();
|
||||
this.live = true;
|
||||
}
|
||||
|
||||
// =========================================================
|
||||
// XP REWARD
|
||||
// =========================================================
|
||||
|
||||
public void rewardXp(Player player) {
|
||||
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
player.gainXp(xpReward);
|
||||
|
||||
System.out.println(
|
||||
player.getName() +
|
||||
" gained " +
|
||||
xpReward +
|
||||
" XP from defeating " +
|
||||
name
|
||||
);
|
||||
}
|
||||
|
||||
// =========================================================
|
||||
// STATUS EFFECTS
|
||||
// =========================================================
|
||||
|
||||
@Override
|
||||
public void addStatusEffect(StatusEffect effect) {
|
||||
effectManager.addEffect(effect, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void takeDamage(int damage) {
|
||||
hp -= damage;
|
||||
public void tickStatusEffects() {
|
||||
effectManager.tick(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StatusEffectManager getEffectManager() {
|
||||
return effectManager;
|
||||
}
|
||||
|
||||
// =========================================================
|
||||
// ABILITIES
|
||||
// =========================================================
|
||||
|
||||
@Override
|
||||
public void addAbilityEffect(SpecialAbility ability, Entity target) {
|
||||
abilityManager.addAbility(ability, target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tickAbilityEffects(Entity target) {
|
||||
abilityManager.tick(this, target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpecialAbility getSpacialAbility() {
|
||||
return specialAbility;
|
||||
}
|
||||
|
||||
// =========================================================
|
||||
// COMBAT
|
||||
// =========================================================
|
||||
|
||||
@Override
|
||||
public void takeDamage(int amount) {
|
||||
|
||||
int finalDamage = Math.max(0, amount);
|
||||
|
||||
hp -= finalDamage;
|
||||
if (hp <= 0) {
|
||||
hp = 0;
|
||||
live = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void heal(int amount) {
|
||||
|
||||
if (!live) {
|
||||
return;
|
||||
}
|
||||
|
||||
hp += amount;
|
||||
if (hp > maxHp) {
|
||||
hp = maxHp;
|
||||
System.out.println("HP reached maximum amount " + maxHp);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void useMana(int amount) {
|
||||
|
||||
if (amount <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mp < amount) {
|
||||
|
||||
System.out.println(name + " doesn't have enough mana!");
|
||||
return;
|
||||
}
|
||||
|
||||
mp -= amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void defend() {
|
||||
defending = true;
|
||||
}
|
||||
|
||||
|
||||
// =========================================================
|
||||
// STATES
|
||||
// =========================================================
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isDefending() {
|
||||
return defending;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFrozen() {
|
||||
return frozen;
|
||||
}
|
||||
|
||||
public boolean isStunned() {return stunned;}
|
||||
|
||||
@Override
|
||||
public void freeze() {
|
||||
frozen = true;
|
||||
}
|
||||
|
||||
public void stun() {
|
||||
stunned = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetTurnState() {
|
||||
|
||||
defending = false;
|
||||
frozen = false;
|
||||
stunned = false;
|
||||
}
|
||||
|
||||
// =========================================================
|
||||
// GETTERS
|
||||
// =========================================================
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHp() {
|
||||
return hp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMp() {
|
||||
return mp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxHP() {
|
||||
return maxHp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxMP() {
|
||||
return maxMp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBaseDamage() {
|
||||
return baseDamage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Weapon getWeapon() {
|
||||
return weapon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Armor getArmor() {
|
||||
return armor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Armor getPersonalArmor() {
|
||||
return armor;
|
||||
}
|
||||
|
||||
public boolean isLive() {
|
||||
return live;
|
||||
}
|
||||
|
||||
public int getXpReward() {
|
||||
return xpReward;
|
||||
}
|
||||
|
||||
// =========================================================
|
||||
// SETTERS
|
||||
// =========================================================
|
||||
|
||||
@Override
|
||||
public void setWeapon(Weapon weapon) {
|
||||
this.weapon = weapon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setArmor(Armor armor) {
|
||||
this.armor = armor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHp(int value) {
|
||||
hp = Math.max(0, Math.min(value, maxHp));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMp(int value) {
|
||||
mp = Math.max(0, Math.min(value, maxMp));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package org.project.entity.enemies;
|
||||
|
||||
import org.project.abilities.PoisonDagger;
|
||||
import org.project.item.armors.Armor;
|
||||
import org.project.item.armors.GoblinArmor;
|
||||
import org.project.item.weapons.Dagger;
|
||||
|
||||
public class Goblin extends Enemy {
|
||||
|
||||
private static final String NAME = "Goblin";
|
||||
private static final int MAX_HP = 45;
|
||||
private static final int MAX_MP = 50;
|
||||
private static final int XP_REWARD = 30;
|
||||
private static final int BASE_DAMAGE = 5;
|
||||
|
||||
private final Armor personalArmor = new GoblinArmor();
|
||||
|
||||
public Goblin() {
|
||||
|
||||
super(
|
||||
NAME,
|
||||
MAX_HP,
|
||||
MAX_MP,
|
||||
XP_REWARD,
|
||||
BASE_DAMAGE,
|
||||
null,
|
||||
new Dagger(),
|
||||
new PoisonDagger()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Armor getPersonalArmor() {
|
||||
return personalArmor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Goblin{" +
|
||||
"MAX_HP : 45 | " +
|
||||
"MAX_MP : 50 | " +
|
||||
"XP_REWARD : 30 | " +
|
||||
"BASE_DAMAGE : 5 | " +
|
||||
"personalArmor = " + personalArmor +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,47 @@
|
||||
package org.project.entity.enemies;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public class Skeleton {
|
||||
// TODO: DESIGN ENEMY AND IMPLEMENT THE CONSTRUCTOR
|
||||
import org.project.abilities.BoneStrike;
|
||||
import org.project.item.armors.Armor;
|
||||
import org.project.item.armors.SkeletonArmor;
|
||||
import org.project.item.weapons.Sword;
|
||||
|
||||
public class Skeleton extends Enemy {
|
||||
|
||||
private static final String NAME = "Skeleton";
|
||||
private static final int MAX_HP = 40;
|
||||
private static final int MAX_MP = 30;
|
||||
private static final int XP_REWARD = 25;
|
||||
private static final int BASE_DAMAGE = 7;
|
||||
|
||||
private final Armor personalArmor = new SkeletonArmor();
|
||||
|
||||
public Skeleton() {
|
||||
|
||||
super(
|
||||
NAME,
|
||||
MAX_HP,
|
||||
MAX_MP,
|
||||
XP_REWARD,
|
||||
BASE_DAMAGE,
|
||||
null,
|
||||
new Sword(),
|
||||
new BoneStrike()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Armor getPersonalArmor() {
|
||||
return personalArmor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Skeleton{" +
|
||||
"MAX_HP : 40 | " +
|
||||
"MAX_MP : 30 | " +
|
||||
"XP_REWARD : 25 | " +
|
||||
"BASE_DAMAGE : 7 | " +
|
||||
"personalArmor = " + personalArmor +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package org.project.entity.enemies;
|
||||
|
||||
import org.project.abilities.LifeSteal;
|
||||
import org.project.item.armors.Armor;
|
||||
import org.project.item.armors.VampireArmor;
|
||||
import org.project.item.weapons.Dagger;
|
||||
|
||||
public class Vampire extends Enemy {
|
||||
|
||||
private static final String NAME = "Vampire";
|
||||
private static final int MAX_HP = 90;
|
||||
private static final int MAX_MP = 80;
|
||||
private static final int XP_REWARD = 80;
|
||||
private static final int BASE_DAMAGE = 12;
|
||||
|
||||
private final Armor personalArmor = new VampireArmor();
|
||||
|
||||
public Vampire() {
|
||||
|
||||
super(
|
||||
NAME,
|
||||
MAX_HP,
|
||||
MAX_MP,
|
||||
XP_REWARD,
|
||||
BASE_DAMAGE,
|
||||
null,
|
||||
new Dagger(),
|
||||
new LifeSteal()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Armor getPersonalArmor() {
|
||||
return personalArmor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "vampire{" +
|
||||
"MAX_HP : 90 | " +
|
||||
"MAX_MP : 80 | " +
|
||||
"XP_REWARD : 80 | " +
|
||||
"BASE_DAMAGE : 12 | " +
|
||||
"personalArmor = " + personalArmor +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user