diff --git a/config.json b/config.json index 6ee6a71d..5f705f5d 100644 --- a/config.json +++ b/config.json @@ -231,7 +231,7 @@ 0, 0 ], - "SaveName": "Arkham SCE - 3.9.2", + "SaveName": "Arkham SCE - 4.0.0", "Sky": "Sky_Museum", "SkyURL": "https://i.imgur.com/GkQqaOF.jpg", "SnapPoints_path": "SnapPoints.json", diff --git a/objects/AllPlayerCards.15bb07/Dream-EnhancingSerum.98c5af.json b/objects/AllPlayerCards.15bb07/Dream-EnhancingSerum.98c5af.json index af8bd8d0..6965b777 100644 --- a/objects/AllPlayerCards.15bb07/Dream-EnhancingSerum.98c5af.json +++ b/objects/AllPlayerCards.15bb07/Dream-EnhancingSerum.98c5af.json @@ -33,7 +33,7 @@ "IgnoreFoW": false, "LayoutGroupSortIndex": 0, "Locked": false, - "LuaScript": "", + "LuaScript": "require(\"playercards/cards/DreamEnhancingSerum\")", "LuaScriptState": "", "MeasureMovement": false, "Name": "Card", diff --git a/objects/OptionPanelSource.830bd0/HandHelper.450688.json b/objects/OptionPanelSource.830bd0/HandHelper.450688.json index 7513d75d..1aa8efe4 100644 --- a/objects/OptionPanelSource.830bd0/HandHelper.450688.json +++ b/objects/OptionPanelSource.830bd0/HandHelper.450688.json @@ -22,7 +22,7 @@ "ImageURL": "https://steamusercontent-a.akamaihd.net/ugc/1704036721123215146/E44A3B99EACF310E49E94977151A03C9A3DC7F17/", "WidthScale": 0 }, - "Description": "Displays the hand size (total or by title for \"Dream Enhancing Serum\" - hover over it to see the regular count).\n\nAllows you to randomly discard a card from your hand.", + "Description": "Displays your hand size. For Dream-Enhacing Serum, use the helper on that card.", "DragSelectable": true, "GMNotes": "", "GUID": "450688", diff --git a/objects/PatchNotes.f47225.luascriptstate b/objects/PatchNotes.f47225.luascriptstate index 5228f7b6..1b3c8696 100644 --- a/objects/PatchNotes.f47225.luascriptstate +++ b/objects/PatchNotes.f47225.luascriptstate @@ -85,7 +85,7 @@ }, "tooltip": "None", "value": [ - "Arkham Horror LCG SCE 3.9.2 - 08/17/2024" + "Arkham Horror LCG SCE 4.0.0 - ??/??/2024" ] }, { @@ -124,7 +124,7 @@ }, "tooltip": "None", "value": [ - "Minor release notes (3.9.2)\n- Added player specific option panel (search for the gear icon on your mat)!\n- Added 'Ready Cards' button to Play Area (mainly to ready enemies)\n- Added a button to the Mythos Area to copy the scenario reference card for each\nplayermat with an investigator\n- Added the 'Card Back Enhancer'! This new tool can update cards/decks with outdated\nplayer or scenario card backs by dropping them on it (located near the Deck Importer)\n- Improved custom card handling for PlayerCard Panel\n(with a new metadata field this can also detect signatures)\n- Updated the Deck Instruction Generator! Now it outputs to the Notebook.\n- Updated counters and Search Assistant to work with number typing while hovering them\n- Myriad of Bugfixes (for example the removal of the additional upkeep resource for parallel Jenny)\n\nMinor release notes (3.9.1)\n- Added Parallel Jenny!\n- Re-Added Learn to Play PDF to table\n- Fixed bug with \"Remove one Use\" gamekey\n- Updated clue replenishing to locations via hotkey (Numpad 8)\n- Updated Deck Importer (arkham.build support and better RBW drawing)\n- Updated Search Assistant to properly handle a revealed top card (looking at Norman)\n\nMain release notes (3.9.0) - highlights only\n- updated note card for patch notes (bless Marum for his awesome tool!)\n- automated discarding for Patrice\n- confirmation dialog for discard hotkey (e.g. for locations)\n- helpers for cards that redraw tokens and Kohaku\n- displaying of token count for cards that seal tokens\n- new action / ability tokens (replacing the old ones)\n- option to enable all card helpers (e.g. Heavy Furs)\n- option to load class-colored playermat backgrounds\n- coloring for player names in broadcasts\n- right-click option for RBW button on Player Card Panel to specify trait(s)" + "" ] } ], diff --git a/src/accessories/HandHelper.ttslua b/src/accessories/HandHelper.ttslua index 0d9a2dde..a334b733 100644 --- a/src/accessories/HandHelper.ttslua +++ b/src/accessories/HandHelper.ttslua @@ -11,25 +11,18 @@ function onLoad() buttonParameters.hover_color = "White" buttonParameters.label = 0 buttonParameters.click_function = "none" - buttonParameters.position = Vector(0, 0.11, -0.2) + buttonParameters.position = Vector(0, 0.11, 0) buttonParameters.height = 0 buttonParameters.width = 0 buttonParameters.font_size = 1000 buttonParameters.font_color = "White" self.createButton(buttonParameters) - -- index 1: button to toggle "DES" - buttonParameters.label = "DES: ✗" - buttonParameters.position.z = 0.6 - buttonParameters.font_size = 200 - self.createButton(buttonParameters) - -- make sure this part executes after the playermats are loaded Wait.time(function() updateColors() -- start loop to update card count - playermatApi.checkForDES(matColor) Wait.time(updateValue, 1, -1) end, 1) end @@ -37,19 +30,6 @@ end -- updates colors when object is dropped somewhere function onDrop() updateColors() end --- disables DES counting while hovered -function onObjectHover(hoverColor, object) - if hoverColor ~= handColor then return end - - if object == self then - hovering = true - playermatApi.checkForDES(matColor) - updateValue() - else - hovering = false - end -end - -- updates the matcolor and handcolor variable function updateColors() matColor = playermatApi.getMatColorByPosition(self.getPosition()) @@ -57,7 +37,7 @@ function updateColors() self.setName(handColor .. " Hand Helper") end --- count cards in hand (by name for DES) +-- count cards in hand function updateValue() -- update colors if handColor doesn't own a handzone if Player[handColor].getHandCount() == 0 then @@ -70,40 +50,18 @@ function updateValue() -- if there is still no handzone, then end here if Player[handColor].getHandCount() == 0 then return end - -- get state of "Dream-Enhancing Serum" from playermat - local hasDES = playermatApi.hasDES(matColor) - - -- default to regular count if hovered - if hovering then - hasDES = false - end - - self.editButton({ index = 1, label = "DES: " .. (hasDES and "✓" or "✗") }) - -- count cards in hand local hand = Player[handColor].getHandObjects() local size = 0 - if hasDES then - local cardHash = {} - for _, obj in pairs(hand) do - if obj.type == "Card" then - local name = obj.getName() - local title = string.match(name, '(.+)(%s%(%d+%))') or name - cardHash[title] = true - end - end - for _, title in pairs(cardHash) do + + for _, obj in pairs(hand) do + if obj.type == "Card" then size = size + 1 end - else - for _, obj in pairs(hand) do - if obj.type == "Card" then - size = size + 1 - end - end end -- update button label and color - self.editButton({ index = 0, font_color = hasDES and "Green" or "White", label = size }) + self.editButton({ index = 0, font_color = "White", label = size }) end + \ No newline at end of file diff --git a/src/core/GameKeyHandler.ttslua b/src/core/GameKeyHandler.ttslua index ea808cc0..5e8e5def 100644 --- a/src/core/GameKeyHandler.ttslua +++ b/src/core/GameKeyHandler.ttslua @@ -50,7 +50,8 @@ function triggerUpkeepMultihanded(playerColor) local colors = Player.getAvailableColors() for _, handColor in ipairs(colors) do local matColor = playermatApi.getMatColor(handColor) - if playermatApi.returnInvestigatorId(matColor) ~= "00000" and Player[handColor].seated == false then + local data = playermatApi.getActiveInvestigatorData(matColor) + if data.id ~= "00000" and Player[handColor].seated == false then playermatApi.doUpkeepFromHotkey(matColor, playerColor) end end diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 3625c798..1870d2b4 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -40,8 +40,8 @@ local bagSearchers = {} local hideTitleSplashWaitFunctionId = nil -- online functionality related variables -local MOD_VERSION = "3.9.2" -local SOURCE_REPO = "https://github.com/Chr1Z93/SCED-downloads/releases/latest/download/" +local MOD_VERSION = "4.0.0" +local SOURCE_REPO = 'https://raw.githubusercontent.com/chr1z93/loadable-objects/main' local library, requestObj, modMeta local acknowledgedUpgradeVersions = {} local contentToShow = "campaign" diff --git a/src/core/PlayArea.ttslua b/src/core/PlayArea.ttslua index 484acd90..e80fceac 100644 --- a/src/core/PlayArea.ttslua +++ b/src/core/PlayArea.ttslua @@ -560,12 +560,12 @@ function readyCards(player, clickType) end end - local cardString = " cards " + local cardString = " cards" if count == 1 then - cardString = " card " + cardString = " card" end - broadcastToAll("Readied " .. count .. cardString .. " in Play Area") + broadcastToAll("Play Area: Readied " .. count .. cardString) end --------------------------------------------------------- diff --git a/src/playercards/cards/DreamEnhancingSerum.ttslua b/src/playercards/cards/DreamEnhancingSerum.ttslua new file mode 100644 index 00000000..ecfc8ad6 --- /dev/null +++ b/src/playercards/cards/DreamEnhancingSerum.ttslua @@ -0,0 +1,130 @@ +require("playercards/CardsWithHelper") +local playermatApi = require("playermat/PlayermatApi") +local matColor, handColor, loopId + +-- intentionally global +hasXML = true +isHelperEnabled = false + +function updateSave() + self.script_state = JSON.encode({ isHelperEnabled = isHelperEnabled, loopId = loopId }) +end + +function onLoad(savedData) + if savedData and savedData ~= "" then + local loadedData = JSON.decode(savedData) + isHelperEnabled = loadedData.isHelperEnabled + loopId = loadedData.loopId + end + updateColors() + createHelperXML() + syncDisplayWithOptionPanel() +end + +function initialize() + updateValue() + loopId = Wait.time(updateValue, 2, -1) +end + +function shutOff() + if loopId then + Wait.stop(loopId) + loopId = nil + end +end + +function createHelperXML() + local xmlTable = { { + tag = "VerticalLayout", + attributes = { + active = "false", + id = "Helper", + height = 1200, + width = 1200, + rotation = "0 0 180", + scale = "0.1 0.1 1", + position = "0 -55 -22", + padding = "30 30 30 30", + color = "#3D3C3AE6", + }, + children = { { + tag = "Panel", + attributes = { + preferredHeight="300" + }, + children = { { + tag = "Text", + attributes = { + text = "DES count:", + color = "White", + font = "font_teutonic-arkham", + fontsize = "200" + } + }} + }, + { + tag = "Panel", + attributes = { + preferredHeight="900" + }, + children = { { + tag = "Text", + attributes = { + id = "Count", + fontSize = "700", + scale = "2.2 2.2 1", + color = "Green", + font = "font_teutonic-arkham", + text = 0 + } + }} + } + } + } } + self.UI.setXmlTable(xmlTable) +end + +------------------------ +-- counting functions +------------------------ + +function onDrop() + updateColors() +end + +-- updates the matcolor and handcolor variable +function updateColors() + matColor = playermatApi.getMatColorByPosition(self.getPosition()) + handColor = playermatApi.getPlayerColor(matColor) +end + +function updateValue() + -- update colors if handColor doesn't own a handzone + if Player[handColor].getHandCount() == 0 then + updateColors() + end + + -- if one of the colors is undefined, then end here + if matColor == nil or handColor == nil then return end + + -- if there is still no handzone, then end here + if Player[handColor].getHandCount() == 0 then return end + + -- count cards in hand + local hand = Player[handColor].getHandObjects() + + local cardHash = {} + for _, obj in pairs(hand) do + if obj.type == "Card" then + local name = obj.getName() + local title = string.match(name, '(.+)(%s%(%d+%))') or name + cardHash[title] = true + end + end + + local size = 0 + for _, title in pairs(cardHash) do + size = size + 1 + end + self.UI.setAttribute("Count", "text", size) +end diff --git a/src/playercards/cards/WellConnected.ttslua b/src/playercards/cards/WellConnected.ttslua index 8f8653f2..3d42f2ca 100644 --- a/src/playercards/cards/WellConnected.ttslua +++ b/src/playercards/cards/WellConnected.ttslua @@ -2,20 +2,11 @@ require("playercards/CardsWithHelper") local playermatApi = require("playermat/PlayermatApi") -- intentionally global -hasXML = false +hasXML = true isHelperEnabled = false local modValue, loopId -local buttonParameters = { - click_function = "shutOff", - function_owner = self, - position = { 0.88, 0.5, -1.33 }, - font_size = 150, - width = 175, - height = 175 -} - function updateSave() self.script_state = JSON.encode({ isHelperEnabled = isHelperEnabled, @@ -37,14 +28,13 @@ function onLoad(savedData) modValue = 4 end + createHelperXML() syncDisplayWithOptionPanel() end function initialize() - self.clearButtons() - self.createButton(buttonParameters) - updateButton() - loopId = Wait.time(updateButton, 2, -1) + updateValue() + loopId = Wait.time(updateValue, 2, -1) end function shutOff() @@ -55,9 +45,37 @@ function shutOff() end end -function updateButton() +function createHelperXML() + local xmlTable = { { + tag = "Panel", + attributes = { + active = "false", + id = "Helper", + height = 155, + width = 155, + rotation = "0 0 180", + scale = "0.18 0.18 1", + position = "-89 109 -22", + padding = "10 10 10 10", + color = "#134201E6", + }, + children = { { + tag = "Text", + attributes = { + id = "Count", + text = "0", + color = "White", + font = "font_teutonic-arkham", + fontsize = "135" + } + }} + } } + self.UI.setXmlTable(xmlTable) +end + +function updateValue() local matColor = playermatApi.getMatColorByPosition(self.getPosition()) local resources = playermatApi.getCounterValue(matColor, "ResourceCounter") local count = tostring(math.floor(resources / modValue)) - self.editButton({ index = 0, label = count }) + self.UI.setAttribute("Count", "text", count) end diff --git a/src/playermat/Playermat.ttslua b/src/playermat/Playermat.ttslua index 78f6a129..4f1696c0 100644 --- a/src/playermat/Playermat.ttslua +++ b/src/playermat/Playermat.ttslua @@ -136,7 +136,6 @@ local defaultSlotData = { } local activeInvestigatorData = {} -local hasDES = false local isClassTextureEnabled = true local isDrawButtonVisible = false local optionPanelVisibility = "" @@ -339,7 +338,6 @@ function doUpkeep(_, clickedByColor, isRightClick) updateMessageColor(clickedByColor) -- unexhaust cards in play zone, flip action tokens and find Forced Learning / Dream-Enhancing Serum - checkForDES() local forcedLearning = false local rot = self.getRotation() for _, obj in ipairs(searchAroundSelf()) do @@ -653,23 +651,6 @@ function concatenateListOfStrings(list) return cardList end --- checks if DES is present -function checkForDES() - hasDES = false - for _, obj in ipairs(searchAroundSelf()) do - if obj.type == "Card" then - local cardMetadata = JSON.decode(obj.getGMNotes()) or {} - - -- position is used to exclude deck / discard - local cardPos = self.positionToLocal(obj.getPosition()) - if cardMetadata.id == "06159" and cardPos.x > -1 then - hasDES = true - break - end - end - end -end - --------------------------------------------------------- -- XML creation and modifying --------------------------------------------------------- @@ -1568,5 +1549,3 @@ end function getActiveInvestigatorData() return activeInvestigatorData end function setActiveInvestigatorData(newData) activeInvestigatorData = newData end - -function getDES() return hasDES end diff --git a/src/playermat/PlayermatApi.ttslua b/src/playermat/PlayermatApi.ttslua index 35d6b941..313f0778 100644 --- a/src/playermat/PlayermatApi.ttslua +++ b/src/playermat/PlayermatApi.ttslua @@ -48,23 +48,6 @@ do end end - -- Instructs a playermat to check for DES - ---@param matColor string Color of the playermat - White, Orange, Green, Red or All - PlayermatApi.checkForDES = function(matColor) - for _, mat in pairs(getMatForColor(matColor)) do - mat.call("checkForDES") - end - end - - -- Returns if there is the card "Dream-Enhancing Serum" on the requested playermat - ---@param matColor string Color of the playermat - White, Orange, Green or Red (does not support "All") - ---@return boolean: whether DES is present on the playermat - PlayermatApi.hasDES = function(matColor) - for _, mat in pairs(getMatForColor(matColor)) do - return mat.call("getDES") - end - end - -- gets the slot data for the playermat ---@param matColor string Color of the playermat - White, Orange, Green or Red (does not support "All") PlayermatApi.getSlotData = function(matColor)