@@ -290,6 +290,8 @@ def set_item_links(self):
290
290
291
291
def link_items (self ) -> None :
292
292
"""Called to link together items in the itempool related to the registered item link groups."""
293
+ from worlds import AutoWorld
294
+
293
295
for group_id , group in self .groups .items ():
294
296
def find_common_pool (players : Set [int ], shared_pool : Set [str ]) -> Tuple [
295
297
Optional [Dict [int , Dict [str , int ]]], Optional [Dict [str , int ]]
@@ -300,15 +302,15 @@ def find_common_pool(players: Set[int], shared_pool: Set[str]) -> Tuple[
300
302
if item .player in counters and item .name in shared_pool :
301
303
counters [item .player ][item .name ] += 1
302
304
classifications [item .name ] |= item .classification
303
-
305
+
304
306
for player in players .copy ():
305
307
if all ([counters [player ][item ] == 0 for item in shared_pool ]):
306
308
players .remove (player )
307
309
del (counters [player ])
308
-
310
+
309
311
if not players :
310
312
return None , None
311
-
313
+
312
314
for item in shared_pool :
313
315
count = min (counters [player ][item ] for player in players )
314
316
if count :
@@ -318,19 +320,19 @@ def find_common_pool(players: Set[int], shared_pool: Set[str]) -> Tuple[
318
320
for player in players :
319
321
del (counters [player ][item ])
320
322
return counters , classifications
321
-
323
+
322
324
common_item_count , classifications = find_common_pool (group ["players" ], group ["item_pool" ])
323
325
if not common_item_count :
324
326
continue
325
-
327
+
326
328
new_itempool : List [Item ] = []
327
329
for item_name , item_count in next (iter (common_item_count .values ())).items ():
328
330
for _ in range (item_count ):
329
331
new_item = group ["world" ].create_item (item_name )
330
332
# mangle together all original classification bits
331
333
new_item .classification |= classifications [item_name ]
332
334
new_itempool .append (new_item )
333
-
335
+
334
336
region = Region ("Menu" , group_id , self , "ItemLink" )
335
337
self .regions .append (region )
336
338
locations = region .locations
@@ -341,16 +343,16 @@ def find_common_pool(players: Set[int], shared_pool: Set[str]) -> Tuple[
341
343
None , region )
342
344
loc .access_rule = lambda state , item_name = item .name , group_id_ = group_id , count_ = count : \
343
345
state .has (item_name , group_id_ , count_ )
344
-
346
+
345
347
locations .append (loc )
346
348
loc .place_locked_item (item )
347
349
common_item_count [item .player ][item .name ] -= 1
348
350
else :
349
351
new_itempool .append (item )
350
-
352
+
351
353
itemcount = len (self .itempool )
352
354
self .itempool = new_itempool
353
-
355
+
354
356
while itemcount > len (self .itempool ):
355
357
items_to_add = []
356
358
for player in group ["players" ]:
0 commit comments