Skip to content

Commit 2fb2cbc

Browse files
committed
feat: update game state with consumeables
1 parent e7796cc commit 2fb2cbc

File tree

1 file changed

+31
-6
lines changed

1 file changed

+31
-6
lines changed

src/lua/utils.lua

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -312,12 +312,30 @@ function utils.get_game_state()
312312
}
313313
end
314314

315-
-- Keeping typo for consistency
316-
local consumeables = {}
317-
if G.consumeables and G.consumeables.config then
318-
consumeables.config = {
319-
card_count = G.consumeables.config.card_count, -- int (default 0), -- number of consumable cards in the shop
320-
card_limit = G.consumeables.config.card_limit, -- int (default 2), -- max number of consumable cards in the shop
315+
local consumeables = nil
316+
if G.consumeables then
317+
local cards = {}
318+
if G.consumeables.cards then
319+
for i, card in pairs(G.consumeables.cards) do
320+
cards[i] = {
321+
label = card.label,
322+
cost = card.cost,
323+
sort_id = card.sort_id, -- Unique identifier for this card instance (used for rearranging)
324+
config = {
325+
center_key = card.config.center_key,
326+
},
327+
debuf = card.debuff,
328+
facing = card.facing,
329+
highlighted = card.highlighted,
330+
}
331+
end
332+
end
333+
consumeables = {
334+
cards = cards,
335+
config = {
336+
card_count = G.consumeables.config.card_count,
337+
card_limit = G.consumeables.config.card_limit,
338+
},
321339
}
322340
end
323341

@@ -517,6 +535,7 @@ function utils.get_game_state()
517535
shop_vouchers = shop_vouchers,
518536
shop_booster = shop_booster,
519537
consumeables = consumeables,
538+
-- NOTE: yes it's consumeables, not consumables. Following the naming convention of the game.
520539
}
521540
end
522541

@@ -724,6 +743,12 @@ utils.COMPLETION_CONDITIONS = {
724743
end,
725744
},
726745

746+
rearrange_consumeables = {
747+
[""] = function()
748+
return #G.E_MANAGER.queues.base < EVENT_QUEUE_THRESHOLD and G.STATE_COMPLETE
749+
end,
750+
},
751+
727752
cash_out = {
728753
[""] = function()
729754
return G.STATE == G.STATES.SHOP and #G.E_MANAGER.queues.base < EVENT_QUEUE_THRESHOLD and G.STATE_COMPLETE

0 commit comments

Comments
 (0)