From 6362960962981f46c31df08b6c4a13e51ab7a911 Mon Sep 17 00:00:00 2001 From: pitavy <> Date: Thu, 12 Sep 2024 11:53:36 +0200 Subject: [PATCH] =?UTF-8?q?lyc=C3=A9e=20(jeu)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jeu de rôle.py | 84 ++++++++++++++++++++++--------------------------- 1 file changed, 38 insertions(+), 46 deletions(-) diff --git a/jeu de rôle.py b/jeu de rôle.py index 50c58bf..2bd46cb 100644 --- a/jeu de rôle.py +++ b/jeu de rôle.py @@ -66,58 +66,50 @@ class Personne: def jet_defense(self): return random.randint(1, 20) + (self.get_xp()*self.get_coef_def()) - def change_pdv(self, other, nb_pdv): - if self == self: - self.__hp += nb_pdv - if other != '': - other.__hp += nb_pdv - else: - pass + def change_pdv(self, nb_pdv): + self.__hp += nb_pdv def change_exp(self, nb_exp): self.__xp += nb_exp - def affiche_caracteristiques(self, other): - if self == self: - print('voici vos caractéristiques:', - '\n nom: ', self.get_nom(), + def affiche_caracteristiques(self): + print('caractéristiques de ', 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(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 + def affiche_inventaire(self): + print('\n votre inventaire: ', self.get_inv()) + +def tour(joueur, bot): + if joueur.jet_attaque() > bot.jet_defense(): + nb_pdv = (-1) * random.randint(1,8) + bot.change_pdv(nb_pdv) + print('\n vous avez infligé ', -nb_pdv, "pts de dégats à l'ennemie!") + elif joueur.jet_attaque() < bot.jet_defense(): + nb_pdv = (-1) * random.randint(1,4) + joueur.change_pdv(nb_pdv) + print('\n vous avez reçu ', -nb_pdv, "pts de dégats de l'ennemie!") + else: + print('\n parade parfaite: aucun des joueur ne perd de points de vie') + +def jeu(joueur, bot): + jhp = joueur.get_hp() + bhp = bot.get_hp() + if jhp > 0 and bhp > 0: + tour(joueur, bot) + joueur.affiche_caracteristiques() + bot.affiche_caracteristiques() + jeu(joueur, bot) + elif joueur.get_hp() > 0: + print('vous avez gagné!') + joueur = Personne('joueur', 'guerrier') + bot = Personne('bot', 'voleur') + else: + print('vous avez perdu!') + joueur = Personne('joueur', 'guerrier') + bot = Personne('bot', 'voleur') + +joueur = Personne('joueur', 'guerrier') +bot = Personne('bot', 'voleur') \ No newline at end of file