@@ -128,10 +128,11 @@ def get_items_for_player(multiworld: MultiWorld, player: int, includePrecollecte
128128 items .extend (multiworld .precollected_items .get (player , []))
129129 return items
130130
131- def get_items_with_value (world : World , multiworld : MultiWorld , value : str , player : Optional [int ] = None , force : bool = False ) -> dict [str , int ]:
131+ def get_items_with_value (world : World , multiworld : MultiWorld , value : str , player : Optional [int ] = None , skipCache : bool = False ) -> dict [str , int ]:
132132 """Return a dict of every items with a specific value type present in their respective 'value' dict\n
133133 Output in the format 'Item Name': 'value count'\n
134- Keep a cache of the result and wont redo unless 'force == True'
134+ Keep a cache of the result, it can be skipped with 'skipCache == True'\n
135+ To force a Reset of the player's cache of a value do world.item_values[player].pop(value) and then run get_items_with_value(..., value)
135136 """
136137 if player is None :
137138 player = world .player
@@ -143,15 +144,18 @@ def get_items_with_value(world: World, multiworld: MultiWorld, value: str, playe
143144
144145 value = value .lower ().strip ()
145146
146- if not hasattr (world , 'item_values' ): #Cache of just the item values
147- world .item_values = {}
147+ if not skipCache :
148+ if not hasattr (world , 'item_values' ): #Cache of just the item values
149+ world .item_values = {}
148150
149- if not world .item_values .get (player ):
150- world .item_values [player ] = {}
151+ if not world .item_values .get (player ):
152+ world .item_values [player ] = {}
151153
152- if value not in world .item_values .get (player , {}).keys () or force :
154+ if value not in world .item_values .get (player , {}).keys () or skipCache :
153155 item_with_values = {i .name : world .item_name_to_item [i .name ]['value' ].get (value , 0 )
154156 for i in player_items if i .code is not None
155157 and i .name in world .item_name_groups .get (f'has_{ value } _value' , [])}
158+ if skipCache :
159+ return item_with_values
156160 world .item_values [player ][value ] = item_with_values
157161 return world .item_values [player ].get (value )
0 commit comments