add Assassin.java Wizard.java Knight.java Player.java

This commit is contained in:
2026-05-17 06:13:28 -07:00
parent e3d7d1d554
commit 011526da36
4 changed files with 415 additions and 37 deletions
@@ -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;
// TODO: UPDATE IMPLEMENTATION
public class Knight {
// TODO: DESIGN KNIGHT'S WEAPON AND ARMOR AND IMPLEMENT THE CONSTRUCTOR
import org.project.abilities.GuardianOath;
import org.project.item.armors.Armor;
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;
import org.project.abilities.SpecialAbility;
import org.project.entity.Entity;
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 Player {
protected String name;
Weapon weapon;
Armor armor;
public abstract class Player implements Entity {
// =========================================================
// BASIC INFO
// =========================================================
private final String name;
private int level;
private int xp;
// =========================================================
// STATS
// =========================================================
private int maxHp;
private int hp;
private int maxHP;
private int maxMp;
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.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.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
public void attack(Entity target) {
target.takeDamage(weapon.getDamage());
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;
}
}
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() {
// TODO
defending = true;
}
public void freeze() {
frozen = true;
}
@Override
public void takeDamage(int damage) {
hp -= damage - armor.getDefense();
public void stun() {
stunned = true;
}
@Override
public void heal(int health) {
hp += health;
if (hp > maxHP) {
hp = maxHP;
public void resetTurnState() {
defending = false;
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 fillMana(int mana) {
mp += mana;
if (mp > maxMP) {
mp = maxMP;
}
public void levelUp() {
level++;
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() {
return name;
}
@Override
public int getHp() {
return hp;
}
@Override
public int getMaxHP() {
return maxHP;
}
public int getMp() {
return mp;
}
public int getLevel() {
return level;
}
public int getXp() {
return xp;
}
@Override
public int getMaxHP() {
return maxHp;
}
@Override
public int getMaxMP() {
return maxMP;
return maxMp;
}
public Weapon getWeapon() {
return weapon;
@Override
public int getBaseDamage() {
return baseDamage;
}
@Override
public Armor getArmor() {
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;
}
}