Browse Source

4e commit

master
manon 2 months ago
parent
commit
e19ad43052
  1. 32
      Mini projet nb1.py

32
Mini projet nb1.py

@ -1,6 +1,6 @@
from random import randint from random import randint
class Personnage: class Personnage:
def __init__(self, nom, pdv, exp, cat): def __init__(self, nom, cat):
pdv = 20 pdv = 20
exp = 1 exp = 1
self.nom = nom self.nom = nom
@ -8,36 +8,50 @@ class Personnage:
self.exp = exp self.exp = exp
self.cat = cat self.cat = cat
if self.cat == "guerrier" if self.cat == "guerrier":
self.inventaire = ["épée","potion"] self.inventaire = ["épée","potion"]
self.coef_at = 10 self.coef_at = 10
self.coef_def = 8 self.coef_def = 8
elif self.cat == "magicien" elif self.cat == "magicien":
self.inventaire = ["baton","potion"] self.inventaire = ["baton","potion"]
self.coef_at = 10 self.coef_at = 10
self.coef_def = 7 self.coef_def = 7
elif self.cat == "voleur" elif self.cat == "voleur":
self.inventaire = ["dague","potion"] self.inventaire = ["dague","potion"]
self.coef_at = 3 self.coef_at = 3
self.coef_def = 9 self.coef_def = 9
elif self.cat == "elfe" elif self.cat == "elfe":
self.inventaire = ["arc","potion"] self.inventaire = ["arc","potion"]
self.coef_at = 8 self.coef_at = 8
self.coef_def = 10 self.coef_def = 10
def jet_attaque (self): def jet_attaque (self):
lancer_dés = random [1,20] lancer_dés = randint (1,20)
attaque = lancer_dés + self.coef_at * self.exp attaque = lancer_dés + self.coef_at * self.exp
return attaque return attaque
def jet_defence (self): def jet_defence (self):
lancer_dés = random [1,20] lancer_dés = randint (1,20)
defence = lancer_dés + self.esp * self.coef_def defence = lancer_dés + self.exp * self.coef_def
return defence return defence
def change_pdv (self): def change_pdv (self):
nb_pdv 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("piero","guerrier")
Loading…
Cancel
Save