from random import randint class Personnage : def __init__(self,nom,cat): self.nom = nom self.pdv = 20 self.exp = 1 self.cat = cat if self.cat == "guerrier": self.inventaire = ["épée","potion"] if self.cat == "magicien": self.inventaire = ["bâton","potion"] if self.cat == "voleur": self.inventaire = ["dague","potion"] if self.cat == "elfe": self.inventaire = ["arc","potion"] def jet_attaque (self): if self.cat == "guerrier": jet = randint(1,20) + self.exp * 10 if self.cat == "magicien": jet = randint(1,20) + self.exp * 10 if self.cat == "voleur": jet = randint(1,20) + self.exp * 3 if self.cat == "elfe": jet = randint(1,20) + self.exp * 8 return jet def jet_defense (self): if self.cat == "guerrier": jet = randint(1,20) + self.exp * 8 if self.cat == "magicien": jet = randint(1,20) + self.exp * 7 if self.cat == "voleur": jet = randint(1,20) + self.exp * 9 if self.cat == "elfe": jet = randint(1,20) + self.exp * 10 return jet def change_pdv (self,nb_pdv): return nb_pdv + self.pdv def change_exp (self,nb_exp): return nb_exp + self.exp def affiche_caracteristiques (self): print ("mon nom est" self.nom,"je suis un" self.cat, "j'ai"self.pdv "point de vie", "et"slef.exp "d'experience") def affiche_inventaire (self): print (self.inventaire)