Kalyax 2 years ago
parent
commit
bc15a4183a
  1. 29
      Inventaire.py
  2. 71
      Personnage.py

29
Inventaire.py

@ -0,0 +1,29 @@
class Item:
def __init__(self, name):
self.name = name
class Arme(Item):
def __init__(self, name, stats_set):
super().__init__(name)
self.stats_set = stats_set
def equip():
pass
class Inventaire:
def __init__(self):
self.__content = []
def get_content(self):
return self.__content
def add_item(self, item):
if isinstance(Item, item):
self.__content.append(item)
return self
else:
raise ValueError("item attends un objet Item")
def remove_item(self, index):
self.__content.pop(index)
return self

71
Personnage.py

@ -1,35 +1,68 @@
from enum import Enum
from random import randint
class StatsSet():
#HP, ATK, DEF%, CRIT, CRITRATE%
def __init__(self, hp, atk, defP, crit, critrateP):
#HP, ATK%, DEF%, CRIT, CRITRATE%, XPCOEF
def __init__(self, hp, atkP, defP, crit, critrateP, xpcoef):
self.hp = hp
self.atk = atk
self.atkP = atkP
self.defP = defP
self.crit = crit
self.critrateP = critrateP
self.xpcoef = xpcoef
class ClassType(Enum):
#HP, ATK, DEF%, CRIT, CRITRATE%
SWORDMAN = StatsSet(20, 10, 12, 5, 10)
MAGE = StatsSet(16, 12, 6, 8, 15)
#class ElementType(Enum):
#TODO: DEF% contre : water, fire, electro, ice, geo
#WATER = ()
#FIRE = ()
#ELECTRO = ()
#ICE = ()
#GEO = ()
GUERRIER = StatsSet(20, 10, 12, 5, 10, 8)
MAGICIEN = StatsSet(16, 12, 6, 8, 15, 7)
#VOLEUR =
#ELF =
class Personnage:
def __init__(self, nom, class_type) -> None:
def __init__(self, nom, class_type):
self.nom = nom
self.class_type = class_type
self.xp = 1
self.stats = StatsSet(0, 0, 0, 0, 0)
self.current_hp = self.class_type.hp
self.__hp = self.class_type.hp
self.stats = StatsSet(0, 0, 0, 0, 0, 0)
self.__xp = 1
#self.inventaire =
#self.element =
def jet_attaque(self):
damage = randint(1, 20)
self.change_exp(self.class_type.xpcoef * self.__xp)
return damage + damage * (self.class_type.atkP + self.stats.atkP)
def jet_defense(self):
damage = randint(1, 20)
self.change_exp(self.class_type.xpcoef * self.__xp)
return damage + damage * (self.class_type.defP + self.stats.defP)
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):
print(f"Nom: {self.nom}")
print(f"Type de classe: {self.class_type.name}")
print(f"Vie: {self.__hp}")
print(f"Expérience: {self.__xp}")
print("Stats (classe + personnage):")
print(f"- HP: {self.class_type.hp} + {self.stats.hp}")
print(f"- ATK%: {self.class_type.atkP} + {self.stats.atkP}")
print(f"- DEF%: {self.class_type.defP} + {self.stats.defP}")
print(f"- CRIT: {self.class_type.crit} + {self.stats.crit}")
print(f"- CRITRATE%: {self.class_type.critrateP} + {self.stats.critrateP}")
print(f"- XPCOEF: {self.class_type.xpcoef} + {self.stats.xpcoef}")
Loading…
Cancel
Save