Develop #1

Open
Ramtin wants to merge 35 commits from develop into main
5 changed files with 247 additions and 22 deletions
Showing only changes of commit 498d455277 - Show all commits
@@ -0,0 +1,53 @@
package org.project.entity.enemies;
import org.project.constants.gameConstant.AttackPowerUp;
import org.project.constants.gameConstant.EntityState;
import org.project.entity.Entity;
import org.project.entity.players.Player;
import org.project.item.Accessory.Costume;
import org.project.item.Accessory.Shield;
import org.project.item.Accessory.Weapon;
import org.project.item.Item;
import org.project.item.KeyItem;
import java.util.ArrayList;
public class Dragon extends Enemy {
public Dragon (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) {
super(name, maxHealth, health, money, baseDamage, state, weapon, shield, costume, inventory, defenseBonus, isDefending, healAmount, stamina, maxStamina);
this.Key = new KeyItem("Dragon Key", this);
}
public Dragon() {
this("Dragon", 5000, 5000, 0, 100, EntityState.ALIVE, null, null, null, new ArrayList<>(){}, 50, false, 50, 500, 500);
}
@Override
public void DropLoot(Player player) {
Key.Owner = player;
player.AddToInventory(Key);
}
@Override
public void SpecialAbility(Entity entity) {
ModifyStamina(SpecialAbilityStamina, false);
Damage(entity, GetDamage() * 2, new AttackPowerUp[]{AttackPowerUp.INEVITABLE, AttackPowerUp.ANTI_SHIELD});
}
@Override
public String GetSpecialAbilityDescription(Entity entity) {
return "Dragon will throw its fiery breath towards " + entity.Name + ". No defense and shield will help";
}
@Override
public String GetSpecialAbilityResultDescription(Entity entity) {
if (entity.IsDefending) {
return "Dragon will threw its fiery breath towards " + entity.Name + ". " + entity.Name + " tries to defend against it, but there's no use";
}
return "Dragon will threw its fiery breath towards " + entity.Name + ". To " + entity.Name + " surprise, their shield had no use";
}
}
@@ -1,34 +1,119 @@
package org.project.entity.enemies;
import org.project.item.weapons.Weapon;
import org.project.Interface.IDamageable;
import org.project.constants.gameConstant.AttackPowerUp;
import org.project.constants.gameConstant.EntityState;
import org.project.constants.gameConstant.FightMoves;
import org.project.constants.gameConstant.ItemClass;
import org.project.entity.Entity;
import org.project.entity.players.Player;
import org.project.item.Accessory.Costume;
import org.project.item.Accessory.Shield;
import org.project.item.Accessory.Weapon;
import org.project.item.Item;
import org.project.item.KeyItem;
// TODO: UPDATE IMPLEMENTATION
public abstract class Enemy {
Weapon weapon;
private int hp;
private int mp;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Objects;
import java.util.Random;
public Enemy(int hp, int mp, Weapon weapon) {
this.hp = hp;
this.mp = mp;
public abstract class Enemy extends Entity {
protected KeyItem Key;
this.weapon = weapon;
public Enemy (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) {
super(name, maxHealth, health, stamina, maxStamina, money, baseDamage, state, weapon, shield, costume, inventory, defenseBonus, isDefending, healAmount);
Key = new KeyItem(null, this);
}
protected Enemy() {
super();
}
public void DropLoot(Player player) {
Random random = new Random();
for (Item item : Inventory) {
int change = random.nextInt(2);
if (change == 0) {
player.AddToInventory(item);
}
}
ArrayList<Item> keys = player.GetInventoryByClass(ItemClass.KEY);
if (keys.stream().noneMatch(obj -> Objects.equals(obj.getName(), Key.getName()))) {
int chance = random.nextInt(5);
if (chance == 0) {
Key.Owner = player;
player.AddToInventory(Key);
}
}
player.ModifyMoney(GetMoney(), true);
}
public FightMoves PlayRound(Player player) {
ArrayList<FightMoves> moves = GetAvailableMoves();
Random random = new Random();
int change = random.nextInt(4);
if (change == 0 && moves.contains(FightMoves.HEAL)) {
HealMove();
return FightMoves.HEAL;
}
else if (change == 1 && moves.contains(FightMoves.DEFEND)) {
defend();
return FightMoves.DEFEND;
}
else if (moves.contains(FightMoves.SPECIAL)) {
SpecialAbility(player);
return FightMoves.SPECIAL;
}
else if (moves.contains(FightMoves.HEAVY_ATTACK)) {
HeavyAttack(player);
return FightMoves.HEAVY_ATTACK;
}
else if (moves.contains(FightMoves.LIGHT_ATTACK)) {
LightAttack(player);
return FightMoves.LIGHT_ATTACK;
}
else return null;
}
@Override
public void takeDamage(int damage) {
hp -= damage;
public void LightAttack(IDamageable target) {
int damage = GetDamage();
Damage(target, (int)(damage * 0.4), new AttackPowerUp[]{});
ModifyStamina(MaxStamina/8, true);
}
public int getHp() {
return hp;
@Override
public void HeavyAttack(IDamageable target) {
int damage = GetDamage();
ModifyStamina(HeavyAttackStamina, false);
Damage(target, (int)(damage * 0.9), new AttackPowerUp[]{});
}
public int getMp() {
return mp;
@Override
public void HealMove() {
super.HealMove();
ModifyStamina(MaxStamina/4, true);
}
public Weapon getWeapon() {
return weapon;
}
@Override
public abstract void SpecialAbility(Entity entity);
@Override
public abstract String GetSpecialAbilityDescription(Entity entity);
@Override
public abstract String GetSpecialAbilityResultDescription(Entity entity);
}
@@ -0,0 +1,43 @@
package org.project.entity.enemies;
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 org.project.item.KeyItem;
import java.util.ArrayList;
public class Goblin extends Enemy {
public Goblin (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) {
super(name, maxHealth, health, money, baseDamage, state, weapon, shield, costume, inventory, defenseBonus, isDefending, healAmount, stamina, maxStamina);
this.Key = new KeyItem("Goblin Key", this);
}
public Goblin() {
this("Goblin", 75, 75, 100, 10, EntityState.ALIVE, null, null, null, new ArrayList<>(), 5, false, 15, 100, 100);
}
@Override
public void SpecialAbility(Entity entity) {
ModifyStamina(SpecialAbilityStamina, false);
Damage(entity, GetDamage() * 4, new AttackPowerUp[]{});
}
@Override
public String GetSpecialAbilityDescription(Entity entity) {
return "Goblin will rage and cause a critical damage to " + entity.Name;
}
@Override
public String GetSpecialAbilityResultDescription(Entity entity) {
return "Goblin looks at " + entity.Name + ", its eyes are red... He rages and charges " + entity.Name + " with all of its power";
}
}
@@ -1,6 +1,5 @@
package org.project.entity.enemies;
// TODO: UPDATE IMPLEMENTATION
public class Skeleton {
// TODO: DESIGN ENEMY AND IMPLEMENT THE CONSTRUCTOR
public class Skeleton extends Enemy {
}
@@ -0,0 +1,45 @@
package org.project.entity.enemies;
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 org.project.item.KeyItem;
import java.util.ArrayList;
public class Vampire extends Enemy {
public Vampire (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) {
super(name, maxHealth, health, money, baseDamage, state, weapon, shield, costume, inventory, defenseBonus, isDefending, healAmount, stamina, maxStamina);
this.Key = new KeyItem("Vampire Key", this);
}
public Vampire() {
this("Vampire", 150, 150, 300, 20, EntityState.ALIVE, null, null, null, new ArrayList<>(), 8, false, 30, 100, 100);
}
@Override
public void SpecialAbility(Entity entity) {
int curHealth = entity.Health;
ModifyStamina(SpecialAbilityStamina, false);
Damage(entity, GetDamage(), new AttackPowerUp[]{AttackPowerUp.INEVITABLE});
Heal(curHealth - entity.Health);
}
@Override
public String GetSpecialAbilityDescription(Entity entity) {
return "Vampire will suck the blood out of " + entity.Name + " and heal themselves while hurting the enemy";
}
@Override
public String GetSpecialAbilityResultDescription(Entity entity) {
return "Vampire attacked " + entity.Name + " and sucked his blood out of his veins. He seems more powerful";
}
}