From cfe48f2d4705d954a7f8fb0a7a100db64ac49266 Mon Sep 17 00:00:00 2001 From: mathis <> Date: Wed, 11 Sep 2024 19:18:54 +0200 Subject: [PATCH] maison (est_gagnant) --- jeu de rôle.py | 66 ++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 55 insertions(+), 11 deletions(-) diff --git a/jeu de rôle.py b/jeu de rôle.py index f1c8b13..50c58bf 100644 --- a/jeu de rôle.py +++ b/jeu de rôle.py @@ -6,13 +6,13 @@ class Personne: self.__xp = 1 self.__cat = cat if self.__cat == 'guerrier': - self.__hp = 30 + self.__hp = 20 elif self.__cat == 'mage': self.__hp =20 elif self.__cat == 'voleur': - self.__hp = 26 + self.__hp = 30 elif self.__cat == 'elfe': - self.__hp = 24 + self.__hp = 22 if cat == 'guerrier': self.__inv = ['epee', 'potion'] elif cat == 'mage': @@ -66,14 +66,58 @@ class Personne: def jet_defense(self): return random.randint(1, 20) + (self.get_xp()*self.get_coef_def()) - def change_pdv(): - pass + def change_pdv(self, other, nb_pdv): + if self == self: + self.__hp += nb_pdv + if other != '': + other.__hp += nb_pdv + else: + pass - def change_exp(): - pass + def change_exp(self, nb_exp): + self.__xp += nb_exp - def affiche_caracteristiques(): - pass + def affiche_caracteristiques(self, other): + if self == self: + print('voici vos caractéristiques:', + '\n nom: ', self.get_nom(), + '\n catégorie: ', self.get_cat(), + '\n hp: ', self.get_hp(), + '\n xp: ', self.get_xp(), + ) + if other != '': + print('\n voici ses caractéristiques:', + '\n nom: ', other.get_nom(), + '\n catégorie: ', other.get_cat(), + '\n hp: ', other.get_hp(), + '\n xp: ', other.get_xp(), + ) + else: + pass - def affiche_inventaire(): - pass \ No newline at end of file + def affiche_inventaire(self, other): + if self == self: + print('\n votre inventaire: ', self.get_inv()) + if other != '': + print('\n inventaire ennemie: ', other.get_inv()) + else: + pass + + def est_gagnant(self, other): + if self.__hp and if other.__hp > 0: + if self.jet_attaque() > other.jet_defense(): + nb_pdv = (-1) * random.randint(1,8) + other.change_pdv('', nb_pdv) + self.affiche_caracteristiques(other) + print('vous avez infligé ', -nb_pdv, "pts de dégats à l'ennemie!") + elif self.jet_attaque() < other.jet_defense(): + nb_pdv = (-1) * random.randint(1,4) + self.change_pdv('', nb_pdv) + self.affiche_caracteristiques(other) + print('vous avez reçu ', -nb_pdv, "pts de dégats de l'ennemie!") + else: + self.affiche_caracteristiques(other) + print('parade parfaite: aucun des joueur ne perd de points de vie') + + else: + pass \ No newline at end of file