edit Player
This commit is contained in:
@@ -1,42 +1,58 @@
|
|||||||
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.entity.enemies.Enemy;
|
||||||
import org.project.item.weapons.Weapon;
|
import org.project.entity.enemies.Vampire;
|
||||||
|
|
||||||
|
|
||||||
public abstract class Player extends Entity{
|
public abstract class Player extends Entity{
|
||||||
|
|
||||||
|
protected final PlayerStats stats;
|
||||||
protected String name;
|
protected String name;
|
||||||
private Armor armor;
|
|
||||||
private int mp;
|
private int mp;
|
||||||
private int maxMP;
|
|
||||||
private boolean defensing;
|
private boolean defensing;
|
||||||
|
private int XP;
|
||||||
|
private boolean skeletonKey;
|
||||||
|
private boolean goblinKey;
|
||||||
|
private boolean vampireKey;
|
||||||
|
|
||||||
public Player(String name, int hp, int maxHP, int mp, int maxMP, Weapon weapon, Armor armor) {
|
|
||||||
super(weapon, hp, maxHP);
|
public Player(String name, PlayerStats stats) {
|
||||||
|
super(stats.maxHP);
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.mp = mp;
|
this.mp = stats.maxMP;
|
||||||
this.maxMP = maxMP;
|
this.stats = stats;
|
||||||
this.armor = armor;
|
|
||||||
|
|
||||||
|
XP = 0;
|
||||||
defensing = false;
|
defensing = false;
|
||||||
|
goblinKey = false;
|
||||||
|
skeletonKey = false;
|
||||||
|
vampireKey = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void lightAttack(Entity target) {
|
public void lightAttack(Enemy target) {target.takeDamage(stats.lightAttackDamage);}
|
||||||
target.takeDamage(super.getWeapon().getDamage());
|
|
||||||
}
|
public abstract void specialAbility(Enemy target);
|
||||||
|
public abstract void heavyAttack(Enemy target);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void takeDamage(int damage) {
|
public void takeDamage(int damage) {
|
||||||
if(!isDefensing()){
|
if(!isDefensing()){
|
||||||
super.takeDamage(damage);
|
super.takeDamage(damage);
|
||||||
|
System.out.println("Enemy's attack dealt " + damage + " damage to you!");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
System.out.println("You blocked the attack!");
|
||||||
|
defensing = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void defend() { setDefensing(true); }
|
||||||
|
|
||||||
public void fillMana(int mana) {
|
public void fillMana(int mana) {
|
||||||
mp += mana;
|
mp += mana;
|
||||||
if (mp > maxMP) {
|
if (mp > stats.maxMP) {
|
||||||
mp = maxMP;
|
mp = stats.maxMP;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,15 +65,25 @@ public abstract class Player extends Entity{
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public PlayerStats getStats() {return stats;}
|
||||||
|
|
||||||
public String getName() { return name; }
|
public String getName() { return name; }
|
||||||
|
|
||||||
public int getMp() { return mp; }
|
public int getMp() { return mp; }
|
||||||
|
|
||||||
public int getMaxMP() { return maxMP; }
|
public int getMaxMP() { return stats.maxMP; }
|
||||||
|
|
||||||
public Armor getArmor() { return armor; }
|
public boolean hasGoblinKey() {return goblinKey;}
|
||||||
|
public boolean hasSkeletonKey() {return skeletonKey;}
|
||||||
|
public boolean hasVampireKey() {return vampireKey;}
|
||||||
|
|
||||||
|
public void giveGoblinKey() { goblinKey = true; }
|
||||||
|
public void giveSkeletonKey() { skeletonKey = true; }
|
||||||
|
public void giveVampireKey() { vampireKey = true; }
|
||||||
|
|
||||||
public boolean isDefensing() { return defensing; }
|
public boolean isDefensing() { return defensing; }
|
||||||
public void setDefensing(boolean defensing) {this.defensing = defensing; }
|
public void setDefensing(boolean defensing) {this.defensing = defensing; }
|
||||||
|
|
||||||
|
public int getXP() { return XP;}
|
||||||
|
public void addXP(int amount) { XP += amount; }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user