3
3
"""
4
4
import dataclasses
5
5
6
- from typing import Dict , Optional
6
+ from typing import Dict , Optional , cast
7
7
from BaseClasses import Region , Location , MultiWorld , Item , Entrance , Tutorial , CollectionState
8
8
from Options import PerGameCommonOptions , Toggle
9
9
from .presets import witness_option_presets
10
10
from worlds .AutoWorld import World , WebWorld
11
11
from .player_logic import WitnessPlayerLogic
12
- from .static_logic import StaticWitnessLogic
12
+ from .static_logic import StaticWitnessLogic , ItemCategory , DoorItemDefinition
13
13
from .hints import get_always_hint_locations , get_always_hint_items , get_priority_hint_locations , \
14
14
get_priority_hint_items , make_always_and_priority_hints , generate_joke_hints , make_area_hints , get_hintable_areas , \
15
- make_extra_location_hints , create_all_hints
15
+ make_extra_location_hints , create_all_hints , make_laser_hints , make_compact_hint_data , CompactItemData
16
16
from .locations import WitnessPlayerLocations , StaticWitnessLocations
17
17
from .items import WitnessItem , StaticWitnessItems , WitnessPlayerItems , ItemData
18
18
from .regions import WitnessRegions
19
19
from .rules import set_rules
20
20
from .options import TheWitnessOptions
21
- from .utils import get_audio_logs
21
+ from .utils import get_audio_logs , get_laser_shuffle
22
22
from logging import warning , error
23
23
24
24
@@ -66,7 +66,8 @@ def __init__(self, multiworld: "MultiWorld", player: int):
66
66
self .items = None
67
67
self .regio = None
68
68
69
- self .log_ids_to_hints = None
69
+ self .log_ids_to_hints : Dict [int , CompactItemData ] = dict ()
70
+ self .laser_ids_to_hints : Dict [int , CompactItemData ] = dict ()
70
71
71
72
self .items_placed_early = []
72
73
self .own_itempool = []
@@ -81,6 +82,7 @@ def _get_slot_data(self):
81
82
'symbols_not_in_the_game' : self .items .get_symbol_ids_not_in_pool (),
82
83
'disabled_entities' : [int (h , 16 ) for h in self .player_logic .COMPLETELY_DISABLED_ENTITIES ],
83
84
'log_ids_to_hints' : self .log_ids_to_hints ,
85
+ 'laser_ids_to_hints' : self .laser_ids_to_hints ,
84
86
'progressive_item_lists' : self .items .get_progressive_item_ids_in_pool (),
85
87
'obelisk_side_id_to_EPs' : StaticWitnessLogic .OBELISK_SIDE_ID_TO_EP_HEXES ,
86
88
'precompleted_puzzles' : [int (h , 16 ) for h in self .player_logic .EXCLUDED_LOCATIONS ],
@@ -100,8 +102,6 @@ def generate_early(self):
100
102
)
101
103
self .regio : WitnessRegions = WitnessRegions (self .locat , self )
102
104
103
- self .log_ids_to_hints = dict ()
104
-
105
105
interacts_with_multiworld = (
106
106
self .options .shuffle_symbols or
107
107
self .options .shuffle_doors or
@@ -272,11 +272,25 @@ def create_items(self):
272
272
self .options .local_items .value .add (item_name )
273
273
274
274
def fill_slot_data (self ) -> dict :
275
+ already_hinted_locations = set ()
276
+
277
+ # Laser hints
278
+
279
+ if self .options .laser_hints :
280
+ laser_hints = make_laser_hints (self , StaticWitnessItems .item_groups ["Lasers" ])
281
+
282
+ for item_name , hint in laser_hints .items ():
283
+ item_def = cast (DoorItemDefinition , StaticWitnessLogic .all_items [item_name ])
284
+ self .laser_ids_to_hints [int (item_def .panel_id_hexes [0 ], 16 )] = make_compact_hint_data (hint , self .player )
285
+ already_hinted_locations .add (hint .location )
286
+
287
+ # Audio Log Hints
288
+
275
289
hint_amount = self .options .hint_amount .value
276
290
277
291
credits_hint = (
278
292
"This Randomizer is brought to you by\n "
279
- "NewSoupVi, Jarno, blastron,\n " ,
293
+ "NewSoupVi, Jarno, blastron,\n "
280
294
"jbzdarkid, sigma144, IHNN, oddGarrett, Exempt-Medic." , - 1 , - 1
281
295
)
282
296
@@ -285,25 +299,19 @@ def fill_slot_data(self) -> dict:
285
299
if hint_amount :
286
300
area_hints = round (self .options .area_hint_percentage / 100 * hint_amount )
287
301
288
- generated_hints = create_all_hints (self , hint_amount , area_hints )
302
+ generated_hints = create_all_hints (self , hint_amount , area_hints , already_hinted_locations )
289
303
290
304
self .random .shuffle (audio_logs )
291
305
292
306
duplicates = min (3 , len (audio_logs ) // hint_amount )
293
307
294
308
for hint in generated_hints :
295
- location = hint .location
296
- area_amount = hint .area_amount
297
-
298
- # None if junk hint, address if location hint, area string if area hint
299
- arg_1 = location .address if location else (hint .area if hint .area else None )
300
-
301
- # self.player if junk hint, player if location hint, progression amount if area hint
302
- arg_2 = area_amount if area_amount is not None else (location .player if location else self .player )
309
+ hint = generated_hints .pop (0 )
310
+ compact_hint_data = make_compact_hint_data (hint , self .player )
303
311
304
312
for _ in range (0 , duplicates ):
305
313
audio_log = audio_logs .pop ()
306
- self .log_ids_to_hints [int (audio_log , 16 )] = ( hint . wording , arg_1 , arg_2 )
314
+ self .log_ids_to_hints [int (audio_log , 16 )] = compact_hint_data
307
315
308
316
if audio_logs :
309
317
audio_log = audio_logs .pop ()
@@ -315,7 +323,7 @@ def fill_slot_data(self) -> dict:
315
323
audio_log = audio_logs .pop ()
316
324
self .log_ids_to_hints [int (audio_log , 16 )] = joke_hints .pop ()
317
325
318
- # generate hints done
326
+ # Options for the client & auto-tracker
319
327
320
328
slot_data = self ._get_slot_data ()
321
329
0 commit comments