import random as rd import time class Monstre: def __init__(self, nom, dsc, img=None, obj=None) -> None: self.nom = nom self.dsc = dsc self.img = img self.obj = obj self.habilite = rd.randint(1, 10) self.endurance_max = 15 self.endurance = self.endurance_max self.force = 2 self.courage = rd.randint(1, 10) self.objet = [] if "Squelette" in self.nom: self.habilite = rd.randint(1, 7) self.endurance = rd.randint(1, 4) self.force = rd.randint(1, 2) self.courage = rd.randint(1, 10) if 'Chauve-souris' in self.nom: self.habilite = rd.randint(5, 10) self.endurance = rd.randint(1, 3) self.force = 1 self.courage = 10 self.objet = ['clé cadena'] if 'Limace-geante' in self.nom: self.habilite = 1 self.endurance = 7 self.force = 1 self.courage = 10 if 'Zombie' in self.nom: self.habilite = rd.randint(1, 4) self.endurance = 7 self.force = 1 self.courage = 8 if 'Zombie_sur_poulet' in self.nom: self.habilite = rd.randint(4, 7) self.endurance = 4 self.force = 2 self.courage = 8 if 'Hydra' in self.nom: self.habilite = rd.randint(8, 10) self.endurance = 10 self.force = 3 self.courage = 10 self.objet = ["Croc d'Hydra"] if 'Poutine' in self.nom: self.habilite = 10 self.endurance = 12 self.force = 4 self.courage = 10 self.objet = ["Bouteille de vodka"] if 'Pikachu' in self.nom: self.habilite = 12 self.endurance = 5 self.force = 2 self.courage = 10 def modifier_endurance(self: 'Monstre', modificateur): endurance_modifie = self.endurance + modificateur if endurance_modifie < 0: self.endurance = 0 elif endurance_modifie > self.endurance_max: self.endurance = self.endurance_max else: self.endurance = endurance_modifie def subir_degats(self: 'Monstre', degats: int) -> None: if degats > 0: self.modifier_endurance(-degats) def get_description(self: 'Monstre') -> str: return self.dsc def get_carac(self: 'Montres') -> str: return f"{self.nom} H{self.habilite} E{self.endurance} F{self.force} C{self.courage}" def est_hs(self: 'Monstre') -> bool: if self.endurance <= 0: return True else: return False def getEndurance(self): return self.endurance