Implement Player classes
This commit is contained in:
@@ -2,6 +2,7 @@ package org.project.entity;
|
||||
|
||||
public interface Entity {
|
||||
|
||||
public void specialAbility(Entity target);
|
||||
|
||||
void defend();
|
||||
|
||||
@@ -11,6 +12,8 @@ public interface Entity {
|
||||
|
||||
void takeDamage(int damage);
|
||||
|
||||
void stun(boolean value);
|
||||
|
||||
void dodge(boolean value);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package org.project.entity.players;
|
||||
|
||||
import org.project.entity.Entity;
|
||||
import org.project.item.weapons.DualDagger;
|
||||
import org.project.item.weapons.Weapon;
|
||||
|
||||
|
||||
public class Assassin extends Player {
|
||||
|
||||
protected String name;
|
||||
Weapon weapon;
|
||||
private static final int maxHP = 110;
|
||||
private static final int maxMP = 110;
|
||||
|
||||
public Assassin(String name){
|
||||
Weapon AssassinWeapon = new DualDagger();
|
||||
super(name, maxHP, maxMP, AssassinWeapon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lightAttack(Entity target) {
|
||||
target.takeDamage(18);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void specialAbility(Entity target) {
|
||||
target.takeDamage(52); // critical attack
|
||||
this.mp -= 30;
|
||||
dodge(true);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,32 @@
|
||||
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.weapons.Sword;
|
||||
import org.project.item.weapons.Weapon;
|
||||
|
||||
|
||||
public class Knight extends Player {
|
||||
|
||||
protected String name;
|
||||
Weapon weapon;
|
||||
private static final int maxHP = 130;
|
||||
private static final int maxMP = 70;
|
||||
|
||||
public Knight(String name){
|
||||
Weapon knightWeapon = new Sword();
|
||||
super(name, maxHP, maxMP, knightWeapon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lightAttack(Entity target) {
|
||||
target.takeDamage(22);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void specialAbility(Entity target) {
|
||||
target.takeDamage(30);
|
||||
this.mp -= 25;
|
||||
target.stun(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,42 +1,43 @@
|
||||
package org.project.entity.players;
|
||||
|
||||
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;
|
||||
private int hp;
|
||||
protected int hp;
|
||||
private int maxHP;
|
||||
private int mp;
|
||||
protected int mp;
|
||||
private int maxMP;
|
||||
private int xp;
|
||||
private boolean defending = false;
|
||||
private boolean stunned = false;
|
||||
private boolean dodged = false;
|
||||
|
||||
public Player(String name, int hp, int mp, Weapon weapon, Armor armor) {
|
||||
|
||||
public Player(String name, int hp, int mp, Weapon weapon) {
|
||||
this.name = name;
|
||||
this.hp = hp;
|
||||
this.mp = mp;
|
||||
|
||||
this.weapon = weapon;
|
||||
this.armor = armor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attack(Entity target) {
|
||||
public void heavyAttack(Entity target){ // Uses weapons
|
||||
target.takeDamage(weapon.getDamage());
|
||||
mp -= weapon.getManaCost();
|
||||
}
|
||||
|
||||
public abstract void lightAttack(Entity target);
|
||||
|
||||
@Override
|
||||
public void defend() {
|
||||
// TODO
|
||||
defending = true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void takeDamage(int damage) {
|
||||
hp -= damage - armor.getDefense();
|
||||
hp -= damage;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -48,6 +49,15 @@ public abstract class Player {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stun(boolean value) {
|
||||
stunned = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dodge(boolean value) {
|
||||
dodged = value;
|
||||
}
|
||||
|
||||
public void fillMana(int mana) {
|
||||
mp += mana;
|
||||
if (mp > maxMP) {
|
||||
@@ -56,6 +66,7 @@ public abstract class Player {
|
||||
}
|
||||
|
||||
|
||||
// Getter Methods
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
@@ -64,7 +75,6 @@ public abstract class Player {
|
||||
return hp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxHP() {
|
||||
return maxHP;
|
||||
}
|
||||
@@ -73,7 +83,6 @@ public abstract class Player {
|
||||
return mp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxMP() {
|
||||
return maxMP;
|
||||
}
|
||||
@@ -82,8 +91,11 @@ public abstract class Player {
|
||||
return weapon;
|
||||
}
|
||||
|
||||
public Armor getArmor() {
|
||||
return armor;
|
||||
public boolean isDefending() {
|
||||
return defending;
|
||||
}
|
||||
|
||||
public boolean isDodged() {
|
||||
return dodged;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package org.project.entity.players;
|
||||
|
||||
import org.project.entity.Entity;
|
||||
import org.project.item.weapons.MagicStaff;
|
||||
import org.project.item.weapons.Weapon;
|
||||
|
||||
|
||||
public class Wizard extends Player {
|
||||
|
||||
protected String name;
|
||||
Weapon weapon;
|
||||
private static final int maxHP = 150;
|
||||
private static final int maxMP = 85;
|
||||
|
||||
public Wizard(String name){
|
||||
Weapon WizardWeapon = new MagicStaff();
|
||||
super(name, maxHP, maxMP, WizardWeapon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lightAttack(Entity target) {
|
||||
target.takeDamage(16);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void specialAbility(Entity target) {
|
||||
target.takeDamage(32); // cast spell
|
||||
this.mp -= 28;
|
||||
heal(15);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user