Skip to content

Commit

Permalink
Merge pull request #383 from randovania/_max-edgecase
Browse files Browse the repository at this point in the history
Prevent inventory update if launcher < 1
  • Loading branch information
ThanatosGit authored Jun 23, 2024
2 parents a8e2450 + 6489bba commit 5c5f5f0
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/open_samus_returns_rando/lua_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,15 @@ def _create_custom_init(self, editor: PatcherEditor, configuration: dict) -> str
max_life += etanks * energy_per_tank

# use _MAX if main is unlocked to unlock the ammo too
# FIXME: These checks are kinda wrong if you use something like `"ITEM_WEAPON_MISSILE_LAUNCHER": 0`
if "ITEM_WEAPON_MISSILE_LAUNCHER" in inventory and "ITEM_MISSILE_TANKS" in inventory:
inventory["ITEM_WEAPON_MISSILE_MAX"] = inventory.pop("ITEM_MISSILE_TANKS")
if "ITEM_WEAPON_SUPER_MISSILE" in inventory and "ITEM_SUPER_MISSILE_TANKS" in inventory:
inventory["ITEM_WEAPON_SUPER_MISSILE_MAX"] = inventory.pop("ITEM_SUPER_MISSILE_TANKS")
if "ITEM_WEAPON_POWER_BOMB" in inventory and "ITEM_POWER_BOMB_TANKS" in inventory:
inventory["ITEM_WEAPON_POWER_BOMB_MAX"] = inventory.pop("ITEM_POWER_BOMB_TANKS")
LAUNCHER_TANK_MAPPING = [
("ITEM_WEAPON_MISSILE_LAUNCHER", "ITEM_MISSILE_TANKS"),
("ITEM_WEAPON_SUPER_MISSILE", "ITEM_SUPER_MISSILE_TANKS"),
("ITEM_WEAPON_POWER_BOMB", "ITEM_POWER_BOMB_TANKS"),
]
for launcher, tanks in LAUNCHER_TANK_MAPPING:
if launcher in inventory and inventory[launcher] > 0 and tanks in inventory:
ammo_max = "ITEM_WEAPON_" + tanks[5:].replace("TANKS", "MAX")
inventory[ammo_max] = inventory.pop(tanks)

# These fields are required to start the game
final_inventory = {
Expand Down

0 comments on commit 5c5f5f0

Please sign in to comment.