Skip to content
Snippets Groups Projects
Commit b56aebbe authored by Camille Okubo's avatar Camille Okubo
Browse files

AttackTest, microfix Attack & Character

parent 1f064988
No related branches found
No related tags found
No related merge requests found
...@@ -14,7 +14,6 @@ public enum Attack implements Action { ...@@ -14,7 +14,6 @@ public enum Attack implements Action {
private String name; private String name;
private ActionHeight height; private ActionHeight height;
private int energyCost; private int energyCost;
public static ArrayList<String> attacksNames = new ArrayList<String>();
Attack(int damage, String name, ActionHeight height, int energyCost) { Attack(int damage, String name, ActionHeight height, int energyCost) {
this.damage = damage; this.damage = damage;
...@@ -44,8 +43,4 @@ public enum Attack implements Action { ...@@ -44,8 +43,4 @@ public enum Attack implements Action {
public static boolean attackInTime(LocalDateTime timeBeforeAttack, int attackTime) { public static boolean attackInTime(LocalDateTime timeBeforeAttack, int attackTime) {
return (Duration.between(timeBeforeAttack, LocalDateTime.now()).toSeconds() > attackTime); return (Duration.between(timeBeforeAttack, LocalDateTime.now()).toSeconds() > attackTime);
} }
public static String getIndexOfInput(String input) {
return Attack.attacksNames.get(attacksNames.indexOf(input)).toUpperCase();
}
} }
\ No newline at end of file
...@@ -73,6 +73,14 @@ public class Character implements Serializable { ...@@ -73,6 +73,14 @@ public class Character implements Serializable {
attackMultiplier = attackMultiplier * 1.2; attackMultiplier = attackMultiplier * 1.2;
} }
public double getMaxEnergy() {
return maxEnergy;
}
public double getCurrentEnergy() {
return currentEnergy;
}
public void damage(double damage){ public void damage(double damage){
this.currentHealth -= damage; this.currentHealth -= damage;
if(this.currentHealth < 0) this.currentHealth = 0; if(this.currentHealth < 0) this.currentHealth = 0;
......
...@@ -7,7 +7,7 @@ import org.junit.jupiter.api.Test; ...@@ -7,7 +7,7 @@ import org.junit.jupiter.api.Test;
public class AttackTest { public class AttackTest {
Player player = new Player("joueur1"); Player player = new Player("joueur1");
Enemy ennemy = new Enemy("ennemy", 3); Enemy ennemy = new Enemy("ennemy", 1);
@Test @Test
void testGetDamage() { void testGetDamage() {
...@@ -19,10 +19,11 @@ public class AttackTest { ...@@ -19,10 +19,11 @@ public class AttackTest {
ennemy.setCurrentHealth(100.0); ennemy.setCurrentHealth(100.0);
assertEquals("Joueur : " + (int)player.getCurrentHealth(), "Joueur : 100"); assertEquals("Joueur : " + (int)player.getCurrentHealth(), "Joueur : 100");
assertEquals("Ennemi : " + (int)ennemy.getCurrentHealth(), "Ennemi : 100"); assertEquals("Ennemi : " + (int)ennemy.getCurrentHealth(), "Ennemi : 100");
String attack = Attack.getIndexOfInput("kick"); ennemy.damage(Attack.PUNCH.getDamage());
ennemy.damage(Attack.valueOf(attack).getDamage()); player.exhaust(Attack.PUNCH.getEnergyCost());
assertEquals("Joueur : " + (int)player.getCurrentHealth(), "Joueur : 100"); assertEquals("Joueur : " + (int)player.getCurrentHealth(), "Joueur : 100");
assertEquals("Ennemi : " + (int)ennemy.getCurrentHealth(), "Ennemi : 90"); assertEquals("Ennemi : " + (int)ennemy.getCurrentHealth(), "Ennemi : 90");
assertEquals("Energie joueur : " + (int)player.getCurrentEnergy(), "Energie joueur : 90");
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment