Keep the bag open after using a Rare Candy (#796)

This commit is contained in:
johnjohto
2026-08-04 13:18:32 -04:00
parent 1820f411ae
commit 54ae20c69b
2 changed files with 193 additions and 10 deletions
+14 -10
View File
@@ -255,6 +255,15 @@ local function useOn(game, battle, id, target, list, moveIndex, picker)
if result == "consumed" then
consume(game, id)
-- refresh counts in the list
for i, it in ipairs(list.items) do
if it.value == id then
local left = game.save.inventory[id]
if left then it.right = "x" .. left else table.remove(list.items, i) end
break
end
end
list.index = math.min(list.index, math.max(1, #list.items))
if extra and extra.evolveTo then
list:close()
local Evolution = require("src.pokemon.Evolution")
@@ -265,7 +274,11 @@ local function useOn(game, battle, id, target, list, moveIndex, picker)
-- moves and a level evolution follow (item_effects.asm .useRareCandy
-- runs PrintStatsBox, LearnMoveFromLevelUp and TryEvolvingMon)
if extra and extra.leveledTo and target then
list:close()
-- ...but the bag stays open underneath it all: RARE_CANDY is in
-- pokered's UsableItems_PartyMenu (data/items/use_party.asm), and
-- .useItem_partyMenu jumps back to StartMenu_Item once UseItem
-- returns, cursor still on the candy (start_sub_menus.asm) -- so
-- mashing A burns through a stack of them (#796)
showMessages(game, payload, function()
local StatBox = require("src.battle.BattleState").StatBox
game.stack:push(StatBox.new(game, target, function()
@@ -304,15 +317,6 @@ local function useOn(game, battle, id, target, list, moveIndex, picker)
end)
return
end
-- refresh counts in the list
for i, it in ipairs(list.items) do
if it.value == id then
local left = game.save.inventory[id]
if left then it.right = "x" .. left else table.remove(list.items, i) end
break
end
end
list.index = math.min(list.index, math.max(1, #list.items))
-- HP medicine: fill the bar in the still-open picker first, then print
-- and close, the order item_effects.asm .doneHealing runs in
-- (SFX_HEAL_HP -> UpdateHPBar2 -> RedrawPartyMenu prints the message).