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.

99 lines
3.1 KiB

2 years ago
from random import randint
2 years ago
from enum import Enum
2 years ago
2 years ago
from graphics.engine import Screen
from graphics.layers import Sprite
2 years ago
class StatsSet:
2 years ago
#HP, ATK, DEF, INITIATIVE, XPCOEF
def __init__(self, hp, atkP, defP, initiative, xpcoef):
2 years ago
self.hp = hp
2 years ago
self.atkP = atkP
2 years ago
self.defP = defP
2 years ago
self.initiative = initiative
2 years ago
self.xpcoef = xpcoef
2 years ago
2 years ago
class ClassType(Enum):
2 years ago
GUERRIER = StatsSet(20, 10, 15, 5, 8)
MAGICIEN = StatsSet(15, 15, 6, 5, 7)
VOLEUR = StatsSet(17, 22, 9, 7, 9)
ELFE = StatsSet(12, 30, 1, 5, 10)
2 years ago
class Personnage:
2 years ago
def __init__(self, nom, class_type, place):
2 years ago
self.nom = nom
2 years ago
self.class_name = class_type.name
self.class_type = class_type.value
2 years ago
2 years ago
self.__hp = self.class_type.hp
self.__xp = 1
2 years ago
self.potions = [Item(Material.POTION, 10)]
self.arme = Item(Material.EPEE, StatsSet(5, 5, 5, 5, 0))
2 years ago
Sprite(3, self.class_name, place)
2 years ago
def jet_attaque(self):
damage = randint(1, 20)
self.change_exp(self.class_type.xpcoef * self.__xp)
return damage + self.class_type.initiative + self.arme.stats.initiative
2 years ago
def jet_defense(self):
damage = randint(1, 20)
self.change_exp(self.class_type.xpcoef * self.__xp)
return damage + self.class_type.initiative + self.arme.stats.initiative
2 years ago
def get_hp(self):
return self.__hp
def change_hp(self, nb_hp):
if self.__hp - nb_hp < 0:
self.__hp = 0
else:
self.__hp -= nb_hp
def get_xp(self):
return self.__xp
def change_exp(self, nb_exp):
if nb_exp > 0:
self.__xp += nb_exp
else:
raise ValueError("nb_exp attends un nombre positif")
def affiche_caracteristiques(self):
return (f"Nom: {self.nom}",
2 years ago
f"Type de classe: {self.class_name}",
f"Vie: {self.__hp}",
f"Expérience: {self.__xp}",
"Stats (classe + inventaire):",
f"- HP: {self.class_type.hp} + {self.arme.stats.hp}",
f"- ATK%: {self.class_type.atkP} + {self.arme.stats.atkP}",
f"- DEF%: {self.class_type.defP} + {self.arme.stats.defP}",
f"- INITIATIVE: {self.class_type.initiative} + {self.arme.stats.initiative}",
f"- XPCOEF: {self.class_type.xpcoef} + {self.arme.stats.xpcoef}"
)
def reduced_stats(self):
2 years ago
return(f"Ennemi: {self.nom}",
f"Type: {self.class_name}",
f"Vie: {self.__hp}",
)
class Item():
def __init__(self, material, stats: int | StatsSet, meta=None):
self.material = material
self.meta = material.value if meta == None else meta
self.stats = stats
class ItemMeta:
def __init__(self, name, description):
self.name = name
self.description = description
class Material(Enum):
POTION = ItemMeta("Potion", "TODO")
EPEE = ItemMeta("Épée", "TODO")
BATON = ItemMeta("Bâton", "TODO")
DAGUE = ItemMeta("Dague", "TODO")
ARC = ItemMeta("Arc", "TODO")