Witness: Fix 2 generation crashes (#2043)

* Fix for error in get_early_items when removing plandoed items.

* Fix Early Caves

* Remove unnecessary list() call

* Update worlds/witness/items.py

Co-authored-by: Fabian Dill <Berserker66@users.noreply.github.com>

---------

Co-authored-by: blastron <blastron@mac.com>
Co-authored-by: Fabian Dill <Berserker66@users.noreply.github.com>
This commit is contained in:
NewSoupVi 2023-07-28 09:39:56 +02:00 committed by GitHub
parent a99a407c41
commit cf37a69e53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 14 deletions

View File

@ -128,6 +128,7 @@ class WitnessWorld(World):
item_pool.pop(inventory_item_name)
else:
item_pool[inventory_item_name] -= 1
self.multiworld.push_precollected(self.create_item(inventory_item_name))
if len(item_pool) > pool_size:
error_string = "The Witness world has too few locations ({num_loc}) to place its necessary items " \

View File

@ -3,7 +3,7 @@ Defines progression, junk and event items for The Witness
"""
import copy
from dataclasses import dataclass
from typing import Optional, Dict, List
from typing import Optional, Dict, List, Set
from BaseClasses import Item, MultiWorld, ItemClassification
from .Options import get_option_value, is_option_enabled, the_witness_options
@ -197,36 +197,36 @@ class WitnessPlayerItems:
"""
Returns items that are ideal for placing on extremely early checks, like the tutorial gate.
"""
output: List[str] = []
output: Set[str] = set()
if "shuffle_symbols" not in the_witness_options.keys() \
or is_option_enabled(self._world, self._player_id, "shuffle_symbols"):
if get_option_value(self._world, self._player_id, "shuffle_doors") > 0:
output = ["Dots", "Black/White Squares", "Symmetry"]
output = {"Dots", "Black/White Squares", "Symmetry"}
else:
output = ["Dots", "Black/White Squares", "Symmetry", "Shapers", "Stars"]
output = {"Dots", "Black/White Squares", "Symmetry", "Shapers", "Stars"}
if is_option_enabled(self._world, self._player_id, "shuffle_discarded_panels"):
if get_option_value(self._world, self._player_id, "puzzle_randomization") == 1:
output.append("Arrows")
output.add("Arrows")
else:
output.append("Triangles")
output.add("Triangles")
# Replace progressive items with their parents.
output = [StaticWitnessLogic.get_parent_progressive_item(item) for item in output]
output = {StaticWitnessLogic.get_parent_progressive_item(item) for item in output}
# Remove items that are mentioned in any plando options. (Hopefully, in the future, plando will get resolved
# before create_items so that we'll be able to check placed items instead of just removing all items mentioned
# regardless of whether or not they actually wind up being manually placed.
for plando_setting in self._world.plando_items[self._player_id]:
if plando_setting.get("from_pool", True):
if "item" in plando_setting and type(plando_setting["item"]) is str:
output.remove(plando_setting["item"])
elif "items" in plando_setting:
if type(plando_setting["items"]) is dict:
output -= [item for item, weight in plando_setting["items"].items() if weight]
for item_setting_key in (key for key in ["item", "items"] if key in plando_setting):
if type(plando_setting[item_setting_key]) is str:
output.remove(plando_setting[item_setting_key])
elif type(plando_setting[item_setting_key]) is dict:
output -= {item for item, weight in plando_setting[item_setting_key].items() if weight}
else:
# Assume this is some other kind of iterable.
output -= plando_setting["items"]
output -= plando_setting[item_setting_key]
# Sort the output for consistency across versions if the implementation changes but the logic does not.
return sorted(output)

View File

@ -157,7 +157,7 @@ class WitnessPlayerLogic:
if StaticWitnessLogic.all_items[item_name].category in [ItemCategory.DOOR, ItemCategory.LASER]:
panel_hexes = cast(DoorItemDefinition, StaticWitnessLogic.all_items[item_name]).panel_id_hexes
for panel_hex in panel_hexes:
if panel_hex in self.DOOR_ITEMS_BY_ID:
if panel_hex in self.DOOR_ITEMS_BY_ID and item_name in self.DOOR_ITEMS_BY_ID[panel_hex]:
self.DOOR_ITEMS_BY_ID[panel_hex].remove(item_name)
if adj_type == "Starting Inventory":