Fixed the shop spoiler when money balancing is needed

This commit is contained in:
aerinon
2021-07-01 16:48:39 -06:00
parent 1a7c3faa76
commit 1fb849c137
2 changed files with 16 additions and 2 deletions

17
Fill.py
View File

@@ -3,7 +3,7 @@ import logging
from BaseClasses import CollectionState from BaseClasses import CollectionState
from Items import ItemFactory from Items import ItemFactory
from Regions import shop_to_location_table from Regions import shop_to_location_table, retro_shops
class FillError(RuntimeError): class FillError(RuntimeError):
@@ -557,7 +557,6 @@ def balance_money_progression(world):
for player in range(1, world.players+1): for player in range(1, world.players+1):
logger.debug(f'Money balance for P{player}: Needed: {total_price[player]} Available: {available_money[player]}') logger.debug(f'Money balance for P{player}: Needed: {total_price[player]} Available: {available_money[player]}')
def get_sphere_locations(sphere_state, locations): def get_sphere_locations(sphere_state, locations):
sphere_state.sweep_for_events(key_only=True, locations=locations) sphere_state.sweep_for_events(key_only=True, locations=locations)
return [loc for loc in locations if sphere_state.can_reach(loc) and sphere_state.not_flooding_a_key(sphere_state.world, loc)] return [loc for loc in locations if sphere_state.can_reach(loc) and sphere_state.not_flooding_a_key(sphere_state.world, loc)]
@@ -584,6 +583,17 @@ def balance_money_progression(world):
path = path[1] path = path[1]
return False return False
def check_shop_swap(l):
if l.parent_region.name in shop_to_location_table:
if l.name in shop_to_location_table[l.parent_region.name]:
idx = shop_to_location_table[l.parent_region.name].index(l.name)
inv_slot = l.parent_region.shop.inventory[idx]
inv_slot['item'] = l.item.name
elif location.parent_region in retro_shops:
idx = retro_shops[l.parent_region.name].index(l.name)
inv_slot = l.parent_region.shop.inventory[idx]
inv_slot['item'] = l.item.name
done = False done = False
while not done: while not done:
sphere_costs = {player: 0 for player in range(1, world.players+1)} sphere_costs = {player: 0 for player in range(1, world.players+1)}
@@ -672,6 +682,7 @@ def balance_money_progression(world):
logger.debug(f'Upgrading {best_target.item.name} @ {best_target.name} for 300 Rupees') logger.debug(f'Upgrading {best_target.item.name} @ {best_target.name} for 300 Rupees')
best_target.item = ItemFactory('Rupees (300)', best_target.item.player) best_target.item = ItemFactory('Rupees (300)', best_target.item.player)
best_target.item.location = best_target best_target.item.location = best_target
check_shop_swap(best_target.item.location)
else: else:
old_item = best_target.item old_item = best_target.item
logger.debug(f'Swapping {best_target.item.name} @ {best_target.name} for {best_swap.item.name} @ {best_swap.name}') logger.debug(f'Swapping {best_target.item.name} @ {best_target.name} for {best_swap.item.name} @ {best_swap.name}')
@@ -679,6 +690,8 @@ def balance_money_progression(world):
best_target.item.location = best_target best_target.item.location = best_target
best_swap.item = old_item best_swap.item = old_item
best_swap.item.location = best_swap best_swap.item.location = best_swap
check_shop_swap(best_target.item.location)
check_shop_swap(best_swap.item.location)
increase = best_value - old_value increase = best_value - old_value
difference -= increase difference -= increase
wallet[target_player] += increase wallet[target_player] += increase

View File

@@ -19,6 +19,7 @@ Thanks to qadan, cheuer, & compiling
* Some text updated (Blind jokes, uncle text) * Some text updated (Blind jokes, uncle text)
* Fixed some enemizer Mystery settings * Fixed some enemizer Mystery settings
* Added a setting that's random enemy shuffle without Unkillable Thieves possible * Added a setting that's random enemy shuffle without Unkillable Thieves possible
* Fixed shop spoiler when money balancing
* 0.4.0.7 * 0.4.0.7
* Reduce flashing option added * Reduce flashing option added
* Sprite author credit added * Sprite author credit added