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
for _, matColor in ipairs(COLORS) do
local data = playermatApi.getActiveInvestigatorData(matColor)
local miniId = data.id .. "-m"
if miniCardIndex[miniId] then
if miniCardIndex[data.miniId] then
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
@ -367,7 +366,7 @@ function tidyPlayerMatCoroutine()
end
-- reset "activeInvestigatorId" and "...class"
playermatApi.setActiveInvestigatorData("All", {class = "Neutral", id = "00000"})
playermatApi.setActiveInvestigatorData("All", { class = "Neutral", id = "00000", miniId = "00000-m" })
playermatApi.updateTexture("All")
end

View File

@ -455,7 +455,7 @@ function removeBusyZones(playerColor, zoneDecks)
-- check for existing minicard
local mat = guidReferenceApi.getObjectByOwnerAndType(playerColor, "Playermat")
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
miniId = miniId:gsub("-t", "")

View File

@ -387,12 +387,10 @@ function doUpkeep(_, clickedByColor, isRightClick)
end
-- 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
if obj.type == "Card" and obj.is_face_down then
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()
end
end
@ -1219,6 +1217,7 @@ function maybeUpdateActiveInvestigator(card)
if notes.id == activeInvestigatorData.id then return end
activeInvestigatorData.class = notes.class
activeInvestigatorData.id = notes.id
activeInvestigatorData.miniId = getMiniId(notes.id)
extraToken = notes.extraToken
ownedObjects.InvestigatorSkillTracker.call("updateStats", {
notes.willpowerIcons,
@ -1230,6 +1229,7 @@ function maybeUpdateActiveInvestigator(card)
elseif activeInvestigatorData.id ~= "00000" then
activeInvestigatorData.class = "Neutral"
activeInvestigatorData.id = "00000"
activeInvestigatorData.miniId = "00000-m"
ownedObjects.InvestigatorSkillTracker.call("updateStats", { 1, 1, 1, 1 })
updateTexture()
else
@ -1284,6 +1284,17 @@ function maybeUpdateActiveInvestigator(card)
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
---@param overrideName? string Force a specific texture
function updateTexture(overrideName)