def hideout(self): dungeon = self.dungeon self.explore_depth = 6 self.explored_nodes = [] # populates back of dungeon with a tough boss, and entrance with some guards. Odd stuff in between. # see what else they've explored: self.explore(dungeon, 0) for node, node_data in dungeon.nodes(data=True): if node in self.explored_nodes: node_data['colour'] = self.colour # put some encounters in there subgraph = dungeon.subgraph(self.explored_nodes) nodes = subgraph.nodes(data=True) paths = {a: len(nx.shortest_path(subgraph, 0, a)) for a, node in nodes} max_path = max(paths.values()) final_room = random.choice([key for key, value in paths.items() if value == max_path]) main_route = nx.shortest_path(subgraph, 0, final_room) for a, node in nodes: if a == final_room: encounter = DirectedEncounter(self.level, style='boss') encounter.pick_monsters(self.monsters) node['encounter'] = encounter.display() t = Treasure(self.level) node['treasure'] = t.roll_on_treasure_table() elif a == 0: encounter = DirectedEncounter(self.level, style='guards') encounter.pick_monsters(self.monsters) node['encounter'] = encounter.display() elif a not in main_route: roll = random.randint(1, 6) if roll > 3: encounter = DirectedEncounter(self.level, style='elite') encounter.pick_monsters(self.monsters) node['encounter'] = encounter.display() else: roll = random.randint(1, 6) if roll > 3: encounter = DirectedEncounter(self.level, style='basic') encounter.pick_monsters(self.monsters) node['encounter'] = encounter.display()
from treasure import Treasure if __name__ == '__main__': treasure = Treasure(1) print(treasure.roll_on_treasure_table())