|
@ -27,13 +27,11 @@ class GUI(Layer): |
|
|
x += len(button)+1 |
|
|
x += len(button)+1 |
|
|
|
|
|
|
|
|
stats = Screen.instance.game.personnage.affiche_caracteristiques() |
|
|
stats = Screen.instance.game.personnage.affiche_caracteristiques() |
|
|
for i in range(4): |
|
|
for i in range(5): |
|
|
self.put_string(stats[i], 1, self.y-8+i, [Colors.RED2]) |
|
|
self.put_string(stats[i], 1, self.y-8+i, [Colors.RED2]) |
|
|
for i in range(6): |
|
|
|
|
|
self.put_string(stats[i+4], (self.x-2)//3, self.y-8+i, [Colors.RED2]) |
|
|
|
|
|
|
|
|
|
|
|
ennemy_stats = Screen.instance.game.ennemy.reduced_stats() |
|
|
ennemy_stats = Screen.instance.game.ennemy.affiche_caracteristiques() |
|
|
for i in range(3): |
|
|
for i in range(5): |
|
|
self.put_string(ennemy_stats[i], self.x-(self.x-2)//3, self.y-8+i, [Colors.BLUE2]) |
|
|
self.put_string(ennemy_stats[i], self.x-(self.x-2)//3, self.y-8+i, [Colors.BLUE2]) |
|
|
|
|
|
|
|
|
else: |
|
|
else: |
|
@ -42,24 +40,11 @@ class GUI(Layer): |
|
|
color = (Colors.REDBG, Colors.BLACK) if self.__buttons[self.__current] == button else (Colors.WHITEBG, Colors.BLACK) |
|
|
color = (Colors.REDBG, Colors.BLACK) if self.__buttons[self.__current] == button else (Colors.WHITEBG, Colors.BLACK) |
|
|
self.put_string(button, x, self.y-10, color) |
|
|
self.put_string(button, x, self.y-10, color) |
|
|
x += len(button)+1 |
|
|
x += len(button)+1 |
|
|
|
|
|
|
|
|
if self.__current == 0: |
|
|
self.put_string("Votre inventaire:", 1, self.y-8, [Colors.RED2]) |
|
|
self.put_string(f"ENTREE pour retourner en arrière", 1, self.y-8, [Colors.RED2]) |
|
|
stats = Screen.instance.game.personnage.affiche_inventaire() |
|
|
elif self.__current == 1: |
|
|
for i in range(len(stats)): |
|
|
potions = Screen.instance.game.personnage.potions |
|
|
self.put_string(stats[i], 1, self.y-7+i, [Colors.RED2]) |
|
|
self.put_string(f"Nombre total de potions: {len(potions)}", 1, self.y-8, [Colors.RED2]) |
|
|
|
|
|
if len(potions) > 0: |
|
|
|
|
|
self.put_string(f"Rénération de la prochaine potion: {potions[0].stats}", 1, self.y-7, [Colors.RED2]) |
|
|
|
|
|
self.put_string(f"ENTEE pour utiliser", 1, self.y-5, [Colors.RED2]) |
|
|
|
|
|
elif self.__current == 2: |
|
|
|
|
|
arme = Screen.instance.game.personnage.arme |
|
|
|
|
|
self.put_string(f"Nom: {arme.meta.name}", 1, self.y-8, [Colors.RED2]) |
|
|
|
|
|
self.put_string(f"Stats:", 1, self.y-7, [Colors.RED2]) |
|
|
|
|
|
self.put_string(f"- HP: {arme.stats.hp}", 1, self.y-6, [Colors.RED2]) |
|
|
|
|
|
self.put_string(f"- ATK%: {arme.stats.atkP}", 1, self.y-5, [Colors.RED2]) |
|
|
|
|
|
self.put_string(f"- DEF%: {arme.stats.defP}", 1, self.y-4, [Colors.RED2]) |
|
|
|
|
|
self.put_string(f"- INITIATIVE: {arme.stats.initiative}", 1, self.y-3, [Colors.RED2]) |
|
|
|
|
|
self.put_string(f"- XPCOEF: {arme.stats.xpcoef}", 1, self.y-2, [Colors.RED2]) |
|
|
|
|
|
|
|
|
|
|
|
return self |
|
|
return self |
|
|
|
|
|
|
|
@ -76,15 +61,18 @@ class GUI(Layer): |
|
|
Screen.instance.game.attack(attacker, victim) |
|
|
Screen.instance.game.attack(attacker, victim) |
|
|
elif self.__current == 1: |
|
|
elif self.__current == 1: |
|
|
self.__inventaire = True |
|
|
self.__inventaire = True |
|
|
self.__buttons = ["Retour", "Potion", "Arme"] |
|
|
self.__buttons = ["Retour", "Utiliser une potion"] |
|
|
else: |
|
|
else: |
|
|
if self.__current == 0: |
|
|
if self.__current == 0: |
|
|
self.__inventaire = False |
|
|
self.__inventaire = False |
|
|
self.__buttons = ["Attaquer", "Inventaire"] |
|
|
self.__buttons = ["Attaquer", "Inventaire"] |
|
|
elif self.__current == 1 and len(Screen.instance.game.personnage.potions) > 0: |
|
|
elif self.__current == 1: |
|
|
personnage = Screen.instance.game.personnage |
|
|
perso = Screen.instance.game.personnage |
|
|
personnage.change_hp(-1*personnage.potions[0].stats) |
|
|
for item in range(len(perso.inventaire)): |
|
|
del personnage.potions[0] |
|
|
if perso.inventaire[item] == "POTION": |
|
|
|
|
|
perso.change_pdv(-10) |
|
|
|
|
|
del perso.inventaire[item] |
|
|
|
|
|
break |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -92,7 +80,7 @@ class StartPopUp(Layer): |
|
|
"""Calque du menu de lancement""" |
|
|
"""Calque du menu de lancement""" |
|
|
def __init__(self, z_index): |
|
|
def __init__(self, z_index): |
|
|
super().__init__(z_index, "popup") |
|
|
super().__init__(z_index, "popup") |
|
|
self.__classes = ["GUERRIER", "MAGICIEN", "VOLEUR", "ELFE"] |
|
|
self.__classes = ["Guerrier", "Magicien", "Voleur", "Elfe"] |
|
|
self.__choosen_class = 0 |
|
|
self.__choosen_class = 0 |
|
|
self.__username = "" |
|
|
self.__username = "" |
|
|
self.__missing_un = False |
|
|
self.__missing_un = False |
|
@ -109,7 +97,7 @@ class StartPopUp(Layer): |
|
|
self.put_string("Classe perso.: (Flèches)", self.x//3 + 1, self.y//6 + 4, [Colors.WHITEBG, Colors.BLACK]) |
|
|
self.put_string("Classe perso.: (Flèches)", self.x//3 + 1, self.y//6 + 4, [Colors.WHITEBG, Colors.BLACK]) |
|
|
y = 0 |
|
|
y = 0 |
|
|
for user_class in self.__classes: |
|
|
for user_class in self.__classes: |
|
|
colors = colors = [Colors.REDBG, Colors.BLACK] if y == self.__choosen_class else [Colors.GREYBG, Colors.WHITE] |
|
|
colors = [Colors.REDBG, Colors.BLACK] if y == self.__choosen_class else [Colors.GREYBG, Colors.WHITE] |
|
|
self.put_string(user_class, self.x//3 + 2, self.y//6 + 5 + y, colors) |
|
|
self.put_string(user_class, self.x//3 + 2, self.y//6 + 5 + y, colors) |
|
|
y += 1 |
|
|
y += 1 |
|
|
|
|
|
|
|
@ -170,17 +158,15 @@ class PopUp(Layer): |
|
|
Screen.instance.del_layer("popup") |
|
|
Screen.instance.del_layer("popup") |
|
|
|
|
|
|
|
|
class Sprite(Layer): |
|
|
class Sprite(Layer): |
|
|
def __init__(self, z_index, sprite_name, place): |
|
|
def __init__(self, z_index, sprite_name, personnage_type): |
|
|
if place != "player" and place != "opponant": |
|
|
super().__init__(z_index, personnage_type) |
|
|
raise ValueError("wrong sprite name") |
|
|
self.personnage_type = personnage_type |
|
|
super().__init__(z_index, place) |
|
|
|
|
|
self.place = place |
|
|
|
|
|
self.sprite_name = sprite_name |
|
|
self.sprite_name = sprite_name |
|
|
|
|
|
|
|
|
def draw(self): |
|
|
def draw(self): |
|
|
super().draw() |
|
|
super().draw() |
|
|
with open(f"game/sprites/{self.sprite_name}.txt", "r") as sprite: |
|
|
with open(f"game/sprites/{self.sprite_name}.txt", "r") as sprite: |
|
|
pos = (1, 1) if self.place == "player" else (Screen.instance.x*2//3+1, 1) |
|
|
pos = (1, 1) if self.personnage_type == "PLAYER" else (Screen.instance.x*2//3+1, 1) |
|
|
self.put_string(sprite.read(), *pos) |
|
|
self.put_string(sprite.read(), *pos) |
|
|
|
|
|
|
|
|
def key_handler(self, key): |
|
|
def key_handler(self, key): |
|
|