pass explicit seed_name from MultiMystery.py

This commit is contained in:
Fabian Dill 2021-04-12 09:45:07 +02:00
parent 2df7e4e537
commit 433981fd3d
4 changed files with 20 additions and 21 deletions

View File

@ -321,7 +321,7 @@ class MultiWorld():
if location.can_fill(self.state, item, False):
location.item = item
item.location = location
item.world = self # try to not have this here anymore
item.world = self # try to not have this here anymore
if collect:
self.state.collect(item, location.event, location)

View File

@ -5,6 +5,7 @@ import threading
import concurrent.futures
import argparse
import logging
import random
def feedback(text: str):
@ -24,7 +25,7 @@ if __name__ == "__main__":
args = parser.parse_args()
from Utils import get_public_ipv4, get_options
from Mystery import get_seed_name
from Patch import create_patch_file
options = get_options()
@ -89,10 +90,11 @@ if __name__ == "__main__":
feedback(f"No player files found. Please put them in a {player_files_path} folder.")
else:
logging.info(f"{target_player_count} Players found.")
seed_name = get_seed_name(random)
command = f"{basemysterycommand} --multi {target_player_count} {player_string} " \
f"--rom \"{rom_file}\" --enemizercli \"{enemizer_path}\" " \
f"--outputpath \"{output_path}\" --teams {teams} --plando \"{plando_options}\""
f"--outputpath \"{output_path}\" --teams {teams} --plando \"{plando_options}\" " \
f"--seed_name {seed_name}"
if create_spoiler:
command += " --create_spoiler"
@ -117,15 +119,9 @@ if __name__ == "__main__":
start = time.perf_counter()
text = subprocess.check_output(command, shell=True).decode()
logging.info(f"Took {time.perf_counter() - start:.3f} seconds to generate multiworld.")
seedname = ""
for segment in text.split():
if segment.startswith("M"):
seedname = segment
break
multidataname = f"AP_{seedname}.archipelago"
spoilername = f"AP_{seedname}_Spoiler.txt"
multidataname = f"AP_{seed_name}.archipelago"
spoilername = f"AP_{seed_name}_Spoiler.txt"
romfilename = ""
if player_name:
@ -162,7 +158,7 @@ if __name__ == "__main__":
logging.info(f"Removed {file} which is now present in the zipfile")
zipname = os.path.join(output_path, f"AP_{seedname}.{typical_zip_ending}")
zipname = os.path.join(output_path, f"AP_{seed_name}.{typical_zip_ending}")
logging.info(f"Creating zipfile {zipname}")
ipv4 = (host if host else get_public_ipv4()) + ":" + str(port)
@ -186,7 +182,7 @@ if __name__ == "__main__":
futures = []
with zipfile.ZipFile(zipname, "w", compression=compression, compresslevel=9) as zf:
for file in os.listdir(output_path):
if seedname in file:
if seed_name in file:
if file.endswith(".sfc"):
futures.append(pool.submit(_handle_sfc_file, file))
elif file.endswith(".apbp"):

View File

@ -54,13 +54,15 @@ def mystery_argparse():
help='Output rolled mystery results to yaml up to specified number (made for async multiworld)')
parser.add_argument('--plando', default="bosses",
help='List of options that can be set manually. Can be combined, for example "bosses, items"')
parser.add_argument('--seed_name')
for player in range(1, multiargs.multi + 1):
parser.add_argument(f'--p{player}', help=argparse.SUPPRESS)
args = parser.parse_args()
args.plando: typing.Set[str] = {arg.strip().lower() for arg in args.plando.split(",")}
return args
def get_seed_name(random):
return f"{random.randint(0, pow(10, seeddigits) - 1)}".zfill(seeddigits)
def main(args=None, callback=ERmain):
if not args:
@ -68,9 +70,8 @@ def main(args=None, callback=ERmain):
seed = get_seed(args.seed)
random.seed(seed)
seedname = f"{random.randint(0, pow(10, seeddigits) - 1)}".zfill(seeddigits)
print(f"Generating for {args.multi} player{'s' if args.multi > 1 else ''}, {seedname} Seed {seed}")
seed_name = args.seed_name if args.seed_name else get_seed_name(random)
print(f"Generating for {args.multi} player{'s' if args.multi > 1 else ''}, {seed_name} Seed {seed}")
if args.race:
random.seed() # reset to time-based random source
@ -112,7 +113,7 @@ def main(args=None, callback=ERmain):
erargs.glitch_triforce = args.glitch_triforce
erargs.race = args.race
erargs.skip_playthrough = args.skip_playthrough
erargs.outputname = seedname
erargs.outputname = seed_name
erargs.outputpath = args.outputpath
erargs.teams = args.teams
@ -195,7 +196,7 @@ def main(args=None, callback=ERmain):
pre_rolled = dict()
pre_rolled["original_seed_number"] = seed
pre_rolled["original_seed_name"] = seedname
pre_rolled["original_seed_name"] = seed_name
pre_rolled["pre_rolled"] = vars(settings).copy()
if "plando_items" in pre_rolled["pre_rolled"]:
pre_rolled["pre_rolled"]["plando_items"] = [item.to_dict() for item in

View File

@ -916,7 +916,9 @@ def set_trock_key_rules(world, player):
forbid_item(world.get_location(location, player), 'Big Key (Turtle Rock)', player)
else:
# A key is required in the Big Key Chest to prevent a possible softlock. Place an extra key to ensure 100% locations still works
world.push_item(world.get_location('Turtle Rock - Big Key Chest', player), ItemFactory('Small Key (Turtle Rock)', player), False)
item = ItemFactory('Small Key (Turtle Rock)', player)
item.world = world
world.push_item(world.get_location('Turtle Rock - Big Key Chest', player), item, False)
world.get_location('Turtle Rock - Big Key Chest', player).event = True
toss_junk_item(world, player)