first pass

This commit is contained in:
dscarpac 2024-06-28 11:41:19 -05:00
parent a90a69efb9
commit c27fcb5b25
6 changed files with 228 additions and 67 deletions

View File

@ -244,6 +244,11 @@
"Type": 0, "Type": 0,
"URL": "http://cloud-3.steamusercontent.com/ugc/2510267932886739653/CB7AA2D73777EF5938A6E6CD664B2ABA52B6E20A/" "URL": "http://cloud-3.steamusercontent.com/ugc/2510267932886739653/CB7AA2D73777EF5938A6E6CD664B2ABA52B6E20A/"
}, },
{
"Name": "token-eldersign",
"Type": 0,
"URL": "http://cloud-3.steamusercontent.com/ugc/2540675016035917168/C0D6F531A85FD94C2F54825DFC50781B5B499A1D/"
},
{ {
"Name": "token-custom-token", "Name": "token-custom-token",
"Type": 0, "Type": 0,

View File

@ -33,7 +33,7 @@
"IgnoreFoW": false, "IgnoreFoW": false,
"LayoutGroupSortIndex": 0, "LayoutGroupSortIndex": 0,
"Locked": false, "Locked": false,
"LuaScript": "require(\"playercards/cards/KhakuNarukami\")", "LuaScript": "require(\"playercards/cards/KohakuNarukami\")",
"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/KohakuNarukami.xml\"/\u003e"
} }

View File

@ -1,64 +0,0 @@
function onSave()
return JSON.encode()
end
function onLoad(savedData)
self.addContextMenuItem("Enable Helper", createButtons)
sigil = JSON.decode(savedData)
if sigil and sigil ~= nil then
makeXMLButton(sigil)
self.clearContextMenu()
self.addContextMenuItem("Clear Helper", deleteButtons)
end
end
function makeXMLButton(chosenToken)
self.UI.setXmlTable({
{
tag="Button",
attributes={
height=450,
width=1400,
rotation="0 0 180",
scale="0.1 0.1 1",
position="0 -55 -22",
padding="50 50 50 50",
font="font_teutonic-arkham",
fontSize=300,
iconWidth=400,
iconAlignment="Right",
onClick="remove",
id=sigil,
icon=dataForToken[sigil].icon,
color=dataForToken[sigil].color,
textColor="White",
},
value="Resolve",
}
}
)
end
-- Create dialog window to choose sigil and create sigil-drawing button
function chooseSigil(playerColor)
self.clearContextMenu()
self.addContextMenuItem("Clear Helper", deleteButtons)
Player[playerColor].showOptionsDialog("Choose Sigil", tokenNames, 1,
function(chosenToken)
if chosenToken == "Custom Token" then
sigil = ""
else
sigil = chosenToken
end
makeXMLButton(sigil)
end
)
end
-- Delete button and remove sigil
function deleteButtons()
self.clearContextMenu()
self.addContextMenuItem("Enable Helper", chooseSigil)
self.UI.setXml("")
sigil = nil
end

View File

@ -0,0 +1,120 @@
require("playercards/CardsWithHelper")
local blessCurseManagerApi = require("chaosbag/BlessCurseManagerApi")
local chaosBagApi = require("chaosbag/ChaosBagApi")
local guidReferenceApi = require("core/GUIDReferenceApi")
local playermatApi = require("playermat/PlayermatApi")
local tokenManager = require("core/token/TokenManager")
function updateSave()
self.script_state = JSON.encode({ isHelperEnabled = isHelperEnabled })
end
function onLoad(savedData)
self.addTag("CardWithHelper")
if savedData and savedData ~= "" then
local loadedData = JSON.decode(savedData)
isHelperEnabled = loadedData.isHelperEnabled
end
checkOptionPanel()
updateDisplay()
end
-- hide buttons and stop monitoring
function shutOff()
self.UI.hide("Helper")
Wait.stopAll()
updateSave()
end
-- show buttons and begin monitoring chaos bag for curse and bless tokens
function initialize()
self.UI.show("Helper")
maybeUpdateButtonState()
Wait.time(maybeUpdateButtonState, 1, -1)
updateSave()
end
function addTokenToBag(_, _, tokenType)
blessCurseManagerApi.addToken(tokenType)
end
function removeAndExtraAction()
blessCurseManagerApi.removeToken("Bless")
blessCurseManagerApi.removeToken("Bless")
blessCurseManagerApi.removeToken("Curse")
blessCurseManagerApi.removeToken("Curse")
local position = self.getPosition()
local matColor = playermatApi.getMatColorByPosition(position)
local mat = guidReferenceApi.getObjectByOwnerAndType(matColor, "Playermat")
local rotation = mat.getRotation()
-- spawn extra action token in the middle of investigator card with Temporary tag
callback = function(spawned) spawned.call("updateClassAndSymbol", { class = "Mystic", symbol = "Mystic" }) spawned.addTag("Temporary") end
tokenManager.spawnToken(position + Vector(0, 0.2, 0), "universalActionAbility", rotation, callback)
end
function elderSignAbility()
blessCurseManagerApi.addToken("Bless")
blessCurseManagerApi.addToken("Curse")
end
-- count tokens in the bag and show appropriate buttons
function maybeUpdateButtonState()
local numInBag = getBlessCurseInBag()
local state = { Bless = false, Curse = false, Action = false, ElderSign = false }
if numInBag.Bless <= numInBag.Curse and numInBag.Bless < 10 then
state.Bless = true
end
if numInBag.Curse <= numInBag.Bless and numInBag.Curse < 10 then
state.Curse = true
end
if numInBag.Curse >= 2 and numInBag.Bless >= 2 then
state.Action = true
end
state.ElderSign = true
setUiState(state)
end
function getBlessCurseInBag()
local numInBag = { Bless = 0, Curse = 0 }
local chaosBag = chaosBagApi.findChaosBag()
for _, v in ipairs(chaosBag.getObjects()) do
if v.name == "Bless" or v.name == "Curse" then
numInBag[v.name] = numInBag[v.name] + 1
end
end
return numInBag
end
function setUiState(params)
for _, tokenName in ipairs({ "Bless", "Curse", "Action", "ElderSign" }) do
if params[tokenName] then
self.UI.show(tokenName)
self.UI.hide("inactive" .. tokenName)
else
self.UI.show("inactive" .. tokenName)
self.UI.hide(tokenName)
end
end
end
function errorMessage(_, _, triggeringButton)
local numInBag = getBlessCurseInBag()
if triggeringButton == "inactiveAction" then
broadcastToAll("There are not enough Blesses and/or Curses in the chaos bag.", "Red")
elseif numInBag.Bless == 10 and numInBag.Curse == 10 then
broadcastToAll("No more tokens can be added to the chaos bag.", "Red")
elseif numInBag.Bless < numInBag.Curse then
broadcastToAll("There are more Bless tokens than Curse tokens in the chaos bag.", "Red")
else
broadcastToAll("There are more Curse tokens than Bless tokens in the chaos bag.", "Red")
end
end

View File

@ -314,7 +314,9 @@ function doUpkeep(_, clickedByColor, isRightClick)
local forcedLearning = false local forcedLearning = false
local rot = self.getRotation() local rot = self.getRotation()
for _, obj in ipairs(searchAroundSelf()) do for _, obj in ipairs(searchAroundSelf()) do
if obj.hasTag("UniversalToken") == true and obj.is_face_down then if obj.hasTag("Temporary") == true then
discardListOfObjects({obj})
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" and not inArea(self.positionToLocal(obj.getPosition()), INVESTIGATOR_AREA) then
local cardMetadata = JSON.decode(obj.getGMNotes()) or {} local cardMetadata = JSON.decode(obj.getGMNotes()) or {}

View File

@ -0,0 +1,98 @@
<Defaults>
<Button padding="50 50 50 50"
font="font_teutonic-arkham"
fontSize="200"
iconWidth="400"
iconAlignment="Right"/>
<Button class="inactive"
onClick="errorMessage"
color="#353535E6"
textColor="#A0A0A0"/>
<Button class="active"
onClick="addTokenToBag"
textColor="white"
active="false"/>
<TableLayout position="0 188 -22"
rotation="0 0 90"
height="1800"
width="700"
scale="0.1 0.1 1"
cellSpacing="80"
cellBackgroundColor="rgba(1,1,1,0)"/>
</Defaults>
<Panel id="Helper"
active="false">
<TableLayout>
<Row>
<Cell>
<Button id="Bless"
icon="token-bless"
text="+ 1"
color="#9D702CE6"
class="active"/>
</Cell>
</Row>
<Row>
<Cell>
<Button id="Curse"
icon="token-curse"
text="+ 1"
color="#633A84E6"
class="active"/>
</Cell>
</Row>
<Row>
<Cell>
<Button id="Action"
text="Remove tokens"
color="#6D202CE6"
class="active"
onClick="removeAndExtraAction"/>
</Cell>
</Row>
<Row>
<Cell>
<Button id="ElderSign"
icon="token-eldersign"
color="#50A8CEE6"
class="active"
onClick="elderSignAbility"/>
</Cell>
</Row>
</TableLayout>
<TableLayout>
<Row>
<Cell>
<Button id="inactiveBless"
icon="token-bless"
text="+ 1"
class="inactive"/>
</Cell>
</Row>
<Row>
<Cell>
<Button id="inactiveCurse"
icon="token-curse"
text="+ 1"
class="inactive"/>
</Cell>
</Row>
<Row>
<Cell>
<Button id="inactiveAction"
text="Remove tokens"
class="inactive"/>
</Cell>
</Row>
<Row>
<Cell>
<Button id="inactiveElderSign"
text="Elder Sign"
icon="token-eldersign"
class="inactive"
onClick="elderSignAbility"/>
</Cell>
</Row>
</TableLayout>
</Panel>