added handling for up to two tokens of the same type

This commit is contained in:
Chr1Z93 2024-06-09 00:10:44 +02:00
parent b8a0b38e55
commit 9803845a97
2 changed files with 40 additions and 18 deletions

View File

@ -8,7 +8,7 @@
"combatIcons": 4, "combatIcons": 4,
"agilityIcons": 2, "agilityIcons": 2,
"cycle": "Path of the Righteous", "cycle": "Path of the Righteous",
"extraToken": "FreeTrigger", "extraToken": "FreeTrigger|FreeTrigger",
"deck_requirements": { "deck_requirements": {
"size": 30, "size": 30,
"randomBasicWeaknessCount": 1, "randomBasicWeaknessCount": 1,

View File

@ -894,31 +894,53 @@ function maybeUpdateActiveInvestigator(card)
-- spawn three regular action tokens (investigator specific one in the bottom spot) -- spawn three regular action tokens (investigator specific one in the bottom spot)
for i = 1, 3 do for i = 1, 3 do
-- get position
local pos = self.positionToWorld(Vector(-1.54 + i * 0.17, 0, -0.28)):add(Vector(0, 0.2, 0)) local pos = self.positionToWorld(Vector(-1.54 + i * 0.17, 0, -0.28)):add(Vector(0, 0.2, 0))
tokenManager.spawnToken(pos, "universalActionAbility", self.getRotation(), function(spawned) tokenManager.spawnToken(pos, "universalActionAbility", self.getRotation(),
function(spawned)
spawned.call("updateClassAndSymbol", { class = activeInvestigatorClass, symbol = activeInvestigatorClass }) spawned.call("updateClassAndSymbol", { class = activeInvestigatorClass, symbol = activeInvestigatorClass })
end) end)
end end
-- spawn additional token (maybe specific for investigator) -- spawn additional token (maybe specific for investigator)
if extraToken and extraToken ~= "None" then if extraToken ~= "None" then
-- set value to class if currently "nil" -- set to current class if nil
extraToken = extraToken or activeInvestigatorClass extraToken = extraToken or activeInvestigatorClass
-- get position (on the investigator card for abilities) -- local positions
local pos local tokenSpawnPos = {
if extraToken == "FreeTrigger" or extraToken == "Reaction" then action = {
pos = self.positionToWorld(Vector(-1, 0, 0.118)):add(Vector(0, 0.2, 0)) Vector(-0.86, 0, -0.28), -- left of the regular three actions
else Vector(-1.54, 0, -0.28), -- right of the regular three actions
pos = self.positionToWorld(Vector(-1.54 + 4 * 0.17, 0, -0.28)):add(Vector(0, 0.2, 0)) },
ability = {
Vector(-1, 0, 0.118), -- bottom left corner of the investigator card
Vector(-1, 0, -0.118), -- top left corner of the investigator card
}
}
-- spawn tokens (split string by "|")
local count = { action = 0, ability = 0 }
for str in string.gmatch(extraToken, "([^|]+)") do
local type = "action"
if str == "FreeTrigger" or str == "Reaction" then
type = "ability"
end end
tokenManager.spawnToken(pos, "universalActionAbility", self.getRotation(), function(spawned) count[type] = count[type] + 1
spawned.call("updateClassAndSymbol", { class = activeInvestigatorClass, symbol = extraToken }) if count[type] > 2 then
print("More than two extra tokens of the same type are not supported.")
else
local localSpawnPos = tokenSpawnPos[type][count[type]]
local globalSpawnPos = self.positionToWorld(localSpawnPos):add(Vector(0, 0.2, 0))
tokenManager.spawnToken(globalSpawnPos, "universalActionAbility", self.getRotation(),
function(spawned)
spawned.call("updateClassAndSymbol", { class = activeInvestigatorClass, symbol = str })
end) end)
end end
end
end
end end
--------------------------------------------------------- ---------------------------------------------------------