|
|
|
@ -37,12 +37,14 @@ class Personnage : |
|
|
|
|
|
|
|
def change_pv(self, nb_pv) : |
|
|
|
self.pv += nb_pv |
|
|
|
if self.pv < 0 : |
|
|
|
self.pv = 0 |
|
|
|
|
|
|
|
def change_exp(self, nb_exp) : |
|
|
|
self.exp += nb_exp |
|
|
|
|
|
|
|
def affiche_caracteristiques(self) : |
|
|
|
print(f"Bonjour {self.nom} le {self.cat}, voici tes caractéristiques actuelle :\n- {self.pv} PV \n- {self.exp} EXP") |
|
|
|
print(f"{self.nom} le {self.cat} a actuellement {self.pv} PV et {self.exp} EXP") |
|
|
|
|
|
|
|
def affiche_inventaire(self) : |
|
|
|
print(f"Bonjour {self.nom}, voici ton inventaire :") |
|
|
|
@ -53,20 +55,42 @@ def combat() : |
|
|
|
perso1 = Personnage(input("Comment s'appelle le premier joueur ? "), input("Quelle est sa catégorie ? (guerrier, magicien, voleur, elfe) ")) |
|
|
|
perso2 = Personnage(input("Comment s'appelle le second joueur ? "), input("Quelle est sa catégorie ? (guerrier, magicien, voleur, elfe) ")) |
|
|
|
print() |
|
|
|
while perso1.pv > 0 and perso2.pv > 0 : |
|
|
|
degats = perso1.jet_attaque() |
|
|
|
defense = perso2.jet_defense() |
|
|
|
if degats == defense : |
|
|
|
print("il y a égalité sur les lancés, personne ne prend de dégâts") |
|
|
|
print() |
|
|
|
elif degats > defense : |
|
|
|
perte_pv = randint(-8,-1) |
|
|
|
perso2.change_pv(perte_pv) |
|
|
|
print(f"{perso1.nom} inflige {perte_pv} dégâts à {perso2.nom}") |
|
|
|
perso2.affiche_caracteristiques() |
|
|
|
print(f"{perso1.nom} inflige {abs(perte_pv)} dégâts à {perso2.nom}") |
|
|
|
print() |
|
|
|
elif degats < defense : |
|
|
|
perte_pv = randint(-4,-1) |
|
|
|
perso1.change_pv(perte_pv) |
|
|
|
print(f"{perso2.nom} se défend parfaitement et inflige même {perte_pv} dégâts de contre à {perso1.nom}") |
|
|
|
print(f"{perso2.nom} se défend parfaitement et inflige même {abs(perte_pv)} dégâts de contre à {perso1.nom}") |
|
|
|
print() |
|
|
|
degats = perso2.jet_attaque() |
|
|
|
defense = perso1.jet_defense() |
|
|
|
if degats == defense : |
|
|
|
print("il y a égalité sur les lancés, personne ne prend de dégâts") |
|
|
|
elif degats > defense : |
|
|
|
perte_pv = randint(-8,-1) |
|
|
|
perso1.change_pv(perte_pv) |
|
|
|
print(f"{perso2.nom} inflige {abs(perte_pv)} dégâts à {perso1.nom}") |
|
|
|
print() |
|
|
|
elif degats < defense : |
|
|
|
perte_pv = randint(-4,-1) |
|
|
|
perso2.change_pv(perte_pv) |
|
|
|
print(f"{perso1.nom} se défend parfaitement et inflige même {abs(perte_pv)} dégâts de contre à {perso2.nom}") |
|
|
|
print() |
|
|
|
perso1.affiche_caracteristiques() |
|
|
|
print() |
|
|
|
perso2.affiche_caracteristiques() |
|
|
|
print() |
|
|
|
print("appuyer sur entrer pour continuer") |
|
|
|
input() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|