def test_taper(): perso = Personnage(10, 4) perso2 = Personnage(8, 2) perso.se_faire_taper(perso2) assert perso.get_vie() == 8 and perso2.get_vie() == 8
def test_magicien(): perso = Personnage(10, 4) mago = Magicien(3, 2, 1) mago.lancer_sort(perso) assert perso.get_vie() == 9
from personnage import Personnage, Guerriere, Magicien xena = Guerriere(10, 2, 50) peon = Personnage(5, 1) gandalf = Magicien(4, 1, 3) while xena.get_vie() > 0 and peon.get_vie() > 0: print("xena : ", xena.get_vie(), " peon : ", peon.get_vie()) xena.taper(peon) peon.taper(xena) print("xena : ", xena.get_vie(), " peon : ", peon.get_vie()) if xena.get_vie() > 0: surviant = xena else: surviant = peon while surviant.get_vie() > 0: print("survivant : ", surviant.get_vie()) gandalf.lancer_sort(surviant)
def test_get_set_vie(): perso = Personnage(10, 4) perso.set_vie(2) assert perso.get_vie() == 2
def test_init(): perso = Personnage(10, 4) assert perso.get_vie() == 10 and perso.attaque == 4