corentin.bollet
1 year ago
1 changed files with 17 additions and 3 deletions
@ -1,5 +1,19 @@ |
|||||
|
from random import randint, choice |
||||
from personnage import Personnage |
from personnage import Personnage |
||||
|
|
||||
|
def combat(perso1, perso2): |
||||
|
"""simule un combat jusqu'à ce que les joueurs n'aient plus de vies""" |
||||
|
attaquant = perso1 |
||||
|
defenseur = perso2 |
||||
|
while perso1.pdv != 0 and perso1.pdv != 0: |
||||
|
if attaquant.jet_attaque() > defenseur.jet_defence(): |
||||
|
perso2.change_pdv(randint(1,8)) |
||||
|
elif attaquant.jet_attaque() < defenseur.jet_defence(): |
||||
|
perso1.change_pdv(randint(1,4)) |
||||
|
perso1.affiche_caracteristiques() |
||||
|
perso2.affiche_caracteristiques() |
||||
|
attaquant, defenseur = defenseur , attaquant |
||||
def main(): |
def main(): |
||||
toto = Personnage("toto", "magicien") |
toto = Personnage("toto", choice(["guerrier","magicien","voleur","elfe"])) |
||||
toto.affiche_caracteristiques() |
baba = Personnage("baba", choice(["guerrier","magicien","voleur","elfe"])) |
||||
toto.affiche_inventaire() |
combat() |
Loading…
Reference in new issue