implement Enemy classes
This commit is contained in:
@@ -1,21 +1,16 @@
|
||||
package org.project.entity;
|
||||
|
||||
public interface Entity {
|
||||
void attack(Entity target);
|
||||
|
||||
|
||||
void defend();
|
||||
|
||||
void heal(int health);
|
||||
|
||||
void fillMana(int mana);
|
||||
// void fillMana(int mana);
|
||||
|
||||
void takeDamage(int damage);
|
||||
|
||||
int getMaxHP();
|
||||
|
||||
int getMaxMP();
|
||||
|
||||
/*
|
||||
TODO: ADD OTHER REQUIRED AND BONUS METHODS
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
package org.project.entity.enemies;
|
||||
|
||||
import org.project.entity.Entity;
|
||||
import org.project.item.weapons.Dagger;
|
||||
import org.project.item.weapons.Flame;
|
||||
import org.project.item.weapons.Weapon;
|
||||
|
||||
public class Dragon extends Enemy{
|
||||
|
||||
private static int maxHP = 220;
|
||||
private int hp = maxHP;
|
||||
|
||||
public Dragon(){
|
||||
Weapon DragonWeapon = new Flame();
|
||||
super(maxHP, DragonWeapon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attack(Entity target) {
|
||||
target.takeDamage(28);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SpecialAbility(Entity target) {
|
||||
target.takeDamage(weapon.getDamage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void heal(int health) {
|
||||
hp += health;
|
||||
if (hp > maxHP) {
|
||||
hp = maxHP;
|
||||
}
|
||||
}
|
||||
|
||||
public int getMaxHP() {
|
||||
return maxHP;
|
||||
}
|
||||
|
||||
public String getName(){
|
||||
return "Dragon";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,17 +1,17 @@
|
||||
package org.project.entity.enemies;
|
||||
|
||||
import org.project.entity.Entity;
|
||||
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;
|
||||
protected int hp;
|
||||
private boolean defending = false;
|
||||
protected boolean lifeStealing = false;
|
||||
private boolean stunned = false;
|
||||
|
||||
public Enemy(int hp, int mp, Weapon weapon) {
|
||||
public Enemy(int hp, Weapon weapon) {
|
||||
this.hp = hp;
|
||||
this.mp = mp;
|
||||
|
||||
this.weapon = weapon;
|
||||
}
|
||||
|
||||
@@ -20,15 +20,35 @@ public abstract class Enemy {
|
||||
hp -= damage;
|
||||
}
|
||||
|
||||
public int getHp() {
|
||||
return hp;
|
||||
public void attack(Entity target) {
|
||||
target.takeDamage(weapon.getDamage());
|
||||
}
|
||||
|
||||
public int getMp() {
|
||||
return mp;
|
||||
public abstract void SpecialAbility(Entity target);
|
||||
|
||||
@Override
|
||||
public void defend() {
|
||||
defending = true;
|
||||
}
|
||||
|
||||
|
||||
public int getHp() {
|
||||
return hp;
|
||||
}
|
||||
|
||||
public Weapon getWeapon() {
|
||||
return weapon;
|
||||
}
|
||||
|
||||
public boolean isDefending() {
|
||||
return defending;
|
||||
}
|
||||
|
||||
public boolean isLifeStealing() {
|
||||
return lifeStealing;
|
||||
}
|
||||
|
||||
public boolean isStunned() {
|
||||
return stunned;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package org.project.entity.enemies;
|
||||
|
||||
import org.project.entity.Entity;
|
||||
import org.project.item.weapons.Dagger;
|
||||
import org.project.item.weapons.Weapon;
|
||||
|
||||
public class Goblin extends Enemy{
|
||||
|
||||
private static int maxHP = 65;
|
||||
private int hp = maxHP;
|
||||
private int criticalHit_damage = 20;
|
||||
|
||||
public Goblin(){
|
||||
Weapon goblinWeapon = new Dagger();
|
||||
super(maxHP, goblinWeapon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SpecialAbility(Entity target) {
|
||||
target.takeDamage(criticalHit_damage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void heal(int health) {
|
||||
hp += health;
|
||||
if (hp > maxHP) {
|
||||
hp = maxHP;
|
||||
}
|
||||
}
|
||||
|
||||
public int getMaxHP() {
|
||||
return maxHP;
|
||||
}
|
||||
|
||||
public String getName(){
|
||||
return "Goblin";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,38 @@
|
||||
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.BoneClub;
|
||||
import org.project.item.weapons.Weapon;
|
||||
|
||||
public class Skeleton extends Enemy{
|
||||
|
||||
private static int maxHP = 80;
|
||||
private int hp = maxHP;
|
||||
|
||||
public Skeleton(){
|
||||
Weapon SkeletonWeapon = new BoneClub();
|
||||
super(maxHP, SkeletonWeapon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SpecialAbility(Entity target) {
|
||||
hp = maxHP/2; // revive
|
||||
}
|
||||
|
||||
@Override
|
||||
public void heal(int health) {
|
||||
hp += health;
|
||||
if (hp > maxHP) {
|
||||
hp = maxHP;
|
||||
}
|
||||
}
|
||||
|
||||
public int getMaxHP() {
|
||||
return maxHP;
|
||||
}
|
||||
|
||||
public String getName(){
|
||||
return "Skeleton";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package org.project.entity.enemies;
|
||||
|
||||
import org.project.entity.Entity;
|
||||
import org.project.item.weapons.Bite;
|
||||
import org.project.item.weapons.Weapon;
|
||||
|
||||
public class Vampire extends Enemy{
|
||||
|
||||
private static int maxHP = 95;
|
||||
private int hp = maxHP;
|
||||
|
||||
public Vampire(){
|
||||
Weapon VampireWeapon = new Bite();
|
||||
super(maxHP, VampireWeapon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SpecialAbility(Entity target) {
|
||||
lifeStealing = true;
|
||||
target.takeDamage((8/10)*(weapon.getDamage()));
|
||||
hp += (int)((2/10)*(weapon.getDamage()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void heal(int health) {
|
||||
hp += health;
|
||||
if (hp > maxHP) {
|
||||
hp = maxHP;
|
||||
}
|
||||
}
|
||||
|
||||
public int getMaxHP() {
|
||||
return maxHP;
|
||||
}
|
||||
|
||||
public String getName(){
|
||||
return "Vampire";
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user