Skip to content

Commit 6c00fa5

Browse files
committed
refactor: update types to better match API
This is not the final version on the types. For now, it's just a incomplete reference. We'll be able to have a complete version once API endpoints are implemented and we know what we need in the game state.
1 parent 353a146 commit 6c00fa5

File tree

1 file changed

+67
-9
lines changed

1 file changed

+67
-9
lines changed

src/lua/types.lua

Lines changed: 67 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@
5252
---@field action "rearrange" The action to perform
5353
---@field cards number[] Array of card indices for every card in hand (0-based)
5454

55+
---@class RearrangeJokersArgs
56+
---@field jokers number[] Array of joker indices for every joker (0-based)
57+
5558
---@class ShopActionArgs
5659
---@field action "next_round" | "buy_card" | "reroll" The action to perform
5760
---@field index? number The index of the card to act on (buy, buy_and_use, redeem, open) (0-based)
@@ -72,7 +75,7 @@
7275
---@field last_client_port? number Port of the last client that sent a message
7376

7477
-- =============================================================================
75-
-- Game Entity Types (used in utils.lua for state extraction)
78+
-- Game Entity Types
7679
-- =============================================================================
7780

7881
-- Root game state response (G object)
@@ -81,14 +84,17 @@
8184
---@field game? GGame Game information (null if not in game)
8285
---@field hand? GHand Hand information (null if not available)
8386
---@field jokers GJokers Jokers area object (with sub-field `cards`)
84-
---@field consumeables GConsumeables Consumables area object (typo intentional to match API)
87+
---@field consumeables GConsumeables Consumables area object (typo intentional)
88+
---@field shop_jokers? GShopJokers Shop jokers area
89+
---@field shop_vouchers? GShopVouchers Shop vouchers area
90+
---@field shop_booster? GShopBooster Shop booster packs area
8591

8692
-- Game state (G.GAME)
8793
---@class GGame
8894
---@field bankrupt_at number Money threshold for bankruptcy
8995
---@field base_reroll_cost number Base cost for rerolling shop
9096
---@field blind_on_deck string Current blind type ("Small", "Big", "Boss")
91-
---@field bosses_used table<string, number> Bosses used in run (bl_<boss_name> = 1|0)
97+
---@field bosses_used GGameBossesUsed Bosses used in run (bl_<boss_name> = 1|0)
9298
---@field chips number Current chip count
9399
---@field current_round GGameCurrentRound Current round information
94100
---@field discount_percent number Shop discount percentage
@@ -141,7 +147,7 @@
141147
---@field hands_played number Number of hands played
142148
---@field reroll_cost number Current dollar cost to reroll the shop offer
143149
---@field free_rerolls number Free rerolls remaining this round
144-
---@field voucher table Vouchers for this round
150+
---@field voucher GGameCurrentRoundVoucher Vouchers for this round
145151

146152
-- Selected deck info (G.GAME.selected_back)
147153
---@class GGameSelectedBack
@@ -182,6 +188,7 @@
182188
-- Hand card (G.hand.cards[])
183189
---@class GHandCards
184190
---@field label string Display label of the card
191+
---@field sort_id number Unique identifier for this card instance
185192
---@field base GHandCardsBase Base card properties
186193
---@field config GHandCardsConfig Card configuration
187194
---@field debuff boolean Whether card is debuffed
@@ -217,19 +224,24 @@
217224
---@field config GCardAreaConfig Config for jokers card area
218225
---@field cards GJokersCard[] Array of joker card objects
219226

220-
-- Keeping typo "consumeables" for compatibility with the runtime table name
227+
-- Keeping typo "consumeables" for compatibility
221228
---@class GConsumeables
222229
---@field config GCardAreaConfig Configuration for the consumables slot
230+
---@field cards? GConsumablesCard[] Array of consumable card objects
223231

224232
-- Joker card (G.jokers.cards[])
225233
---@class GJokersCard
226234
---@field label string Display label of the joker
227235
---@field cost number Purchase cost of the joker
236+
---@field sort_id number Unique identifier for this card instance
228237
---@field config GJokersCardConfig Joker card configuration
238+
---@field debuff boolean Whether joker is debuffed
239+
---@field facing string Card facing direction ("front", "back")
240+
---@field highlighted boolean Whether joker is highlighted
229241

230242
-- Joker card configuration (G.jokers.cards[].config)
231243
---@class GJokersCardConfig
232-
---@field center table Center configuration for joker
244+
---@field center_key string Key identifier for the joker center
233245

234246
-- Consumable card (G.consumeables.cards[])
235247
---@class GConsumablesCard
@@ -239,10 +251,10 @@
239251

240252
-- Consumable card configuration (G.consumeables.cards[].config)
241253
---@class GConsumablesCardConfig
242-
---@field center table Center configuration for consumable
254+
---@field center_key string Key identifier for the consumable center
243255

244256
-- =============================================================================
245-
-- Utility Module (implemented in utils.lua)
257+
-- Utility Module
246258
-- =============================================================================
247259

248260
---Utility functions for game state extraction and data processing
@@ -290,5 +302,51 @@
290302
---@field vsync_enabled boolean Whether vertical sync is enabled
291303

292304
-- =============================================================================
293-
-- New composite area types (match utils.lua)
305+
-- Shop Area Types
294306
-- =============================================================================
307+
308+
-- Shop jokers area
309+
---@class GShopJokers
310+
---@field config GCardAreaConfig Configuration for the shop jokers area
311+
---@field cards? GShopCard[] Array of shop card objects
312+
313+
-- Shop vouchers area
314+
---@class GShopVouchers
315+
---@field config GCardAreaConfig Configuration for the shop vouchers area
316+
---@field cards? GShopCard[] Array of shop voucher objects
317+
318+
-- Shop booster area
319+
---@class GShopBooster
320+
---@field config GCardAreaConfig Configuration for the shop booster area
321+
---@field cards? GShopCard[] Array of shop booster objects
322+
323+
-- Shop card
324+
---@class GShopCard
325+
---@field label string Display label of the shop card
326+
---@field cost number Purchase cost of the card
327+
---@field sell_cost number Sell cost of the card
328+
---@field debuff boolean Whether card is debuffed
329+
---@field facing string Card facing direction ("front", "back")
330+
---@field highlighted boolean Whether card is highlighted
331+
---@field ability GShopCardAbility Card ability information
332+
---@field config GShopCardConfig Shop card configuration
333+
334+
-- Shop card ability (G.shop_*.cards[].ability)
335+
---@class GShopCardAbility
336+
---@field set string The set of the card: "Joker", "Planet", "Voucher", "Booster", or "Consumable"
337+
338+
-- Shop card configuration (G.shop_*.cards[].config)
339+
---@class GShopCardConfig
340+
---@field center_key string Key identifier for the card center
341+
342+
-- =============================================================================
343+
-- Additional Game State Types
344+
-- =============================================================================
345+
346+
-- Round voucher (G.GAME.current_round.voucher)
347+
---@class GGameCurrentRoundVoucher
348+
-- This is intentionally empty as the voucher table structure varies
349+
350+
-- Bosses used (G.GAME.bosses_used)
351+
---@class GGameBossesUsed
352+
-- Dynamic table with boss name keys mapping to 1|0

0 commit comments

Comments
 (0)