You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.4 KiB
39 lines
1.4 KiB
from game.personnage import Personnage, ClassType
|
|
|
|
from graphics.layers import Sprite, PopUp
|
|
|
|
from random import randint
|
|
|
|
class Game:
|
|
def __init__(self):
|
|
self.personnage = None
|
|
self.ennemy = None
|
|
|
|
def late_init(self):
|
|
self.personnage = Personnage(" ", ClassType.GUERRIER, "player")
|
|
self.ennemy = self.rand_ennemy()
|
|
|
|
def rand_ennemy(self):
|
|
classes = ["GUERRIER", "MAGICIEN", "VOLEUR", "ELFE"]
|
|
noms = ["Bill Gates", "Dark Vador", "Gargamel", "G-Man"]
|
|
return Personnage(noms[randint(0, 3)], ClassType[classes[randint(0, 3)]], "opponant")
|
|
|
|
def init_personnage(self, nom, class_type):
|
|
self.personnage = Personnage(nom, ClassType[class_type], "player")
|
|
|
|
def attack(self, attacker, victim):
|
|
atk_jet = attacker.jet_attaque()
|
|
def_jet = victim.jet_defense()
|
|
if (atk_jet >= def_jet):
|
|
rand = randint(1, 8)
|
|
victim.change_hp(rand + rand * ((attacker.class_type.atkP + attacker.arme.stats.atkP)//100))
|
|
else:
|
|
rand = randint(1, 4)
|
|
attacker.change_hp(rand + rand * ((victim.class_type.defP + victim.arme.stats.defP)//100))
|
|
|
|
if self.personnage.get_hp() == 0:
|
|
for i in range(50):
|
|
PopUp(1, "Vous avez perdu! Relancez le jeu pour continuer...", True)
|
|
if self.ennemy.get_hp() == 0:
|
|
self.ennemy = self.rand_ennemy()
|
|
PopUp(1, "Ennemi vaincu!")
|