removed inventory and item modules and moved item
to utils. Updated imports accordingly. decentralized entity stats-item coordination.
This commit is contained in:
15
utils/dice.py
Normal file
15
utils/dice.py
Normal file
@@ -0,0 +1,15 @@
|
||||
# Native imports
|
||||
import random as rd
|
||||
|
||||
class Dice():
|
||||
@staticmethod
|
||||
def roll(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
|
||||
return "head" # face
|
||||
else:
|
||||
return "tails" # pile
|
||||
16
utils/item.py
Normal file
16
utils/item.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from typing import Dict
|
||||
from serializable import Serializable
|
||||
|
||||
import uuid
|
||||
|
||||
class Item(Serializable):
|
||||
def __init__(self,name:str, description:str, stat_modifier:Dict[str, int]):
|
||||
super().__init__()
|
||||
self.id = str(uuid.uuid4())
|
||||
self.name = name
|
||||
self.description = description
|
||||
self.stat_modifier = stat_modifier
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.name}: {self.description}"
|
||||
|
||||
Reference in New Issue
Block a user