Skip to content

Commit ec123d6

Browse files
stirbyS1M0N38
authored andcommitted
feat: add state checking for use consumable with cards parameter
1 parent 1775952 commit ec123d6

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/lua/api.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,7 +1110,7 @@ API.functions["use_consumable"] = function(args)
11101110
-- Validate current game state is SELECTING_HAND when cards are provided
11111111
if G.STATE ~= G.STATES.SELECTING_HAND then
11121112
API.send_error_response(
1113-
"Cannot use consumable with cards when not in selecting hand state",
1113+
"Cannot use consumable with cards when there are no cards to select. Expects SELECTING_HAND state.",
11141114
ERROR_CODES.INVALID_GAME_STATE,
11151115
{ current_state = G.STATE, required_state = G.STATES.SELECTING_HAND }
11161116
)
@@ -1128,11 +1128,11 @@ API.functions["use_consumable"] = function(args)
11281128
end
11291129

11301130
-- Validate number of cards is between 1 and 5 (inclusive) for consistency with play_hand_or_discard
1131-
if #args.cards < 1 or #args.cards > 5 then
1131+
if #args.cards < 1 or #args.cards > 3 then
11321132
API.send_error_response(
1133-
"Invalid number of cards. Expected 1-5, got " .. tostring(#args.cards),
1133+
"Invalid number of cards. Expected 1-3, got " .. tostring(#args.cards),
11341134
ERROR_CODES.PARAMETER_OUT_OF_RANGE,
1135-
{ cards_count = #args.cards, valid_range = "1-5" }
1135+
{ cards_count = #args.cards, valid_range = "1-3" }
11361136
)
11371137
return
11381138
end
@@ -1218,7 +1218,7 @@ API.functions["use_consumable"] = function(args)
12181218
-- Check if the consumable can be used
12191219
if not consumable_card:can_use_consumeable() then
12201220
API.send_error_response(
1221-
"Consumable cannot be used at this time",
1221+
"Consumable cannot be used at this time. Some consumables require cards to be selected first.",
12221222
ERROR_CODES.INVALID_ACTION,
12231223
{ index = args.index }
12241224
)

0 commit comments

Comments
 (0)