allow ER coop

This commit is contained in:
Fabian Dill 2021-02-20 02:30:55 +01:00
parent a7cbb440d1
commit c55cf28229
5 changed files with 24 additions and 2 deletions

View File

@ -4,6 +4,7 @@ import copy
from enum import Enum, unique from enum import Enum, unique
import logging import logging
import json import json
import functools
from collections import OrderedDict, Counter, deque from collections import OrderedDict, Counter, deque
from typing import Union, Optional, List, Dict, NamedTuple, Iterable from typing import Union, Optional, List, Dict, NamedTuple, Iterable
import secrets import secrets
@ -160,6 +161,10 @@ class World(object):
region.world = self region.world = self
self._region_cache[region.player][region.name] = region self._region_cache[region.player][region.name] = region
@functools.cached_property
def world_name_lookup(self):
return {self.player_names[player_id][0]: player_id for player_id in self.player_ids}
def _recache(self): def _recache(self):
"""Rebuild world cache""" """Rebuild world cache"""
for region in self.regions: for region in self.regions:

View File

@ -359,7 +359,7 @@ def swap_location_item(location_1: Location, location_2: Location, check_locked=
def distribute_planned(world): def distribute_planned(world):
world_name_lookup = {world.player_names[player_id][0]: player_id for player_id in world.player_ids} world_name_lookup = world.world_name_lookup
for player in world.player_ids: for player in world.player_ids:
placement: PlandoItem placement: PlandoItem

6
Gui.py
View File

@ -236,7 +236,8 @@ def guiMain(args=None):
shuffleVar.set('vanilla') shuffleVar.set('vanilla')
shuffleOptionMenu = OptionMenu(shuffleFrame, shuffleVar, 'vanilla', 'simple', 'restricted', 'full', 'crossed', shuffleOptionMenu = OptionMenu(shuffleFrame, shuffleVar, 'vanilla', 'simple', 'restricted', 'full', 'crossed',
'insanity', 'restricted_legacy', 'full_legacy', 'madness_legacy', 'insanity_legacy', 'insanity', 'restricted_legacy', 'full_legacy', 'madness_legacy', 'insanity_legacy',
'dungeonsfull', 'dungeonssimple') 'dungeonsfull', 'dungeonssimple', "same simple", "same restricted", "same full",
"same crossed", "same insanity", "same dungeonsfull", "same dungeonssimple")
shuffleOptionMenu.pack(side=RIGHT) shuffleOptionMenu.pack(side=RIGHT)
shuffleLabel = Label(shuffleFrame, text='Entrance shuffle') shuffleLabel = Label(shuffleFrame, text='Entrance shuffle')
shuffleLabel.pack(side=LEFT) shuffleLabel.pack(side=LEFT)
@ -417,6 +418,9 @@ def guiMain(args=None):
guiargs.accessibility = accessibilityVar.get() guiargs.accessibility = accessibilityVar.get()
guiargs.algorithm = algorithmVar.get() guiargs.algorithm = algorithmVar.get()
guiargs.shuffle = shuffleVar.get() guiargs.shuffle = shuffleVar.get()
if "same " in guiargs.shuffle:
guiargs.shuffle = guiargs.shuffle[5:] + "-" + str(seedVar.get() if seedVar.get() else
random.randint(0, 2**64))
guiargs.heartbeep = rom_vars.heartbeepVar.get() guiargs.heartbeep = rom_vars.heartbeepVar.get()
guiargs.heartcolor = rom_vars.heartcolorVar.get() guiargs.heartcolor = rom_vars.heartcolorVar.get()
guiargs.fastmenu = rom_vars.fastMenuVar.get() guiargs.fastmenu = rom_vars.fastMenuVar.get()

10
Main.py
View File

@ -170,12 +170,22 @@ def main(args, seed=None):
{"vanilla", "dungeonssimple", "dungeonsfull", "simple", "restricted", "full"}: {"vanilla", "dungeonssimple", "dungeonsfull", "simple", "restricted", "full"}:
world.fix_fake_world[player] = False world.fix_fake_world[player] = False
old_random = world.random
# seeded entrance shuffle
if "-" in world.shuffle[player]:
shuffle, seed = world.shuffle[player].split("-")
world.random = random.Random(int(seed))
world.shuffle[player] = shuffle
if world.mode[player] != 'inverted': if world.mode[player] != 'inverted':
link_entrances(world, player) link_entrances(world, player)
mark_light_world_regions(world, player) mark_light_world_regions(world, player)
else: else:
link_inverted_entrances(world, player) link_inverted_entrances(world, player)
mark_dark_world_regions(world, player) mark_dark_world_regions(world, player)
world.random = old_random
plando_connect(world, player) plando_connect(world, player)
logger.info('Generating Item Pool.') logger.info('Generating Item Pool.')

View File

@ -87,6 +87,9 @@ entrance_shuffle: # Documentation: https://alttpr.com/en/options#entrance_shuffl
full: 0 # Less strict than restricted full: 0 # Less strict than restricted
crossed: 0 # Less strict than full crossed: 0 # Less strict than full
insanity: 0 # Very few grouping rules. Good luck insanity: 0 # Very few grouping rules. Good luck
# you can also define entrance shuffle seed, like so:
crossed-1000: 0 # using this method, you can have the same layout as another player and share entrance information
# however, many other settings like logic, world state, retro etc. may affect the shuffle result as well.
goals: goals:
ganon: 50 # Climb GT, defeat Agahnim 2, and then kill Ganon ganon: 50 # Climb GT, defeat Agahnim 2, and then kill Ganon
fast_ganon: 0 # Only killing Ganon is required. However, items may still be placed in GT fast_ganon: 0 # Only killing Ganon is required. However, items may still be placed in GT