diff --git a/src/main/java/re/forestier/edu/rpg/Adventurer.java b/src/main/java/re/forestier/edu/rpg/Adventurer.java index 254162e196b5cae705d5832d4efbddb17bf614b0..a9ef56851d393862c3c49912c4bfa3af232e2983 100644 --- a/src/main/java/re/forestier/edu/rpg/Adventurer.java +++ b/src/main/java/re/forestier/edu/rpg/Adventurer.java @@ -60,8 +60,6 @@ public class Adventurer extends player { currenthealthpoints-=1; } } - if(currenthealthpoints >= healthpoints) { - currenthealthpoints = healthpoints; - } + super.maxHealth(); } } diff --git a/src/main/java/re/forestier/edu/rpg/Archer.java b/src/main/java/re/forestier/edu/rpg/Archer.java index 7d7b4be998ad01e4a50a9db8145492b0d6e4c9ff..3605eb7207c67d6a7c97fe08d51d3bf643e9a460 100644 --- a/src/main/java/re/forestier/edu/rpg/Archer.java +++ b/src/main/java/re/forestier/edu/rpg/Archer.java @@ -56,8 +56,7 @@ public class Archer extends player { } } - if (currenthealthpoints >= healthpoints) { - currenthealthpoints = healthpoints; - } + super.maxHealth(); + } } diff --git a/src/main/java/re/forestier/edu/rpg/Dwarf.java b/src/main/java/re/forestier/edu/rpg/Dwarf.java index 05ff508f3728f4c4fd3d8878390fc2809c05d6b7..0553bbdbe0ff5d32c1b9819ff8aa83b2274c8fc6 100644 --- a/src/main/java/re/forestier/edu/rpg/Dwarf.java +++ b/src/main/java/re/forestier/edu/rpg/Dwarf.java @@ -57,9 +57,6 @@ public class Dwarf extends player{ currenthealthpoints+=1; } - - if(currenthealthpoints >= healthpoints) { - currenthealthpoints = healthpoints; - } + super.maxHealth(); } } diff --git a/src/main/java/re/forestier/edu/rpg/player.java b/src/main/java/re/forestier/edu/rpg/player.java index 1093ea81db5eddf8a1da4bee1f010ded28cd0cc3..11026eff2b52cbf497b01c36e52c921ba513ffb9 100644 --- a/src/main/java/re/forestier/edu/rpg/player.java +++ b/src/main/java/re/forestier/edu/rpg/player.java @@ -7,7 +7,6 @@ import java.util.Random; public abstract class player { public String playerName; public String Avatar_name; - public String Avatar_class; public Integer money; @@ -28,7 +27,6 @@ public abstract class player { this.playerName = playerName; Avatar_name = avatar_name; - Avatar_class = this.getClass().getSimpleName().toUpperCase(); this.money = money; this.inventory = inventory; this.level = 1; @@ -37,10 +35,6 @@ public abstract class player { this.abilities = new HashMap<>(); } - public String getAvatarClass() { - return this.Avatar_class; - } - public void changeMoney(Integer amount) throws IllegalArgumentException { @@ -79,6 +73,12 @@ public abstract class player { //The rest of the method is implemented in the subclasses } + protected void maxHealth() { + if (currenthealthpoints >= healthpoints) { + currenthealthpoints = healthpoints; + } + } + public Integer getLevel() { return this.level;