Core: fix missing import for `MultiWorld.link_items()` (#3731)
This commit is contained in:
parent
4620493828
commit
c0ef02d6fa
|
@ -290,6 +290,8 @@ class MultiWorld():
|
||||||
|
|
||||||
def link_items(self) -> None:
|
def link_items(self) -> None:
|
||||||
"""Called to link together items in the itempool related to the registered item link groups."""
|
"""Called to link together items in the itempool related to the registered item link groups."""
|
||||||
|
from worlds import AutoWorld
|
||||||
|
|
||||||
for group_id, group in self.groups.items():
|
for group_id, group in self.groups.items():
|
||||||
def find_common_pool(players: Set[int], shared_pool: Set[str]) -> Tuple[
|
def find_common_pool(players: Set[int], shared_pool: Set[str]) -> Tuple[
|
||||||
Optional[Dict[int, Dict[str, int]]], Optional[Dict[str, int]]
|
Optional[Dict[int, Dict[str, int]]], Optional[Dict[str, int]]
|
||||||
|
@ -300,15 +302,15 @@ class MultiWorld():
|
||||||
if item.player in counters and item.name in shared_pool:
|
if item.player in counters and item.name in shared_pool:
|
||||||
counters[item.player][item.name] += 1
|
counters[item.player][item.name] += 1
|
||||||
classifications[item.name] |= item.classification
|
classifications[item.name] |= item.classification
|
||||||
|
|
||||||
for player in players.copy():
|
for player in players.copy():
|
||||||
if all([counters[player][item] == 0 for item in shared_pool]):
|
if all([counters[player][item] == 0 for item in shared_pool]):
|
||||||
players.remove(player)
|
players.remove(player)
|
||||||
del (counters[player])
|
del (counters[player])
|
||||||
|
|
||||||
if not players:
|
if not players:
|
||||||
return None, None
|
return None, None
|
||||||
|
|
||||||
for item in shared_pool:
|
for item in shared_pool:
|
||||||
count = min(counters[player][item] for player in players)
|
count = min(counters[player][item] for player in players)
|
||||||
if count:
|
if count:
|
||||||
|
@ -318,11 +320,11 @@ class MultiWorld():
|
||||||
for player in players:
|
for player in players:
|
||||||
del (counters[player][item])
|
del (counters[player][item])
|
||||||
return counters, classifications
|
return counters, classifications
|
||||||
|
|
||||||
common_item_count, classifications = find_common_pool(group["players"], group["item_pool"])
|
common_item_count, classifications = find_common_pool(group["players"], group["item_pool"])
|
||||||
if not common_item_count:
|
if not common_item_count:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
new_itempool: List[Item] = []
|
new_itempool: List[Item] = []
|
||||||
for item_name, item_count in next(iter(common_item_count.values())).items():
|
for item_name, item_count in next(iter(common_item_count.values())).items():
|
||||||
for _ in range(item_count):
|
for _ in range(item_count):
|
||||||
|
@ -330,7 +332,7 @@ class MultiWorld():
|
||||||
# mangle together all original classification bits
|
# mangle together all original classification bits
|
||||||
new_item.classification |= classifications[item_name]
|
new_item.classification |= classifications[item_name]
|
||||||
new_itempool.append(new_item)
|
new_itempool.append(new_item)
|
||||||
|
|
||||||
region = Region("Menu", group_id, self, "ItemLink")
|
region = Region("Menu", group_id, self, "ItemLink")
|
||||||
self.regions.append(region)
|
self.regions.append(region)
|
||||||
locations = region.locations
|
locations = region.locations
|
||||||
|
@ -341,16 +343,16 @@ class MultiWorld():
|
||||||
None, region)
|
None, region)
|
||||||
loc.access_rule = lambda state, item_name = item.name, group_id_ = group_id, count_ = count: \
|
loc.access_rule = lambda state, item_name = item.name, group_id_ = group_id, count_ = count: \
|
||||||
state.has(item_name, group_id_, count_)
|
state.has(item_name, group_id_, count_)
|
||||||
|
|
||||||
locations.append(loc)
|
locations.append(loc)
|
||||||
loc.place_locked_item(item)
|
loc.place_locked_item(item)
|
||||||
common_item_count[item.player][item.name] -= 1
|
common_item_count[item.player][item.name] -= 1
|
||||||
else:
|
else:
|
||||||
new_itempool.append(item)
|
new_itempool.append(item)
|
||||||
|
|
||||||
itemcount = len(self.itempool)
|
itemcount = len(self.itempool)
|
||||||
self.itempool = new_itempool
|
self.itempool = new_itempool
|
||||||
|
|
||||||
while itemcount > len(self.itempool):
|
while itemcount > len(self.itempool):
|
||||||
items_to_add = []
|
items_to_add = []
|
||||||
for player in group["players"]:
|
for player in group["players"]:
|
||||||
|
|
Loading…
Reference in New Issue