--- /dev/null
+import random
+import items
+
+class Section:
+ def __init__(self, level: int):
+ self.level = level
+
+class Armory(Section):
+ def __init__(self, level: int):
+ super().__init__(level)
+ self.weapons = []
+ self.lost_weapons = []
+ self.is_messy = False
+
+ def store(self, weapons: list(items.Weapon)):
+ """
+ Put some weapons in the armory to store it.
+ If it is not organized you might loose some
+ """
+ if len(weapons) > 1 and self.is_messy:
+ for weapon in weapons:
+ if random.choice([True, False]):
+ self.lost_weapons.append(weapon)
+ else:
+ self.weapons.append(weapon)
+
+ elif len(weapons) > 1:
+ self.is_messy = random.choice([True, False])
+ else:
+ self.weapons.extend(weapons)
+
+
+ def checkout(self) -> items.Weapon:
+ """
+ Checkout any weapon!
+ Well if the armory is organzied you might even find it.
+ Or just pick one
+ """
+ try:
+ return self.weapons.pop()
+ except IndexError:
+ return None
+ finally:
+ self.is_messy = True
+
+ def tidy_up(self):
+ """
+ Sometimes you need to actually cleanup your armory.
+ You may even find some lost items!
+ """
+ try:
+ random.shuffle(self.lost_weapons)
+
+ lost_weapon = self.lost_weapons.pop()
+ self.weapons.append(lost_weapon)
+
+ except IndexError:
+ pass
+
+ finally:
+ self.is_messy = True
+
+class Workshop:
+ def __init__(self, level: int):
+ super().__init__(level)
+ self.is_cleaned_up = True
+
+ def craft(self, blueprint: items.Blueprint, ressources: list(items.Ressource)) -> items.Item:
+ """
+ Use the Workshop to craft something cool
+ All you need are: a blueprint, some ressources and a little bit of time
+ """
+ needed_ressources = []
+ for ingredient in blueprint.required_ressources:
+ if ingredient in ressources:
+ ressources.remove(ingredient)
+ needed_ressources.append(ingredient)
+ else:
+ ressources.extend(needed_ressources)
+ return None
+
+ product = blueprint.build(needed_ressources)
+
+ self.is_cleaned_up = random.choice([True, False])
+ return product
+
+ def break_up(self, item: items.Item) -> list(items.Item):
+ """
+ Use the Workshop and try to break up any item.
+ This will destroy the item and return some components
+ """
+ self.is_cleaned_up = random.choice([True, False])
+ return item.components
+
+class Dark_Tower:
+ def __init__(self):
+ self.levels = 0
+ self.sections = []
+
+ def build_section(self, section: Section) -> bool:
+ if len(self.sections) < self.levels:
+ self.sections.append(section)
+ return True
+ return False
--- /dev/null
+class Item:
+ def __init__(self, name, components=[], value=1):
+ self.name = name
+ self.value = value
+ self.components = components
+
+class Weapon(Item):
+ def __init__(self, name="Dagger", components=[Ressource("Scrap")], value=5):
+ super().__init__(name, components, value)
+ self.damage = 1
+
+class Tool(Item):
+ def __init__(self, name="Hammer", components=[Ressource("Scrap")], value=1):
+ super().__init__(name, components, value)
+
+class Blueprint:
+ def __init__(self, required_ressources=[], product=None):
+ self.required_ressources = required_ressources
+ self.product = product
+
+class Ressource(Item):
+ def __init__(self, name="Scrap", value=1):
+ super().__init__(name, value)