Support for long mini-IDs

This commit is contained in:
Chr1Z93 2024-09-12 19:59:05 +02:00
parent bcce50caa4
commit b815a998db
3 changed files with 18 additions and 8 deletions

View File

@ -260,10 +260,9 @@ function returnMiniCards()
-- move mini cards -- move mini cards
for _, matColor in ipairs(COLORS) do for _, matColor in ipairs(COLORS) do
local data = playermatApi.getActiveInvestigatorData(matColor) local data = playermatApi.getActiveInvestigatorData(matColor)
local miniId = data.id .. "-m" if miniCardIndex[data.miniId] then
if miniCardIndex[miniId] then
local pos = playermatApi.transformLocalPosition(Vector(-1.36, 0, -0.625), matColor) local pos = playermatApi.transformLocalPosition(Vector(-1.36, 0, -0.625), matColor)
miniCardIndex[miniId].setPosition(pos:setAt("y", 1.67)) miniCardIndex[data.miniId].setPosition(pos:setAt("y", 1.67))
end end
end end
end end
@ -367,7 +366,7 @@ function tidyPlayerMatCoroutine()
end end
-- reset "activeInvestigatorId" and "...class" -- reset "activeInvestigatorId" and "...class"
playermatApi.setActiveInvestigatorData("All", {class = "Neutral", id = "00000"}) playermatApi.setActiveInvestigatorData("All", { class = "Neutral", id = "00000", miniId = "00000-m" })
playermatApi.updateTexture("All") playermatApi.updateTexture("All")
end end

View File

@ -455,7 +455,7 @@ function removeBusyZones(playerColor, zoneDecks)
-- check for existing minicard -- check for existing minicard
local mat = guidReferenceApi.getObjectByOwnerAndType(playerColor, "Playermat") local mat = guidReferenceApi.getObjectByOwnerAndType(playerColor, "Playermat")
local activeInvestigatorData = playermatApi.getActiveInvestigatorData(playerColor) local activeInvestigatorData = playermatApi.getActiveInvestigatorData(playerColor)
local miniId = activeInvestigatorData.id .. "-m" local miniId = activeInvestigatorData.miniId
-- remove taboo suffix since we don't have this for minicards -- remove taboo suffix since we don't have this for minicards
miniId = miniId:gsub("-t", "") miniId = miniId:gsub("-t", "")

View File

@ -387,12 +387,10 @@ function doUpkeep(_, clickedByColor, isRightClick)
end end
-- flip investigator mini-card and summoned servitor mini-card -- flip investigator mini-card and summoned servitor mini-card
-- (all characters allowed to account for custom IDs - e.g. 'Z0000' for TTS Zoop generated IDs)
local miniId = string.match(activeInvestigatorData.id, ".....") .. "-m"
for _, obj in ipairs(getObjects()) do for _, obj in ipairs(getObjects()) do
if obj.type == "Card" and obj.is_face_down then if obj.type == "Card" and obj.is_face_down then
local notes = JSON.decode(obj.getGMNotes()) local notes = JSON.decode(obj.getGMNotes())
if notes ~= nil and notes.type == "Minicard" and (notes.id == miniId or notes.id == "09080-m") then if notes ~= nil and notes.type == "Minicard" and (notes.id == activeInvestigatorData.miniId or notes.id == "09080-m") then
obj.flip() obj.flip()
end end
end end
@ -1219,6 +1217,7 @@ function maybeUpdateActiveInvestigator(card)
if notes.id == activeInvestigatorData.id then return end if notes.id == activeInvestigatorData.id then return end
activeInvestigatorData.class = notes.class activeInvestigatorData.class = notes.class
activeInvestigatorData.id = notes.id activeInvestigatorData.id = notes.id
activeInvestigatorData.miniId = getMiniId(notes.id)
extraToken = notes.extraToken extraToken = notes.extraToken
ownedObjects.InvestigatorSkillTracker.call("updateStats", { ownedObjects.InvestigatorSkillTracker.call("updateStats", {
notes.willpowerIcons, notes.willpowerIcons,
@ -1230,6 +1229,7 @@ function maybeUpdateActiveInvestigator(card)
elseif activeInvestigatorData.id ~= "00000" then elseif activeInvestigatorData.id ~= "00000" then
activeInvestigatorData.class = "Neutral" activeInvestigatorData.class = "Neutral"
activeInvestigatorData.id = "00000" activeInvestigatorData.id = "00000"
activeInvestigatorData.miniId = "00000-m"
ownedObjects.InvestigatorSkillTracker.call("updateStats", { 1, 1, 1, 1 }) ownedObjects.InvestigatorSkillTracker.call("updateStats", { 1, 1, 1, 1 })
updateTexture() updateTexture()
else else
@ -1284,6 +1284,17 @@ function maybeUpdateActiveInvestigator(card)
end end
end end
-- returns the mini ID for the currently placed investigator
function getMiniId(baseId)
if #baseId < 16 then
-- use the first 5 characters to exclude suffixes
return string.match(baseId, ".....") .. "-m"
else
-- use the full ID (long -> assume it's from Zoop)
return baseId .. "-m"
end
end
-- updates the texture of the playermat -- updates the texture of the playermat
---@param overrideName? string Force a specific texture ---@param overrideName? string Force a specific texture
function updateTexture(overrideName) function updateTexture(overrideName)