edit Player
This commit is contained in:
@@ -1,42 +1,58 @@
|
||||
package org.project.entity.players;
|
||||
|
||||
import org.project.entity.Entity;
|
||||
import org.project.item.armors.Armor;
|
||||
import org.project.item.weapons.Weapon;
|
||||
import org.project.entity.enemies.Enemy;
|
||||
import org.project.entity.enemies.Vampire;
|
||||
|
||||
|
||||
public abstract class Player extends Entity{
|
||||
|
||||
protected final PlayerStats stats;
|
||||
protected String name;
|
||||
private Armor armor;
|
||||
private int mp;
|
||||
private int maxMP;
|
||||
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.mp = mp;
|
||||
this.maxMP = maxMP;
|
||||
this.armor = armor;
|
||||
this.mp = stats.maxMP;
|
||||
this.stats = stats;
|
||||
|
||||
XP = 0;
|
||||
defensing = false;
|
||||
goblinKey = false;
|
||||
skeletonKey = false;
|
||||
vampireKey = false;
|
||||
}
|
||||
|
||||
public void lightAttack(Entity target) {
|
||||
target.takeDamage(super.getWeapon().getDamage());
|
||||
}
|
||||
public void lightAttack(Enemy target) {target.takeDamage(stats.lightAttackDamage);}
|
||||
|
||||
public abstract void specialAbility(Enemy target);
|
||||
public abstract void heavyAttack(Enemy target);
|
||||
|
||||
@Override
|
||||
public void takeDamage(int damage) {
|
||||
if(!isDefensing()){
|
||||
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) {
|
||||
mp += mana;
|
||||
if (mp > maxMP) {
|
||||
mp = maxMP;
|
||||
if (mp > stats.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 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 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