Complete Characters

This commit is contained in:
2026-05-05 17:56:16 +03:30
parent 78d4bedb08
commit 08f26044f0
13 changed files with 302 additions and 75 deletions
@@ -5,7 +5,9 @@ public interface Entity {
void defend();
void heal(int health);
void heal();
boolean isAlive();
void fillMana(int mana);
@@ -15,7 +17,5 @@ public interface Entity {
int getMaxMP();
/*
TODO: ADD OTHER REQUIRED AND BONUS METHODS
*/
void specialAbility(Entity target);
}
@@ -0,0 +1,21 @@
package org.project.entity.enemies;
import org.project.entity.Entity;
import org.project.item.weapons.Weapon;
public class Dragon extends Enemy
{
public Dragon(int hp, int mp) { super(30, 30); }
@Override
public void specialAbility(Entity target)
{
if(getMp() >= 5)
{
super.specialAbility(target);
target.takeDamage(10);
this.setMp(this.getMp() - 5);
System.out.println("The Dragon threw a huge fire at the player 🔥🔥");
}
}
}
@@ -1,34 +1,91 @@
package org.project.entity.enemies;
import org.project.item.weapons.Weapon;
import org.project.entity.Entity;
// TODO: UPDATE IMPLEMENTATION
public abstract class Enemy {
Weapon weapon;
public abstract class Enemy implements Entity {
protected boolean isDefending = false;
private int hp;
private int mp;
private int maxHP = 50;
private int maxMP = 50;
public Enemy(int hp, int mp, Weapon weapon) {
public Enemy(int hp, int mp) {
this.hp = hp;
this.mp = mp;
}
this.weapon = weapon;
@Override
public void attack(Entity target)
{
target.takeDamage(2);
System.out.println("Enemy is attacking ⚔️");
}
@Override
public void defend()
{
if(getMp() >= 3)
{
this.setMp(this.getMp() - 3);
System.out.println("Enemy is defending 🛡️");
isDefending = true;
}
else System.out.println("Enemy does not have enough mp to defend");
}
@Override
public void takeDamage(int damage) {
hp -= damage;
if(isDefending == true) {
damage = damage / 2;
hp -= damage;
isDefending = false;
System.out.println("Enemy get a little damage !");
}
else
{
hp -= damage;
if (hp < 0) hp = 0;
System.out.println("The enemy get damage 🩸");
}
}
public int getHp() {
return hp;
@Override
public void specialAbility(Entity target)
{
System.out.println("Enemy is using its special ability !");
}
public int getMp() {
return mp;
@Override
public void heal() {
if(getMp() >= 6) {
hp += 10;
if (hp > maxHP) hp = maxHP;
}
}
public Weapon getWeapon() {
return weapon;
@Override
public void fillMana(int mana) {
mp += mana;
if (mp > maxMP) {
mp = maxMP;
}
}
@Override
public boolean isAlive() { return hp > 0; }
@Override
public int getMaxHP() { return maxHP; }
@Override
public int getMaxMP() { return maxMP;}
public int getHp() { return hp; }
public void setHp(int newHp) { this.hp = newHp; }
public int getMp() { return mp; }
public void setMp(int newMp) { this.mp = newMp; }
}
@@ -0,0 +1,21 @@
package org.project.entity.enemies;
import org.project.entity.Entity;
import org.project.item.weapons.Weapon;
public class Goblin extends Enemy
{
public Goblin(int hp, int mp) { super(10, 15); }
@Override
public void specialAbility(Entity target)
{
if(getMp() >= 5)
{
super.specialAbility(target);
target.takeDamage(7);
this.setMp(this.getMp() - 5);
System.out.println("The Goblin struck a powerful below 👊");
}
}
}
@@ -1,6 +1,22 @@
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
{
public Skeleton(int hp, int mp) { super(10, 10); }
@Override
public void specialAbility(Entity target)
{
if(getMp() >= 4)
{
super.specialAbility(target);
target.takeDamage(0);
this.setMp(this.getMp() - 4);
this.setHp(10);
System.out.println("Skeleton is regenerating its bones !");
}
}
}
@@ -0,0 +1,20 @@
package org.project.entity.enemies;
import org.project.entity.Entity;
public class Vampire extends Enemy
{
public Vampire(int hp, int mp) { super(15, 20); }
@Override
public void specialAbility(Entity target)
{
if(getMp() >= 8)
{
super.specialAbility(target);
target.takeDamage(10);
this.setMp(this.getMp() - 8);
System.out.println("The Goblin struck a powerful below 👊");
}
}
}
@@ -0,0 +1,26 @@
package org.project.entity.players;
import org.project.entity.Entity;
import org.project.item.armors.Armor;
import org.project.item.weapons.Weapon;
public class Assassin extends Player
{
public Assassin (String name) { super(name , 40, 60, 0); }
@Override
public void specialAbility(Entity target)
{
if (this.getMp() >= 9)
{
target.takeDamage(15);
super.specialAbility(target);
this.setMp(this.getMp() - 9);
System.out.println("Assassin picks up the axe and deals a heavy below to the enemy ⚒️");
}
else
{
System.out.println("You dont have enough mp to use special ability 😓");
}
}
}
@@ -1,6 +1,30 @@
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.item.armors.Armor;
import org.project.item.weapons.Sword;
import org.project.item.weapons.Weapon;
public class Knight extends Player
{
public Knight(String name)
{
super(name , 50, 50 , 0);
}
@Override
public void specialAbility(Entity target)
{
if (this.getMp() >= 7)
{
target.takeDamage(10);
super.specialAbility(target);
this.setMp(this.getMp() - 7);
System.out.println("The Knight atacked the enemy with a sharp sword 🗡️💪");
}
else
{
System.out.println("You dont have enough mp to use special ability 😓");
}
}
}
@@ -4,47 +4,78 @@ 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;
protected boolean isDefending = false;
private int hp;
private int maxHP;
private int maxHP = 100;
private int mp;
private int maxMP;
private int maxMP = 100;
private int xp;
public Player(String name, int hp, int mp, Weapon weapon, Armor armor) {
public Player(String name, int hp, int mp,int xp) {
this.name = name;
this.isDefending = isDefending;
this.hp = hp;
this.mp = mp;
this.xp = xp;
}
this.weapon = weapon;
this.armor = armor;
public void gainXp(int amount) {
setXp(this.xp += amount);
System.out.println(getName() + " gained " + amount + " XP 🪙");
}
@Override
public void attack(Entity target) {
target.takeDamage(weapon.getDamage());
target.takeDamage(2);
System.out.println(getName() + " is attacking ⚔️");
}
public void heavyAttack(Entity target) {
if(getMp() >= 2) {
target.takeDamage(4);
System.out.println(getName() + "has heavy attack 💣");
this.setMp(this.getMp() - 2);
}
else {
System.out.println("You do not have enough mp to have heavy attack 😓");
}
}
@Override
public void defend() {
// TODO
if(getMp() >= 3) {
this.setMp(this.getMp() - 3);
System.out.println(getName() + " is defending 🛡️");
isDefending = true;
}
else System.out.println("You do not have enough mp to defend 😓");
}
@Override
public void takeDamage(int damage) {
hp -= damage - armor.getDefense();
if(isDefending == true) {
damage = damage / 2;
hp -= damage;
isDefending = false;
System.out.println(getName() + " get a little damage !");
}
else
{
hp -= damage;
if (hp < 0) hp = 0;
System.out.println("Oh, the " + getName() + " get damage 🩸");
}
}
@Override
public void heal(int health) {
hp += health;
if (hp > maxHP) {
hp = maxHP;
public void heal() {
if(getMp() >= 6) {
hp += 10;
if (hp > maxHP) hp = maxHP;
}
else System.out.println("Unfortunately you dont have enough mp 😓");
}
@Override
@@ -55,35 +86,32 @@ public abstract class Player {
}
}
public String getName() {
return name;
}
public int getHp() {
return hp;
}
@Override
public boolean isAlive() { return hp > 0; }
@Override
public int getMaxHP() {
return maxHP;
public void specialAbility(Entity target) {
System.out.println(getName() + "is using special ability 😎");
}
public int getMp() {
return mp;
}
public String getName() { return name; }
public int getHp() { return hp; }
public void setHp(int newHp) { this.hp = newHp; }
public int getXp() { return xp; }
public void setXp(int newXp) { this.xp = newXp; }
@Override
public int getMaxMP() {
return maxMP;
}
public int getMaxHP() { return maxHP; }
public Weapon getWeapon() {
return weapon;
}
public int getMp() { return mp; }
public Armor getArmor() {
return armor;
}
public void setMp(int newMp) { mp = newMp; }
@Override
public int getMaxMP() { return maxMP; }
}
@@ -0,0 +1,26 @@
package org.project.entity.players;
import org.project.entity.Entity;
import org.project.item.armors.Armor;
import org.project.item.weapons.Weapon;
public class Wizard extends Player
{
public Wizard (String name) { super(name , 60, 40,0); }
@Override
public void specialAbility(Entity target)
{
if (this.getMp() >= 8)
{
target.takeDamage(12);
super.specialAbility(target);
this.setMp(this.getMp() - 8);
System.out.println("Amazing magic is comingggg, Bibbidi bobbidi boooooooo ⭐🪄");
}
else
{
System.out.println("You dont have enough mp to use special ability 😓");
}
}
}
@@ -5,7 +5,4 @@ import org.project.entity.Entity;
public interface Item {
void use(Entity target);
/*
TODO: ADD OTHER REQUIRED AND BONUS METHODS
*/
}
@@ -2,15 +2,10 @@ package org.project.item.weapons;
import org.project.entity.Entity;
// TODO: UPDATE IMPLEMENTATION
public abstract class Weapon {
private int damage;
private int manaCost;
/*
TODO: ADD OTHER REQUIRED AND BONUS ATTRIBUTES
*/
public Weapon(int damage, int manaCost) {
this.damage = damage;
this.manaCost = manaCost;
@@ -29,7 +24,4 @@ public abstract class Weapon {
return manaCost;
}
/*
TODO: ADD OTHER REQUIRED AND BONUS METHODS
*/
}
@@ -6,7 +6,6 @@ import java.util.ArrayList;
public class Location {
private String name;
private ArrayList<Enemy> enemies;
public Location(ArrayList<Location> locations, ArrayList<Enemy> enemies) {