Browse Source

9eme git

master
manon 2 months ago
parent
commit
e24f1f994d
  1. 25
      Mini projet nb1.py

25
Mini projet nb1.py

@ -39,12 +39,11 @@ class Personnage:
defence = lancer_dés + self.exp * 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 self.pdv = self.pdv + nb_pdv
return self.pdv return self.pdv
def change_exp (self): def change_exp (self, nb_exp):
nb_exp = int(x) nb_exp = int(x)
self.exp = self.exp + nb_exp self.exp = self.exp + nb_exp
return self.exp return self.exp
@ -67,10 +66,18 @@ def jouer():
p2 = Personnage (nomP2, catP2) p2 = Personnage (nomP2, catP2)
while p1.pdv > 0 and p2.pdv > 0: while p1.pdv > 0 and p2.pdv > 0:
p1.jet_attaque ja = p1.jet_attaque()
p2.jet_defense jd = p2.jet_defense()
if ja > jd :
p2.change_pdv(-randint(1,8)) #p2 perd des point de vie
elif jd > ja :
p1..change_pdv(-randint(1,4))
if p1.pdv > 0 and p2.pdv > 0: if p1.pdv > 0 and p2.pdv > 0:
p2.jet_attaque ja = p2.jet_attaque()
p1.jet_defense jd = p1.jet_defense()
else : if ja > jd :
print ("you are dead") p2.change_pdv(-randint(1,8)) #p2 perd des point de vie
elif jd > ja :
p1..change_pdv(-randint(1,4))
Loading…
Cancel
Save