Implement Player classes
This commit is contained in:
@@ -2,6 +2,7 @@ package org.project.entity;
|
|||||||
|
|
||||||
public interface Entity {
|
public interface Entity {
|
||||||
|
|
||||||
|
public void specialAbility(Entity target);
|
||||||
|
|
||||||
void defend();
|
void defend();
|
||||||
|
|
||||||
@@ -11,6 +12,8 @@ public interface Entity {
|
|||||||
|
|
||||||
void takeDamage(int damage);
|
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;
|
package org.project.entity.players;
|
||||||
|
|
||||||
// TODO: UPDATE IMPLEMENTATION
|
import org.project.entity.Entity;
|
||||||
public class Knight {
|
import org.project.item.weapons.Sword;
|
||||||
// TODO: DESIGN KNIGHT'S WEAPON AND ARMOR AND IMPLEMENT THE CONSTRUCTOR
|
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;
|
package org.project.entity.players;
|
||||||
|
|
||||||
import org.project.entity.Entity;
|
import org.project.entity.Entity;
|
||||||
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;
|
Weapon weapon;
|
||||||
Armor armor;
|
protected int hp;
|
||||||
private int hp;
|
|
||||||
private int maxHP;
|
private int maxHP;
|
||||||
private int mp;
|
protected int mp;
|
||||||
private int maxMP;
|
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.name = name;
|
||||||
this.hp = hp;
|
this.hp = hp;
|
||||||
this.mp = mp;
|
this.mp = mp;
|
||||||
|
|
||||||
this.weapon = weapon;
|
this.weapon = weapon;
|
||||||
this.armor = armor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void heavyAttack(Entity target){ // Uses weapons
|
||||||
public void attack(Entity target) {
|
|
||||||
target.takeDamage(weapon.getDamage());
|
target.takeDamage(weapon.getDamage());
|
||||||
|
mp -= weapon.getManaCost();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract void lightAttack(Entity target);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void defend() {
|
public void defend() {
|
||||||
// TODO
|
defending = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void takeDamage(int damage) {
|
public void takeDamage(int damage) {
|
||||||
hp -= damage - armor.getDefense();
|
hp -= damage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -48,6 +49,15 @@ public abstract class Player {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
public void stun(boolean value) {
|
||||||
|
stunned = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dodge(boolean value) {
|
||||||
|
dodged = value;
|
||||||
|
}
|
||||||
|
|
||||||
public void fillMana(int mana) {
|
public void fillMana(int mana) {
|
||||||
mp += mana;
|
mp += mana;
|
||||||
if (mp > maxMP) {
|
if (mp > maxMP) {
|
||||||
@@ -56,6 +66,7 @@ public abstract class Player {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Getter Methods
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
@@ -64,7 +75,6 @@ public abstract class Player {
|
|||||||
return hp;
|
return hp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMaxHP() {
|
public int getMaxHP() {
|
||||||
return maxHP;
|
return maxHP;
|
||||||
}
|
}
|
||||||
@@ -73,7 +83,6 @@ public abstract class Player {
|
|||||||
return mp;
|
return mp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMaxMP() {
|
public int getMaxMP() {
|
||||||
return maxMP;
|
return maxMP;
|
||||||
}
|
}
|
||||||
@@ -82,8 +91,11 @@ public abstract class Player {
|
|||||||
return weapon;
|
return weapon;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Armor getArmor() {
|
public boolean isDefending() {
|
||||||
return armor;
|
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