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.
80 lines
2.5 KiB
80 lines
2.5 KiB
2 years ago
|
from random import randint
|
||
2 years ago
|
from enum import Enum
|
||
2 years ago
|
|
||
2 years ago
|
class StatsSet:
|
||
2 years ago
|
#HP, ATK%, DEF%, CRIT, CRITRATE%, XPCOEF
|
||
|
def __init__(self, hp, atkP, defP, crit, critrateP, xpcoef):
|
||
2 years ago
|
self.hp = hp
|
||
2 years ago
|
self.atkP = atkP
|
||
2 years ago
|
self.defP = defP
|
||
|
self.crit = crit
|
||
|
self.critrateP = critrateP
|
||
2 years ago
|
self.xpcoef = xpcoef
|
||
2 years ago
|
|
||
2 years ago
|
|
||
|
class ClassType(Enum):
|
||
2 years ago
|
GUERRIER = StatsSet(20, 10, 12, 5, 10, 8)
|
||
|
MAGICIEN = StatsSet(16, 12, 6, 8, 15, 7)
|
||
2 years ago
|
#TODO: Changer stats
|
||
|
VOLEUR = StatsSet(16, 12, 6, 8, 15, 7)
|
||
|
ELF = StatsSet(16, 12, 6, 8, 15, 7)
|
||
|
|
||
2 years ago
|
#Enemy
|
||
|
ZOMBIE = StatsSet(16, 12, 6, 8, 15, 7)
|
||
|
|
||
2 years ago
|
|
||
|
class Personnage:
|
||
2 years ago
|
def __init__(self, nom, class_type):
|
||
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.stats = StatsSet(0, 0, 0, 0, 0, 0)
|
||
|
self.__xp = 1
|
||
2 years ago
|
#self.inventaire =
|
||
2 years ago
|
#self.element =
|
||
|
|
||
|
def jet_attaque(self):
|
||
2 years ago
|
#TODO: ajouter crit
|
||
2 years ago
|
damage = randint(1, 20)
|
||
|
self.change_exp(self.class_type.xpcoef * self.__xp)
|
||
2 years ago
|
return damage + damage * (self.class_type.atkP//100 + self.stats.atkP//100)
|
||
2 years ago
|
|
||
|
def jet_defense(self):
|
||
|
damage = randint(1, 20)
|
||
|
self.change_exp(self.class_type.xpcoef * self.__xp)
|
||
2 years ago
|
return damage + damage * (self.class_type.defP//100 + self.stats.defP//100)
|
||
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):
|
||
2 years ago
|
return (f"Nom: {self.nom}",
|
||
2 years ago
|
f"Type de classe: {self.class_name}",
|
||
2 years ago
|
f"Vie: {self.__hp}",
|
||
|
f"Expérience: {self.__xp}",
|
||
2 years ago
|
"Stats (classe + inventaire):",
|
||
2 years ago
|
f"- HP: {self.class_type.hp} + {self.stats.hp}",
|
||
|
f"- ATK%: {self.class_type.atkP} + {self.stats.atkP}",
|
||
|
f"- DEF%: {self.class_type.defP} + {self.stats.defP}",
|
||
|
f"- CRIT: {self.class_type.crit} + {self.stats.crit}",
|
||
|
f"- CRITRATE%: {self.class_type.critrateP} + {self.stats.critrateP}",
|
||
|
f"- XPCOEF: {self.class_type.xpcoef} + {self.stats.xpcoef}"
|
||
2 years ago
|
)
|
||
|
|
||
|
def reduced_stats(self):
|
||
|
return("Ennemi:", f"Type: {self.class_name}", f"Vie: {self.__hp}",)
|