@@ -128,10 +128,21 @@ 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  reset_specific_item_value_cache_for_player (world : World , value : str , player : Optional [int ] =  None ) ->  dict [str , int ]:
132+     if  player  is  None :
133+         player  =  world .player 
134+     return  world .item_values [player ].pop (value , {})
135+ 
136+ def  reset_item_value_cache_for_player (world : World , player : Optional [int ] =  None ):
137+     if  player  is  None :
138+         player  =  world .player 
139+     world .item_values [player ] =  {}
140+ 
141+ def  get_items_with_value (world : World , multiworld : MultiWorld , value : str , player : Optional [int ] =  None , skipCache : bool  =  False ) ->  dict [str , int ]:
132142    """Return a dict of every items with a specific value type present in their respective 'value' dict\n  
133143    Output in the format 'Item Name': 'value count'\n  
134-     Keep a cache of the result and wont redo unless 'force == True' 
144+     Keep a cache of the result, it can be skipped with 'skipCache == True'\n  
145+     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) 
135146    """ 
136147    if  player  is  None :
137148        player  =  world .player 
@@ -143,15 +154,18 @@ def get_items_with_value(world: World, multiworld: MultiWorld, value: str, playe
143154
144155    value  =  value .lower ().strip ()
145156
146-     if  not  hasattr (world , 'item_values' ): #Cache of just the item values 
147-         world .item_values  =  {}
157+     if  not  skipCache :
158+         if  not  hasattr (world , 'item_values' ): #Cache of just the item values 
159+             world .item_values  =  {}
148160
149-     if  not  world .item_values .get (player ):
150-         world .item_values [player ] =  {}
161+          if  not  world .item_values .get (player ):
162+              world .item_values [player ] =  {}
151163
152-     if  value  not  in world .item_values .get (player , {}).keys () or  force :
164+     if  value  not  in world .item_values .get (player , {}).keys () or  skipCache :
153165        item_with_values  =  {i .name : world .item_name_to_item [i .name ]['value' ].get (value , 0 )
154166                            for  i  in  player_items  if  i .code  is  not None 
155167                            and  i .name  in  world .item_name_groups .get (f'has_{ value }  , [])}
168+         if  skipCache :
169+             return  item_with_values 
156170        world .item_values [player ][value ] =  item_with_values 
157171    return  world .item_values [player ].get (value )
0 commit comments