complete players package
This commit is contained in:
@@ -1,4 +1,118 @@
|
||||
package org.project.entity.players;
|
||||
|
||||
public class Assassin {
|
||||
import org.project.entity.Entity;
|
||||
import org.project.item.armors.LeatherArmor;
|
||||
import org.project.item.weapons.Dagger;
|
||||
|
||||
public class Assassin extends Player {
|
||||
|
||||
private boolean isHidden = false;
|
||||
private boolean nextAttackCritical = false;
|
||||
|
||||
public Assassin(String name)
|
||||
{
|
||||
super(name, 150, 120, new Dagger(), new LeatherArmor());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBaseDamage()
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void specialAbility(Entity target)
|
||||
{
|
||||
if (this.getMp() < costSpecial)
|
||||
{
|
||||
System.out.println(YELLOW+"Not enough Mana for Vanish!"+RESET);
|
||||
return;
|
||||
}
|
||||
|
||||
setIsHidden(true);
|
||||
setNextAttackCritical(true);
|
||||
this.setMp(this.getMp() - costSpecial);
|
||||
System.out.println("👻 " +PURPLE+ name + " has turned invisible!"+RESET);
|
||||
System.out.println("🎯 Next attack is guaranteed to be a Critical Hit!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void heavyAttack(Entity target) {
|
||||
int baseDmg = getBaseDamage() * 2;
|
||||
int weaponDmg = (weapon != null) ? weapon.getDamage() : 0;
|
||||
int totalDmg = baseDmg + weaponDmg;
|
||||
if (getNextAttackCritical()) {
|
||||
totalDmg *= 2;
|
||||
System.out.println("⚡ Critical Hit! Damage doubled!");
|
||||
setNextAttackCritical(false);
|
||||
}
|
||||
|
||||
|
||||
if (this.getMp() < costHeavy) {
|
||||
System.out.println(YELLOW+"Not enough Mana for Heavy Attack!"+RESET);
|
||||
return;
|
||||
}
|
||||
this.setMp(this.getMp() - costHeavy);
|
||||
|
||||
target.takeDamage(totalDmg);
|
||||
System.out.println("🔪 " + name + " (Assassin) used Heavy Attack! " + "( " + BLUE + costHeavy + RESET + " Mana)");
|
||||
System.out.println("💥 " + target.getClass().getSimpleName() + " took " + RED+totalDmg+RESET + " damage!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lightAttack(Entity target)
|
||||
{
|
||||
int baseDmg = getBaseDamage();
|
||||
int weaponDmg = (weapon != null) ? weapon.getDamage() : 0;
|
||||
int totalDmg = baseDmg + weaponDmg;
|
||||
if (getNextAttackCritical()) {
|
||||
totalDmg *= 2;
|
||||
System.out.println("⚡ Critical Hit! Damage doubled!");
|
||||
setNextAttackCritical(false);
|
||||
}
|
||||
|
||||
target.takeDamage(totalDmg);
|
||||
System.out.println("️🗡️ " + name + " (Assassin) used Light Attack! " + "( " + BLUE+costLight+RESET + " Mana)");
|
||||
System.out.println("💥 " + target.getClass().getSimpleName() + " took " + RED+totalDmg+RESET + " damage!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void heal(int health)
|
||||
{
|
||||
setHp(getHp() + health);
|
||||
if (this.getHp() > getMaxHP()) {
|
||||
setHp(getMaxHP());
|
||||
}
|
||||
System.out.println("💚" + name + " (Assassin) healed " + health + " HP!" );
|
||||
}
|
||||
@Override
|
||||
public void defend()
|
||||
{
|
||||
if (this.getMp() >= costDefend)
|
||||
{
|
||||
this.setMp(getMp() - costDefend);
|
||||
this.setDefending(true);
|
||||
System.out.println("🛡️" + name + " (Assassin) is defending!" + "( " + BLUE+costDefend+RESET + " Mana)");
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println(YELLOW+"Not enough Mana!"+RESET);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getIsHidden() {
|
||||
return isHidden;
|
||||
}
|
||||
|
||||
public void setIsHidden(boolean hidden) {
|
||||
isHidden = hidden;
|
||||
}
|
||||
|
||||
public boolean getNextAttackCritical() {
|
||||
return nextAttackCritical;
|
||||
}
|
||||
|
||||
public void setNextAttackCritical(boolean nextAttackCritical) {
|
||||
this.nextAttackCritical = nextAttackCritical;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,97 @@
|
||||
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.entity.Entity;
|
||||
import org.project.entity.enemies.Enemy;
|
||||
import org.project.item.armors.Armor;
|
||||
import org.project.item.armors.KnightArmor;
|
||||
import org.project.item.weapons.Sword;
|
||||
import org.project.item.weapons.Weapon;
|
||||
|
||||
public class Knight extends Player{
|
||||
|
||||
private boolean isStunned = false;
|
||||
public Knight(String name)
|
||||
{
|
||||
super(name, 120, 60, new Sword(), new KnightArmor());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBaseDamage()
|
||||
{
|
||||
return 15;
|
||||
//Knight has the highest base dmg
|
||||
}
|
||||
@Override
|
||||
public void specialAbility(Entity target)
|
||||
{
|
||||
if (this.getMp() < costSpecial)
|
||||
{
|
||||
System.out.println(YELLOW+"Not enough Mana for shield bash!"+RESET);
|
||||
return;
|
||||
}
|
||||
|
||||
this.setMp(this.getMp() - costSpecial);
|
||||
if (target instanceof Enemy) {
|
||||
Enemy enemyTarget = (Enemy) target;
|
||||
enemyTarget.setStunned(true);
|
||||
System.out.println("🛡️ " + PURPLE+getName() + " used Shield Bash!" +RESET+ "( " + BLUE+costSpecial+RESET + " Mana)");
|
||||
System.out.println("Enemy is Stunned and will skip their next turn!");
|
||||
}
|
||||
|
||||
int damage = getBaseDamage() + (weapon != null ? weapon.getDamage() : 0) + 10;
|
||||
target.takeDamage(damage);
|
||||
System.out.println("💥 " + target.getClass().getSimpleName() + " took " + RED+damage+RESET + " damage!");
|
||||
}
|
||||
|
||||
public void heavyAttack(Entity target)
|
||||
{
|
||||
int baseDmg = getBaseDamage() * 2;
|
||||
int weaponDmg = (weapon != null) ? weapon.getDamage() : 0;
|
||||
int totalDmg = baseDmg + weaponDmg;
|
||||
|
||||
if (this.getMp() < costHeavy)
|
||||
{
|
||||
System.out.println(YELLOW+"Not enough Mana for Heavy Attack!"+RESET);
|
||||
return;
|
||||
}
|
||||
this.setMp(this.getMp() - costHeavy);
|
||||
|
||||
target.takeDamage(totalDmg);
|
||||
System.out.println("💥 " + name + " (Knight) used Heavy Attack! " + "( " + BLUE+costHeavy+RESET + " Mana)");
|
||||
System.out.println("💥 " + target.getClass().getSimpleName() + " took " + RED+totalDmg+RESET + " damage!");
|
||||
}
|
||||
|
||||
public void lightAttack(Entity target)
|
||||
{
|
||||
int baseDmg = getBaseDamage();
|
||||
int weaponDmg = (weapon != null) ? weapon.getDamage() : 0;
|
||||
int totalDmg = baseDmg + weaponDmg;
|
||||
target.takeDamage(totalDmg);
|
||||
System.out.println("⚔️ " + name + " (Knight) used Light Attack! " + "( " + BLUE+costLight+RESET + " Mana)");
|
||||
System.out.println("💥 " + target.getClass().getSimpleName() + " took " + RED+totalDmg+RESET + " damage!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void heal(int health)
|
||||
{
|
||||
setHp(getHp() + health);
|
||||
if (this.getHp() > getMaxHP()) {
|
||||
setHp(getMaxHP());
|
||||
}
|
||||
System.out.println("💚" + name + " (Knight) healed " + health + " HP!" );
|
||||
}
|
||||
@Override
|
||||
public void defend()
|
||||
{
|
||||
if (this.getMp() >= costDefend)
|
||||
{
|
||||
this.setMp(getMp() - costDefend);
|
||||
this.setDefending(true);
|
||||
System.out.println("🛡️" + name + " (Knight) is defending!" + "( " + BLUE+costDefend+RESET + " Mana)");
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println(YELLOW+"Not enough Mana!"+RESET);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,7 @@ import org.project.entity.Entity;
|
||||
import org.project.item.armors.Armor;
|
||||
import org.project.item.weapons.Weapon;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public abstract class Player {
|
||||
public abstract class Player implements Entity {
|
||||
protected String name;
|
||||
Weapon weapon;
|
||||
Armor armor;
|
||||
@@ -13,38 +12,46 @@ public abstract class Player {
|
||||
private int maxHP;
|
||||
private int mp;
|
||||
private int maxMP;
|
||||
private int currentXp = 0;
|
||||
private int level = 1;
|
||||
private int xpToNextLevel = 100;
|
||||
|
||||
public Player(String name, int hp, int mp, Weapon weapon, Armor armor) {
|
||||
protected static final int costLight = 0;
|
||||
protected static final int costHeavy = 20;
|
||||
protected static final int costDefend = 15;
|
||||
protected static final int costHeal = 30;
|
||||
protected static final int costSpecial = 50;
|
||||
private boolean isDefending = false;
|
||||
|
||||
public static final String BLUE = "\u001B[34m";
|
||||
public static final String RED = "\033[31m";
|
||||
public static final String YELLOW = "\033[33m";
|
||||
protected static final String PURPLE = "\033[35m";
|
||||
public static final String RESET = "\u001B[0m";
|
||||
|
||||
public Player(String name, int maxHP, int maxMP, Weapon weapon, Armor armor) {
|
||||
this.name = name;
|
||||
this.hp = hp;
|
||||
this.mp = mp;
|
||||
|
||||
this.hp = maxHP;
|
||||
this.mp = maxMP;
|
||||
this.weapon = weapon;
|
||||
this.armor = armor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attack(Entity target) {
|
||||
target.takeDamage(weapon.getDamage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void defend() {
|
||||
// TODO
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void takeDamage(int damage) {
|
||||
hp -= damage - armor.getDefense();
|
||||
if (isDefending)
|
||||
{
|
||||
damage = (int) (damage * 0.1);
|
||||
isDefending = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void heal(int health) {
|
||||
hp += health;
|
||||
if (hp > maxHP) {
|
||||
hp = maxHP;
|
||||
int actualDamage = Math.max(0, damage - (armor != null ? armor.getDefense() : 0));
|
||||
hp -= actualDamage;
|
||||
if (this.hp < 0)
|
||||
{
|
||||
this.hp = 0;
|
||||
}
|
||||
System.out.println("💥 " + name + " took " + RED+damage+RESET + " damage!");
|
||||
System.out.println("❤️ " + name + " HP remaining: " + hp + "/" + maxHP);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -55,7 +62,6 @@ public abstract class Player {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
@@ -85,5 +91,93 @@ public abstract class Player {
|
||||
public Armor getArmor() {
|
||||
return armor;
|
||||
}
|
||||
public void setMp(int mp) {
|
||||
this.mp = mp;
|
||||
}
|
||||
|
||||
public void setHp(int hp)
|
||||
{
|
||||
this.hp = hp;
|
||||
}
|
||||
|
||||
public int getCurrentXp() {
|
||||
return currentXp;
|
||||
}
|
||||
|
||||
public void setCurrentXp(int currentXp) {
|
||||
this.currentXp = currentXp;
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public void setLevel(int level) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public int getXpToNextLevel() {
|
||||
return xpToNextLevel;
|
||||
}
|
||||
|
||||
public void setXpToNextLevel(int xpToNextLevel) {
|
||||
this.xpToNextLevel = xpToNextLevel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAlive()
|
||||
{
|
||||
return getHp() > 0;
|
||||
}
|
||||
|
||||
public abstract int getBaseDamage();
|
||||
|
||||
|
||||
public void setDefending(boolean defending) {
|
||||
isDefending = defending;
|
||||
}
|
||||
|
||||
public boolean isDefending() {
|
||||
return isDefending;
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract void defend();
|
||||
@Override
|
||||
public abstract void heal(int health);
|
||||
public abstract void lightAttack(Entity target);
|
||||
public abstract void specialAbility(Entity target);
|
||||
public abstract void heavyAttack(Entity target);
|
||||
|
||||
public void addXp(int amount)
|
||||
{
|
||||
this.setCurrentXp(getCurrentXp()+amount);
|
||||
System.out.println("✨ You earned "+ amount + " XP!");
|
||||
while (this.getCurrentXp() >= this.getXpToNextLevel())
|
||||
{
|
||||
levelUp();
|
||||
}
|
||||
}
|
||||
|
||||
public void levelUp()
|
||||
{
|
||||
this.setCurrentXp(this.getCurrentXp()-this.getXpToNextLevel());
|
||||
this.setLevel(this.getLevel()+1);
|
||||
|
||||
int hpBonus = 10 + (this.getLevel() * 5);
|
||||
int mpBonus = 5 + (this.getLevel() * 2);
|
||||
|
||||
this.maxHP += hpBonus;
|
||||
this.maxMP += mpBonus;
|
||||
|
||||
this.hp = this.maxHP;
|
||||
this.mp = this.maxMP;
|
||||
|
||||
this.setXpToNextLevel((int) (this.getXpToNextLevel()*1.5));
|
||||
|
||||
System.out.println("🎉 LEVEL UP! You are now Level " + this.getLevel() + "!");
|
||||
System.out.println("❤️ Max HP increased to " + this.maxHP);
|
||||
System.out.println("💎 Max MP increased to " + this.maxMP);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,92 @@
|
||||
package org.project.entity.players;
|
||||
|
||||
public class Wizard {
|
||||
import org.project.entity.Entity;
|
||||
import org.project.item.armors.Robe;
|
||||
import org.project.item.weapons.Wand;
|
||||
|
||||
public class Wizard extends Player{
|
||||
|
||||
public Wizard(String name)
|
||||
{
|
||||
super(name, 200, 100, new Wand(), new Robe());
|
||||
//Wizard: Highest Max Health (HP).
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBaseDamage()
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void specialAbility(Entity target)
|
||||
{
|
||||
if (this.getMp() < costSpecial)
|
||||
{
|
||||
System.out.println(YELLOW+"Not enough Mana for Soul Siphon!"+RESET);
|
||||
return;
|
||||
}
|
||||
this.setMp(this.getMp() - costSpecial);
|
||||
int damage = getBaseDamage() + (weapon != null ? weapon.getDamage() : 0) + 25;
|
||||
target.takeDamage(damage);
|
||||
int selfHeal = 15;
|
||||
|
||||
System.out.println("🪄 " +PURPLE+ name + " (Wizard) used soul siphon!"+RESET + " (" + BLUE+costSpecial+RESET + " Mana)");
|
||||
System.out.println("💥 " + target.getClass().getSimpleName() + " took " + RED+damage+RESET + " damage!");
|
||||
heal(selfHeal);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void heavyAttack(Entity target)
|
||||
{
|
||||
int baseDmg = getBaseDamage() * 2;
|
||||
int weaponDmg = (weapon != null) ? weapon.getDamage() : 0;
|
||||
int totalDmg = baseDmg + weaponDmg;
|
||||
|
||||
if (this.getMp() < costHeavy)
|
||||
{
|
||||
System.out.println(YELLOW+"Not enough Mana for Heavy Attack!"+RESET);
|
||||
return;
|
||||
}
|
||||
this.setMp(this.getMp() - costHeavy);
|
||||
|
||||
target.takeDamage(totalDmg);
|
||||
System.out.println("💥 " + name + " (Wizard) used Heavy Attack! " + "( " + BLUE+costHeavy+RESET + " Mana)");
|
||||
System.out.println("💥 " + target.getClass().getSimpleName() + " took " + RED+totalDmg+RESET + " fire damage!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lightAttack(Entity target)
|
||||
{
|
||||
int baseDmg = getBaseDamage();
|
||||
int weaponDmg = (weapon != null) ? weapon.getDamage() : 0;
|
||||
int totalDmg = baseDmg + weaponDmg;
|
||||
target.takeDamage(totalDmg);
|
||||
System.out.println("️🧙 " + name + " (Wizard) used Light Attack! " + "( " + BLUE+costLight+RESET + " Mana)");
|
||||
System.out.println("💥 " + target.getClass().getSimpleName() + " took " + RED+totalDmg+RESET + " magical damage!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void heal(int health)
|
||||
{
|
||||
setHp(getHp() + health);
|
||||
if (this.getHp() > getMaxHP()) {
|
||||
setHp(getMaxHP());
|
||||
}
|
||||
System.out.println("💚" + name + " (Wizard) healed " + health + " HP!" );
|
||||
}
|
||||
@Override
|
||||
public void defend()
|
||||
{
|
||||
if (this.getMp() >= costDefend)
|
||||
{
|
||||
this.setMp(getMp() - costDefend);
|
||||
this.setDefending(true);
|
||||
System.out.println("🛡️" + name + " (Wizard) is defending!" + "( " + BLUE+costDefend+RESET + " Mana)");
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println(YELLOW+"Not enough Mana!"+RESET);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user