From b815a998db1f5273982aa106b0b5f421e0c967b1 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Thu, 12 Sep 2024 19:59:05 +0200 Subject: [PATCH] Support for long mini-IDs --- src/accessories/CleanUpHelper.ttslua | 7 +++---- src/arkhamdb/DeckImporter.ttslua | 2 +- src/playermat/Playermat.ttslua | 17 ++++++++++++++--- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/accessories/CleanUpHelper.ttslua b/src/accessories/CleanUpHelper.ttslua index 0d0ae94c..a42fd377 100644 --- a/src/accessories/CleanUpHelper.ttslua +++ b/src/accessories/CleanUpHelper.ttslua @@ -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 diff --git a/src/arkhamdb/DeckImporter.ttslua b/src/arkhamdb/DeckImporter.ttslua index d1839c51..64fd4dca 100644 --- a/src/arkhamdb/DeckImporter.ttslua +++ b/src/arkhamdb/DeckImporter.ttslua @@ -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", "") diff --git a/src/playermat/Playermat.ttslua b/src/playermat/Playermat.ttslua index 4f1696c0..98e5aec3 100644 --- a/src/playermat/Playermat.ttslua +++ b/src/playermat/Playermat.ttslua @@ -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)