develop #1

Merged
Meraj merged 12 commits from develop into main 2026-05-18 22:10:15 +00:00
5 changed files with 261 additions and 9 deletions
Showing only changes of commit 9804cf7237 - Show all commits
@@ -1,4 +1,41 @@
package org.project.entity.enemies;
public class Dragon {
import org.project.entity.Entity;
import org.project.entity.players.Player;
import org.project.item.weapons.Weapon;
public class Dragon extends Enemy{
private static final double BREATH_DAMAGE_PENETRATION = 0.5;
public Dragon(Weapon weapon)
{
super(200, 0, weapon);
}
@Override
public void attack(Entity target)
{
if(!this.isAlive()) return;
int damage = 25;
if(super.getWeapon() != null)
{
damage += super.getWeapon().getDamage();
}
target.takeDamage(damage);
System.out.println("🐉 Dragon used Fire Breath!");
if (target instanceof Player)
{
Player player = (Player) target;
if (player.isDefending())
{
int penetrationDamage = (int) (damage * BREATH_DAMAGE_PENETRATION);
player.takeDamage(penetrationDamage);
System.out.println("🔥 Dragon's fiery breath bypassed the shield!");
System.out.println("💥 " + player.getName() + " took " + penetrationDamage + " additional damage from fire!");
}
}
}
}
@@ -1,29 +1,78 @@
package org.project.entity.enemies;
import org.project.entity.Entity;
import org.project.item.armors.Armor;
import org.project.item.weapons.Weapon;
// TODO: UPDATE IMPLEMENTATION
public abstract class Enemy {
public abstract class Enemy implements Entity{
Weapon weapon;
private int hp;
private int mp;
private int maxHp;
private boolean isAlive = true;
private int maxMp;
private int xpReward;
private boolean hasDroppedKey = false;
private boolean keyDroppable = false;
private boolean isStunned = false;
public static final String GREEN = "\u001B[32m";
public static final String RESET = "\u001B[0m";
public Enemy(int hp, int mp, Weapon weapon) {
this.hp = hp;
this.mp = mp;
this.weapon = weapon;
this.maxHp = maxHp;
}
@Override
public void takeDamage(int damage) {
if (!isAlive) return;
hp -= damage;
System.out.println("❤️ " + this.getClass().getSimpleName() + " HP remaining: " + hp + "/" + maxHp);
if (this.hp <= 0) {
this.hp = 0;
this.isAlive = false;
}
}
@Override
public void defend()
{
System.out.println(this.getClass().getSimpleName() + " attempts to defend!");
}
@Override
public void heal(int health)
{
if (!isAlive) return;
this.hp += health;
if (this.hp > maxHp) this.hp = maxHp;
System.out.println("💚 " + this.getClass().getSimpleName() + " healed " + health + " HP!");
}
@Override
public boolean isAlive() {
return this.isAlive;
}
public abstract void attack(Entity target);
public int getHp() {
return hp;
}
public void setHp(int hp)
{
this.hp = hp;
}
public int getMp() {
return mp;
}
@@ -31,4 +80,52 @@ public abstract class Enemy {
public Weapon getWeapon() {
return weapon;
}
public void setStunned(boolean b)
{
this.isStunned = b;
}
public int getXpReward()
{
return xpReward;
}
public boolean hasKey()
{
return keyDroppable && !hasDroppedKey;
}
public void dropKey()
{
if (keyDroppable && !hasDroppedKey)
{
hasDroppedKey = true;
System.out.println("🔑 " +GREEN+ this.getClass().getSimpleName() + " dropped a key!"+RESET);
}
}
public void setKeyDroppable(boolean droppable)
{
this.keyDroppable = droppable;
}
public void setXpReward(int xp)
{
this.xpReward = xp;
}
@Override
public void fillMana(int mana)
{
this.mp = 0;
}
public int getMaxHP() {
return maxHp;
}
public int getMaxMP() {
return maxHp;
}
}
@@ -1,4 +1,38 @@
package org.project.entity.enemies;
public class Goblin {
import org.project.entity.Entity;
import org.project.item.weapons.Weapon;
public class Goblin extends Enemy{
public Goblin(Weapon weapon)
{
super(30, 0, weapon);
}
@Override
public void attack(Entity target)
{
if (!this.isAlive()) return;
int baseDamage = 0;
if (super.getWeapon() != null)
{
baseDamage += super.getWeapon().getDamage();
}
else
{
baseDamage = 8;
}
if (Math.random() < 0.4)
{
int criticalDamage = baseDamage*2;
target.takeDamage(criticalDamage);
System.out.println("👹 Goblin used Critical Strike!");
}
else
{
target.takeDamage(baseDamage);
System.out.println("👹 Goblin used Slash!");
}
}
}
@@ -1,6 +1,53 @@
package org.project.entity.enemies;
// TODO: UPDATE IMPLEMENTATION
public class Skeleton {
// TODO: DESIGN ENEMY AND IMPLEMENT THE CONSTRUCTOR
import org.project.entity.Entity;
import org.project.item.weapons.Weapon;
public class Skeleton extends Enemy{
private boolean hasResurrected = false;
private int resurrectionThreshold;
public Skeleton(Weapon weapon)
{
super(40, 0, weapon);
this.resurrectionThreshold = 20;
}
@Override
public void takeDamage(int damage)
{
super.takeDamage(damage);
if (!this.isAlive() && !hasResurrected)
{
resurrect();
}
}
@Override
public void attack(Entity target)
{
if (!this.isAlive()) return;
int damage = 0;
if (super.getWeapon() != null)
{
damage = super.getWeapon().getDamage();
}
else
{
damage = 5;
}
target.takeDamage(damage);
}
public void resurrect()
{
int healAmount = super.getMaxHP() / 2;
super.heal(healAmount);
this.hasResurrected = true;
System.out.println("👻 Skeleton is rising from the grave! HP restored to " + super.getHp());
}
}
@@ -1,4 +1,41 @@
package org.project.entity.enemies;
public class Vampire {
import org.project.entity.Entity;
import org.project.item.weapons.Weapon;
public class Vampire extends Enemy{
private static final double lifeStealPercent = 0.3;
public Vampire(Weapon weapon)
{
super(60, 0, weapon);
}
@Override
public void attack(Entity target) {
if (!this.isAlive()) return;
int damage = 0;
if (super.getWeapon() != null) {
damage = super.getWeapon().getDamage();
}
else
{
damage = 12;
}
target.takeDamage(damage);
int healAmount = (int) (damage * lifeStealPercent);
if (healAmount > 0)
{
super.heal(healAmount);
System.out.println("🦇 Vampire used Life Drain and drained " + healAmount + " HP!");
}
else
{
System.out.println("🦇 Vampire used Bite!");
}
}
}