Dice to Static + Items

This commit is contained in:
KuMiShi
2026-01-25 16:01:34 +01:00
parent 65c9d206dd
commit b5806605ff
2 changed files with 13 additions and 4 deletions

View File

@@ -2,13 +2,14 @@ import random as rd
from . import serializable
class Dice(serializable.Serializable):
def __init__(self, seed=42):
self.seed = seed
rd.seed(self.seed)
def __init__(self):
raise TypeError("Un dé ne peut pas être instanciée!")
@staticmethod
def roll(self, num_faces=20):
return rd.randrange(start=1, stop=num_faces+1, step=1)
@staticmethod
def head_or_tails():
result = rd.randint(0,1)
if result: # true

10
item.py
View File

@@ -8,4 +8,12 @@ class Item(Serializable):
self.weight = weight
def __str__(self):
return self.name + '(' + self.weight + ' kg)' + ': ' + self.description
return self.name + '(' + self.weight + ' kg)' + ': ' + self.description
class Equippable(Item):
def __init__(self, name, description, weight = 10):
super().__init__(name, description, weight)
class Consummable(Item):
def __init__(self, name, description, weight = 10):
super().__init__(name, description, weight)