Skip to content

Commit

Permalink
Spoiler additions for doors
Browse files Browse the repository at this point in the history
  • Loading branch information
aerinon committed Aug 27, 2019
1 parent 02f4ad9 commit 1e495de
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 16 deletions.
13 changes: 12 additions & 1 deletion BaseClasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -1027,6 +1027,7 @@ class Spoiler(object):
def __init__(self, world):
self.world = world
self.entrances = OrderedDict()
self.doors = OrderedDict()
self.medallions = {}
self.playthrough = {}
self.locations = {}
Expand All @@ -1041,6 +1042,12 @@ def set_entrance(self, entrance, exit, direction, player):
else:
self.entrances[(entrance, direction, player)] = OrderedDict([('player', player), ('entrance', entrance), ('exit', exit), ('direction', direction)])

def set_door(self, entrance, exit, direction, player):
if self.world.players == 1:
self.doors[(entrance, direction, player)] = OrderedDict([('entrance', entrance), ('exit', exit), ('direction', direction)])
else:
self.doors[(entrance, direction, player)] = OrderedDict([('player', player), ('entrance', entrance), ('exit', exit), ('direction', direction)])

def parse_data(self):
self.medallions = OrderedDict()
if self.world.players == 1:
Expand Down Expand Up @@ -1135,6 +1142,7 @@ def to_json(self):
self.parse_data()
out = OrderedDict()
out['Entrances'] = list(self.entrances.values())
out['Doors'] = list(self.doors.values())
out.update(self.locations)
out['Special'] = self.medallions
if self.shops:
Expand Down Expand Up @@ -1164,9 +1172,12 @@ def to_file(self, filename):
outfile.write('Menu speed: %s\n' % self.world.fastmenu)
outfile.write('Keysanity enabled: %s\n' % ('Yes' if self.metadata['keysanity'] else 'No'))
outfile.write('Players: %d' % self.world.players)
if self.doors:
outfile.write('\n\nDoors:\n\n')
outfile.write('\n'.join(['%s%s %s %s' % ('Player {0}: '.format(entry['player']) if self.world.players > 1 else '', entry['entrance'], '<=>' if entry['direction'] == 'both' else '<=' if entry['direction'] == 'exit' else '=>', entry['exit']) for entry in self.doors.values()]))
if self.entrances:
outfile.write('\n\nEntrances:\n\n')
outfile.write('\n'.join(['%s%s %s %s' % ('Player {0}: '.format(entry['player']) if self.world.players >1 else '', entry['entrance'], '<=>' if entry['direction'] == 'both' else '<=' if entry['direction'] == 'exit' else '=>', entry['exit']) for entry in self.entrances.values()]))
outfile.write('\n'.join(['%s%s %s %s' % ('Player {0}: '.format(entry['player']) if self.world.players > 1 else '', entry['entrance'], '<=>' if entry['direction'] == 'both' else '<=' if entry['direction'] == 'exit' else '=>', entry['exit']) for entry in self.entrances.values()]))
outfile.write('\n\nMedallions\n')
if self.world.players == 1:
outfile.write('\nMisery Mire Medallion: %s' % (self.medallions['Misery Mire']))
Expand Down
20 changes: 11 additions & 9 deletions DoorShuffle.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@ def link_doors(world, player):

# These connection are here because they are currently unable to be shuffled
for entrance, ext in spiral_staircases:
connect_two_way(world, entrance, ext, player)
connect_two_way(world, entrance, ext, player, True)
for entrance, ext in straight_staircases:
connect_two_way(world, entrance, ext, player)
connect_two_way(world, entrance, ext, player, True)
for entrance, ext in open_edges:
connect_two_way(world, entrance, ext, player)
connect_two_way(world, entrance, ext, player, True)
for exitName, regionName in falldown_pits:
connect_simple_door(world, exitName, regionName, player)
for exitName, regionName in dungeon_warps:
connect_simple_door(world, exitName, regionName, player)

if world.doorShuffle == 'vanilla':
for entrance, ext in default_door_connections:
connect_two_way(world, entrance, ext, player)
connect_two_way(world, entrance, ext, player, True)
for ent, ext in default_one_way_connections:
connect_one_way(world, ent, ext, player)
connect_one_way(world, ent, ext, True)
normal_dungeon_pool(world, player)
elif world.doorShuffle == 'basic':
normal_dungeon_pool(world, player)
Expand Down Expand Up @@ -91,7 +91,7 @@ def connect_simple_door(world, exit_name, region_name, player):
d.dest = region


def connect_two_way(world, entrancename, exitname, player):
def connect_two_way(world, entrancename, exitname, player, skipSpoiler=False):
entrance = world.get_entrance(entrancename, player)
ext = world.get_entrance(exitname, player)

Expand All @@ -112,10 +112,11 @@ def connect_two_way(world, entrancename, exitname, player):
x.dest = y
if y is not None:
y.dest = x
# world.spoiler.set_entrance(entrance.name, exit.name, 'both') # todo: spoiler stuff
if not skipSpoiler and x is not None and y is not None:
world.spoiler.set_door(x.name, y.name, 'both', player)


def connect_one_way(world, entrancename, exitname, player):
def connect_one_way(world, entrancename, exitname, player, skipSpoiler=False):
entrance = world.get_entrance(entrancename, player)
ext = world.get_entrance(exitname, player)

Expand All @@ -134,7 +135,8 @@ def connect_one_way(world, entrancename, exitname, player):
x.dest = y
if y is not None:
y.dest = x
# spoiler info goes here?
if not skipSpoiler and x is not None and y is not None:
world.spoiler.set_door(x.name, y.name, 'entrance', player)


def within_dungeon(world, player):
Expand Down
13 changes: 7 additions & 6 deletions Regions.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,12 +413,13 @@ def mark_light_world_regions(world):
current = queue.popleft()
current.is_dark_world = True
for exit in current.exits:
if exit.connected_region.type == RegionType.LightWorld:
# Don't venture into the light world
continue
if exit.connected_region not in seen:
seen.add(exit.connected_region)
queue.append(exit.connected_region)
if exit.connected_region is not None:
if exit.connected_region.type == RegionType.LightWorld:
# Don't venture into the light world
continue
if exit.connected_region not in seen:
seen.add(exit.connected_region)
queue.append(exit.connected_region)

# (room_id, shopkeeper, replaceable)
shop_table = {
Expand Down

0 comments on commit 1e495de

Please sign in to comment.