added stella helper

This commit is contained in:
dscarpac 2024-09-29 15:47:26 -05:00
parent 08cb7c85a1
commit 21d058f675
5 changed files with 160 additions and 4 deletions

View File

@ -8,7 +8,6 @@
"combatIcons": 3, "combatIcons": 3,
"agilityIcons": 4, "agilityIcons": 4,
"cycle": "Investigator Packs", "cycle": "Investigator Packs",
"extraToken": "Survivor",
"signatures": [ "signatures": [
{ {
"60502": 3, "60502": 3,

View File

@ -33,7 +33,7 @@
"IgnoreFoW": false, "IgnoreFoW": false,
"LayoutGroupSortIndex": 0, "LayoutGroupSortIndex": 0,
"Locked": false, "Locked": false,
"LuaScript": "", "LuaScript": "require(\"playercards/cards/StellaClark\")",
"LuaScriptState": "", "LuaScriptState": "",
"MeasureMovement": false, "MeasureMovement": false,
"Name": "Card", "Name": "Card",
@ -58,5 +58,5 @@
"scaleZ": 1.15 "scaleZ": 1.15
}, },
"Value": 0, "Value": 0,
"XmlUI": "" "XmlUI": "\u003cInclude src=\"playercards/StellaClark.xml\"/\u003e"
} }

View File

@ -0,0 +1,118 @@
require("playercards/CardsWithHelper")
local guidReferenceApi = require("core/GUIDReferenceApi")
local playermatApi = require("playermat/PlayermatApi")
local searchLib = require("util/SearchLib")
local tokenManagerApi = require("core/token/TokenManagerApi")
-- intentionally global
hasXML = true
isHelperEnabled = false
local updated
local state
local xmlData = {
Action = { color = "#6D202CE6", onClick = "addExtraAction" },
ElderSign = { color = "#50A8CEE6", onClick = "elderSignAbility" }
}
function updateSave()
self.script_state = JSON.encode({
isHelperEnabled = isHelperEnabled,
state = state
})
end
function onLoad(savedData)
self.addTag("DoInUpkeep")
if savedData and savedData ~= "" then
local loadedData = JSON.decode(savedData)
isHelperEnabled = loadedData.isHelperEnabled
state = loadedData.state
else
state = { Action = true, ElderSign = true }
end
syncDisplayWithOptionPanel()
end
function initialize()
setUiState(state)
updated = true
end
function addExtraAction()
if not updated then return end
updated = false
local position = self.getPosition()
local matColor = playermatApi.getMatColorByPosition(position)
local mat = guidReferenceApi.getObjectByOwnerAndType(matColor, "Playermat")
local rotation = mat.getRotation()
-- find empty action token slots by checking snap points
local snaps = mat.getSnapPoints()
-- get first empty slot in the top row (so the second empty slot because of the ability token)
local emptyPos = position -- default to card position
for i, snap in ipairs(snaps) do
if i > 1 then
if snap.tags[1] == "UniversalToken" then
local snapPos = mat.positionToWorld(snap.position)
local searchResult = searchLib.atPosition(snapPos, "isUniversalToken")
if #searchResult == 0 then
emptyPos = snapPos
break
end
end
end
end
local callbackName = "updateUniversalActionAbilityToken"
local callbackParams = { class = "Survivor", symbol = "Survivor", addTag = "Temporary"}
tokenManagerApi.spawnToken(emptyPos + Vector(0, 0.7, 0), "universalActionAbility", rotation, callbackName, callbackParams)
state = { Action = false, ElderSign = true }
setUiState(state)
updated = true
updateSave()
end
function elderSignAbility()
local matColor = playermatApi.getMatColorByPosition(self.getPosition())
playermatApi.updateCounter(matColor, "DamageCounter", _, -1)
playermatApi.updateCounter(matColor, "HorrorCounter", _, -1)
-- check if reaction ability has already been used
local actionColor = self.UI.getAttribute("Action", "color")
if actionColor ~= "#353535E6" then
addExtraAction()
broadcastToAll("Healing 1 damage and 1 horror from Stella and triggering her reaction.", "White")
else
broadcastToAll("Healing 1 damage and 1 horror from Stella.", "White")
end
end
function setUiState(params)
for buttonId, onState in pairs(params) do
if onState then
self.UI.setAttribute(buttonId, "color", xmlData[buttonId].color)
self.UI.setAttribute(buttonId, "onClick", xmlData[buttonId].onClick)
self.UI.setAttribute(buttonId, "textColor", "white")
else
self.UI.setAttribute(buttonId, "color", "#353535E6")
self.UI.setAttribute(buttonId, "onClick", "errorMessage")
self.UI.setAttribute(buttonId, "textColor", "#A0A0A0")
end
end
end
function errorMessage(_, _, triggeringButton)
if triggeringButton == "Action" then
broadcastToAll("You have already triggered this once this round.", "Red")
end
end
function doInUpkeep()
state = { Action = true, ElderSign = true }
setUiState(state)
updated = true
updateSave()
end

View File

@ -345,8 +345,17 @@ function doUpkeep(_, clickedByColor, isRightClick)
discardListOfObjects({ obj }) discardListOfObjects({ obj })
elseif obj.hasTag("UniversalToken") == true and obj.is_face_down then elseif obj.hasTag("UniversalToken") == true and obj.is_face_down then
obj.flip() obj.flip()
elseif obj.type == "Card" and not inArea(self.positionToLocal(obj.getPosition()), INVESTIGATOR_AREA) then elseif obj.type == "Card" then
local cardMetadata = JSON.decode(obj.getGMNotes()) or {} local cardMetadata = JSON.decode(obj.getGMNotes()) or {}
if obj.hasTag("DoInUpkeep") then
obj.call("doInUpkeep")
end
-- do not rotate, replenish, etc. on cards in investigator card area
if inArea(self.positionToLocal(obj.getPosition()), INVESTIGATOR_AREA) then
return
end
if not (obj.getVar("do_not_ready") or obj.hasTag("DoNotReady")) then if not (obj.getVar("do_not_ready") or obj.hasTag("DoNotReady")) then
local cardRotation = obj.getRotation() local cardRotation = obj.getRotation()
local yRotDiff = round(cardRotation.y, 0) - rot.y local yRotDiff = round(cardRotation.y, 0) - rot.y

View File

@ -0,0 +1,30 @@
<Defaults>
<Button padding="50 50 50 50"
font="font_arkhamicons"
fontSize="300"
iconWidth="300"
iconAlignment="Right"/>
<TableLayout position="0 188 -22"
rotation="0 0 90"
height="900"
width="700"
scale="0.1 0.1 1"
cellSpacing="80"
cellBackgroundColor="rgba(1,1,1,0)"/>
</Defaults>
<TableLayout id="Helper"
active="false">
<Row>
<Cell>
<Button id="Action"
text="u"/>
</Cell>
</Row>
<Row>
<Cell>
<Button id="ElderSign"
icon="token-eldersign"/>
</Cell>
</Row>
</TableLayout>