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.

54 lines
1.8 KiB

from game.personnage import *
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(" ", "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)], classes[randint(0, 3)], "OPPONENT")
def init_personnage(self, nom, class_type):
self.personnage = Personnage(nom, 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_pdv(rand)
else:
rand = randint(1, 4)
attacker.change_pdv(rand)
if self.personnage.get_pdv() == 0:
for i in range(50):
PopUp(1, "Vous avez perdu! Relancez le jeu pour continuer...", True)
if self.ennemy.get_pdv() == 0:
self.ennemy = self.rand_ennemy()
potions = ""
inv = self.personnage.inventaire
if len(inv) >= 6:
potions = f"- Pas de potion car inventaire plein\n"
else:
maxpot = 3
if len(inv) > 3:
maxpot = 6-len(inv)
for i in range(randint(0, maxpot)):
random = randint(5, 25)
inv.append(Material.POTION)
potions += f"- Potion de 10HP\n"
PopUp(1, f"Ennemi vaincu!\n{potions}")
self.personnage.change_exp(1)