The Witness: Make location order in the spoiler log deterministic (#3895)
* Fix location order * Update worlds/witness/data/static_logic.py Co-authored-by: Exempt-Medic <60412657+Exempt-Medic@users.noreply.github.com> --------- Co-authored-by: Exempt-Medic <60412657+Exempt-Medic@users.noreply.github.com>
This commit is contained in:
parent
0de1369ec5
commit
8dbecf3d57
|
@ -106,6 +106,7 @@ class StaticWitnessLogicObj:
|
||||||
"entityType": location_id,
|
"entityType": location_id,
|
||||||
"locationType": None,
|
"locationType": None,
|
||||||
"area": current_area,
|
"area": current_area,
|
||||||
|
"order": len(self.ENTITIES_BY_HEX),
|
||||||
}
|
}
|
||||||
|
|
||||||
self.ENTITIES_BY_NAME[self.ENTITIES_BY_HEX[entity_hex]["checkName"]] = self.ENTITIES_BY_HEX[entity_hex]
|
self.ENTITIES_BY_NAME[self.ENTITIES_BY_HEX[entity_hex]["checkName"]] = self.ENTITIES_BY_HEX[entity_hex]
|
||||||
|
@ -186,6 +187,7 @@ class StaticWitnessLogicObj:
|
||||||
"entityType": entity_type,
|
"entityType": entity_type,
|
||||||
"locationType": location_type,
|
"locationType": location_type,
|
||||||
"area": current_area,
|
"area": current_area,
|
||||||
|
"order": len(self.ENTITIES_BY_HEX),
|
||||||
}
|
}
|
||||||
|
|
||||||
self.ENTITY_ID_TO_NAME[entity_hex] = full_entity_name
|
self.ENTITY_ID_TO_NAME[entity_hex] = full_entity_name
|
||||||
|
|
|
@ -114,7 +114,7 @@ class WitnessPlayerRegions:
|
||||||
if k not in player_logic.UNREACHABLE_REGIONS
|
if k not in player_logic.UNREACHABLE_REGIONS
|
||||||
}
|
}
|
||||||
|
|
||||||
event_locations_per_region = defaultdict(list)
|
event_locations_per_region = defaultdict(dict)
|
||||||
|
|
||||||
for event_location, event_item_and_entity in player_logic.EVENT_ITEM_PAIRS.items():
|
for event_location, event_item_and_entity in player_logic.EVENT_ITEM_PAIRS.items():
|
||||||
region = static_witness_logic.ENTITIES_BY_HEX[event_item_and_entity[1]]["region"]
|
region = static_witness_logic.ENTITIES_BY_HEX[event_item_and_entity[1]]["region"]
|
||||||
|
@ -122,20 +122,33 @@ class WitnessPlayerRegions:
|
||||||
region_name = "Entry"
|
region_name = "Entry"
|
||||||
else:
|
else:
|
||||||
region_name = region["name"]
|
region_name = region["name"]
|
||||||
event_locations_per_region[region_name].append(event_location)
|
order = self.reference_logic.ENTITIES_BY_HEX[event_item_and_entity[1]]["order"]
|
||||||
|
event_locations_per_region[region_name][event_location] = order
|
||||||
|
|
||||||
for region_name, region in regions_to_create.items():
|
for region_name, region in regions_to_create.items():
|
||||||
locations_for_this_region = [
|
location_entities_for_this_region = [
|
||||||
self.reference_logic.ENTITIES_BY_HEX[panel]["checkName"] for panel in region["entities"]
|
self.reference_logic.ENTITIES_BY_HEX[entity] for entity in region["entities"]
|
||||||
if self.reference_logic.ENTITIES_BY_HEX[panel]["checkName"]
|
|
||||||
in self.player_locations.CHECK_LOCATION_TABLE
|
|
||||||
]
|
]
|
||||||
|
locations_for_this_region = {
|
||||||
|
entity["checkName"]: entity["order"] for entity in location_entities_for_this_region
|
||||||
|
if entity["checkName"] in self.player_locations.CHECK_LOCATION_TABLE
|
||||||
|
}
|
||||||
|
|
||||||
locations_for_this_region += event_locations_per_region[region_name]
|
events = event_locations_per_region[region_name]
|
||||||
|
locations_for_this_region.update(events)
|
||||||
|
|
||||||
|
# First, sort by keys.
|
||||||
|
locations_for_this_region = dict(sorted(locations_for_this_region.items()))
|
||||||
|
|
||||||
|
# Then, sort by game order (values)
|
||||||
|
locations_for_this_region = dict(sorted(
|
||||||
|
locations_for_this_region.items(),
|
||||||
|
key=lambda location_name_and_order: location_name_and_order[1]
|
||||||
|
))
|
||||||
|
|
||||||
all_locations = all_locations | set(locations_for_this_region)
|
all_locations = all_locations | set(locations_for_this_region)
|
||||||
|
|
||||||
new_region = create_region(world, region_name, self.player_locations, locations_for_this_region)
|
new_region = create_region(world, region_name, self.player_locations, list(locations_for_this_region))
|
||||||
|
|
||||||
regions_by_name[region_name] = new_region
|
regions_by_name[region_name] = new_region
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue