|
@ -1,3 +1,5 @@ |
|
|
|
|
|
# Manon BELLYNCK TG2 |
|
|
|
|
|
|
|
|
from random import randint |
|
|
from random import randint |
|
|
|
|
|
|
|
|
class Personnage: |
|
|
class Personnage: |
|
@ -34,17 +36,16 @@ class Personnage: |
|
|
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_defense (self): |
|
|
lancer_dés = randint (1,20) |
|
|
lancer_dés = randint (1,20) |
|
|
defence = lancer_dés + self.exp * self.coef_def |
|
|
defense = lancer_dés + self.exp * self.coef_def |
|
|
return defence |
|
|
return defense |
|
|
|
|
|
|
|
|
def change_pdv (self, nb_pdv): |
|
|
def change_pdv (self, nb_pdv): |
|
|
self.pdv = self.pdv + nb_pdv |
|
|
self.pdv = self.pdv + nb_pdv |
|
|
return self.pdv |
|
|
return self.pdv |
|
|
|
|
|
|
|
|
def change_exp (self, nb_exp): |
|
|
def change_exp (self, nb_exp): |
|
|
nb_exp = int(x) |
|
|
|
|
|
self.exp = self.exp + nb_exp |
|
|
self.exp = self.exp + nb_exp |
|
|
return self.exp |
|
|
return self.exp |
|
|
|
|
|
|
|
@ -65,19 +66,35 @@ def jouer(): |
|
|
catP2 =input ("quel est la catégorie du jouer 2") |
|
|
catP2 =input ("quel est la catégorie du jouer 2") |
|
|
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 attaque p2 |
|
|
ja = p1.jet_attaque() |
|
|
ja = p1.jet_attaque() |
|
|
jd = p2.jet_defense() |
|
|
jd = p2.jet_defense() |
|
|
|
|
|
|
|
|
if ja > jd : |
|
|
if ja > jd : |
|
|
p2.change_pdv(-randint(1,8)) #p2 perd des point de vie |
|
|
p2.change_pdv(-randint(1,8)) #p2 perd des point de vie |
|
|
elif jd > ja : |
|
|
elif jd > ja : |
|
|
p1..change_pdv(-randint(1,4)) |
|
|
p1.change_pdv(-randint(1,4))#p1 perd des point de vie |
|
|
|
|
|
|
|
|
|
|
|
elif p1.pdv == 0: |
|
|
|
|
|
p2.change_exp(1) |
|
|
|
|
|
print ("p2 gagnant et p1 perdant") #p1 mort en attaquant |
|
|
|
|
|
elif p2.pdv == 0: |
|
|
|
|
|
p1.change_exp(1) |
|
|
|
|
|
print ("p1 gagnant et p2 perdant") #p2 mort en défendant |
|
|
|
|
|
|
|
|
if p1.pdv > 0 and p2.pdv > 0: |
|
|
elif p1.pdv > 0 and p2.pdv > 0: #p2 attaque p1 |
|
|
ja = p2.jet_attaque() |
|
|
ja = p2.jet_attaque() |
|
|
jd = p1.jet_defense() |
|
|
jd = p1.jet_defense() |
|
|
|
|
|
|
|
|
if ja > jd : |
|
|
if ja > jd : |
|
|
p2.change_pdv(-randint(1,8)) #p2 perd des point de vie |
|
|
p2.change_pdv(-randint(1,8)) #p2 perd des point de vie |
|
|
elif jd > ja : |
|
|
elif jd > ja : |
|
|
p1..change_pdv(-randint(1,4)) |
|
|
p1.change_pdv(-randint(1,4))#p1 perd des point de vie |
|
|
|
|
|
|
|
|
|
|
|
elif p1.pdv == 0: |
|
|
|
|
|
p2.change_exp(1) |
|
|
|
|
|
print ("p2 gagnant et p1 perdant") #p1 mort en défendant |
|
|
|
|
|
elif p2.pdv == 0: |
|
|
|
|
|
p1.change_exp(1) |
|
|
|
|
|
print ("p1 gagnant et p2 perdant")#p2 mort en attaquant |
|
|
|
|
|
|