The Dragon class and DragonClaw class completed.

This commit is contained in:
2026-05-10 20:44:42 +03:30
parent 92e5c2575f
commit 3f9ec31bba
7 changed files with 88 additions and 13 deletions
@@ -0,0 +1,75 @@
package org.project.entity.enemies;
import org.project.entity.Entity;
import org.project.entity.players.Player;
import org.project.item.weapons.BoneDagger;
import org.project.item.weapons.DragonClaw;
import java.util.Random;
public class Dragon extends Enemy {
private Random random;
public Dragon() {
super("Dragon", 150, 100, new DragonClaw());
this.random = new Random();
}
@Override
public void attack(Entity target) {
int chance = random.nextInt(100);
if (chance > 40) { //Fire breath chance 60%
//Fire breath attack
fireBreath(target);
} else {
//Normal claw attack
normalAttack(target);
}
}
private void normalAttack(Entity target) {
int damage = 25;
if (target instanceof Player) {
Player player = (Player) target;
if (player.isDefending()) {
System.out.println("🐉 Dragon ignores your pathetic shield!");
//Complete damage is done
}
}
target.takeDamage(damage);
System.out.println("🐉 Dragon strikes with its claw!");
System.out.println("💥 " + damage + " damage dealt to " + getName(target) + "!");
}
private void fireBreath(Entity target) {
int damage = 45;
System.out.println("🐉🐉🐉 DRAGON BREATHES FIRE! 🐉🐉🐉");
System.out.println("🔥🔥🔥 FIERY BREATH ENGULFS EVERYTHING! 🔥🔥🔥");
if (target instanceof Player) {
Player player = (Player) target;
if (player.isDefending()) {
System.out.println("🛡️ Your shield MELTS under the dragon's breath!");
System.out.println("🔥 Defense is USELESS against this attack!");
player.setDefending(false); //The defense is invalid
}
}
target.takeDamage(damage);
System.out.println("💥 " + getName(target) + " takes " + damage + " MASSIVE damage!");
}
@Override
public int getMaxHP() {
return 150;
}
@Override
public int getMaxMP() {
return 100;
}
}
@@ -1,9 +1,7 @@
package org.project.item.weapons;
import org.project.item.Item;
//The skeleton's weapon
public class BoneDagger extends Weapon implements Item {
public class BoneDagger extends Weapon {
public BoneDagger() {
super(10, 5);
}
@@ -3,7 +3,7 @@ package org.project.item.weapons;
import org.project.item.Item;
//The assassin's weapon
public class Dagger extends Weapon implements Item {
public class Dagger extends Weapon {
int abilityCharge;
public Dagger() {
@@ -0,0 +1,8 @@
package org.project.item.weapons;
//The dragon's weapon
public class DragonClaw extends Weapon {
public DragonClaw() {
super(25, 20);
}
}
@@ -1,9 +1,7 @@
package org.project.item.weapons;
import org.project.item.Item;
//The vampire's weapon
public class Rapier extends Weapon implements Item {
public class Rapier extends Weapon {
public Rapier() {
super(20, 10);
}
@@ -1,9 +1,7 @@
package org.project.item.weapons;
import org.project.item.Item;
//The goblin's weapon
public class ToothedHook extends Weapon implements Item {
public class ToothedHook extends Weapon {
public ToothedHook() {
super(15, 6);
}
@@ -1,9 +1,7 @@
package org.project.item.weapons;
import org.project.item.Item;
//The wizard's weapon
public class Wand extends Weapon implements Item {
public class Wand extends Weapon{
int abilityCharge;
public Wand() {