diff --git a/main.py b/main.py index b4b3377..f0bdb00 100644 --- a/main.py +++ b/main.py @@ -5,15 +5,16 @@ def combat(perso1, perso2): """simule un combat jusqu'à ce que les joueurs n'aient plus de vies""" attaquant = perso1 defenseur = perso2 - while perso1.pdv != 0 and perso1.pdv != 0: - if attaquant.jet_attaque() > defenseur.jet_defence(): - perso2.change_pdv(randint(1,8)) - elif attaquant.jet_attaque() < defenseur.jet_defence(): - perso1.change_pdv(randint(1,4)) + while perso1.get_pdv() > 0 and perso1.get_pdv() > 0: + if attaquant.jet_attaque() > defenseur.jet_defense(): + defenseur.change_pdv(-randint(1,8)) + elif attaquant.jet_attaque() < defenseur.jet_defense(): + attaquant.change_pdv(-randint(1,4)) perso1.affiche_caracteristiques() perso2.affiche_caracteristiques() attaquant, defenseur = defenseur , attaquant + #ajouter points d'exp au survivant def main(): toto = Personnage("toto", choice(["guerrier","magicien","voleur","elfe"])) baba = Personnage("baba", choice(["guerrier","magicien","voleur","elfe"])) - combat() \ No newline at end of file + combat(toto, baba) \ No newline at end of file diff --git a/personnage.py b/personnage.py index 3db55a2..1410e64 100644 --- a/personnage.py +++ b/personnage.py @@ -54,3 +54,5 @@ class Personnage: def affiche_inventaire(self): """affiche l'inventaire du personnage""" print("inventaire : ", self.inventaire) + def get_pdv(self): + return self.pdv \ No newline at end of file