From b5806605ff1b6969febbbc6ff4772a27dfd1ea97 Mon Sep 17 00:00:00 2001 From: KuMiShi Date: Sun, 25 Jan 2026 16:01:34 +0100 Subject: [PATCH] Dice to Static + Items --- dice.py | 7 ++++--- item.py | 10 +++++++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/dice.py b/dice.py index 74a3f22..e75eaa0 100644 --- a/dice.py +++ b/dice.py @@ -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 diff --git a/item.py b/item.py index 7abb753..9efe375 100644 --- a/item.py +++ b/item.py @@ -8,4 +8,12 @@ class Item(Serializable): self.weight = weight def __str__(self): - return self.name + '(' + self.weight + ' kg)' + ': ' + self.description \ No newline at end of file + 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) \ No newline at end of file