Skip to content

Commit ad062bb

Browse files
committed
feat(api): add shop jokers field to game state
Note: the jokers filed is not only jokers, but also all cards in the shop.
1 parent bddbad1 commit ad062bb

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

src/lua/utils.lua

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ function utils.get_game_state()
106106
discards_left = G.GAME.current_round.discards_left, -- Number of discards left for this round
107107
discards_used = G.GAME.current_round.discards_used, -- int (default 0) Number of discard used in this round
108108

109-
-- "dollars": int, (default 0) -- maybe dollars earned in this round?
109+
--"dollars": int, (default 0) -- maybe dollars earned in this round?
110110
-- "dollars_to_be_earned": str, (default "") -- ??
111111
-- "free_rerolls": int, (default 0) -- Number of free rerolls in the shop?
112112
hands_left = G.GAME.current_round.hands_left, -- Number of hands left for this round
@@ -377,13 +377,52 @@ function utils.get_game_state()
377377
end
378378
end
379379

380+
local shop_jokers = nil
381+
if G.shop_jokers then
382+
local config = {}
383+
if G.shop_jokers.config then
384+
config = {
385+
card_count = G.shop_jokers.config.card_count, -- int. how many cards are in the the shop
386+
card_limit = G.shop_jokers.config.card_limit, -- int. how many cards can be in the shop
387+
}
388+
end
389+
local cards = {}
390+
if G.shop_jokers.cards then
391+
for i, card in pairs(G.shop_jokers.cards) do
392+
cards[i] = {
393+
ability = {
394+
set = card.ability.set,
395+
},
396+
config = {
397+
card_key = card.config.center_key,
398+
},
399+
debuff = card.debuff,
400+
cost = card.cost,
401+
label = card.label,
402+
facing = card.facing,
403+
highlighted = card.highlighted,
404+
sell_cost = card.sell_cost,
405+
}
406+
end
407+
end
408+
shop_jokers = {
409+
config = config,
410+
cards = cards,
411+
}
412+
end
413+
380414
-- TODO: add consumables, ante, and shop
381415

382416
return {
383417
state = G.STATE,
384418
game = game,
385419
hand = hand,
386420
jokers = jokers,
421+
shop_jokers = shop_jokers, -- NOTE: This contains all cards in the shop, not only jokers.
422+
423+
-- TODO: add later
424+
-- shop_vouchers = G.shop_vouchers,
425+
-- shop_booster = G.shop_booster,
387426
}
388427
end
389428

0 commit comments

Comments
 (0)