Skip to content

Commit a6b8b0f

Browse files
stirbyS1M0N38
authored andcommitted
feat: add hook for buy_card, should work with buy_and_use card
1 parent 58d488b commit a6b8b0f

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/lua/log.lua

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,26 @@ function hook_toggle_shop()
217217
sendDebugMessage("Hooked into G.FUNCS.toggle_shop for logging", "LOG")
218218
end
219219

220+
function hook_buy_card()
221+
local original_function = G.FUNCS.buy_card
222+
-- e is the UI element for buy_card button on the targeted card.
223+
G.FUNCS.buy_card = function(e)
224+
-- object that owns the UI element, always a card in shop_jokers.cards
225+
local c1 = e.config.ref_table
226+
-- string representation of action, "buy_card" or "buy_and_use_card"
227+
-- Vouchers are not "bought" but "used"
228+
local action = e.config.id
229+
for i, card in ipairs(G.shop_jokers.cards) do
230+
if card.unique_id == c1.unique_id then
231+
LOG.schedule_write({ name = "shop", arguments = { action = action, index = i - 1 } })
232+
break
233+
end
234+
end
235+
return original_function(e)
236+
end
237+
sendDebugMessage("Hooked into G.FUNCS.buy_card for logging", "LOG")
238+
end
239+
220240
-- -----------------------------------------------------------------------------
221241
-- hand_rearrange Hook
222242
-- -----------------------------------------------------------------------------

0 commit comments

Comments
 (0)