ah_sce_unpacked/unpacked/Checker_white Move Command 0b55d8.ttslua

71 lines
1.8 KiB
Plaintext
Raw Normal View History

2021-09-03 13:52:12 -04:00
---
--- Generated by EmmyLua(https://github.com/EmmyLua)
--- Created by Whimsical.
--- DateTime: 2021-08-24 6:02 p.m.
---
command_name = "move"
---@type ArkhamImport_Command_RunDirectives
runOn = {
instructions = true,
handlers = true
}
---@param parameters ArkhamImport_Command_DescriptionInstructionArguments
---@return ArkhamImport_Command_DescriptionInstructionResults
function do_instruction(parameters)
local args = parameters.arguments
if (#args~=2 and #args~=3) then
return { is_successful = false, error_message = "Move Command requires 2 or 3 arguments. " .. #args .. " were provided." }
end
local card_id = args[1]
local new_zone = args[2]
local count = tonumber(args[3]) or 3
if not parameters.configuration.zones[new_zone] then
return { is_successful = false, error_message = "Move Command: Zone \"" .. new_zone .. "\" was not found." }
end
local state = parameters.command_state["move"]
if not state then
state = {}
parameters.command_state["move"] = state
end
local card_data = state[card_id]
if not card_data then
card_data = {
zone = {},
offset = 0
}
state[card_id] = card_data
end
local zone = card_data.zone
local offset = card_data.offset
for index=offset,offset+count do
zone[index] = new_zone
end
return { command_state = parameters.command_state, is_successful = true }
end
---@param parameters ArkhamImport_Command_HandlerArguments
---@return ArkhamImport_Command_HandlerResults
function handle_card(parameters)
local state = parameters.command_state["move"] or {}
local card_data = state[parameters.card.code]
if not card_data then return { is_successful = true} end
return { zone = card_data.zone, is_successful = true }
end