Skip to content
Snippets Groups Projects
Commit 0ac845b6 authored by VIGNERON Steven's avatar VIGNERON Steven
Browse files

fix V7

parent 53030d3c
Branches
Tags V7
No related merge requests found
doc/V7.png

219 KiB | W: | H:

doc/V7.png

219 KiB | W: | H:

doc/V7.png
doc/V7.png
doc/V7.png
doc/V7.png
  • 2-up
  • Swipe
  • Onion skin
...@@ -29,11 +29,12 @@ package DP{ ...@@ -29,11 +29,12 @@ package DP{
#int niveau #int niveau
#String nom #String nom
+ Personnage(int pointsDeVie, String nom, Arme arme) + Personnage(int pointsDeVie, String nom, Arme arme)
+ void subirDegats(int d)
+ void setStrategie(StrategieCombat strategie) + void setStrategie(StrategieCombat strategie)
+ boolean estVivant() + boolean estVivant()
+ void setEtat(Etat etat) + void setEtat(Etat etat)
+ Etat getEtat() + Etat getEtat()
+ void attaquer()
+ void subirDegats(int d)
} }
Personnage -left- "1" Arme Personnage -left- "1" Arme
Personnage -- "1" StrategieCombat Personnage -- "1" StrategieCombat
......
...@@ -26,6 +26,8 @@ public abstract class Personnage implements ComposantEquipe { ...@@ -26,6 +26,8 @@ public abstract class Personnage implements ComposantEquipe {
public void setPointsDeVie(int pointsDeVie) { public void setPointsDeVie(int pointsDeVie) {
if(pointsDeVie > 0) { if(pointsDeVie > 0) {
this.pointsDeVie = pointsDeVie; this.pointsDeVie = pointsDeVie;
} else {
this.pointsDeVie = 0;
} }
} }
...@@ -82,15 +84,6 @@ public abstract class Personnage implements ComposantEquipe { ...@@ -82,15 +84,6 @@ public abstract class Personnage implements ComposantEquipe {
} }
} }
// garder uniquement pour les tests de V5
public void subirDegats(int d) {
int degats = strategie.modifieDegats(d);
pointsDeVie -= degats;
if (pointsDeVie <= 0) {
this.setEtat(new EtatMort(this));
}
}
public void setEtat(Etat etat){ public void setEtat(Etat etat){
this.etat = etat; this.etat = etat;
} }
...@@ -98,4 +91,13 @@ public abstract class Personnage implements ComposantEquipe { ...@@ -98,4 +91,13 @@ public abstract class Personnage implements ComposantEquipe {
public Etat getEtat(){ public Etat getEtat(){
return this.etat; return this.etat;
} }
public void attaquer(Personnage p){
etat.attaquer(p);
}
public void subirDegats(int d){
etat.subirDegats(d);
}
} }
...@@ -52,7 +52,7 @@ public class TestV5 { ...@@ -52,7 +52,7 @@ public class TestV5 {
r.subirDegats(attaqueDuGuerrier); r.subirDegats(attaqueDuGuerrier);
// le roi a 100 points de vie et recoie un coup de 50*2*2 degats // le roi a 100 points de vie et recoie un coup de 50*2*2 degats
assertEquals("Le roi devrais avoir 0 points de vie", -100, r.getPointsDeVie()); assertEquals("Le roi devrais avoir 0 points de vie", 0, r.getPointsDeVie());
assertEquals("Le roi devrais etre mort", false, r.estVivant()); assertEquals("Le roi devrais etre mort", false, r.estVivant());
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment