add Assassin.java Wizard.java Knight.java Player.java
This commit is contained in:
@@ -0,0 +1,38 @@
|
|||||||
|
package org.project.entity.players;
|
||||||
|
|
||||||
|
import org.project.abilities.ArcaneStorm;
|
||||||
|
import org.project.item.armors.Armor;
|
||||||
|
import org.project.item.armors.AssassinArmor;
|
||||||
|
import org.project.item.weapons.Dagger;
|
||||||
|
|
||||||
|
public class Assassin extends Player {
|
||||||
|
|
||||||
|
private static final int MAX_HP = 90;
|
||||||
|
private static final int MAX_MP = 120;
|
||||||
|
private static final int LEVEL = 1;
|
||||||
|
private static final int XP = 0;
|
||||||
|
private static final int BASE_DAMAGE = 15;
|
||||||
|
|
||||||
|
private final Armor personalArmor =
|
||||||
|
new AssassinArmor();
|
||||||
|
|
||||||
|
public Assassin(String name) {
|
||||||
|
|
||||||
|
super(
|
||||||
|
name,
|
||||||
|
MAX_HP,
|
||||||
|
MAX_MP,
|
||||||
|
LEVEL,
|
||||||
|
XP,
|
||||||
|
null,
|
||||||
|
BASE_DAMAGE,
|
||||||
|
new Dagger(),
|
||||||
|
new ArcaneStorm()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Armor getPersonalArmor() {
|
||||||
|
return personalArmor;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,38 @@
|
|||||||
package org.project.entity.players;
|
package org.project.entity.players;
|
||||||
|
|
||||||
// TODO: UPDATE IMPLEMENTATION
|
import org.project.abilities.GuardianOath;
|
||||||
public class Knight {
|
import org.project.item.armors.Armor;
|
||||||
// TODO: DESIGN KNIGHT'S WEAPON AND ARMOR AND IMPLEMENT THE CONSTRUCTOR
|
import org.project.item.armors.KnightArmor;
|
||||||
|
import org.project.item.weapons.Sword;
|
||||||
|
|
||||||
|
public class Knight extends Player {
|
||||||
|
|
||||||
|
private static final int MAX_HP = 150;
|
||||||
|
private static final int MAX_MP = 80;
|
||||||
|
private static final int LEVEL = 1;
|
||||||
|
private static final int XP = 0;
|
||||||
|
private static final int BASE_DAMAGE = 12;
|
||||||
|
|
||||||
|
private final Armor personalArmor =
|
||||||
|
new KnightArmor();
|
||||||
|
|
||||||
|
public Knight(String name) {
|
||||||
|
|
||||||
|
super(
|
||||||
|
name,
|
||||||
|
MAX_HP,
|
||||||
|
MAX_MP,
|
||||||
|
LEVEL,
|
||||||
|
XP,
|
||||||
|
null,
|
||||||
|
BASE_DAMAGE,
|
||||||
|
new Sword(),
|
||||||
|
new GuardianOath()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Armor getPersonalArmor() {
|
||||||
|
return personalArmor;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,89 +1,359 @@
|
|||||||
package org.project.entity.players;
|
package org.project.entity.players;
|
||||||
|
|
||||||
|
import org.project.abilities.SpecialAbility;
|
||||||
import org.project.entity.Entity;
|
import org.project.entity.Entity;
|
||||||
import org.project.item.armors.Armor;
|
import org.project.item.armors.Armor;
|
||||||
import org.project.item.weapons.Weapon;
|
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 Player implements Entity {
|
||||||
public abstract class Player {
|
|
||||||
protected String name;
|
// =========================================================
|
||||||
Weapon weapon;
|
// BASIC INFO
|
||||||
Armor armor;
|
// =========================================================
|
||||||
|
|
||||||
|
private final String name;
|
||||||
|
|
||||||
|
private int level;
|
||||||
|
private int xp;
|
||||||
|
|
||||||
|
// =========================================================
|
||||||
|
// STATS
|
||||||
|
// =========================================================
|
||||||
|
|
||||||
|
private int maxHp;
|
||||||
private int hp;
|
private int hp;
|
||||||
private int maxHP;
|
|
||||||
|
private int maxMp;
|
||||||
private int mp;
|
private int mp;
|
||||||
private int maxMP;
|
|
||||||
|
|
||||||
public Player(String name, int hp, int mp, Weapon weapon, Armor armor) {
|
private int baseDamage;
|
||||||
|
|
||||||
|
// =========================================================
|
||||||
|
// EQUIPMENT
|
||||||
|
// =========================================================
|
||||||
|
|
||||||
|
private Armor armor;
|
||||||
|
private Weapon weapon;
|
||||||
|
|
||||||
|
// =========================================================
|
||||||
|
// ABILITIES
|
||||||
|
// =========================================================
|
||||||
|
|
||||||
|
protected 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 Player(
|
||||||
|
String name,
|
||||||
|
int maxHp,
|
||||||
|
int maxMp,
|
||||||
|
int level,
|
||||||
|
int xp,
|
||||||
|
Armor armor,
|
||||||
|
int baseDamage,
|
||||||
|
Weapon weapon,
|
||||||
|
SpecialAbility specialAbility
|
||||||
|
) {
|
||||||
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.hp = hp;
|
|
||||||
this.mp = mp;
|
|
||||||
|
|
||||||
this.weapon = weapon;
|
this.maxHp = maxHp;
|
||||||
|
this.hp = maxHp;
|
||||||
|
|
||||||
|
this.maxMp = maxMp;
|
||||||
|
this.mp = maxMp;
|
||||||
|
|
||||||
|
this.level = level;
|
||||||
|
this.xp = xp;
|
||||||
|
|
||||||
this.armor = armor;
|
this.armor = armor;
|
||||||
|
this.baseDamage = baseDamage;
|
||||||
|
this.weapon = weapon;
|
||||||
|
|
||||||
|
this.specialAbility = specialAbility;
|
||||||
|
|
||||||
|
this.effectManager = new StatusEffectManager();
|
||||||
|
this.abilityManager = new SpecialAbilityManager();
|
||||||
|
|
||||||
|
this.defending = false;
|
||||||
|
this.frozen = false;
|
||||||
|
this.stunned = false;
|
||||||
|
this.live = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// =========================================================
|
||||||
|
// STATUS EFFECTS
|
||||||
|
// =========================================================
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addStatusEffect(StatusEffect effect) {
|
||||||
|
effectManager.addEffect(effect, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void attack(Entity target) {
|
public void tickStatusEffects() {
|
||||||
target.takeDamage(weapon.getDamage());
|
effectManager.tick(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void heal(int amount) {
|
||||||
|
|
||||||
|
if (!live) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
hp += amount;
|
||||||
|
|
||||||
|
if (hp > maxHp) {
|
||||||
|
hp = maxHp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void useMana(int amount) {
|
||||||
|
|
||||||
|
if (amount <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mp < amount) {
|
||||||
|
|
||||||
|
System.out.println(name + " doesn't have enough mana!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mp -= amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void restoreMana(int amount) {
|
||||||
|
|
||||||
|
mp += amount;
|
||||||
|
|
||||||
|
if (mp > maxMp) {
|
||||||
|
mp = maxMp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// =========================================================
|
||||||
|
// STATES
|
||||||
|
// =========================================================
|
||||||
|
|
||||||
public void defend() {
|
public void defend() {
|
||||||
// TODO
|
defending = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void freeze() {
|
||||||
|
frozen = true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
public void stun() {
|
||||||
public void takeDamage(int damage) {
|
stunned = true;
|
||||||
hp -= damage - armor.getDefense();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void heal(int health) {
|
public void resetTurnState() {
|
||||||
hp += health;
|
|
||||||
if (hp > maxHP) {
|
defending = false;
|
||||||
hp = maxHP;
|
frozen = false;
|
||||||
|
stunned = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void restore() {
|
||||||
|
hp = maxHp;
|
||||||
|
mp = maxMp;
|
||||||
|
System.out.println(name + " fully restored!");
|
||||||
|
System.out.println(" HP: " + hp + "/" + maxHp + " | MP: " + mp + "/" + maxMp + "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
// =========================================================
|
||||||
|
// LEVEL SYSTEM
|
||||||
|
// =========================================================
|
||||||
|
|
||||||
|
public void gainXp(int amount) {
|
||||||
|
|
||||||
|
xp += amount;
|
||||||
|
|
||||||
|
while (xp >= level * 100) {
|
||||||
|
|
||||||
|
xp -= level * 100;
|
||||||
|
levelUp();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void levelUp() {
|
||||||
public void fillMana(int mana) {
|
|
||||||
mp += mana;
|
level++;
|
||||||
if (mp > maxMP) {
|
|
||||||
mp = maxMP;
|
maxHp += 20;
|
||||||
}
|
maxMp += 10;
|
||||||
|
|
||||||
|
baseDamage += 5;
|
||||||
|
|
||||||
|
hp = maxHp;
|
||||||
|
mp = maxMp;
|
||||||
|
|
||||||
|
System.out.println(name + " leveled up!");
|
||||||
|
System.out.println("Current Level: " + level);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// =========================================================
|
||||||
|
// GETTERS
|
||||||
|
// =========================================================
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getHp() {
|
public int getHp() {
|
||||||
return hp;
|
return hp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMaxHP() {
|
|
||||||
return maxHP;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMp() {
|
public int getMp() {
|
||||||
return mp;
|
return mp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getLevel() {
|
||||||
|
return level;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getXp() {
|
||||||
|
return xp;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMaxHP() {
|
||||||
|
return maxHp;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMaxMP() {
|
public int getMaxMP() {
|
||||||
return maxMP;
|
return maxMp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Weapon getWeapon() {
|
@Override
|
||||||
return weapon;
|
public int getBaseDamage() {
|
||||||
|
return baseDamage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Armor getArmor() {
|
public Armor getArmor() {
|
||||||
return armor;
|
return armor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Weapon getWeapon() {
|
||||||
|
return weapon;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Armor getPersonalArmor() {
|
||||||
|
return armor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDefending() {
|
||||||
|
return defending;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFrozen() {
|
||||||
|
return frozen;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isStunned() {
|
||||||
|
return stunned;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isLive() {
|
||||||
|
return live;
|
||||||
|
}
|
||||||
|
|
||||||
|
// =========================================================
|
||||||
|
// SETTERS
|
||||||
|
// =========================================================
|
||||||
|
|
||||||
|
@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));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setArmor(Armor armor) {
|
||||||
|
this.armor = armor;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setWeapon(Weapon weapon) {
|
||||||
|
this.weapon = weapon;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package org.project.entity.players;
|
||||||
|
|
||||||
|
import org.project.abilities.ArcaneStorm;
|
||||||
|
import org.project.item.armors.Armor;
|
||||||
|
import org.project.item.armors.WizardArmor;
|
||||||
|
import org.project.item.weapons.Sword;
|
||||||
|
|
||||||
|
public class Wizard extends Player {
|
||||||
|
|
||||||
|
private static final int MAX_HP = 80;
|
||||||
|
private static final int MAX_MP = 200;
|
||||||
|
private static final int LEVEL = 1;
|
||||||
|
private static final int XP = 0;
|
||||||
|
private static final int BASE_DAMAGE = 10;
|
||||||
|
|
||||||
|
private final Armor personalArmor =
|
||||||
|
new WizardArmor();
|
||||||
|
|
||||||
|
public Wizard(String name) {
|
||||||
|
|
||||||
|
super(
|
||||||
|
name,
|
||||||
|
MAX_HP,
|
||||||
|
MAX_MP,
|
||||||
|
LEVEL,
|
||||||
|
XP,
|
||||||
|
null,
|
||||||
|
BASE_DAMAGE,
|
||||||
|
new Sword(),
|
||||||
|
new ArcaneStorm()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Armor getPersonalArmor() {
|
||||||
|
return personalArmor;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user