Added ArkhamDB Importer support for SS upgrade sheet changes, and minor refactor on code logic for the same

This commit is contained in:
Jorge Parra 2023-03-16 15:27:33 -04:00
parent da2dd66966
commit ed9d8c2614
3 changed files with 36 additions and 26 deletions

View File

@ -34,7 +34,7 @@
"LayoutGroupSortIndex": 0, "LayoutGroupSortIndex": 0,
"Locked": false, "Locked": false,
"LuaScript": "require(\"playercards/customizable/SummonedServitorUpgradeSheet\")", "LuaScript": "require(\"playercards/customizable/SummonedServitorUpgradeSheet\")",
"LuaScriptState": "[[0,0,0,0,0,0,0,0,0,0],[\"\",\"\",\"\",\"\",\"\"],\"\"]", "LuaScriptState": "[[0,0,0,0,0,0,0,0,0,0],[\"\"]]",
"MeasureMovement": false, "MeasureMovement": false,
"Name": "CardCustom", "Name": "CardCustom",
"Nickname": "Summoned Servitor Upgrade Sheet", "Nickname": "Summoned Servitor Upgrade Sheet",

View File

@ -5,7 +5,7 @@ local playAreaApi = require("core/PlayAreaApi")
local arkhamDb = require("arkhamdb/ArkhamDb") local arkhamDb = require("arkhamdb/ArkhamDb")
local zones = require("playermat/Zones") local zones = require("playermat/Zones")
local DEBUG = false local DEBUG = true
local ALL_CARDS_GUID = "15bb07" local ALL_CARDS_GUID = "15bb07"
@ -30,6 +30,11 @@ customizationRowsWithFields["09079"].inputMap = {}
customizationRowsWithFields["09079"].inputMap[1] = 1 customizationRowsWithFields["09079"].inputMap[1] = 1
customizationRowsWithFields["09079"].inputMap[5] = 2 customizationRowsWithFields["09079"].inputMap[5] = 2
customizationRowsWithFields["09079"].inputMap[6] = 3 customizationRowsWithFields["09079"].inputMap[6] = 3
-- Summoned Servitor
customizationRowsWithFields["09080"] = {}
customizationRowsWithFields["09080"].inputCount = 1
customizationRowsWithFields["09080"].inputMap = {}
customizationRowsWithFields["09080"].inputMap[6] = 1
-- Grizzled -- Grizzled
customizationRowsWithFields["09101"] = {} customizationRowsWithFields["09101"] = {}
customizationRowsWithFields["09101"].inputCount = 3 customizationRowsWithFields["09101"].inputCount = 3
@ -372,6 +377,9 @@ function handleCustomizableUpgrades(cardList, customizations)
table.insert(inputValues, "") table.insert(inputValues, "")
end end
end end
for key, value in pairs(inputValues) do
log("Key " .. key.." Value " .. value)
end
local inputCount = 0 local inputCount = 0
for _, entry in ipairs(index_xp) do for _, entry in ipairs(index_xp) do
local counter = 0 local counter = 0
@ -389,15 +397,19 @@ function handleCustomizableUpgrades(cardList, customizations)
inputValues[customizationRowsWithFields[baseId].inputMap[index]] = convertRavenQuillSelections(str) inputValues[customizationRowsWithFields[baseId].inputMap[index]] = convertRavenQuillSelections(str)
elseif customizationRowsWithFields[baseId] ~= nil then elseif customizationRowsWithFields[baseId] ~= nil then
inputValues[customizationRowsWithFields[baseId].inputMap[index]] = str inputValues[customizationRowsWithFields[baseId].inputMap[index]] = str
log(str)
end end
end end
end end
end end
-- remove first entry in markedBoxes if row 0 has textbox -- remove first entry in markedBoxes if row 0 has textbox
if customizationRowsWithFields[baseId] ~= nil if customizationRowsWithFields[baseId] ~= nil and customizationRowsWithFields[baseId].inputCount > 0 then
and customizationRowsWithFields[baseId].inputCount > 0 then if (baseId == "09080" and markedBoxes[6] == 2 and inputValues[customizationRowsWithFields[baseId].inputMap[6]] == "") then
table.remove(markedBoxes, 1) inputValues[customizationRowsWithFields[baseId].inputMap[6]] = "0"
else
table.remove(markedBoxes, 1)
end
end end
-- write the loaded values to the save_data of the sheets -- write the loaded values to the save_data of the sheets

View File

@ -35,9 +35,12 @@ inputBoxes = {}
local SLOT_ICON_POSITIONS = { local SLOT_ICON_POSITIONS = {
arcane = { x = 0.160, z = 0.65}, arcane = { x = 0.160, z = 0.65},
ally = { x = -0.073, z = 0.65} ally = { x = -0.073, z = 0.65}
} }
local selectedSlot = "" -- These match with ArkhamDB's way of storing the data in the dropdown menu
local slotIndices = {arcane = "1", ally = "0", none = ""}
local selectedSlot = slotIndices.none
-- override 'marked boxes' for debugging ('all' or 'none') -- override 'marked boxes' for debugging ('all' or 'none')
markDEBUG = "" markDEBUG = ""
@ -45,22 +48,17 @@ markDEBUG = ""
-- save state when going into bags / decks -- save state when going into bags / decks
function onDestroy() self.script_state = onSave() end function onDestroy() self.script_state = onSave() end
function onSave() return JSON.encode({ markedBoxes, inputValues, selectedSlot }) end function onSave() return JSON.encode({ markedBoxes, {selectedSlot} }) end
-- Startup procedure -- Startup procedure
function onLoad(saved_data) function onLoad(saved_data)
if saved_data ~= "" and markDEBUG == "" then if saved_data ~= "" and markDEBUG == "" then
local loaded_data = JSON.decode(saved_data) local loaded_data = JSON.decode(saved_data)
markedBoxes = loaded_data[1] markedBoxes = loaded_data[1]
inputValues = loaded_data[2] selectedSlot = loaded_data[2][1]
if #loaded_data > 2 then
selectedSlot = loaded_data[3]
else
selectedSlot = ""
end
else else
markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
inputValues = { "", "", "", "", "" } selectedSlot = ""
end end
makeData() makeData()
@ -214,22 +212,22 @@ function makeSlotSelectionButtons()
buttonPositions.x = -1 * SLOT_ICON_POSITIONS.ally.x buttonPositions.x = -1 * SLOT_ICON_POSITIONS.ally.x
buttonData.position = buttonPositions buttonData.position = buttonPositions
self.createButton(buttonData) self.createButton(buttonData)
end end
function click_arcane() function click_arcane()
if selectedSlot ~= "arcane" then if selectedSlot == slotIndices.arcane then
selectedSlot = "arcane" selectedSlot = slotIndices.none
else else
selectedSlot = "" selectedSlot = slotIndices.arcane
end end
updateSlotDisplay() updateSlotDisplay()
end end
function click_ally() function click_ally()
if selectedSlot ~= "ally" then if selectedSlot == slotIndices.ally then
selectedSlot = "ally" selectedSlot = slotIndices.none
else else
selectedSlot = "" selectedSlot = slotIndices.ally
end end
updateSlotDisplay() updateSlotDisplay()
end end
@ -256,9 +254,9 @@ function updateSlotDisplay()
} }
local arcaneVecColor = {0.5, 0.5, 0.5, 0.75} local arcaneVecColor = {0.5, 0.5, 0.5, 0.75}
local allyVecColor = {0.5, 0.5, 0.5, 0.75} local allyVecColor = {0.5, 0.5, 0.5, 0.75}
if selectedSlot == "arcane" then if selectedSlot == slotIndices.arcane then
arcaneVecColor = {0.597, 0.195, 0.796} arcaneVecColor = {0.597, 0.195, 0.796}
elseif selectedSlot == "ally" then elseif selectedSlot == slotIndices.ally then
allyVecColor = {0.597, 0.195, 0.796} allyVecColor = {0.597, 0.195, 0.796}
end end