some bugfixes and QoL

This commit is contained in:
Chr1Z93 2024-02-16 10:12:58 +01:00
parent 237ea15949
commit 2c7bba922f
2 changed files with 17 additions and 14 deletions

View File

@ -299,8 +299,11 @@ do
local pos = string.find(description, "++SCED import instructions++") local pos = string.find(description, "++SCED import instructions++")
if not pos then return end if not pos then return end
-- remove everything before instructions (including newline) -- remove everything before instructions
local tempStr = string.sub(description, pos + 30) local tempStr = string.sub(description, pos)
-- remove instruction header (and potential copies)
tempStr = tempStr:gsub("++SCED import instructions++\n")
-- parse each line in instructions -- parse each line in instructions
for line in tempStr:gmatch("([^\n]+)") do for line in tempStr:gmatch("([^\n]+)") do
@ -333,14 +336,12 @@ do
elseif instructor == "remove:" then elseif instructor == "remove:" then
if slots[str] == nil then if slots[str] == nil then
internal.maybePrint("Tried to remove " .. str .. ", but didn't find card in deck.", playerColor) internal.maybePrint("Tried to remove " .. str .. ", but didn't find card in deck.", playerColor)
break else
end
slots[str] = math.max(slots[str] - 1, 0) slots[str] = math.max(slots[str] - 1, 0)
-- fully remove cards that have a quantity of 0 -- fully remove cards that have a quantity of 0
if slots[str] == 0 then if slots[str] == 0 then
slots[str] = nil slots[str] = nil
end
-- also remove related minicard -- also remove related minicard
slots[str .. "-m"] = nil slots[str .. "-m"] = nil
@ -348,6 +349,8 @@ do
end end
end end
end end
end
end
-- Process the slot list and looks for any cards which are bonded to those in the deck. Adds those cards to the slot list. -- Process the slot list and looks for any cards which are bonded to those in the deck. Adds those cards to the slot list.
---@param slots table The slot list for cards in this deck. Table key is the cardId, value is the number of those cards which will be spawned ---@param slots table The slot list for cards in this deck. Table key is the cardId, value is the number of those cards which will be spawned

View File

@ -46,10 +46,10 @@ function generate(_, playerColor)
-- sort the idList -- sort the idList
table.sort(idList, sortById) table.sort(idList, sortById)
-- construct the string -- construct the string (new line for each instruction)
local description = "++SCED import instructions++\n- add: " local description = "++SCED import instructions++"
for _, entry in ipairs(idList) do for _, entry in ipairs(idList) do
description = description .. entry.id .. " (**" .. entry.name .. "**)" .. ", " description = description .. "\n- add: " .. entry.id .. " (**" .. entry.name .. "**)" .. ", "
end end
-- remove last delimiter (last two characters) -- remove last delimiter (last two characters)