From 4086365b382fe4ed81ff14d7eda096e89c8b1bf7 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Mon, 12 Dec 2022 12:23:36 +0100 Subject: [PATCH 1/5] data for 10 tokens (akachi + brand lvl 4) --- src/core/DataHelper.ttslua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/core/DataHelper.ttslua b/src/core/DataHelper.ttslua index 39fcfcb3..f1d4edc6 100644 --- a/src/core/DataHelper.ttslua +++ b/src/core/DataHelper.ttslua @@ -923,6 +923,18 @@ PLAYER_CARD_TOKEN_OFFSETS = { { 0, 3, 0.5 }, { -0.7, 3, 0.5 } }, + [10] = { + { 0.7, 3, -0.9 }, + { 0, 3, -0.9 }, + { -0.7, 3, -0.9 }, + { 0.7, 3, -0.2 }, + { 0, 3, -0.2 }, + { -0.7, 3, -0.2 }, + { 0.7, 3, 0.5 }, + { 0, 3, 0.5 }, + { -0.7, 3, 0.5 }, + { 0, 3, 1.2 } + }, [12] = { { 0.7, 3, -0.9 }, { 0, 3, -0.9 }, From 62ae162179d61a13a5299c40ae808ab1d109824c Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Mon, 12 Dec 2022 21:00:59 +0100 Subject: [PATCH 2/5] future-proofed with data for 11 uses --- src/core/DataHelper.ttslua | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/core/DataHelper.ttslua b/src/core/DataHelper.ttslua index f1d4edc6..0e933bca 100644 --- a/src/core/DataHelper.ttslua +++ b/src/core/DataHelper.ttslua @@ -935,6 +935,19 @@ PLAYER_CARD_TOKEN_OFFSETS = { { -0.7, 3, 0.5 }, { 0, 3, 1.2 } }, + [11] = { + { 0.7, 3, -0.9 }, + { 0, 3, -0.9 }, + { -0.7, 3, -0.9 }, + { 0.7, 3, -0.2 }, + { 0, 3, -0.2 }, + { -0.7, 3, -0.2 }, + { 0.7, 3, 0.5 }, + { 0, 3, 0.5 }, + { -0.7, 3, 0.5 }, + { -0.35, 3, 1.2 }, + { 0.35, 3, 1.2 } + }, [12] = { { 0.7, 3, -0.9 }, { 0, 3, -0.9 }, From c9087192450aeb88f45518021250a9f1ecf789cf Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Mon, 12 Dec 2022 22:42:12 +0100 Subject: [PATCH 3/5] gave variables better names --- src/playermat/Playmat.ttslua | 12 ++++++------ src/playermat/PlaymatApi.ttslua | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/playermat/Playmat.ttslua b/src/playermat/Playmat.ttslua index 7294d6b5..9d861bf1 100644 --- a/src/playermat/Playmat.ttslua +++ b/src/playermat/Playmat.ttslua @@ -45,14 +45,14 @@ local RESOURCE_COUNTER -- global variable so it can be reset by the Clean Up Helper activeInvestigatorId = "00000" -local drawButton = false +local isDrawButtonVisible = false function onSave() return JSON.encode({ zoneID = zoneID, playerColor = PLAYER_COLOR, activeInvestigatorId = activeInvestigatorId, - drawButton = drawButton + isDrawButtonVisible = isDrawButtonVisible }) end @@ -104,10 +104,10 @@ function onLoad(save_state) zoneID = state.zoneID PLAYER_COLOR = state.playerColor activeInvestigatorId = state.activeInvestigatorId - drawButton = state.drawButton + isDrawButtonVisible = state.isDrawButtonVisible end - showDrawButton(drawButton) + showDrawButton(isDrawButtonVisible) if getObjectFromGUID(zoneID) == nil then spawnDeckZone() end COLLISION_ENABLED = true @@ -662,10 +662,10 @@ end -- Sets this playermat's draw 1 button to visible ---@param visible Boolean. Whether the draw 1 button should be visible function showDrawButton(visible) - drawButton = visible + isDrawButtonVisible = visible -- create the "Draw 1" button - if drawButton then + if isDrawButtonVisible then self.createButton({ label = "Draw 1", click_function = "doDrawOne", diff --git a/src/playermat/PlaymatApi.ttslua b/src/playermat/PlaymatApi.ttslua index a8b0e952..68498fa3 100644 --- a/src/playermat/PlaymatApi.ttslua +++ b/src/playermat/PlaymatApi.ttslua @@ -24,17 +24,17 @@ do end -- Sets the requested playermat's draw 1 button to visible - ---@param visibleButton Boolean. Whether the draw 1 button should be visible or not + ---@param isDrawButtonVisible Boolean. Whether the draw 1 button should be visible or not ---@param matColor String for one of the active player colors - White, Orange, Green, Red. Also -- accepts "All" as a special value which will apply the setting to all four mats. - PlaymatApi.showDrawButton = function(visibleButton, matColor) + PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor) for _, mat in ipairs(internal.getMatForColor(matColor)) do - mat.call("showDrawButton", visibleButton) + mat.call("showDrawButton", isDrawButtonVisible) end end -- Shows or hides the clickable clue counter for the requested playermat - ---@param visibleButton Boolean. Whether the clickable counter should be present or not + ---@param showCounter Boolean. Whether the clickable counter should be present or not ---@param matColor String for one of the active player colors - White, Orange, Green, Red. Also -- accepts "All" as a special value which will apply the setting to all four mats. PlaymatApi.clickableClues = function(showCounter, matColor) From db65f3c8e375d3c761a5ee0e4e26f40f19822510 Mon Sep 17 00:00:00 2001 From: Buhallin Date: Mon, 12 Dec 2022 18:56:04 -0800 Subject: [PATCH 4/5] Add PlayArea API Creates an API object for the PlayArea, and moves most references to the PlayArea to use the API instead. Image swapper is excluded on this, as I'm not completely sure how TTS will handle having an object rebuild itself. --- .../CleanUpHelper.26cf4b.ttslua | 15 ++-- .../CustomPlaymatImages.004fe7.ttslua | 1 - .../DisplacementTool.0f1374.ttslua | 35 ++-------- src/arkhamdb/DeckImporterMain.ttslua | 9 ++- src/core/PlayArea.ttslua | 69 ++++++++++++++++++- src/core/PlayAreaApi.ttslua | 50 ++++++++++++++ 6 files changed, 134 insertions(+), 45 deletions(-) create mode 100644 src/core/PlayAreaApi.ttslua diff --git a/objects/Fan-MadeAccessories.aa8b38/CleanUpHelper.26cf4b.ttslua b/objects/Fan-MadeAccessories.aa8b38/CleanUpHelper.26cf4b.ttslua index a24cde38..ab7d3542 100644 --- a/objects/Fan-MadeAccessories.aa8b38/CleanUpHelper.26cf4b.ttslua +++ b/objects/Fan-MadeAccessories.aa8b38/CleanUpHelper.26cf4b.ttslua @@ -5,6 +5,8 @@ -- - puts everything on playmats and hands into respective trashcans -- - use the IGNORE_TAG to exclude objects from tidying (default: "CleanUpHelper_Ignore") +local playAreaApi = require("core/PlayAreaApi") + -- enable this for debugging local SHOW_RAYS = false @@ -207,10 +209,10 @@ function resetCounters() end -- reset doom on agenda - local doomcounter = getObjectFromGUID("85c4c6") - if doomcounter ~= nil then - doomcounter.call("setToZero") - end + -- local doomcounter = getObjectFromGUID("85c4c6") + -- if doomcounter ~= nil then + -- doomcounter.call("setToZero") + -- end for i, guid in ipairs(TRACKER_GUIDS) do local obj = getObjectFromGUID(guid) @@ -300,10 +302,7 @@ function tidyPlaymatCoroutine() end end - local PLAYMAT = getObjectFromGUID('721ba2') - if PLAYMAT then - PLAYMAT.setTable("SPAWNED_LOCATION_GUIDS", {}) - end + playAreaApi.resetSpawnedCards() printToAll("Tidying playermats and agenda mat...", "White") startLuaCoroutine(self, "tidyPlayerMatCoroutine") diff --git a/objects/Fan-MadeAccessories.aa8b38/CustomPlaymatImages.004fe7.ttslua b/objects/Fan-MadeAccessories.aa8b38/CustomPlaymatImages.004fe7.ttslua index c019395a..5d817f82 100644 --- a/objects/Fan-MadeAccessories.aa8b38/CustomPlaymatImages.004fe7.ttslua +++ b/objects/Fan-MadeAccessories.aa8b38/CustomPlaymatImages.004fe7.ttslua @@ -762,4 +762,3 @@ function removeImages() tile.destruct() end end - diff --git a/objects/Fan-MadeAccessories.aa8b38/DisplacementTool.0f1374.ttslua b/objects/Fan-MadeAccessories.aa8b38/DisplacementTool.0f1374.ttslua index b3c9b3a1..b2989cb1 100644 --- a/objects/Fan-MadeAccessories.aa8b38/DisplacementTool.0f1374.ttslua +++ b/objects/Fan-MadeAccessories.aa8b38/DisplacementTool.0f1374.ttslua @@ -1,15 +1,4 @@ -local excluded = { - ["b7b45b"] = true, - ["f182ee"] = true, - ["721ba2"] = true -} - -local OFFSETS = { - left = { x = 0.00, y = 0, z = 7.67 }, - right = { x = 0.00, y = 0, z = -7.67 }, - up = { x = 6.54, y = 0, z = 0.00 }, - down = { x = -6.54, y = 0, z = 0.00 } -} +local playAreaApi = require("core/PlayAreaApi") local UI_offset = 1.15 @@ -46,24 +35,10 @@ function onLoad() self.createButton(buttonParamaters) end -function shift_left(color) shift(color, "left") end +function shift_left(color) playAreaApi.shiftContentsLeft(color) end -function shift_right(color) shift(color, "right") end +function shift_right(color) playAreaApi.shiftContentsRight(color) end -function shift_up(color) shift(color, "up") end +function shift_up(color) playAreaApi.shiftContentsUp(color) end -function shift_down(color) shift(color, "down") end - -function shift(color, direction) - local zone = getObjectFromGUID("a2f932") - if not zone then - broadcastToColor("Scripting zone couldn't be found.", color, "Red") - return - end - - for _, object in ipairs(zone.getObjects()) do - if not (excluded[object.getGUID()] or object.hasTag("displacement_excluded")) then - object.translate(OFFSETS[direction]) - end - end -end +function shift_down(color) playAreaApi.shiftContentsDown(color) end diff --git a/src/arkhamdb/DeckImporterMain.ttslua b/src/arkhamdb/DeckImporterMain.ttslua index deea3712..88989e68 100644 --- a/src/arkhamdb/DeckImporterMain.ttslua +++ b/src/arkhamdb/DeckImporterMain.ttslua @@ -1,5 +1,6 @@ require("arkhamdb/LoaderUi") require("playercards/PlayerCardSpawner") +local playAreaApi = require("core/PlayAreaApi") local zones = require("playermat/Zones") @@ -33,8 +34,6 @@ customizationRowsWithFields["09101"].inputMap[1] = 1 customizationRowsWithFields["09101"].inputMap[2] = 2 customizationRowsWithFields["09101"].inputMap[3] = 3 -local PLAY_AREA_GUID = "721ba2" - local RANDOM_WEAKNESS_ID = "01000" local tags = { configuration = "import_configuration_provider" } local Priority = { @@ -260,9 +259,9 @@ end -- of those cards which will be spawned function maybeAddOnTheMend(slots) if slots["09006"] ~= nil then - local playArea = getObjectFromGUID(PLAY_AREA_GUID) - if playArea ~= nil then - slots["09006"] = playArea.call("getInvestigatorCount") + local investigatorCount = playAreaApi.getInvestigatorCount() + if investigatorCount ~= nil then + slots["09006"] = investigatorCount end end end diff --git a/src/core/PlayArea.ttslua b/src/core/PlayArea.ttslua index 503cc145..1216e429 100644 --- a/src/core/PlayArea.ttslua +++ b/src/core/PlayArea.ttslua @@ -8,7 +8,21 @@ DEBUG = false -- we use this to turn off collision handling until onLoad() is complete COLLISION_ENABLED = false +local SHIFT_OFFSETS = { + left = { x = 0.00, y = 0, z = 7.67 }, + right = { x = 0.00, y = 0, z = -7.67 }, + up = { x = 6.54, y = 0, z = 0.00 }, + down = { x = -6.54, y = 0, z = 0.00 } +} +local SHIFT_EXCLUSION = { + ["b7b45b"] = true, + ["f182ee"] = true, + ["721ba2"] = true +} + local INVESTIGATOR_COUNTER_GUID = "f182ee" +local PLAY_AREA_ZONE_GUID = "a2f932" + local clueData = {} spawnedLocationGUIDs = {} @@ -122,7 +136,60 @@ function onCollisionEnter(collision_info) end end +-- Move all contents on the play area (cards, tokens, etc) one row up. Certain fixed objects will +-- be ignored, as will anything the player has tagged with 'displacement_excluded' +---@param playerColor Color of the player requesting the shift. Used solely to send an error +--- message in the unlikely case that the scripting zone has been deleted +function shiftContentsUp(playerColor) + shiftContents(playerColor, "up") +end + +-- Move all contents on the play area (cards, tokens, etc) one row down. Certain fixed objects +-- will be ignored, as will anything the player has tagged with 'displacement_excluded' +---@param playerColor Color of the player requesting the shift. Used solely to send an error +--- message in the unlikely case that the scripting zone has been deleted +function shiftContentsDown(playerColor) + shiftContents(playerColor, "down") +end + +-- Move all contents on the play area (cards, tokens, etc) one column left. Certain fixed objects +-- will be ignored, as will anything the player has tagged with 'displacement_excluded' +---@param playerColor Color of the player requesting the shift. Used solely to send an error +--- message in the unlikely case that the scripting zone has been deleted +function shiftContentsLeft(playerColor) + shiftContents(playerColor, "left") +end + +-- Move all contents on the play area (cards, tokens, etc) one column right. Certain fixed +-- objects will be ignored, as will anything the player has tagged with 'displacement_excluded' +---@param playerColor Color of the player requesting the shift. Used solely to send an error +--- message in the unlikely case that the scripting zone has been deleted +function shiftContentsRight(playerColor) + shiftContents(playerColor, "right") +end + +function shiftContents(playerColor, direction) + local zone = getObjectFromGUID(PLAY_AREA_ZONE_GUID) + if not zone then + broadcastToColor("Scripting zone couldn't be found.", playerColor, "Red") + return + end + + for _, object in ipairs(zone.getObjects()) do + if not (SHIFT_EXCLUSION[object.getGUID()] or object.hasTag("displacement_excluded")) then + object.translate(SHIFT_OFFSETS[direction]) + end + end +end + +-- Returns the current value of the investigator counter from the playmat +---@return Integer. Number of investigators currently set on the counter function getInvestigatorCount() - local investigatorCounter = getObjectFromGUID('f182ee') + local investigatorCounter = getObjectFromGUID("f182ee") return investigatorCounter.getVar("val") end + +-- Reset the play area's tracking of which cards have had tokens spawned. +function resetSpawnedCards() + spawnedLocationGUIDs = {} +end diff --git a/src/core/PlayAreaApi.ttslua b/src/core/PlayAreaApi.ttslua new file mode 100644 index 00000000..0107085d --- /dev/null +++ b/src/core/PlayAreaApi.ttslua @@ -0,0 +1,50 @@ +do + local PlayAreaApi = { } + + local PLAY_AREA_GUID = "721ba2" + + -- Returns the current value of the investigator counter from the playmat + ---@return Integer. Number of investigators currently set on the counter + PlayAreaApi.getInvestigatorCount = function() + return getObjectFromGUID(PLAY_AREA_GUID).call("getInvestigatorCount") + end + + -- Move all contents on the play area (cards, tokens, etc) one row up. Certain fixed objects will + -- be ignored, as will anything the player has tagged with 'displacement_excluded' + ---@param playerColor Color of the player requesting the shift. Used solely to send an error + --- message in the unlikely case that the scripting zone has been deleted + PlayAreaApi.shiftContentsUp = function(playerColor) + return getObjectFromGUID(PLAY_AREA_GUID).call("shiftContentsUp", playerColor) + end + + -- Move all contents on the play area (cards, tokens, etc) one row down. Certain fixed objects + -- will be ignored, as will anything the player has tagged with 'displacement_excluded' + ---@param playerColor Color of the player requesting the shift. Used solely to send an error + --- message in the unlikely case that the scripting zone has been deleted + PlayAreaApi.shiftContentsDown = function(playerColor) + return getObjectFromGUID(PLAY_AREA_GUID).call("shiftContentsDown", playerColor) + end + + -- Move all contents on the play area (cards, tokens, etc) one column left. Certain fixed objects + -- will be ignored, as will anything the player has tagged with 'displacement_excluded' + ---@param playerColor Color of the player requesting the shift. Used solely to send an error + --- message in the unlikely case that the scripting zone has been deleted + PlayAreaApi.shiftContentsLeft = function(playerColor) + return getObjectFromGUID(PLAY_AREA_GUID).call("shiftContentsLeft", playerColor) + end + + -- Move all contents on the play area (cards, tokens, etc) one column right. Certain fixed + -- objects will be ignored, as will anything the player has tagged with 'displacement_excluded' + ---@param playerColor Color of the player requesting the shift. Used solely to send an error + --- message in the unlikely case that the scripting zone has been deleted + PlayAreaApi.shiftContentsRight = function(playerColor) + return getObjectFromGUID(PLAY_AREA_GUID).call("shiftContentsRight", playerColor) + end + + -- Reset the play area's tracking of which cards have had tokens spawned. + PlayAreaApi.resetSpawnedCards = function() + return getObjectFromGUID(PLAY_AREA_GUID).call("resetSpawnedCards") + end + + return PlayAreaApi +end From c8cec711094b01535d0df2794a6e87b1f01f9d10 Mon Sep 17 00:00:00 2001 From: Buhallin Date: Tue, 13 Dec 2022 02:15:16 -0800 Subject: [PATCH 5/5] Handle review comments --- src/arkhamdb/DeckImporterMain.ttslua | 8 ++++++-- src/core/PlayArea.ttslua | 17 +++-------------- src/core/PlayAreaApi.ttslua | 17 +++-------------- 3 files changed, 12 insertions(+), 30 deletions(-) diff --git a/src/arkhamdb/DeckImporterMain.ttslua b/src/arkhamdb/DeckImporterMain.ttslua index 88989e68..4d568269 100644 --- a/src/arkhamdb/DeckImporterMain.ttslua +++ b/src/arkhamdb/DeckImporterMain.ttslua @@ -151,7 +151,7 @@ local function onDeckResult(deck, playerColor, configuration) maybeAddInvestigatorCards(deck, slots) maybeAddCustomizeUpgradeSheets(slots, configuration) maybeAddSummonedServitor(slots) - maybeAddOnTheMend(slots) + maybeAddOnTheMend(slots, playerColor) extractBondedCards(slots, configuration) checkTaboos(deck.taboo_id, slots, playerColor, configuration) @@ -257,11 +257,15 @@ end -- the count based on the investigator count ---@param slots: The slot list for cards in this deck. Table key is the cardId, value is the number -- of those cards which will be spawned -function maybeAddOnTheMend(slots) +---@param playerColor: Color name of the player this deck is being loaded for. Used for broadcast if an error occurs +function maybeAddOnTheMend(slots, playerColor) if slots["09006"] ~= nil then local investigatorCount = playAreaApi.getInvestigatorCount() if investigatorCount ~= nil then slots["09006"] = investigatorCount + else + debugPrint("Something went wrong with the load, adding 4 copies of On the Mend", Priority.INFO, playerColor) + slots["09006"] = 4 end end end diff --git a/src/core/PlayArea.ttslua b/src/core/PlayArea.ttslua index 1216e429..adf67ee9 100644 --- a/src/core/PlayArea.ttslua +++ b/src/core/PlayArea.ttslua @@ -136,34 +136,23 @@ function onCollisionEnter(collision_info) end end --- Move all contents on the play area (cards, tokens, etc) one row up. Certain fixed objects will --- be ignored, as will anything the player has tagged with 'displacement_excluded' +-- Move all contents on the play area (cards, tokens, etc) one slot in the given direction. Certain +-- fixed objects will be ignored, as will anything the player has tagged with +-- 'displacement_excluded' ---@param playerColor Color of the player requesting the shift. Used solely to send an error --- message in the unlikely case that the scripting zone has been deleted function shiftContentsUp(playerColor) shiftContents(playerColor, "up") end --- Move all contents on the play area (cards, tokens, etc) one row down. Certain fixed objects --- will be ignored, as will anything the player has tagged with 'displacement_excluded' ----@param playerColor Color of the player requesting the shift. Used solely to send an error ---- message in the unlikely case that the scripting zone has been deleted function shiftContentsDown(playerColor) shiftContents(playerColor, "down") end --- Move all contents on the play area (cards, tokens, etc) one column left. Certain fixed objects --- will be ignored, as will anything the player has tagged with 'displacement_excluded' ----@param playerColor Color of the player requesting the shift. Used solely to send an error ---- message in the unlikely case that the scripting zone has been deleted function shiftContentsLeft(playerColor) shiftContents(playerColor, "left") end --- Move all contents on the play area (cards, tokens, etc) one column right. Certain fixed --- objects will be ignored, as will anything the player has tagged with 'displacement_excluded' ----@param playerColor Color of the player requesting the shift. Used solely to send an error ---- message in the unlikely case that the scripting zone has been deleted function shiftContentsRight(playerColor) shiftContents(playerColor, "right") end diff --git a/src/core/PlayAreaApi.ttslua b/src/core/PlayAreaApi.ttslua index 0107085d..1fd9d54a 100644 --- a/src/core/PlayAreaApi.ttslua +++ b/src/core/PlayAreaApi.ttslua @@ -9,34 +9,23 @@ do return getObjectFromGUID(PLAY_AREA_GUID).call("getInvestigatorCount") end - -- Move all contents on the play area (cards, tokens, etc) one row up. Certain fixed objects will - -- be ignored, as will anything the player has tagged with 'displacement_excluded' + -- Move all contents on the play area (cards, tokens, etc) one slot in the given direction. Certain + -- fixed objects will be ignored, as will anything the player has tagged with + -- 'displacement_excluded' ---@param playerColor Color of the player requesting the shift. Used solely to send an error --- message in the unlikely case that the scripting zone has been deleted PlayAreaApi.shiftContentsUp = function(playerColor) return getObjectFromGUID(PLAY_AREA_GUID).call("shiftContentsUp", playerColor) end - -- Move all contents on the play area (cards, tokens, etc) one row down. Certain fixed objects - -- will be ignored, as will anything the player has tagged with 'displacement_excluded' - ---@param playerColor Color of the player requesting the shift. Used solely to send an error - --- message in the unlikely case that the scripting zone has been deleted PlayAreaApi.shiftContentsDown = function(playerColor) return getObjectFromGUID(PLAY_AREA_GUID).call("shiftContentsDown", playerColor) end - -- Move all contents on the play area (cards, tokens, etc) one column left. Certain fixed objects - -- will be ignored, as will anything the player has tagged with 'displacement_excluded' - ---@param playerColor Color of the player requesting the shift. Used solely to send an error - --- message in the unlikely case that the scripting zone has been deleted PlayAreaApi.shiftContentsLeft = function(playerColor) return getObjectFromGUID(PLAY_AREA_GUID).call("shiftContentsLeft", playerColor) end - -- Move all contents on the play area (cards, tokens, etc) one column right. Certain fixed - -- objects will be ignored, as will anything the player has tagged with 'displacement_excluded' - ---@param playerColor Color of the player requesting the shift. Used solely to send an error - --- message in the unlikely case that the scripting zone has been deleted PlayAreaApi.shiftContentsRight = function(playerColor) return getObjectFromGUID(PLAY_AREA_GUID).call("shiftContentsRight", playerColor) end