Skip to content

Commit a041eef

Browse files
committed
refactor: Fix joker config in get gamestate, add consumables, and add types
1 parent efe3752 commit a041eef

File tree

2 files changed

+45
-8
lines changed

2 files changed

+45
-8
lines changed

src/lua/types.lua

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@
8080
---@field state any Current game state enum value
8181
---@field game? GGame Game information (null if not in game)
8282
---@field hand? GHand Hand information (null if not available)
83-
---@field jokers GJokersCards[] Array of joker cards
83+
---@field jokers GJokers Jokers area object (with sub-field `cards`)
84+
---@field consumeables GConsumeables Consumables area object (typo intentional to match API)
8485

8586
-- Game state (G.GAME)
8687
---@class GGame
@@ -206,16 +207,37 @@
206207
---@field suit string Card suit
207208
---@field value string Card value
208209

210+
---@class GCardAreaConfig
211+
---@field card_count number Number of cards currently present in the area
212+
---@field card_limit number Maximum cards allowed in the area
213+
214+
---@class GJokers
215+
---@field config GCardAreaConfig Config for jokers card area
216+
---@field cards GJokersCard[] Array of joker card objects
217+
218+
-- Keeping typo "consumeables" for compatibility with the runtime table name
219+
---@class GConsumeables
220+
---@field config GCardAreaConfig Configuration for the consumables slot
221+
209222
-- Joker card (G.jokers.cards[])
210-
---@class GJokersCards
223+
---@class GJokersCard
211224
---@field label string Display label of the joker
212-
---@field config GJokersCardsConfig Joker configuration
225+
---@field cost number Purchase cost of the joker
226+
---@field config GJokersCardConfig Joker card configuration
213227

214228
-- Joker card configuration (G.jokers.cards[].config)
215-
---@class GJokersCardsConfig
229+
---@class GJokersCardConfig
216230
---@field center table Center configuration for joker
217-
---@field card_count number Number of cards in joker area
218-
---@field card_limit number Maximum number of cards in joker area
231+
232+
-- Consumable card (G.consumeables.cards[])
233+
---@class GConsumablesCard
234+
---@field label string Display label of the consumable
235+
---@field cost number Purchase cost of the consumable
236+
---@field config GConsumablesCardConfig Consumable configuration
237+
238+
-- Consumable card configuration (G.consumeables.cards[].config)
239+
---@class GConsumablesCardConfig
240+
---@field center table Center configuration for consumable
219241

220242
-- =============================================================================
221243
-- Utility Module (implemented in utils.lua)
@@ -264,3 +286,8 @@
264286
---@field dt number Tells the game that every update is dt seconds long
265287
---@field max_fps integer? Maximum frames per second
266288
---@field vsync_enabled boolean Whether vertical sync is enabled
289+
290+
-- =============================================================================
291+
-- New composite area types (match utils.lua)
292+
-- =============================================================================
293+

src/lua/utils.lua

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,15 @@ function utils.get_game_state()
307307
}
308308
end
309309

310+
-- Keeping typo for consistency
311+
local consumeables = {}
312+
if G.consumeables and G.consumeables.config then
313+
consumeables.config = {
314+
card_count = G.consumeables.config.card_count, -- int (default 0), -- number of consumable cards in the shop
315+
card_limit = G.consumeables.config.card_limit, -- int (default 2), -- max number of consumable cards in the shop
316+
}
317+
end
318+
310319
local hand = nil
311320
if G.hand then
312321
local cards = {}
@@ -370,8 +379,8 @@ function utils.get_game_state()
370379
}
371380
if G.jokers then
372381

373-
jokers.card_limit = G.jokers.card_limit
374-
jokers.card_count = G.jokers.card_count
382+
jokers.config.card_limit = G.jokers.config.card_limit
383+
jokers.config.card_count = G.jokers.config.card_count
375384
if G.jokers.cards then
376385
for i, card in pairs(G.jokers.cards) do
377386
jokers.cards[i] = {
@@ -495,6 +504,7 @@ function utils.get_game_state()
495504
shop_jokers = shop_jokers, -- NOTE: This contains all cards in the shop, not only jokers.
496505
shop_vouchers = shop_vouchers,
497506
shop_booster = shop_booster,
507+
consumeables = consumeables,
498508
}
499509
end
500510

0 commit comments

Comments
 (0)