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.
58 lines
1.6 KiB
58 lines
1.6 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, self.pdv, self.exp)
|
|
|
|
def affiche_inventaire (self):
|
|
print ("j'ai", self.inventaire)
|
|
|
|
p = Personnage("pierrot","guerrier")
|
|
|