You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
2.0 KiB

from random import randint
class Personnage:
def __init__(self, nom, cat):
pdv = 20
exp = 1
self.nom = nom
self.pdv = pdv
self.exp = exp
self.cat = cat
if self.cat == "guerrier":
self.inventaire = ["épée","potion"]
self.coef_at = 10
self.coef_def = 8
elif self.cat == "magicien":
self.inventaire = ["baton","potion"]
self.coef_at = 10
self.coef_def = 7
elif self.cat == "voleur":
self.inventaire = ["dague","potion"]
self.coef_at = 3
self.coef_def = 9
elif self.cat == "elfe":
self.inventaire = ["arc","potion"]
self.coef_at = 8
self.coef_def = 10
def jet_attaque (self):
lancer_dés = randint (1,20)
attaque = lancer_dés + self.coef_at * self.exp
return attaque
def jet_defence (self):
lancer_dés = randint (1,20)
defence = lancer_dés + self.exp * self.coef_def
return defence
def change_pdv (self):
nb_pdv = int(x)
self.pdv = self.pdv + nb_pdv
return self.pdv
def change_exp (self):
nb_exp = int(x)
self.exp = self.exp + nb_exp
return self.exp
def affiche_caracteristiques (self):
print ("Je suis", self.nom, "je suis un", self.cat, "j'ai", self.pdv,"point de vie et", self.exp, "point d'experience")
def affiche_inventaire (self):
print ("j'ai", self.inventaire)
#p = Personnage("pierrot","guerrier")
def jouer():
nomP1 = input("joueur 1 votre nom")
catP1 =input ("quel est la catégorie du jouer 1")
p1 = Personnage (nomP1, catP1)
nomP2 = input("joueur 2 votre nom")
catP2 =input ("quel est la catégorie du jouer 2")
p2 = Personnage (nomP2, catP2)
while p1.pdv > 0 and p2.pdv > 0:
p1.jet_defense
p2.jet_