Core: assert that items have a single reference (#1075)

* Core: assert that items have a single reference

* Fix duplicate item reference in The Witness

* Ori: fix duplicate item references

* DKC3: fix duplicate item references

* RL: fix duplicate item references

* SA2B: fix duplicate item references

* SMW: fix duplicate item references

Co-authored-by: NewSoupVi <57900059+NewSoupVi@users.noreply.github.com>
This commit is contained in:
black-sliver
2022-10-20 10:42:33 +02:00
committed by GitHub
parent 40b7e78178
commit ed76c13961
7 changed files with 38 additions and 37 deletions

View File

@@ -79,8 +79,16 @@ def call_single(world: "MultiWorld", method_name: str, player: int, *args: Any)
def call_all(world: "MultiWorld", method_name: str, *args: Any) -> None:
world_types: Set[AutoWorldRegister] = set()
for player in world.player_ids:
prev_item_count = len(world.itempool)
world_types.add(world.worlds[player].__class__)
call_single(world, method_name, player, *args)
if __debug__:
new_items = world.itempool[prev_item_count:]
for i, item in enumerate(new_items):
for other in new_items[i+1:]:
assert item is not other, (
f"Duplicate item reference of \"{item.name}\" in \"{world.worlds[player].game}\" "
f"of player \"{world.player_name[player]}\". Please make a copy instead.")
for world_type in world_types:
stage_callable = getattr(world_type, f"stage_{method_name}", None)