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.
61 lines
1.8 KiB
61 lines
1.8 KiB
from random import randint
|
|
class Personnage:
|
|
def __init__(self, nom, cat):
|
|
self.nom = nom
|
|
self.pdv = 20
|
|
self.exp = 1
|
|
self.cat = cat
|
|
self.inventaire = []
|
|
|
|
if self.cat == "guerrier":
|
|
self.inventaire = ["épée", "potion"]
|
|
elif self.cat == "magicien":
|
|
self.inventaire = ["bâton", "potion"]
|
|
elif self.cat == "voleur":
|
|
self.inventaire = ["dague", "potion"]
|
|
elif self.cat == "elfe":
|
|
self.inventaire = ["arc", "potion"]
|
|
|
|
def jet_attaque(self):
|
|
lancer = randint(1, 20)
|
|
if self.cat == "guerrier":
|
|
degats = self.exp * 10
|
|
elif self.cat == "magicien":
|
|
degats = self.exp * 10
|
|
elif self.cat == "voleur":
|
|
degats = self.exp * 3
|
|
elif self.cat == "elfe":
|
|
degats = self.exp * 8
|
|
return lancer + degats
|
|
|
|
def jet_defense(self):
|
|
lancer = randint(1, 20)
|
|
if self.cat == "guerrier":
|
|
protection = self.exp * 8
|
|
elif self.cat == "magicien":
|
|
protection = self.exp * 7
|
|
elif self.cat == "voleur":
|
|
protection = self.exp * 9
|
|
elif self.cat == "elfe":
|
|
protection = self.exp * 10
|
|
return lancer + protection
|
|
|
|
def change_pdv(self, nb_pdv):
|
|
self.pdv = self.pdv + nb_pdv
|
|
|
|
def change_exp(self, nb_exp):
|
|
if nb_exp < 0:
|
|
raise ValueError("le parametre doit etre positif")
|
|
self.exp = self.exp + nb_exp
|
|
|
|
|
|
def affiche_caracteristiques(self):
|
|
print("vous vous appelez", self.nom, ", vous etes un", self.cat, ", vous avez", self.pdv, " points de vie et", self.exp, "points d'experience.")
|
|
|
|
def affiche_inventaire(self):
|
|
print(self.inventaire)
|
|
|
|
|
|
|
|
|
|
mon_perso = Personnage("moi", "guerrier")
|