From c66f3f4bc3d88a3cef9f8ea366dd8eed2ff64176 Mon Sep 17 00:00:00 2001 From: Ixrec Date: Mon, 5 Feb 2024 02:11:29 +0000 Subject: [PATCH] generate coordinates earlier so we can write them to the spoiler log --- worlds/outer_wilds/__init__.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/worlds/outer_wilds/__init__.py b/worlds/outer_wilds/__init__.py index 2670ec8e6181..e95c8a31916f 100644 --- a/worlds/outer_wilds/__init__.py +++ b/worlds/outer_wilds/__init__.py @@ -1,4 +1,5 @@ -from typing import List +import json +from typing import List, TextIO from BaseClasses import Tutorial from worlds.AutoWorld import WebWorld, World @@ -33,6 +34,12 @@ class OuterWildsWorld(World): # but the server is allowed to be a little older required_server_version = (0, 4, 3) + eotu_coordinates = 'vanilla' + + def generate_early(self) -> None: + self.eotu_coordinates = generate_random_coordinates(self.random) \ + if self.options.randomize_coordinates else "vanilla" + # members and methods implemented by Items.py and items.jsonc item_name_to_id = all_non_event_items_table @@ -87,9 +94,17 @@ def set_rules(self) -> None: def fill_slot_data(self): slot_data = self.options.as_dict("goal", "death_link", "logsanity") - slot_data["eotu_coordinates"] = generate_random_coordinates(self.random) \ - if self.options.randomize_coordinates else "vanilla" + slot_data["eotu_coordinates"] = self.eotu_coordinates # Archipelago does not yet have apworld versions (data_version is deprecated), # so we have to roll our own with slot_data for the time being slot_data["apworld_version"] = "0.2.0-dev" return slot_data + + def write_spoiler(self, spoiler_handle: TextIO) -> None: + if self.eotu_coordinates != 'vanilla': + spoiler_handle.write('\n\nRandomized Eye of the Universe Coordinates:' + '\n(0-5 are the points of the hexagon, starting at ' + 'the rightmost point and going counterclockwise)' + '\n\n%s\n%s\n%s\n\n' % (json.dumps(self.eotu_coordinates[0]), + json.dumps(self.eotu_coordinates[1]), + json.dumps(self.eotu_coordinates[2])))