Skip to content

Commit 74c7327

Browse files
authored
Merge pull request #1703 from dscarpac/andrepatel
Adds temporary action token for Andre
2 parents ec4b1e0 + 37c2735 commit 74c7327

4 files changed

Lines changed: 156 additions & 2 deletions

File tree

objects/AllPlayerCards.15bb07/AndréPatel.60351.gmnotes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"health": 7,
1515
"sanity": 8,
1616
"cycle": "Starters 2026",
17-
"extraToken": "Reaction",
17+
"extraToken": "None",
1818
"signatures": [
1919
{
2020
"60352": 1,

objects/AllPlayerCards.15bb07/AndréPatel.60351.json

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,27 @@
1111
"UniqueBack": true
1212
}
1313
},
14+
"CustomUIAssets": [
15+
{
16+
"Name": "font_arkhamicons",
17+
"Type": 1,
18+
"URL": "https://steamusercontent-a.akamaihd.net/ugc/16577956848173876106/49B31DA9BD35FC54A6B33926EA220FBBB2CAD038/"
19+
},
20+
{
21+
"Name": "token-blue",
22+
"Type": 0,
23+
"URL": "https://steamusercontent-a.akamaihd.net/ugc/13603340044969501197/DC8691C239014FE7DDABB886BB1D383C05DC490F/"
24+
}
25+
],
1426
"Description": "The Film Star",
1527
"GMNotes_path": "AllPlayerCards.15bb07/AndréPatel.60351.gmnotes",
1628
"GUID": "60351",
29+
"LuaScript": "require(\"playercards/cards/AndrePatel\")",
1730
"Name": "Card",
1831
"Nickname": "André Patel",
1932
"SidewaysCard": true,
2033
"Tags": [
34+
"CardWithHelper",
2135
"Investigator",
2236
"PlayerCard"
2337
],
@@ -26,5 +40,6 @@
2640
"scaleX": 1.15,
2741
"scaleY": 1,
2842
"scaleZ": 1.15
29-
}
43+
},
44+
"XmlUI": "<Include src=\"playercards/AndrePatel.xml\"/>"
3045
}
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
require("playercards/CardsWithHelper")
2+
local GUIDReferenceApi = require("core/GUIDReferenceApi")
3+
local PlayermatApi = require("playermat/PlayermatApi")
4+
local SearchLib = require("util/SearchLib")
5+
local TokenManagerApi = require("tokens/TokenManagerApi")
6+
7+
-- intentionally global
8+
hasXML = true
9+
isHelperEnabled = false
10+
local updated
11+
local state
12+
13+
local xmlData = {
14+
Action = { color = "#15693FE6", onClick = "addExtraAction" },
15+
ElderSign = { color = "#50A8CEE6", onClick = "elderSignAbility" }
16+
}
17+
18+
function updateSave()
19+
self.script_state = JSON.encode({
20+
isHelperEnabled = isHelperEnabled,
21+
state = state
22+
})
23+
end
24+
25+
function onLoad(savedData)
26+
self.addTag("DoInUpkeep")
27+
if savedData and savedData ~= "" then
28+
local loadedData = JSON.decode(savedData)
29+
isHelperEnabled = loadedData.isHelperEnabled
30+
state = loadedData.state
31+
else
32+
state = { Action = true, ElderSign = true }
33+
end
34+
if isHelperEnabled then updateDisplay() end
35+
end
36+
37+
function initialize()
38+
setUiState(state)
39+
updated = true
40+
end
41+
42+
function addExtraAction()
43+
if not updated then return end
44+
updated = false
45+
46+
local position = self.getPosition()
47+
local matColor = PlayermatApi.getMatColorByPosition(position)
48+
local mat = GUIDReferenceApi.getObjectByOwnerAndType(matColor, "Playermat")
49+
local rotation = mat.getRotation()
50+
51+
-- find empty action token slots by checking snap points
52+
local snaps = mat.getSnapPoints()
53+
54+
-- get first empty slot in the top row (so the second empty slot because of the ability token)
55+
local emptyPos = position -- default to card position
56+
for i, snap in ipairs(snaps) do
57+
if i > 1 then
58+
if snap.tags[1] == "UniversalToken" then
59+
local snapPos = mat.positionToWorld(snap.position)
60+
local searchResult = SearchLib.atPosition(snapPos, "isUniversalToken")
61+
if #searchResult == 0 then
62+
emptyPos = snapPos
63+
break
64+
end
65+
end
66+
end
67+
end
68+
69+
local callbackName = "updateUniversalActionAbilityToken"
70+
local callbackParams = { class = "Rogue", symbol = "Rogue" }
71+
TokenManagerApi.spawnToken(emptyPos + Vector(0, 0.7, 0), "universalActionAbility", rotation, callbackName, callbackParams, nil, "Temporary")
72+
state = { Action = false, ElderSign = true }
73+
setUiState(state)
74+
Wait.frames(function() updated = true end, 3)
75+
updateSave()
76+
end
77+
78+
function elderSignAbility()
79+
local matColor = PlayermatApi.getMatColorByPosition(self.getPosition())
80+
PlayermatApi.updateCounter(matColor, "ResourceCounter", nil, 1)
81+
broadcastToAll("Gaining 1 resource from André's elder sign.", "White")
82+
end
83+
84+
function setUiState(params)
85+
for buttonId, onState in pairs(params) do
86+
if onState then
87+
self.UI.setAttribute(buttonId, "color", xmlData[buttonId].color)
88+
self.UI.setAttribute(buttonId, "onClick", xmlData[buttonId].onClick)
89+
self.UI.setAttribute(buttonId, "textColor", "white")
90+
else
91+
self.UI.setAttribute(buttonId, "color", "#353535E6")
92+
self.UI.setAttribute(buttonId, "onClick", "errorMessage")
93+
self.UI.setAttribute(buttonId, "textColor", "#A0A0A0")
94+
end
95+
end
96+
end
97+
98+
function errorMessage(_, _, triggeringButton)
99+
if triggeringButton == "Action" then
100+
broadcastToAll("You have already triggered this ability this round.", "Red")
101+
end
102+
end
103+
104+
function doInUpkeep()
105+
state = { Action = true, ElderSign = true }
106+
setUiState(state)
107+
updated = true
108+
updateSave()
109+
end

xml/playercards/AndrePatel.xml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<Defaults>
2+
<Button padding="50 50 50 50"
3+
font="font_arkhamicons"
4+
fontSize="300"
5+
iconWidth="300"
6+
iconAlignment="Right"/>
7+
<TableLayout position="0 188 -40"
8+
rotation="0 0 90"
9+
height="900"
10+
width="700"
11+
scale="0.1 0.1 1"
12+
cellSpacing="80"
13+
cellBackgroundColor="rgba(1,1,1,0)"/>
14+
</Defaults>
15+
16+
<TableLayout id="Helper"
17+
active="false">
18+
<Row>
19+
<Cell>
20+
<Button id="Action"
21+
text="u"/>
22+
</Cell>
23+
</Row>
24+
<Row>
25+
<Cell>
26+
<Button id="ElderSign"
27+
icon="token-blue"/>
28+
</Cell>
29+
</Row>
30+
</TableLayout>

0 commit comments

Comments
 (0)