Skip to content

Commit b998062

Browse files
committed
feat(api): add shop vouchers field to game state
- Add shop_vouchers collection with config and cards structure - Include center_key, cost, sell_cost, and other card properties - Mirror shop_jokers structure for consistency
1 parent e3910fa commit b998062

File tree

1 file changed

+37
-3
lines changed

1 file changed

+37
-3
lines changed

src/lua/utils.lua

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -389,12 +389,46 @@ function utils.get_game_state()
389389
local cards = {}
390390
if G.shop_jokers.cards then
391391
for i, card in pairs(G.shop_jokers.cards) do
392+
cards[i] = {
393+
ability = {
394+
set = card.ability.set, -- str. The set of the card: Joker, Planet, Voucher, Booster, or Consumable
395+
},
396+
config = {
397+
center_key = card.config.center_key, -- id of the card
398+
},
399+
debuff = card.debuff, -- bool. True if the card is a debuff
400+
cost = card.cost, -- int. The cost of the card
401+
label = card.label, -- str. The label of the card
402+
facing = card.facing, -- str. The facing of the card: front | back
403+
highlighted = card.highlighted, -- bool. True if the card is highlighted
404+
sell_cost = card.sell_cost, -- int. The sell cost of the card
405+
}
406+
end
407+
end
408+
shop_jokers = {
409+
config = config,
410+
cards = cards,
411+
}
412+
end
413+
414+
local shop_vouchers = nil
415+
if G.shop_vouchers then
416+
local config = {}
417+
if G.shop_vouchers.config then
418+
config = {
419+
card_count = G.shop_vouchers.config.card_count,
420+
card_limit = G.shop_vouchers.config.card_limit,
421+
}
422+
end
423+
local cards = {}
424+
if G.shop_vouchers.cards then
425+
for i, card in pairs(G.shop_vouchers.cards) do
392426
cards[i] = {
393427
ability = {
394428
set = card.ability.set,
395429
},
396430
config = {
397-
card_key = card.config.center_key,
431+
center_key = card.config.center_key,
398432
},
399433
debuff = card.debuff,
400434
cost = card.cost,
@@ -405,7 +439,7 @@ function utils.get_game_state()
405439
}
406440
end
407441
end
408-
shop_jokers = {
442+
shop_vouchers = {
409443
config = config,
410444
cards = cards,
411445
}
@@ -419,9 +453,9 @@ function utils.get_game_state()
419453
hand = hand,
420454
jokers = jokers,
421455
shop_jokers = shop_jokers, -- NOTE: This contains all cards in the shop, not only jokers.
456+
shop_vouchers = shop_vouchers,
422457

423458
-- TODO: add later
424-
-- shop_vouchers = G.shop_vouchers,
425459
-- shop_booster = G.shop_booster,
426460
}
427461
end

0 commit comments

Comments
 (0)