Develop #1
@@ -1,7 +1,9 @@
|
||||
package org.project.Interface;
|
||||
|
||||
import org.project.constants.gameConstant.AttackPowerUp;
|
||||
|
||||
public interface IDamager {
|
||||
public void Damage(IDamageable target);
|
||||
public IDamager[] GetUtils();
|
||||
public void Damage(IDamageable target, int amount, AttackPowerUp[] powerUps);
|
||||
public IDamageUtil[] GetUtils();
|
||||
public int GetDamage();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.project.Interface;
|
||||
|
||||
import org.project.constants.gameConstant.FightMoves;
|
||||
import org.project.entity.Entity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public interface IFighter {
|
||||
public void LightAttack(IDamageable target);
|
||||
public void HeavyAttack(IDamageable target);
|
||||
public void defend();
|
||||
public void HealMove();
|
||||
public void SpecialAbility(Entity entity);
|
||||
public ArrayList<FightMoves> GetAvailableMoves();
|
||||
|
||||
public String GetSpecialAbilityDescription(Entity entity);
|
||||
|
||||
public String GetSpecialAbilityResultDescription(Entity entity);
|
||||
}
|
||||
@@ -2,5 +2,7 @@ package org.project.constants.gameConstant;
|
||||
|
||||
public enum AttackPowerUp {
|
||||
ANTI_SHIELD,
|
||||
ANTI_CUSTOM
|
||||
ANTI_CUSTOM,
|
||||
NO_DEFENSE,
|
||||
INEVITABLE,
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package org.project.constants.gameConstant;
|
||||
|
||||
public enum DefencePowerUp {
|
||||
INVISIBLE,
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package org.project.constants.gameConstant;
|
||||
|
||||
public enum FightMoves {
|
||||
LIGHT_ATTACK,
|
||||
HEAVY_ATTACK,
|
||||
HEAL,
|
||||
DEFEND,
|
||||
SPECIAL
|
||||
}
|
||||
@@ -1,13 +1,7 @@
|
||||
package org.project.entity;
|
||||
|
||||
import org.project.Interface.IDamageable;
|
||||
import org.project.Interface.IDefendable;
|
||||
import org.project.Interface.IDefender;
|
||||
import org.project.Interface.IHealable;
|
||||
import org.project.constants.gameConstant.AttackPowerUp;
|
||||
import org.project.constants.gameConstant.EntityState;
|
||||
import org.project.constants.gameConstant.ItemClass;
|
||||
import org.project.constants.gameConstant.ItemClassExt;
|
||||
import org.project.Interface.*;
|
||||
import org.project.constants.gameConstant.*;
|
||||
import org.project.item.Accessory.Costume;
|
||||
import org.project.item.Accessory.Shield;
|
||||
import org.project.item.Accessory.Weapon;
|
||||
@@ -15,22 +9,76 @@ import org.project.item.Item;
|
||||
import org.project.item.SellableItem;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
public abstract class Entity implements IDamageable, IHealable, IDefendable {
|
||||
public abstract class Entity implements IDamageable, IHealable, IDefendable, IFighter, IDamager {
|
||||
|
||||
public String Name;
|
||||
public int MaxHealth;
|
||||
public int Health;
|
||||
private int Stamina;
|
||||
protected int MaxStamina;
|
||||
private long Money;
|
||||
private int BaseDamage;
|
||||
protected int BaseDamage;
|
||||
private EntityState State;
|
||||
public Weapon Weapon;
|
||||
public Shield Shield;
|
||||
public Costume Costume;
|
||||
public ArrayList<Item> Inventory;
|
||||
protected int DefenseBonus;
|
||||
public boolean IsDefending;
|
||||
public ArrayList<DefencePowerUp> defencePowerUps;
|
||||
protected int HealAmount;
|
||||
protected int HeavyAttackStamina;
|
||||
protected int SpecialAbilityStamina;
|
||||
|
||||
public Entity(String name, int maxHealth, int health, int stamina, int maxStamina, long money, int baseDamage, EntityState state, Weapon weapon,
|
||||
Shield shield, Costume costume, ArrayList<Item> inventory, int defenseBonus, boolean isDefending, int healAmount) {
|
||||
|
||||
Name = name;
|
||||
MaxHealth = maxHealth;
|
||||
Health = health;
|
||||
Stamina = stamina;
|
||||
MaxStamina = maxStamina;
|
||||
Money = money;
|
||||
BaseDamage = baseDamage;
|
||||
State = state;
|
||||
Weapon = weapon;
|
||||
Shield = shield;
|
||||
Costume = costume;
|
||||
Inventory = inventory;
|
||||
DefenseBonus = defenseBonus;
|
||||
IsDefending = isDefending;
|
||||
HealAmount = healAmount;
|
||||
HeavyAttackStamina = 50;
|
||||
SpecialAbilityStamina = 100;
|
||||
}
|
||||
|
||||
protected Entity() {}
|
||||
|
||||
public int getStamina() { return Stamina; }
|
||||
|
||||
public void ResetStamina() { Stamina = MaxStamina; }
|
||||
|
||||
public void ModifyStamina(int amount, boolean dir) {
|
||||
if (dir) {
|
||||
Stamina += amount;
|
||||
|
||||
if (Stamina > MaxStamina) {
|
||||
Stamina = MaxStamina;
|
||||
}
|
||||
}
|
||||
|
||||
Stamina -= amount;
|
||||
if (Stamina < 0) {
|
||||
Stamina = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public EntityState GetState() { return State; }
|
||||
|
||||
public int GetBaseDamage() { return BaseDamage; }
|
||||
@Override
|
||||
public int GetDamage() { return BaseDamage; }
|
||||
|
||||
public long GetMoney() { return Money; }
|
||||
|
||||
@@ -48,6 +96,10 @@ public abstract class Entity implements IDamageable, IHealable, IDefendable {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void SetState(EntityState state) {
|
||||
State = state;
|
||||
}
|
||||
|
||||
public void ModifyMoney(long amount, boolean dir) {
|
||||
if (dir) {
|
||||
Money += amount;
|
||||
@@ -73,15 +125,28 @@ public abstract class Entity implements IDamageable, IHealable, IDefendable {
|
||||
|
||||
@Override
|
||||
public void TakeDamage(int amount, AttackPowerUp[] powerUps) {
|
||||
if (!defencePowerUps.contains(DefencePowerUp.INVISIBLE)) return;
|
||||
|
||||
IDefender[] defenders = GetDefenders();
|
||||
|
||||
for (IDefender defender : defenders) {
|
||||
if (defender != null) {
|
||||
amount = defender.Apply(amount, powerUps);
|
||||
if (Arrays.binarySearch(powerUps, AttackPowerUp.INEVITABLE) < 0) {
|
||||
for (IDefender defender : defenders) {
|
||||
if (defender != null) {
|
||||
amount = defender.Apply(amount, powerUps);
|
||||
}
|
||||
}
|
||||
|
||||
if (IsDefending) {
|
||||
if (Arrays.binarySearch(powerUps, AttackPowerUp.INEVITABLE) < 0) {
|
||||
amount -= DefenseBonus;
|
||||
}
|
||||
IsDefending = false;
|
||||
}
|
||||
}
|
||||
|
||||
Health -= amount;
|
||||
if (amount > 0) {
|
||||
Health -= amount;
|
||||
}
|
||||
|
||||
if (IsDestroyed()) {
|
||||
HandleZeroHealth();
|
||||
@@ -120,4 +185,40 @@ public abstract class Entity implements IDamageable, IHealable, IDefendable {
|
||||
public void RemoveFromInventory(Item item) {
|
||||
Inventory.remove(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract void LightAttack(IDamageable target);
|
||||
@Override
|
||||
public abstract void HeavyAttack(IDamageable target);
|
||||
@Override
|
||||
public void defend() {
|
||||
IsDefending = true;
|
||||
}
|
||||
@Override
|
||||
public void HealMove() {
|
||||
Heal(HealAmount);
|
||||
}
|
||||
@Override
|
||||
public abstract void SpecialAbility(Entity entity);
|
||||
|
||||
@Override
|
||||
public FightMoves[] getAvailableMoves() {
|
||||
ArrayList<FightMoves> result = new ArrayList<>();
|
||||
result.add(FightMoves.DEFEND);
|
||||
result.add(FightMoves.LIGHT_ATTACK);
|
||||
|
||||
if (Health < MaxHealth) {
|
||||
result.add(FightMoves.HEAL);
|
||||
}
|
||||
|
||||
if (Stamina > MaxStamina / 2) {
|
||||
result.add(FightMoves.SPECIAL);
|
||||
}
|
||||
|
||||
if (Stamina > MaxStamina / 4) {
|
||||
result.add(FightMoves.HEAVY_ATTACK);
|
||||
}
|
||||
|
||||
return result.toArray(new FightMoves[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package org.project.entity.players;
|
||||
|
||||
import org.project.constants.gameConstant.AttackPowerUp;
|
||||
import org.project.constants.gameConstant.EntityState;
|
||||
import org.project.entity.Entity;
|
||||
import org.project.item.Accessory.Costume;
|
||||
import org.project.item.Accessory.Shield;
|
||||
import org.project.item.Accessory.Weapon;
|
||||
import org.project.item.Item;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Assassin extends Player {
|
||||
public Assassin(String name, int maxHealth, int health, long money, int baseDamage, EntityState state, Weapon weapon,
|
||||
Shield shield, Costume costume, ArrayList<Item> inventory, int defenseBonus, boolean isDefending,
|
||||
int healAmount, int stamina, int maxStamina, int level, int levelProgress) {
|
||||
|
||||
super(name, maxHealth, health, money, baseDamage, state, weapon, shield, costume, inventory, defenseBonus, isDefending, healAmount, stamina, maxStamina, level, levelProgress);
|
||||
}
|
||||
|
||||
public Assassin(String name, int level) {
|
||||
this(name);
|
||||
LevelUpTo(level);
|
||||
}
|
||||
|
||||
public Assassin(String name) {
|
||||
this(name, 125, 125, 100, 15, EntityState.ALIVE, null, null, null, new ArrayList<>(), 5, false, 35, 100, 100, 1, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SpecialAbility(Entity entity) {
|
||||
ModifyStamina(SpecialAbilityStamina, false);
|
||||
entity.SetState(EntityState.FROZEN);
|
||||
Damage(entity, GetDamage() * 3, new AttackPowerUp[]{AttackPowerUp.NO_DEFENSE});
|
||||
Heal(MaxHealth/4);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String GetSpecialAbilityDescription(Entity entity) {
|
||||
return "Turn invisible and cause a critical damage to " + entity.Name + ". Your enemy cannot defend your attack \n";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String GetSpecialAbilityResultDescription(Entity entity) {
|
||||
if (entity.IsDefending) {
|
||||
return entity.Name + " Holds their guard up, but you strike them from another direction";
|
||||
}
|
||||
return "\"Show Yourself coward\" Says " + entity.Name + " As they helplessly try to hit you. But their eyes cannot find you no matter how hard they try";
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,50 @@
|
||||
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.constants.gameConstant.AttackPowerUp;
|
||||
import org.project.constants.gameConstant.EntityState;
|
||||
import org.project.entity.Entity;
|
||||
import org.project.item.Accessory.Costume;
|
||||
import org.project.item.Accessory.Shield;
|
||||
import org.project.item.Accessory.Weapon;
|
||||
import org.project.item.Item;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Knight extends Player {
|
||||
public Knight(String name, int maxHealth, int health, long money, int baseDamage, EntityState state, Weapon weapon,
|
||||
Shield shield, Costume costume, ArrayList<Item> inventory, int defenseBonus, boolean isDefending,
|
||||
int healAmount, int stamina, int maxStamina, int level, int levelProgress) {
|
||||
|
||||
super(name, maxHealth, health, money, baseDamage, state, weapon, shield, costume, inventory, defenseBonus, isDefending, healAmount, stamina, maxStamina, level, levelProgress);
|
||||
}
|
||||
|
||||
public Knight(String name, int level) {
|
||||
this(name);
|
||||
LevelUpTo(level);
|
||||
}
|
||||
|
||||
public Knight(String name) {
|
||||
this(name, 150, 150, 100, 20, EntityState.ALIVE, null, null, null, new ArrayList<>(), 8, false, 30, 100, 100, 1, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SpecialAbility(Entity entity) {
|
||||
ModifyStamina(SpecialAbilityStamina, false);
|
||||
Damage(entity, GetDamage(), new AttackPowerUp[]{});
|
||||
entity.SetState(EntityState.FROZEN);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String GetSpecialAbilityDescription(Entity entity) {
|
||||
return "Slam " + entity.Name + "with your unstoppable strength and stun them for the next turn";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String GetSpecialAbilityResultDescription(Entity entity) {
|
||||
if (entity.IsDefending) {
|
||||
return "You slammed " + entity.Name + ", they try to defend, but they were thrown to the ground";
|
||||
}
|
||||
|
||||
return "You slammed " + entity.Name + ", your enemy seems deezy";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,89 +1,113 @@
|
||||
package org.project.entity.players;
|
||||
|
||||
import org.project.Interface.IDamageUtil;
|
||||
import org.project.Interface.IDamageable;
|
||||
import org.project.constants.gameConstant.AttackPowerUp;
|
||||
import org.project.constants.gameConstant.EntityState;
|
||||
import org.project.entity.Entity;
|
||||
import org.project.item.armors.Armor;
|
||||
import org.project.item.weapons.Weapon;
|
||||
import org.project.item.Accessory.Costume;
|
||||
import org.project.item.Accessory.Shield;
|
||||
import org.project.item.Accessory.Weapon;
|
||||
import org.project.item.Item;
|
||||
|
||||
// TODO: UPDATE IMPLEMENTATION
|
||||
public abstract class Player {
|
||||
protected String name;
|
||||
Weapon weapon;
|
||||
Armor armor;
|
||||
private int hp;
|
||||
private int maxHP;
|
||||
private int mp;
|
||||
private int maxMP;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public Player(String name, int hp, int mp, Weapon weapon, Armor armor) {
|
||||
this.name = name;
|
||||
this.hp = hp;
|
||||
this.mp = mp;
|
||||
public abstract class Player extends Entity {
|
||||
public int Level;
|
||||
private int LevelProgress;
|
||||
|
||||
this.weapon = weapon;
|
||||
this.armor = armor;
|
||||
public Player (String name, int maxHealth, int health, long money, int baseDamage, EntityState state, Weapon weapon,
|
||||
Shield shield, Costume costume, ArrayList<Item> inventory, int defenseBonus, boolean isDefending,
|
||||
int healAmount, int stamina, int maxStamina, int level, int levelProgress) {
|
||||
|
||||
super(name, maxHealth, health, stamina, maxStamina, money, baseDamage, state, weapon, shield, costume, inventory, defenseBonus, isDefending, healAmount);
|
||||
|
||||
Level = level;
|
||||
LevelProgress = levelProgress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attack(Entity target) {
|
||||
target.takeDamage(weapon.getDamage());
|
||||
protected Player() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void defend() {
|
||||
// TODO
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void takeDamage(int damage) {
|
||||
hp -= damage - armor.GetDefense();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void heal(int health) {
|
||||
hp += health;
|
||||
if (hp > maxHP) {
|
||||
hp = maxHP;
|
||||
public void LevelUpTo(int level) {
|
||||
while (Level < level) {
|
||||
LevelUp();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillMana(int mana) {
|
||||
mp += mana;
|
||||
if (mp > maxMP) {
|
||||
mp = maxMP;
|
||||
public void AddLevelProgress(int amount) {
|
||||
LevelProgress += amount;
|
||||
|
||||
if (LevelProgress >= 100) {
|
||||
LevelUp();
|
||||
}
|
||||
}
|
||||
|
||||
public void LevelUp() {
|
||||
Level++;
|
||||
double upgradeRatio = (1.1 + ((double) Level * 0.02));
|
||||
int gift = Level * 10;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public int getHp() {
|
||||
return hp;
|
||||
LevelProgress -= 100;
|
||||
MaxStamina = (int) (MaxStamina * upgradeRatio);
|
||||
MaxHealth = (int) (MaxHealth * upgradeRatio);
|
||||
BaseDamage = (int) (BaseDamage * upgradeRatio);
|
||||
DefenseBonus = (int) (DefenseBonus * upgradeRatio);
|
||||
HealAmount = (int) (HealAmount * upgradeRatio);
|
||||
ModifyMoney(gift, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxHP() {
|
||||
return maxHP;
|
||||
}
|
||||
public int GetDamage() {
|
||||
int damage = BaseDamage;
|
||||
IDamageUtil[] utils = GetUtils();
|
||||
|
||||
public int getMp() {
|
||||
return mp;
|
||||
for (IDamageUtil util : utils) {
|
||||
if (util != null) {
|
||||
damage += util.GetDamage();
|
||||
}
|
||||
}
|
||||
|
||||
return damage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxMP() {
|
||||
return maxMP;
|
||||
public IDamageUtil[] GetUtils() {
|
||||
return new IDamageUtil[] {Weapon};
|
||||
}
|
||||
|
||||
public Weapon getWeapon() {
|
||||
return weapon;
|
||||
@Override
|
||||
public void Damage(IDamageable target, int amount, AttackPowerUp[] powerUps) {
|
||||
target.TakeDamage(amount, powerUps);
|
||||
}
|
||||
|
||||
public Armor getArmor() {
|
||||
return armor;
|
||||
@Override
|
||||
public void LightAttack(IDamageable target) {
|
||||
int damage = GetDamage();
|
||||
|
||||
Damage(target, (int)(damage * 0.5), new AttackPowerUp[]{});
|
||||
ModifyStamina(MaxStamina/8, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void HeavyAttack(IDamageable target) {
|
||||
int damage = GetDamage();
|
||||
ModifyStamina(HeavyAttackStamina, false);
|
||||
|
||||
Damage(target, damage, new AttackPowerUp[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void HealMove() {
|
||||
super.HealMove();
|
||||
ModifyStamina(MaxStamina/4, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract void SpecialAbility(Entity entity);
|
||||
|
||||
public abstract String GetSpecialAbilityDescription(Entity entity);
|
||||
|
||||
public abstract String GetSpecialAbilityResultDescription(Entity entity);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package org.project.entity.players;
|
||||
|
||||
import org.project.constants.gameConstant.AttackPowerUp;
|
||||
import org.project.constants.gameConstant.EntityState;
|
||||
import org.project.entity.Entity;
|
||||
import org.project.item.Accessory.Costume;
|
||||
import org.project.item.Accessory.Shield;
|
||||
import org.project.item.Accessory.Weapon;
|
||||
import org.project.item.Item;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Wizard extends Player {
|
||||
public Wizard(String name, int maxHealth, int health, long money, int baseDamage, EntityState state, Weapon weapon,
|
||||
Shield shield, Costume costume, ArrayList<Item> inventory, int defenseBonus, boolean isDefending,
|
||||
int healAmount, int stamina, int maxStamina, int level, int levelProgress) {
|
||||
|
||||
super(name, maxHealth, health, money, baseDamage, state, weapon, shield, costume, inventory, defenseBonus, isDefending, healAmount, stamina, maxStamina, level, levelProgress);
|
||||
}
|
||||
|
||||
public Wizard(String name, int level) {
|
||||
this(name);
|
||||
LevelUpTo(level);
|
||||
}
|
||||
|
||||
public Wizard(String name) {
|
||||
this(name, 100, 100, 100, 15, EntityState.ALIVE, null, null, null, new ArrayList<>(), 5, false, 40, 100, 100, 1, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SpecialAbility(Entity entity) {
|
||||
ModifyStamina(SpecialAbilityStamina, false);
|
||||
Damage(entity, GetDamage() * 3, new AttackPowerUp[]{AttackPowerUp.INEVITABLE});
|
||||
Heal(MaxHealth/4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String GetSpecialAbilityDescription(Entity entity) {
|
||||
return "Cast a spell to damage " + entity.Name + "and heal yourself. Your spell will pass enemy's defences";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String GetSpecialAbilityResultDescription(Entity entity) {
|
||||
return "You cased the spell, enemy cannot do anything but to look at you with fear";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user