Skip to content

Commit 6412506

Browse files
committed
fix: buy card hook (#68)
1 parent f84e257 commit 6412506

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

src/lua/log.lua

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -219,23 +219,20 @@ function hook_toggle_shop()
219219
end
220220

221221
function hook_buy_card()
222-
local original_function = G.FUNCS.buy_card
222+
local original_function = G.FUNCS.buy_from_shop
223223
-- e is the UI element for buy_card button on the targeted card.
224-
G.FUNCS.buy_card = function(e)
225-
-- object that owns the UI element, always a card in shop_jokers.cards
226-
local c1 = e.config.ref_table
227-
-- string representation of action, "buy_card" or "buy_and_use_card"
228-
-- Vouchers are not "bought" but "used"
229-
local action = e.config.id
224+
G.FUNCS.buy_from_shop = function(e)
225+
local card_id = e.config.ref_table.sort_id
230226
for i, card in ipairs(G.shop_jokers.cards) do
231-
if card.unique_id == c1.unique_id then
232-
LOG.schedule_write({ name = "shop", arguments = { action = action, index = i - 1 } })
227+
if card.sort_id == card_id then
228+
local function_call = { name = "shop", arguments = { action = "buy_card", index = i - 1 } }
229+
LOG.schedule_write(function_call)
233230
break
234231
end
235232
end
236233
return original_function(e)
237234
end
238-
sendDebugMessage("Hooked into G.FUNCS.buy_card for logging", "LOG")
235+
sendDebugMessage("Hooked into G.FUNCS.buy_from_shop for logging", "LOG")
239236
end
240237

241238
-- -----------------------------------------------------------------------------

0 commit comments

Comments
 (0)