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 defend();
void heal(int health); void heal();
boolean isAlive();
void fillMana(int mana); void fillMana(int mana);
@@ -15,7 +17,5 @@ public interface Entity {
int getMaxMP(); int getMaxMP();
/* void specialAbility(Entity target);
TODO: ADD OTHER REQUIRED AND BONUS METHODS
*/
} }
@@ -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; package org.project.entity.enemies;
import org.project.item.weapons.Weapon; import org.project.entity.Entity;
// TODO: UPDATE IMPLEMENTATION public abstract class Enemy implements Entity {
public abstract class Enemy { protected boolean isDefending = false;
Weapon weapon;
private int hp; private int hp;
private int mp; 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.hp = hp;
this.mp = mp; 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 @Override
public void takeDamage(int damage) { 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() { @Override
return hp; public void specialAbility(Entity target)
{
System.out.println("Enemy is using its special ability !");
} }
public int getMp() { @Override
return mp; public void heal() {
if(getMp() >= 6) {
hp += 10;
if (hp > maxHP) hp = maxHP;
}
} }
public Weapon getWeapon() { @Override
return weapon; 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; package org.project.entity.enemies;
// TODO: UPDATE IMPLEMENTATION import org.project.entity.Entity;
public class Skeleton { import org.project.item.weapons.Weapon;
// TODO: DESIGN ENEMY AND IMPLEMENT THE CONSTRUCTOR
} 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; package org.project.entity.players;
// TODO: UPDATE IMPLEMENTATION import org.project.entity.Entity;
public class Knight { import org.project.item.armors.Armor;
// TODO: DESIGN KNIGHT'S WEAPON AND ARMOR AND IMPLEMENT THE CONSTRUCTOR 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.armors.Armor;
import org.project.item.weapons.Weapon; import org.project.item.weapons.Weapon;
// TODO: UPDATE IMPLEMENTATION public abstract class Player implements Entity{
public abstract class Player {
protected String name; protected String name;
Weapon weapon; protected boolean isDefending = false;
Armor armor;
private int hp; private int hp;
private int maxHP; private int maxHP = 100;
private int mp; 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.name = name;
this.isDefending = isDefending;
this.hp = hp; this.hp = hp;
this.mp = mp; this.mp = mp;
this.xp = xp;
}
this.weapon = weapon; public void gainXp(int amount) {
this.armor = armor; setXp(this.xp += amount);
System.out.println(getName() + " gained " + amount + " XP 🪙");
} }
@Override @Override
public void attack(Entity target) { 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 @Override
public void defend() { 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 @Override
public void takeDamage(int damage) { 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 @Override
public void heal(int health) { public void heal() {
hp += health; if(getMp() >= 6) {
if (hp > maxHP) { hp += 10;
hp = maxHP; if (hp > maxHP) hp = maxHP;
} }
else System.out.println("Unfortunately you dont have enough mp 😓");
} }
@Override @Override
@@ -55,35 +86,32 @@ public abstract class Player {
} }
} }
@Override
public String getName() { public boolean isAlive() { return hp > 0; }
return name;
}
public int getHp() {
return hp;
}
@Override @Override
public int getMaxHP() { public void specialAbility(Entity target) {
return maxHP; System.out.println(getName() + "is using special ability 😎");
} }
public int getMp() { public String getName() { return name; }
return mp;
} 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 @Override
public int getMaxMP() { public int getMaxHP() { return maxHP; }
return maxMP;
}
public Weapon getWeapon() { public int getMp() { return mp; }
return weapon;
}
public Armor getArmor() { public void setMp(int newMp) { mp = newMp; }
return armor;
} @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 { public interface Item {
void use(Entity target); 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; import org.project.entity.Entity;
// TODO: UPDATE IMPLEMENTATION
public abstract class Weapon { public abstract class Weapon {
private int damage; private int damage;
private int manaCost; private int manaCost;
/*
TODO: ADD OTHER REQUIRED AND BONUS ATTRIBUTES
*/
public Weapon(int damage, int manaCost) { public Weapon(int damage, int manaCost) {
this.damage = damage; this.damage = damage;
this.manaCost = manaCost; this.manaCost = manaCost;
@@ -29,7 +24,4 @@ public abstract class Weapon {
return manaCost; return manaCost;
} }
/*
TODO: ADD OTHER REQUIRED AND BONUS METHODS
*/
} }
@@ -6,7 +6,6 @@ import java.util.ArrayList;
public class Location { public class Location {
private String name; private String name;
private ArrayList<Enemy> enemies; private ArrayList<Enemy> enemies;
public Location(ArrayList<Location> locations, ArrayList<Enemy> enemies) { public Location(ArrayList<Location> locations, ArrayList<Enemy> enemies) {