Updated Knight Class.
This commit is contained in:
@@ -2,8 +2,6 @@ package org.project.entity;
|
||||
|
||||
public interface Entity {
|
||||
|
||||
void attack(Entity target);
|
||||
|
||||
void defend();
|
||||
|
||||
void heal(int health);
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package org.project.entity.players;
|
||||
|
||||
import org.project.entity.Entity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public interface ICombatActions {
|
||||
|
||||
void lightAttack(Entity target);
|
||||
|
||||
void heavyAttack(Entity target);
|
||||
|
||||
void defend();
|
||||
|
||||
void heal();
|
||||
|
||||
void specialAbility(Entity target);
|
||||
}
|
||||
@@ -10,13 +10,13 @@ import org.project.item.weapons.Weapon;
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
||||
public class Knight extends Player {
|
||||
public class Knight extends Player implements ICombatActions {
|
||||
public Knight(String name) {
|
||||
super(name, 45, 45, new Sword(), new KnightArmor());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uniqueAbility(Entity target) {
|
||||
public void specialAbility(Entity target) {
|
||||
//Checking if the mana is enough of not
|
||||
if (getMp() < 15) {
|
||||
System.out.println("Mana is not enough for Shield Bash!");
|
||||
@@ -33,4 +33,46 @@ public class Knight extends Player {
|
||||
|
||||
System.out.println("💥 Shield Bash! Enemy is stunned!");
|
||||
}
|
||||
|
||||
public void lightAttack(Entity target) {
|
||||
int damage = 10;
|
||||
target.takeDamage(damage);
|
||||
System.out.println("⚔️ " + getName() + " used Light Attack! Dealt " + damage + " damage.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void heavyAttack(Entity target) {
|
||||
if (getMp() < 8) {
|
||||
System.out.println("❌ Not enough mana for Heavy Attack!");
|
||||
return;
|
||||
}
|
||||
setMp(getMp() - 8);
|
||||
int damage = 20;
|
||||
target.takeDamage(damage);
|
||||
System.out.println("💥 " + getName() + " used Heavy Attack! Dealt " + damage + " damage.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void defend() {
|
||||
if (getMp() < 6) {
|
||||
System.out.println("❌ Not enough mana to defend!");
|
||||
return;
|
||||
}
|
||||
setMp(getMp() - 6);
|
||||
setDefending(true);
|
||||
System.out.println("🛡️ " + getName() + " is defending! Next attack will be halved.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void heal() {
|
||||
if (getMp() < 12) {
|
||||
System.out.println("❌ Not enough mana to heal!");
|
||||
return;
|
||||
}
|
||||
setMp(getMp() - 12);
|
||||
int healAmount = 20;
|
||||
setHp(getHp() + healAmount);
|
||||
if (getHp() > getMaxHP()) setHp(getMaxHP());
|
||||
System.out.println("💚 " + getName() + " healed " + healAmount + " HP!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,11 +28,6 @@ public abstract class Player implements Entity {
|
||||
this.armor = armor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attack(Entity target) {
|
||||
target.takeDamage(weapon.getDamage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void defend() {
|
||||
//checking mana
|
||||
@@ -115,8 +110,6 @@ public abstract class Player implements Entity {
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void uniqueAbility(Entity target);
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@@ -36,8 +36,4 @@ public abstract class Weapon implements Item {
|
||||
public void setManaCost(int manaCost) {
|
||||
this.manaCost = manaCost;
|
||||
}
|
||||
|
||||
/*
|
||||
TODO: ADD OTHER REQUIRED AND BONUS METHODS
|
||||
*/
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user