Skip to content

Commit 13fcbca

Browse files
committed
refactor: change from "consumeables" to "consumables"
1 parent 4b54e65 commit 13fcbca

File tree

6 files changed

+95
-103
lines changed

6 files changed

+95
-103
lines changed

src/lua/api.lua

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -606,12 +606,12 @@ API.functions["rearrange_jokers"] = function(args)
606606
}
607607
end
608608

609-
---Rearranges the consumeables based on the given card indices
610-
---Call G.FUNCS.rearrange_consumeables(new_consumeables)
611-
---@param args RearrangeConsumeablesArgs The card indices to rearrange the consumeables with
612-
API.functions["rearrange_consumeables"] = function(args)
609+
---Rearranges the consumables based on the given card indices
610+
---Call G.FUNCS.rearrange_consumables(new_consumables)
611+
---@param args RearrangeConsumablesArgs The card indices to rearrange the consumables with
612+
API.functions["rearrange_consumables"] = function(args)
613613
-- Validate required parameters
614-
local success, error_message, error_code, context = validate_request(args, { "consumeables" })
614+
local success, error_message, error_code, context = validate_request(args, { "consumables" })
615615

616616
if not success then
617617
---@cast error_message string
@@ -620,34 +620,34 @@ API.functions["rearrange_consumeables"] = function(args)
620620
return
621621
end
622622

623-
-- Validate that consumeables exist
623+
-- Validate that consumables exist
624624
if not G.consumeables or not G.consumeables.cards or #G.consumeables.cards == 0 then
625625
API.send_error_response(
626-
"No consumeables available to rearrange",
626+
"No consumables available to rearrange",
627627
ERROR_CODES.MISSING_GAME_OBJECT,
628-
{ consumeables_available = false }
628+
{ consumables_available = false }
629629
)
630630
return
631631
end
632632

633-
-- Validate number of consumeables is equal to the number of consumeables in the consumeables area
634-
if #args.consumeables ~= #G.consumeables.cards then
633+
-- Validate number of consumables is equal to the number of consumables in the consumables area
634+
if #args.consumables ~= #G.consumeables.cards then
635635
API.send_error_response(
636-
"Invalid number of consumeables to rearrange",
636+
"Invalid number of consumables to rearrange",
637637
ERROR_CODES.PARAMETER_OUT_OF_RANGE,
638-
{ consumeables_count = #args.consumeables, valid_range = tostring(#G.consumeables.cards) }
638+
{ consumables_count = #args.consumables, valid_range = tostring(#G.consumeables.cards) }
639639
)
640640
return
641641
end
642642

643643
-- Convert incoming indices from 0-based to 1-based
644-
for i, joker_index in ipairs(args.consumeables) do
645-
args.consumeables[i] = joker_index + 1
644+
for i, consumable_index in ipairs(args.consumables) do
645+
args.consumables[i] = consumable_index + 1
646646
end
647647

648-
-- Create a new consumeables array to swap card indices
648+
-- Create a new consumables array to swap card indices
649649
local new_consumables = {}
650-
for _, old_index in ipairs(args.consumeables) do
650+
for _, old_index in ipairs(args.consumables) do
651651
local card = G.consumeables.cards[old_index]
652652
if not card then
653653
API.send_error_response(
@@ -662,7 +662,7 @@ API.functions["rearrange_consumeables"] = function(args)
662662

663663
G.consumeables.cards = new_consumables
664664

665-
-- Update each consumeable's order field so future sort('order') calls work correctly
665+
-- Update each consumable's order field so future sort('order') calls work correctly
666666
for i, card in ipairs(G.consumeables.cards) do
667667
if card.ability then
668668
card.ability.order = i
@@ -673,8 +673,8 @@ API.functions["rearrange_consumeables"] = function(args)
673673
end
674674

675675
---@type PendingRequest
676-
API.pending_requests["rearrange_consumeables"] = {
677-
condition = utils.COMPLETION_CONDITIONS["rearrange_consumeables"][""],
676+
API.pending_requests["rearrange_consumables"] = {
677+
condition = utils.COMPLETION_CONDITIONS["rearrange_consumables"][""],
678678
action = function()
679679
local game_state = utils.get_game_state()
680680
API.send_response(game_state)

src/lua/log.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ function hook_hand_rearrange()
260260
local previous_orders = {
261261
hand = {},
262262
joker = {},
263-
consumeables = {},
263+
consumables = {},
264264
}
265265
-- local previous_hand_order = {}
266266
-- local previous_joker_order = {}
@@ -271,7 +271,7 @@ function hook_hand_rearrange()
271271
self.config
272272
---@diagnostic disable-next-line: undefined-field
273273
and (self.config.type == "hand" or self.config.type == "joker")
274-
-- consumeables are type "joker"
274+
-- consumables are type "joker"
275275
---@diagnostic disable-next-line: undefined-field
276276
and self.cards
277277
---@diagnostic disable-next-line: undefined-field
@@ -343,8 +343,8 @@ function hook_hand_rearrange()
343343

344344
if are_consumables and not are_jokers then
345345
function_call = {
346-
name = "rearrange_consumeables",
347-
arguments = { consumeables = cards },
346+
name = "rearrange_consumables",
347+
arguments = { consumables = cards },
348348
}
349349
elseif are_jokers and not are_consumables then
350350
function_call = {

src/lua/types.lua

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@
5555
---@class RearrangeJokersArgs
5656
---@field jokers number[] Array of joker indices for every joker (0-based)
5757

58-
---@class RearrangeConsumeablesArgs
59-
---@field consumeables number[] Array of consumeable indices for every consumeable (0-based)
58+
---@class RearrangeConsumablesArgs
59+
---@field consumables number[] Array of consumable indices for every consumable (0-based)
6060

6161
---@class ShopActionArgs
6262
---@field action "next_round" | "buy_card" | "reroll" The action to perform
@@ -87,7 +87,7 @@
8787
---@field game? GGame Game information (null if not in game)
8888
---@field hand? GHand Hand information (null if not available)
8989
---@field jokers GJokers Jokers area object (with sub-field `cards`)
90-
---@field consumeables GConsumeables Consumables area object (typo intentional)
90+
---@field consumables GConsumables Consumables area object
9191
---@field shop_jokers? GShopJokers Shop jokers area
9292
---@field shop_vouchers? GShopVouchers Shop vouchers area
9393
---@field shop_booster? GShopBooster Shop booster packs area
@@ -227,8 +227,7 @@
227227
---@field config GCardAreaConfig Config for jokers card area
228228
---@field cards GJokersCard[] Array of joker card objects
229229

230-
-- Keeping typo "consumeables" for compatibility
231-
---@class GConsumeables
230+
---@class GConsumables
232231
---@field config GCardAreaConfig Configuration for the consumables slot
233232
---@field cards? GConsumablesCard[] Array of consumable card objects
234233

@@ -246,13 +245,13 @@
246245
---@class GJokersCardConfig
247246
---@field center_key string Key identifier for the joker center
248247

249-
-- Consumable card (G.consumeables.cards[])
248+
-- Consumable card (G.consumables.cards[])
250249
---@class GConsumablesCard
251250
---@field label string Display label of the consumable
252251
---@field cost number Purchase cost of the consumable
253252
---@field config GConsumablesCardConfig Consumable configuration
254253

255-
-- Consumable card configuration (G.consumeables.cards[].config)
254+
-- Consumable card configuration (G.consumables.cards[].config)
256255
---@class GConsumablesCardConfig
257256
---@field center_key string Key identifier for the consumable center
258257

src/lua/utils.lua

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ function utils.get_game_state()
312312
}
313313
end
314314

315-
local consumeables = nil
315+
local consumables = nil
316316
if G.consumeables then
317317
local cards = {}
318318
if G.consumeables.cards then
@@ -330,7 +330,7 @@ function utils.get_game_state()
330330
}
331331
end
332332
end
333-
consumeables = {
333+
consumables = {
334334
cards = cards,
335335
config = {
336336
card_count = G.consumeables.config.card_count,
@@ -534,8 +534,7 @@ function utils.get_game_state()
534534
shop_jokers = shop_jokers, -- NOTE: This contains all cards in the shop, not only jokers.
535535
shop_vouchers = shop_vouchers,
536536
shop_booster = shop_booster,
537-
consumeables = consumeables,
538-
-- NOTE: yes it's consumeables, not consumables. Following the naming convention of the game.
537+
consumables = consumables,
539538
}
540539
end
541540

@@ -743,7 +742,7 @@ utils.COMPLETION_CONDITIONS = {
743742
end,
744743
},
745744

746-
rearrange_consumeables = {
745+
rearrange_consumables = {
747746
[""] = function()
748747
return #G.E_MANAGER.queues.base < EVENT_QUEUE_THRESHOLD and G.STATE_COMPLETE
749748
end,

0 commit comments

Comments
 (0)