projet jeu de role
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.

56 lines
1.6 KiB

import random
class Personnage :
def __init__ (self, nom, cat) :
self.nom = nom
self.pdv = 20
self.exp = 1
self.cat =cat
if self.cat == "guerrier":
self.inventaire = ["épée", "potion"]
if self.cat == "magicien":
self.inventaire = ["bâton", "potion"]
if self.cat== "voleur":
self.inventaire = ["dague", "potion"]
if self.cat == "elfe":
self.inventaire = ["arc", "potion"]
def jet_attaque (self):
= random.randint(1, 20)
if self.cat == "voleur" :
mult = self.exp*3
if self.cat == "elfe" :
mult = self.exp*8
else :
mult = self.exp*10
return mult +
def jet_defense (self):
= random.randint(1, 20)
if self.cat == "voleur" :
mult = self.exp*9
if self.cat == "elfe" :
mult = self.exp*10
if self.cat == "guerrier" :
mult = self.exp*8
if self.cat == "magicien" :
mult = self.exp*7
return mult +
def change_pdv (self, nb_pdv) :
self.pdv = self.pdv + nb_pdv
def change_exp(self , nb_exp) :
self.exp = self.exp + nb_exp
def affiche_caracteristiques(self) :
print("ton nom est", self.nom, "ta catégorie est", self.cat, "ton nombre de point de vie est", self.pdv,"et tu as ", self.exp, "d experience")
def affiche_inventaire(self) :
print(self.inventaire)
toto = Personnage("toto","magicien")
gab = Personnage ("gab","guerrier")