Merge pull request #123 from Catobat/ItemPool

Fix money balancing with reduced item pool
This commit is contained in:
aerinon
2021-09-01 15:57:14 -06:00
committed by GitHub
2 changed files with 13 additions and 10 deletions

View File

@@ -1164,6 +1164,8 @@ class CollectionState(object):
def collect(self, item, event=False, location=None): def collect(self, item, event=False, location=None):
if location: if location:
self.locations_checked.add(location) self.locations_checked.add(location)
if not item:
return
changed = False changed = False
if item.name.startswith('Progressive '): if item.name.startswith('Progressive '):
if 'Sword' in item.name: if 'Sword' in item.name:

21
Fill.py
View File

@@ -644,7 +644,7 @@ def balance_money_progression(world):
base_value = sum(rupee_rooms.values()) base_value = sum(rupee_rooms.values())
available_money = {player: base_value for player in range(1, world.players+1)} available_money = {player: base_value for player in range(1, world.players+1)}
for loc in world.get_locations(): for loc in world.get_locations():
if loc.item.name in rupee_chart: if loc.item and loc.item.name in rupee_chart:
available_money[loc.item.player] += rupee_chart[loc.item.name] available_money[loc.item.player] += rupee_chart[loc.item.name]
total_price = {player: 0 for player in range(1, world.players+1)} total_price = {player: 0 for player in range(1, world.players+1)}
@@ -709,7 +709,7 @@ def balance_money_progression(world):
slot = shop_to_location_table[location.parent_region.name].index(location.name) slot = shop_to_location_table[location.parent_region.name].index(location.name)
shop = location.parent_region.shop shop = location.parent_region.shop
shop_item = shop.inventory[slot] shop_item = shop.inventory[slot]
if interesting_item(location, location.item, world, location.item.player): if location.item and interesting_item(location, location.item, world, location.item.player):
if location.item.name.startswith('Rupee') and loc_player == location.item.player: if location.item.name.startswith('Rupee') and loc_player == location.item.player:
if shop_item['price'] < rupee_chart[location.item.name]: if shop_item['price'] < rupee_chart[location.item.name]:
wallet[loc_player] -= shop_item['price'] # will get picked up in the location_free block wallet[loc_player] -= shop_item['price'] # will get picked up in the location_free block
@@ -729,14 +729,15 @@ def balance_money_progression(world):
if location_free: if location_free:
state.collect(location.item, True, location) state.collect(location.item, True, location)
unchecked_locations.remove(location) unchecked_locations.remove(location)
if location.item.name.startswith('Rupee'): if location.item:
wallet[location.item.player] += rupee_chart[location.item.name] if location.item.name.startswith('Rupee'):
if location.item.name != 'Rupees (300)': wallet[location.item.player] += rupee_chart[location.item.name]
if location.item.name != 'Rupees (300)':
balance_locations[location.item.player].add(location)
if interesting_item(location, location.item, world, location.item.player):
checked_locations.append(location)
elif location.item.name in acceptable_balancers:
balance_locations[location.item.player].add(location) balance_locations[location.item.player].add(location)
if interesting_item(location, location.item, world, location.item.player):
checked_locations.append(location)
elif location.item.name in acceptable_balancers:
balance_locations[location.item.player].add(location)
for room, income in rupee_rooms.items(): for room, income in rupee_rooms.items():
for player in range(1, world.players+1): for player in range(1, world.players+1):
if room not in rooms_visited[player] and world.get_region(room, player) in state.reachable_regions[player]: if room not in rooms_visited[player] and world.get_region(room, player) in state.reachable_regions[player]:
@@ -801,5 +802,5 @@ def balance_money_progression(world):
else: else:
state.collect(location.item, True, location) state.collect(location.item, True, location)
unchecked_locations.remove(location) unchecked_locations.remove(location)
if location.item.name.startswith('Rupee'): if location.item and location.item.name.startswith('Rupee'):
wallet[location.item.player] += rupee_chart[location.item.name] wallet[location.item.player] += rupee_chart[location.item.name]