]>
wolfpit.net Git - projects/underlord/.git/blob - buildings.py
6 def __init__(self
, level
: int):
9 class Storage(Section
):
10 def __init__(self
, level
: int):
11 super().__init
__(level
)
14 self
.lost_ressources
= []
16 def store(self
, ressources
: list(items
.Weapon
)):
18 Put some ressources in the armory to store it.
19 If it is not organized you might loose some
21 if len(ressources
) > 1 and self
.is_messy
:
22 for ressource
in ressources
:
23 if random
.choice([True, False]):
24 self
.lost_ressources
.append(ressource
)
26 self
.ressources
.append(ressource
)
28 elif len(ressources
) > 1:
29 self
.is_messy
= random
.choice([True, False])
31 self
.ressources
.extend(ressources
)
34 def checkout(self
) -> items
.Weapon
:
36 Checkout any ressource!
37 Well if the armory is organzied you might even find it.
41 return self
.ressources
.pop()
49 Sometimes you need to actually cleanup your armory.
50 You may even find some lost items!
53 random
.shuffle(self
.lost_ressources
)
55 lost_ressource
= self
.lost_ressources
.pop()
56 self
.ressources
.append(lost_ressource
)
65 class Armory(Section
):
66 def __init__(self
, level
: int):
67 super().__init
__(level
)
69 self
.lost_weapons
= []
72 def store(self
, weapons
: list(items
.Weapon
)):
74 Put some weapons in the armory to store it.
75 If it is not organized you might loose some
77 if len(weapons
) > 1 and self
.is_messy
:
78 for weapon
in weapons
:
79 if random
.choice([True, False]):
80 self
.lost_weapons
.append(weapon
)
82 self
.weapons
.append(weapon
)
84 elif len(weapons
) > 1:
85 self
.is_messy
= random
.choice([True, False])
87 self
.weapons
.extend(weapons
)
90 def checkout(self
) -> items
.Weapon
:
93 Well if the armory is organzied you might even find it.
97 return self
.weapons
.pop()
105 Sometimes you need to actually cleanup your armory.
106 You may even find some lost items!
109 random
.shuffle(self
.lost_weapons
)
111 lost_weapon
= self
.lost_weapons
.pop()
112 self
.weapons
.append(lost_weapon
)
121 def __init__(self
, level
: int):
122 super().__init
__(level
)
123 self
.is_cleaned_up
= True
125 def craft(self
, blueprint
: items
.Blueprint
, ressources
: list(items
.Ressource
)) -> items
.Item
:
127 Use the Workshop to craft something cool
128 All you need are: a blueprint, some ressources and a little bit of time
130 needed_ressources
= []
131 for ingredient
in blueprint
.required_ressources
:
132 if ingredient
in ressources
:
133 ressources
.remove(ingredient
)
134 needed_ressources
.append(ingredient
)
136 ressources
.extend(needed_ressources
)
139 product
= blueprint
.build(needed_ressources
)
141 self
.is_cleaned_up
= random
.choice([True, False])
144 def break_up(self
, item
: items
.Item
) -> list(items
.Item
):
146 Use the Workshop and try to break up any item.
147 This will destroy the item and return some components
149 self
.is_cleaned_up
= random
.choice([True, False])
150 return item
.components
156 def dig_corpses_up(self
, workers
: list(creatures
.Minion
)):
157 self
.corpses
.extend([items
.Ressource("Corpse", 0) for _
in random
.randrange(3 * len(workers
))])
159 def bring_corpses_home(self
, workers
: list(creatures
.Minion
)) -> list(items
.Ressource
):
162 yield self
.corpses
.pop()
171 def build_section(self
, section
: Section
) -> bool:
172 if len(self
.sections
) < self
.levels
:
173 self
.sections
.append(section
)
177 def build_level(self
):