Equippable & Consummable
This commit is contained in:
24
item.py
24
item.py
@@ -1,19 +1,33 @@
|
||||
from .serializable import Serializable
|
||||
|
||||
class Item(Serializable):
|
||||
def __init__(self,name:str, description:str, weight:float = 10.0):
|
||||
def __init__(self,name:str, description:str, stat_modifier:str, weight:float = 10.0):
|
||||
super().__init__()
|
||||
self.name = name
|
||||
self.description = description
|
||||
self.stat_modifier = stat_modifier
|
||||
self.weight = weight
|
||||
|
||||
def __str__(self):
|
||||
return self.name + '(' + self.weight + ' kg)' + ': ' + self.description
|
||||
|
||||
class Equippable(Item):
|
||||
def __init__(self, name, description, weight = 10):
|
||||
super().__init__(name, description, weight)
|
||||
def __init__(self, name, description, stat_modifier, equipped:bool, weight = 10.0):
|
||||
super().__init__(name, description, stat_modifier, weight)
|
||||
self.equipped = equipped
|
||||
|
||||
def equip(self):
|
||||
self.equipped = True
|
||||
|
||||
def unequip(self):
|
||||
self.equipped = False
|
||||
|
||||
class Consummable(Item):
|
||||
def __init__(self, name, description, weight = 10):
|
||||
super().__init__(name, description, weight)
|
||||
def __init__(self, name, description, stat_modifier, nb_of_uses:int, weight = 10.0):
|
||||
super().__init__(name, description, stat_modifier, weight)
|
||||
self.nb_of_uses = nb_of_uses
|
||||
|
||||
def consumme(self):
|
||||
if self.nb_of_uses > 0:
|
||||
self.nb_of_uses -= 1
|
||||
|
||||
Reference in New Issue
Block a user