From a0785cbffbd0a71628d9e8950d85279b4ec579b6 Mon Sep 17 00:00:00 2001 From: Denis Leenaerts <> Date: Wed, 9 Sep 2026 21:09:13 +0200 Subject: [PATCH] =?UTF-8?q?creation=20d'affichages=20(=C3=A0=20rendre=20me?= =?UTF-8?q?illeur=20mais=20booonnn)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- projet.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/projet.py b/projet.py index 8e8c534..a1c0c78 100644 --- a/projet.py +++ b/projet.py @@ -5,20 +5,32 @@ class Personnage: self.nom = nom self.pdv = 20 self.exp = 1 - self.cat = cat - 1 + self.cat = cat - if self.cat == "0": #0 = guerrier + if self.cat == 0: #0 = guerrier self.inventaire = ["épée","potion"] - elif self.cat == "1":#1 = magicien + elif self.cat == 1:#1 = magicien self.inventaire = ["bâton","potion"] - elif self.cat == "2":#2 = voleur + elif self.cat == 2:#2 = voleur self.inventaire = ["dague","potion"] - elif self.cat == "3":#3 = elfe + elif self.cat == 3:#3 = elfe self.inventaire = ["arc","potion"] def jet_attaque(self) -> int: degatsAttaque = [10,10,3,8] #guerrier,magicien,voleur,elfe return randint(1,20) + self.exp*degatsAttaque[self.cat] def jet_defense(self) -> int: - degatsDefense = [8,7,9,10] - return randint(1,20) + self.exp*degatsDefense[self.cat] \ No newline at end of file + degatsDefense = [8,7,9,10] #pareil + return randint(1,20) + self.exp*degatsDefense[self.cat] + def change_pdv(self,nb_pdv : int) -> None: + self.pdv += nb_pdv + def change_exp(self,nb_exp : int) -> None: + self.exp += nb_exp + def affiche_caracteristiques(self): + print(f"""Le personnage {self.nom} et de catégorie {["guerrier", + "magicien","voleur","elfe"][self.cat]} a {self.pdv} points de vie et +{self.exp} point(s) d'experience""") + + def affiche_inventaire(self): + print(f"Le joueur {self.nom} possède", *((item + ",")for item in self.inventaire), + "dans son inventaire") \ No newline at end of file