@@ -168,9 +168,11 @@ class Context:
168
168
slot_info : typing .Dict [int , NetworkSlot ]
169
169
generator_version = Version (0 , 0 , 0 )
170
170
checksums : typing .Dict [str , str ]
171
- item_names : typing .Dict [int , str ] = Utils .KeyedDefaultDict (lambda code : f'Unknown item (ID:{ code } )' )
171
+ item_names : typing .Dict [str , typing .Dict [int , str ]] = (
172
+ collections .defaultdict (lambda : Utils .KeyedDefaultDict (lambda code : f'Unknown item (ID:{ code } )' )))
172
173
item_name_groups : typing .Dict [str , typing .Dict [str , typing .Set [str ]]]
173
- location_names : typing .Dict [int , str ] = Utils .KeyedDefaultDict (lambda code : f'Unknown location (ID:{ code } )' )
174
+ location_names : typing .Dict [str , typing .Dict [int , str ]] = (
175
+ collections .defaultdict (lambda : Utils .KeyedDefaultDict (lambda code : f'Unknown location (ID:{ code } )' )))
174
176
location_name_groups : typing .Dict [str , typing .Dict [str , typing .Set [str ]]]
175
177
all_item_and_group_names : typing .Dict [str , typing .Set [str ]]
176
178
all_location_and_group_names : typing .Dict [str , typing .Set [str ]]
@@ -271,14 +273,21 @@ def _init_game_data(self):
271
273
if "checksum" in game_package :
272
274
self .checksums [game_name ] = game_package ["checksum" ]
273
275
for item_name , item_id in game_package ["item_name_to_id" ].items ():
274
- self .item_names [item_id ] = item_name
276
+ self .item_names [game_name ][ item_id ] = item_name
275
277
for location_name , location_id in game_package ["location_name_to_id" ].items ():
276
- self .location_names [location_id ] = location_name
278
+ self .location_names [game_name ][ location_id ] = location_name
277
279
self .all_item_and_group_names [game_name ] = \
278
280
set (game_package ["item_name_to_id" ]) | set (self .item_name_groups [game_name ])
279
281
self .all_location_and_group_names [game_name ] = \
280
282
set (game_package ["location_name_to_id" ]) | set (self .location_name_groups .get (game_name , []))
281
283
284
+ archipelago_item_names = self .item_names ["Archipelago" ]
285
+ archipelago_location_names = self .location_names ["Archipelago" ]
286
+ for game in [game_name for game_name in self .gamespackage if game_name != "Archipelago" ]:
287
+ # Add Archipelago items and locations to each data package.
288
+ self .item_names [game ].update (archipelago_item_names )
289
+ self .location_names [game ].update (archipelago_location_names )
290
+
282
291
def item_names_for_game (self , game : str ) -> typing .Optional [typing .Dict [str , int ]]:
283
292
return self .gamespackage [game ]["item_name_to_id" ] if game in self .gamespackage else None
284
293
@@ -783,10 +792,7 @@ async def on_client_connected(ctx: Context, client: Client):
783
792
for slot , connected_clients in clients .items ():
784
793
if connected_clients :
785
794
name = ctx .player_names [team , slot ]
786
- players .append (
787
- NetworkPlayer (team , slot ,
788
- ctx .name_aliases .get ((team , slot ), name ), name )
789
- )
795
+ players .append (NetworkPlayer (team , slot , ctx .name_aliases .get ((team , slot ), name ), name ))
790
796
games = {ctx .games [x ] for x in range (1 , len (ctx .games ) + 1 )}
791
797
games .add ("Archipelago" )
792
798
await ctx .send_msgs (client , [{
@@ -801,8 +807,6 @@ async def on_client_connected(ctx: Context, client: Client):
801
807
'permissions' : get_permissions (ctx ),
802
808
'hint_cost' : ctx .hint_cost ,
803
809
'location_check_points' : ctx .location_check_points ,
804
- 'datapackage_versions' : {game : game_data ["version" ] for game , game_data
805
- in ctx .gamespackage .items () if game in games },
806
810
'datapackage_checksums' : {game : game_data ["checksum" ] for game , game_data
807
811
in ctx .gamespackage .items () if game in games and "checksum" in game_data },
808
812
'seed_name' : ctx .seed_name ,
@@ -1006,8 +1010,8 @@ def register_location_checks(ctx: Context, team: int, slot: int, locations: typi
1006
1010
send_items_to (ctx , team , target_player , new_item )
1007
1011
1008
1012
ctx .logger .info ('(Team #%d) %s sent %s to %s (%s)' % (
1009
- team + 1 , ctx .player_names [(team , slot )], ctx .item_names [item_id ],
1010
- ctx .player_names [(team , target_player )], ctx .location_names [location ]))
1013
+ team + 1 , ctx .player_names [(team , slot )], ctx .item_names [ctx . slot_info [ target_player ]. game ][ item_id ],
1014
+ ctx .player_names [(team , target_player )], ctx .location_names [ctx . slot_info [ slot ]. game ][ location ]))
1011
1015
info_text = json_format_send_event (new_item , target_player )
1012
1016
ctx .broadcast_team (team , [info_text ])
1013
1017
@@ -1061,8 +1065,8 @@ def collect_hint_location_id(ctx: Context, team: int, slot: int, seeked_location
1061
1065
1062
1066
def format_hint (ctx : Context , team : int , hint : NetUtils .Hint ) -> str :
1063
1067
text = f"[Hint]: { ctx .player_names [team , hint .receiving_player ]} 's " \
1064
- f"{ ctx .item_names [hint .item ]} is " \
1065
- f"at { ctx .location_names [hint .location ]} " \
1068
+ f"{ ctx .item_names [ctx . slot_info [ hint . receiving_player ]. game ][ hint .item ]} is " \
1069
+ f"at { ctx .location_names [ctx . slot_info [ hint . finding_player ]. game ][ hint .location ]} " \
1066
1070
f"in { ctx .player_names [team , hint .finding_player ]} 's World"
1067
1071
1068
1072
if hint .entrance :
@@ -1364,7 +1368,7 @@ def _cmd_remaining(self) -> bool:
1364
1368
if self .ctx .remaining_mode == "enabled" :
1365
1369
remaining_item_ids = get_remaining (self .ctx , self .client .team , self .client .slot )
1366
1370
if remaining_item_ids :
1367
- self .output ("Remaining items: " + ", " .join (self .ctx .item_names [item_id ]
1371
+ self .output ("Remaining items: " + ", " .join (self .ctx .item_names [self . client . slot . game ][ item_id ]
1368
1372
for item_id in remaining_item_ids ))
1369
1373
else :
1370
1374
self .output ("No remaining items found." )
@@ -1377,7 +1381,7 @@ def _cmd_remaining(self) -> bool:
1377
1381
if self .ctx .client_game_state [self .client .team , self .client .slot ] == ClientStatus .CLIENT_GOAL :
1378
1382
remaining_item_ids = get_remaining (self .ctx , self .client .team , self .client .slot )
1379
1383
if remaining_item_ids :
1380
- self .output ("Remaining items: " + ", " .join (self .ctx .item_names [item_id ]
1384
+ self .output ("Remaining items: " + ", " .join (self .ctx .item_names [self . client . slot . game ][ item_id ]
1381
1385
for item_id in remaining_item_ids ))
1382
1386
else :
1383
1387
self .output ("No remaining items found." )
@@ -1395,7 +1399,8 @@ def _cmd_missing(self, filter_text="") -> bool:
1395
1399
locations = get_missing_checks (self .ctx , self .client .team , self .client .slot )
1396
1400
1397
1401
if locations :
1398
- names = [self .ctx .location_names [location ] for location in locations ]
1402
+ game = self .ctx .slot_info [self .client .slot ].game
1403
+ names = [self .ctx .location_names [game ][location ] for location in locations ]
1399
1404
if filter_text :
1400
1405
location_groups = self .ctx .location_name_groups [self .ctx .games [self .client .slot ]]
1401
1406
if filter_text in location_groups : # location group name
@@ -1420,7 +1425,8 @@ def _cmd_checked(self, filter_text="") -> bool:
1420
1425
locations = get_checked_checks (self .ctx , self .client .team , self .client .slot )
1421
1426
1422
1427
if locations :
1423
- names = [self .ctx .location_names [location ] for location in locations ]
1428
+ game = self .ctx .slot_info [self .client .slot ].game
1429
+ names = [self .ctx .location_names [game ][location ] for location in locations ]
1424
1430
if filter_text :
1425
1431
location_groups = self .ctx .location_name_groups [self .ctx .games [self .client .slot ]]
1426
1432
if filter_text in location_groups : # location group name
@@ -1501,10 +1507,10 @@ def get_hints(self, input_text: str, for_location: bool = False) -> bool:
1501
1507
elif input_text .isnumeric ():
1502
1508
game = self .ctx .games [self .client .slot ]
1503
1509
hint_id = int (input_text )
1504
- hint_name = self .ctx .item_names [hint_id ] \
1505
- if not for_location and hint_id in self .ctx .item_names \
1506
- else self .ctx .location_names [hint_id ] \
1507
- if for_location and hint_id in self .ctx .location_names \
1510
+ hint_name = self .ctx .item_names [game ][ hint_id ] \
1511
+ if not for_location and hint_id in self .ctx .item_names [ game ] \
1512
+ else self .ctx .location_names [game ][ hint_id ] \
1513
+ if for_location and hint_id in self .ctx .location_names [ game ] \
1508
1514
else None
1509
1515
if hint_name in self .ctx .non_hintable_names [game ]:
1510
1516
self .output (f"Sorry, \" { hint_name } \" is marked as non-hintable." )
0 commit comments