added arkhamdb deck description parsing
This commit is contained in:
parent
8732e438d5
commit
7e2a4d71d5
@ -145,6 +145,7 @@ do
|
|||||||
loadAltInvestigator = internal.addInvestigatorCards(deck, slots)
|
loadAltInvestigator = internal.addInvestigatorCards(deck, slots)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
internal.maybeModifyDeckFromDescription(slots, deck.description_md)
|
||||||
internal.maybeAddSummonedServitor(slots)
|
internal.maybeAddSummonedServitor(slots)
|
||||||
internal.maybeAddOnTheMend(slots, playerColor)
|
internal.maybeAddOnTheMend(slots, playerColor)
|
||||||
internal.maybeAddRealityAcidReference(slots)
|
internal.maybeAddRealityAcidReference(slots)
|
||||||
@ -285,6 +286,49 @@ do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Processes the deck description from ArkhamDB and modifies the slot list accordingly
|
||||||
|
---@param slots Table The slot list for cards in this deck. Table key is the cardId, value is the number
|
||||||
|
---@param description String The deck desription from ArkhamDB
|
||||||
|
internal.maybeModifyDeckFromDescription = function(slots, description)
|
||||||
|
-- check for import instructions
|
||||||
|
local pos = string.find(description, "++SCED import instructions++")
|
||||||
|
if not pos then return end
|
||||||
|
|
||||||
|
-- remove everything before instructions (including newline)
|
||||||
|
local tempStr = string.sub(description, pos + 30)
|
||||||
|
|
||||||
|
-- parse each line in instructions
|
||||||
|
for line in tempStr:gmatch("([^\n]+)") do
|
||||||
|
-- remove dashes at the start
|
||||||
|
line = line:gsub("%- ", "")
|
||||||
|
|
||||||
|
-- remove spaces
|
||||||
|
line = line:gsub("%s", "")
|
||||||
|
|
||||||
|
-- get instructor
|
||||||
|
local instructor = ""
|
||||||
|
for word in line:gmatch("%a+:") do
|
||||||
|
instructor = word
|
||||||
|
break
|
||||||
|
end
|
||||||
|
|
||||||
|
if instructor == "" or (instructor ~= "add:" and instructor ~= "remove:") then return end
|
||||||
|
|
||||||
|
-- remove instructor from line
|
||||||
|
line = line:gsub(instructor, "")
|
||||||
|
|
||||||
|
-- evaluate instructions
|
||||||
|
local cardIds = {}
|
||||||
|
for str in line:gmatch("([^,]+)") do
|
||||||
|
if instructor == "add:" then
|
||||||
|
slots[str] = (slots[str] or 0) + 1
|
||||||
|
elseif instructor == "remove:" then
|
||||||
|
slots[str] = math.max(slots[str] - 1, 0)
|
||||||
|
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
|
||||||
internal.extractBondedCards = function(slots)
|
internal.extractBondedCards = function(slots)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user