Dice to Static + Items
This commit is contained in:
7
dice.py
7
dice.py
@@ -2,13 +2,14 @@ import random as rd
|
|||||||
from . import serializable
|
from . import serializable
|
||||||
|
|
||||||
class Dice(serializable.Serializable):
|
class Dice(serializable.Serializable):
|
||||||
def __init__(self, seed=42):
|
def __init__(self):
|
||||||
self.seed = seed
|
raise TypeError("Un dé ne peut pas être instanciée!")
|
||||||
rd.seed(self.seed)
|
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
def roll(self, num_faces=20):
|
def roll(self, num_faces=20):
|
||||||
return rd.randrange(start=1, stop=num_faces+1, step=1)
|
return rd.randrange(start=1, stop=num_faces+1, step=1)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
def head_or_tails():
|
def head_or_tails():
|
||||||
result = rd.randint(0,1)
|
result = rd.randint(0,1)
|
||||||
if result: # true
|
if result: # true
|
||||||
|
|||||||
8
item.py
8
item.py
@@ -9,3 +9,11 @@ class Item(Serializable):
|
|||||||
|
|
||||||
def __str__(self):
|
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)
|
||||||
Reference in New Issue
Block a user