Add Bomb Shop to paths output if Pyramid Fairy Entrance is needed

Tweak internal handling of paths
This commit is contained in:
Kevin Cathcart 2018-01-06 16:25:14 -05:00
parent a86573d529
commit a155d455bb
2 changed files with 15 additions and 7 deletions

View File

@ -1,7 +1,6 @@
import copy
import logging
import json
from itertools import zip_longest
from collections import OrderedDict
@ -769,11 +768,9 @@ class Spoiler(object):
outfile.write('\n\nPaths:\n\n')
path_listings = []
for location, paths in self.paths.items():
for location, path in self.paths.items():
path_lines = []
pathsiter = iter(paths)
pathpairs = zip_longest(pathsiter, pathsiter)
for region, exit in pathpairs:
for region, exit in path:
if exit is not None:
path_lines.append("{} -> {}".format(region, exit))
else:

15
Main.py
View File

@ -1,4 +1,5 @@
from collections import OrderedDict
from itertools import zip_longest
import json
import logging
import random
@ -257,7 +258,6 @@ def create_playthrough(world):
if not sphere:
raise RuntimeError('Not all required items reachable. Something went terribly wrong here.')
# store the required locations for statistical analysis
old_world.required_locations = [location.name for sphere in collection_spheres for location in sphere]
@ -266,7 +266,18 @@ def create_playthrough(world):
value, node = node
yield value
old_world.spoiler.paths = {location.name : list(reversed(list(map(str, flist_to_iter(state.path.get(location.parent_region, (location.parent_region, None))))))) for sphere in collection_spheres for location in sphere}
def get_path(state, region):
reversed_path_as_flist = state.path.get(region, (region, None))
string_path_flat = reversed(list(map(str, flist_to_iter(reversed_path_as_flist))))
# Now we combine the flat string list into (region, exit) pairs
pathsiter = iter(string_path_flat)
pathpairs = zip_longest(pathsiter, pathsiter)
return list(pathpairs)
old_world.spoiler.paths = {location.name : get_path(state, location.parent_region) for sphere in collection_spheres for location in sphere}
if any(exit == 'Pyramid Fairy' for path in old_world.spoiler.paths.values() for (_, exit) in path):
old_world.spoiler.paths['Big Bomb Shop'] = get_path(state, world.get_region('Big Bomb Shop'))
print(world.seed)
# we can finally output our playthrough
old_world.spoiler.playthrough = OrderedDict([(str(i + 1), {str(location): str(location.item) for location in sphere}) for i, sphere in enumerate(collection_spheres)])