Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion objects/AllPlayerCards.15bb07/AndréPatel.60351.gmnotes
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"health": 7,
"sanity": 8,
"cycle": "Starters 2026",
"extraToken": "Reaction",
"extraToken": "None",
"signatures": [
{
"60352": 1,
Expand Down
17 changes: 16 additions & 1 deletion objects/AllPlayerCards.15bb07/AndréPatel.60351.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,27 @@
"UniqueBack": true
}
},
"CustomUIAssets": [
{
"Name": "font_arkhamicons",
"Type": 1,
"URL": "https://steamusercontent-a.akamaihd.net/ugc/16577956848173876106/49B31DA9BD35FC54A6B33926EA220FBBB2CAD038/"
},
{
"Name": "token-blue",
"Type": 0,
"URL": "https://steamusercontent-a.akamaihd.net/ugc/13603340044969501197/DC8691C239014FE7DDABB886BB1D383C05DC490F/"
}
],
"Description": "The Film Star",
"GMNotes_path": "AllPlayerCards.15bb07/AndréPatel.60351.gmnotes",
"GUID": "60351",
"LuaScript": "require(\"playercards/cards/AndrePatel\")",
"Name": "Card",
"Nickname": "André Patel",
"SidewaysCard": true,
"Tags": [
"CardWithHelper",
"Investigator",
"PlayerCard"
],
Expand All @@ -26,5 +40,6 @@
"scaleX": 1.15,
"scaleY": 1,
"scaleZ": 1.15
}
},
"XmlUI": "<Include src=\"playercards/AndrePatel.xml\"/>"
}
109 changes: 109 additions & 0 deletions src/playercards/cards/AndrePatel.ttslua
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
require("playercards/CardsWithHelper")
local GUIDReferenceApi = require("core/GUIDReferenceApi")
local PlayermatApi = require("playermat/PlayermatApi")
local SearchLib = require("util/SearchLib")
local TokenManagerApi = require("tokens/TokenManagerApi")

-- intentionally global
hasXML = true
isHelperEnabled = false
local updated
local state

local xmlData = {
Action = { color = "#15693FE6", 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
if isHelperEnabled then updateDisplay() end
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 = "Rogue", symbol = "Rogue" }
TokenManagerApi.spawnToken(emptyPos + Vector(0, 0.7, 0), "universalActionAbility", rotation, callbackName, callbackParams, nil, "Temporary")
state = { Action = false, ElderSign = true }
setUiState(state)
Wait.frames(function() updated = true end, 3)
updateSave()
end

function elderSignAbility()
local matColor = PlayermatApi.getMatColorByPosition(self.getPosition())
PlayermatApi.updateCounter(matColor, "ResourceCounter", nil, 1)
broadcastToAll("Gaining 1 resource from André's elder sign.", "White")
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 ability this round.", "Red")
end
end

function doInUpkeep()
state = { Action = true, ElderSign = true }
setUiState(state)
updated = true
updateSave()
end
30 changes: 30 additions & 0 deletions xml/playercards/AndrePatel.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<Defaults>
<Button padding="50 50 50 50"
font="font_arkhamicons"
fontSize="300"
iconWidth="300"
iconAlignment="Right"/>
<TableLayout position="0 188 -40"
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-blue"/>
</Cell>
</Row>
</TableLayout>
Loading