Fix NoneType object error when BK in starting inventory

ZenArcane has a mode that starts you with all the big keys, maps, compasses, and enough universal small keys to open all doors. The item pool is updated to remove them, but generation fails due to NoneType item variables.

This changes how current_amount is determined to prevent a NoneType variable access and allows for generation to continue.

I haven't noticed any adverse side-effects to this, so I decided to PR this upstream.
This commit is contained in:
Cody
2024-10-21 13:47:14 -04:00
committed by aerinon
parent 8ec25d8476
commit fb6727c527

View File

@@ -1280,7 +1280,7 @@ def make_customizer_pool(world, player):
or (d_item.map and not world.mapshuffle[player])): or (d_item.map and not world.mapshuffle[player])):
d_name = d_item.dungeon d_name = d_item.dungeon
dungeon = world.get_dungeon(d_name, player) dungeon = world.get_dungeon(d_name, player)
current_amount = 1 if d_item == dungeon.big_key or d_item in dungeon.dungeon_items else 0 current_amount = 1 if dungeon.big_key and (d_item == dungeon.big_key or d_item in dungeon.dungeon_items) else 0
additional_amount = amount - current_amount additional_amount = amount - current_amount
possible_fit = min(additional_amount, len(dungeon_locations[d_name])-dungeon_count[d_name]) possible_fit = min(additional_amount, len(dungeon_locations[d_name])-dungeon_count[d_name])
if possible_fit > 0: if possible_fit > 0:
@@ -1291,7 +1291,7 @@ def make_customizer_pool(world, player):
pool.extend([item_name] * amount) pool.extend([item_name] * amount)
else: else:
dungeon = world.get_dungeon(d_item.dungeon, player) dungeon = world.get_dungeon(d_item.dungeon, player)
current_amount = 1 if d_item == dungeon.big_key or d_item in dungeon.dungeon_items else 0 current_amount = 1 if dungeon.big_key and (d_item == dungeon.big_key or d_item in dungeon.dungeon_items) else 0
additional_amount = amount - current_amount additional_amount = amount - current_amount
dungeon.dungeon_items.extend([d_item] * additional_amount) dungeon.dungeon_items.extend([d_item] * additional_amount)
else: else: