Merge pull request #589 from dscarpac/ResolveBlurse
Resolves Bless/Curse and Sealed tokens
This commit is contained in:
commit
543c771648
@ -33,7 +33,7 @@
|
||||
"IgnoreFoW": false,
|
||||
"LayoutGroupSortIndex": 0,
|
||||
"Locked": false,
|
||||
"LuaScript": "",
|
||||
"LuaScript": "require(\"playercards/cards/BookofLivingMyths\")",
|
||||
"LuaScriptState": "",
|
||||
"MeasureMovement": false,
|
||||
"Name": "CardCustom",
|
||||
@ -58,5 +58,22 @@
|
||||
"scaleZ": 1
|
||||
},
|
||||
"Value": 0,
|
||||
"XmlUI": ""
|
||||
"XmlUI": "\u003cInclude src=\"playercards/BookofLivingMyths.xml\"/\u003e",
|
||||
"CustomUIAssets": [
|
||||
{
|
||||
"Type": 1,
|
||||
"Name": "font_teutonic-arkham",
|
||||
"URL": "http://cloud-3.steamusercontent.com/ugc/2027213118467703445/89328E273B4C5180BF491516CE998DE3C604E162/"
|
||||
},
|
||||
{
|
||||
"Type": 0,
|
||||
"Name": "bless",
|
||||
"URL": "http://cloud-3.steamusercontent.com/ugc/2380784374775547028/7855033DE0EB1FDDF706E1303054D35FE0902532/"
|
||||
},
|
||||
{
|
||||
"Type": 0,
|
||||
"Name": "curse",
|
||||
"URL": "http://cloud-3.steamusercontent.com/ugc/2380784374775547135/2360372CBE9452CB7B4D135BE13BBA6D46B7D427/"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -1,62 +1,63 @@
|
||||
{
|
||||
"AltLookAngle": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"Autoraise": true,
|
||||
"CardID": 378929,
|
||||
"ColorDiffuse": {
|
||||
"b": 0.71324,
|
||||
"g": 0.71324,
|
||||
"r": 0.71324
|
||||
},
|
||||
"CustomDeck": {
|
||||
"3789": {
|
||||
"BackIsHidden": true,
|
||||
"BackURL": "http://cloud-3.steamusercontent.com/ugc/2342503777940352139/A2D42E7E5C43D045D72CE5CFC907E4F886C8C690/",
|
||||
"FaceURL": "http://cloud-3.steamusercontent.com/ugc/1625226898126493809/0EE7F5B9B916B56425CAC1C46F7FCEF9DBF55112/",
|
||||
"NumHeight": 7,
|
||||
"NumWidth": 10,
|
||||
"Type": 0,
|
||||
"UniqueBack": false
|
||||
}
|
||||
},
|
||||
"Description": "Enigmatic Warlock",
|
||||
"DragSelectable": true,
|
||||
"GMNotes_path": "AllPlayerCards.15bb07/NkosiMabati3.6c5628.gmnotes",
|
||||
"GUID": "6c5628",
|
||||
"Grid": true,
|
||||
"GridProjection": false,
|
||||
"Hands": true,
|
||||
"HideWhenFaceDown": true,
|
||||
"IgnoreFoW": false,
|
||||
"LayoutGroupSortIndex": 0,
|
||||
"Locked": false,
|
||||
"LuaScript": "",
|
||||
"LuaScriptState": "",
|
||||
"MeasureMovement": false,
|
||||
"Name": "Card",
|
||||
"Nickname": "Nkosi Mabati (3)",
|
||||
"SidewaysCard": false,
|
||||
"Snap": true,
|
||||
"Sticky": true,
|
||||
"Tags": [
|
||||
"Asset",
|
||||
"PlayerCard"
|
||||
],
|
||||
"Tooltip": true,
|
||||
"Transform": {
|
||||
"posX": 9.182,
|
||||
"posY": 2.801,
|
||||
"posZ": -16.733,
|
||||
"rotX": 0,
|
||||
"rotY": 270,
|
||||
"rotZ": 0,
|
||||
"scaleX": 1,
|
||||
"scaleY": 1,
|
||||
"scaleZ": 1
|
||||
},
|
||||
"Value": 0,
|
||||
"XmlUI": ""
|
||||
}
|
||||
"AltLookAngle": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"Autoraise": true,
|
||||
"CardID": 378929,
|
||||
"ColorDiffuse": {
|
||||
"b": 0.71324,
|
||||
"g": 0.71324,
|
||||
"r": 0.71324
|
||||
},
|
||||
"CustomDeck": {
|
||||
"3789": {
|
||||
"BackIsHidden": true,
|
||||
"BackURL": "http://cloud-3.steamusercontent.com/ugc/2342503777940352139/A2D42E7E5C43D045D72CE5CFC907E4F886C8C690/",
|
||||
"FaceURL": "http://cloud-3.steamusercontent.com/ugc/1625226898126493809/0EE7F5B9B916B56425CAC1C46F7FCEF9DBF55112/",
|
||||
"NumHeight": 7,
|
||||
"NumWidth": 10,
|
||||
"Type": 0,
|
||||
"UniqueBack": false
|
||||
}
|
||||
},
|
||||
"Description": "Enigmatic Warlock",
|
||||
"DragSelectable": true,
|
||||
"GMNotes_path": "AllPlayerCards.15bb07/NkosiMabati3.6c5628.gmnotes",
|
||||
"GUID": "6c5628",
|
||||
"Grid": true,
|
||||
"GridProjection": false,
|
||||
"Hands": true,
|
||||
"HideWhenFaceDown": true,
|
||||
"IgnoreFoW": false,
|
||||
"LayoutGroupSortIndex": 0,
|
||||
"Locked": false,
|
||||
"LuaScript": "",
|
||||
"LuaScriptState": "",
|
||||
"MeasureMovement": false,
|
||||
"Name": "Card",
|
||||
"Nickname": "Nkosi Mabati (3)",
|
||||
"SidewaysCard": false,
|
||||
"Snap": true,
|
||||
"Sticky": true,
|
||||
"Tags": [
|
||||
"Asset",
|
||||
"PlayerCard"
|
||||
],
|
||||
"Tooltip": true,
|
||||
"Transform": {
|
||||
"posX": 9.182,
|
||||
"posY": 2.801,
|
||||
"posZ": -16.733,
|
||||
"rotX": 0,
|
||||
"rotY": 270,
|
||||
"rotZ": 0,
|
||||
"scaleX": 1,
|
||||
"scaleY": 1,
|
||||
"scaleZ": 1
|
||||
},
|
||||
"Value": 0,
|
||||
"XmlUI": ""
|
||||
}
|
||||
|
@ -69,8 +69,10 @@ do
|
||||
-- called by playermats (by the "Draw chaos token" button)
|
||||
---@param mat tts__Object Playermat that triggered this
|
||||
---@param drawAdditional boolean Controls whether additional tokens should be drawn
|
||||
ChaosBagApi.drawChaosToken = function(mat, drawAdditional)
|
||||
return Global.call("drawChaosToken", {mat = mat, drawAdditional = drawAdditional})
|
||||
---@param tokenType? string Name of token (e.g. "Bless") to be drawn from the bag
|
||||
---@param guidToBeResolved? string GUID of the sealed token to be resolved instead of drawing a token from the bag
|
||||
ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, guidToBeResolved)
|
||||
return Global.call("drawChaosToken", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, guidToBeResolved = guidToBeResolved})
|
||||
end
|
||||
|
||||
-- returns a Table List of chaos token ids in the current chaos bag
|
||||
|
@ -302,12 +302,34 @@ function drawChaosToken(params)
|
||||
|
||||
-- add the token to the list, compute new position based on list length
|
||||
tokenOffset[1] = tokenOffset[1] + (0.17 * #chaosTokens)
|
||||
local token = chaosBag.takeObject({
|
||||
index = 0,
|
||||
position = params.mat.positionToWorld(tokenOffset),
|
||||
rotation = params.mat.getRotation()
|
||||
})
|
||||
|
||||
local token
|
||||
|
||||
if params.guidToBeResolved then -- resolve a sealed token from a card
|
||||
token = getObjectFromGUID(params.guidToBeResolved)
|
||||
token.setPositionSmooth(params.mat.positionToWorld(tokenOffset))
|
||||
local guid = token.getGUID()
|
||||
local tokenType = token.getName()
|
||||
if tokenType == "Bless" or tokenType == "Curse" then
|
||||
blessCurseManagerApi.releasedToken(tokenType, guid)
|
||||
end
|
||||
tokenArrangerApi.layout()
|
||||
else -- take a token from the bag, either specified or random
|
||||
local takeParameters = {
|
||||
position = params.mat.positionToWorld(tokenOffset),
|
||||
rotation = params.mat.getRotation()
|
||||
}
|
||||
|
||||
if params.tokenType then
|
||||
for i, lookedForToken in ipairs(chaosBag.getObjects()) do
|
||||
if lookedForToken.name == params.tokenType then
|
||||
takeParameters.index = i - 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
token = chaosBag.takeObject(takeParameters)
|
||||
end
|
||||
-- get data for token description
|
||||
local name = token.getName()
|
||||
local tokenData = mythosAreaApi.returnTokenData().tokenData or {}
|
||||
|
@ -75,6 +75,8 @@ Thus it should be implemented like this:
|
||||
|
||||
local blessCurseManagerApi = require("chaosbag/BlessCurseManagerApi")
|
||||
local chaosBagApi = require("chaosbag/ChaosBagApi")
|
||||
local guidReferenceApi = require("core/GUIDReferenceApi")
|
||||
local playmatApi = require("playermat/PlaymatApi")
|
||||
local tokenArrangerApi = require("accessories/TokenArrangerApi")
|
||||
|
||||
local sealedTokens = {}
|
||||
@ -101,6 +103,15 @@ function generateContextMenu()
|
||||
self.addContextMenuItem("Release token(s)", releaseAllTokens)
|
||||
end
|
||||
|
||||
if RESOLVE_TOKEN then
|
||||
local firstTokenType
|
||||
for tokenType, val in pairs(VALID_TOKENS) do
|
||||
firstTokenType = tokenType
|
||||
break
|
||||
end
|
||||
self.addContextMenuItem("Resolve " .. firstTokenType, resolveSealed)
|
||||
end
|
||||
|
||||
-- conditional release option
|
||||
if SHOW_MULTI_RETURN then
|
||||
self.addContextMenuItem("Return " .. SHOW_MULTI_RETURN .. " token(s)", returnMultipleTokens)
|
||||
@ -262,3 +273,15 @@ function returnToken(guid)
|
||||
blessCurseManagerApi.returnedToken(name, guid)
|
||||
end
|
||||
end
|
||||
|
||||
-- resolves sealed token as if it came from the chaos bag
|
||||
function resolveSealed()
|
||||
if #sealedTokens == 0 then
|
||||
broadcastToAll("No tokens sealed.", "Red")
|
||||
return
|
||||
end
|
||||
local closestMatColor = playmatApi.getMatColorByPosition(self.getPosition())
|
||||
local mat = guidReferenceApi.getObjectByOwnerAndType(closestMatColor, "Playermat")
|
||||
local guidToBeResolved = table.remove(sealedTokens)
|
||||
chaosBagApi.drawChaosToken(mat, true, _, guidToBeResolved)
|
||||
end
|
||||
|
104
src/playercards/cards/BookofLivingMyths.ttslua
Normal file
104
src/playercards/cards/BookofLivingMyths.ttslua
Normal file
@ -0,0 +1,104 @@
|
||||
local chaosBagApi = require("chaosbag/ChaosBagApi")
|
||||
local guidReferenceApi = require("core/GUIDReferenceApi")
|
||||
local playmatApi = require("playermat/PlaymatApi")
|
||||
|
||||
function onSave()
|
||||
return JSON.encode({ loopId = loopId })
|
||||
end
|
||||
|
||||
function onLoad(savedData)
|
||||
self.addContextMenuItem("Enable Helper", createButtons)
|
||||
if savedData ~= "" then
|
||||
local loadedData = JSON.decode(savedData)
|
||||
if loadedData.loopId then
|
||||
createButtons()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function deleteButtons()
|
||||
self.UI.setAttribute("inactives", "active", false)
|
||||
self.UI.setAttribute("actives", "active", false)
|
||||
self.clearContextMenu()
|
||||
self.addContextMenuItem("Enable Helper", createButtons)
|
||||
Wait.stop(loopId)
|
||||
loopId = nil
|
||||
end
|
||||
|
||||
-- Create buttons and begin monitoring chaos bag for curse and bless tokens
|
||||
function createButtons()
|
||||
self.clearContextMenu()
|
||||
self.addContextMenuItem("Clear Helper", deleteButtons)
|
||||
self.UI.setAttribute("inactives", "active", true)
|
||||
self.UI.setAttribute("actives", "active", true)
|
||||
self.UI.show("inactiveBless")
|
||||
self.UI.show("inactiveCurse")
|
||||
self.UI.hide("Bless")
|
||||
self.UI.hide("Curse")
|
||||
currentState = "Empty"
|
||||
loopId = Wait.time(countBlessCurse, 1, -1)
|
||||
end
|
||||
|
||||
function resolveToken(_, _, tokenType)
|
||||
local closestMatColor = playmatApi.getMatColorByPosition(self.getPosition())
|
||||
local mat = guidReferenceApi.getObjectByOwnerAndType(closestMatColor, "Playermat")
|
||||
chaosBagApi.drawChaosToken(mat, true, tokenType)
|
||||
end
|
||||
|
||||
-- count tokens in the bag and show appropriate buttons
|
||||
function countBlessCurse()
|
||||
local numInBag = { Bless = 0, Curse = 0 }
|
||||
local chaosBag = chaosBagApi.findChaosBag()
|
||||
local tokens = {}
|
||||
for _, v in ipairs(chaosBag.getObjects()) do
|
||||
if v.name == "Bless" then
|
||||
numInBag.Bless = numInBag.Bless + 1
|
||||
elseif v.name == "Curse" then
|
||||
numInBag.Curse = numInBag.Curse + 1
|
||||
end
|
||||
end
|
||||
|
||||
if numInBag.Bless > numInBag.Curse then
|
||||
if currentState ~= "More Bless" then
|
||||
self.UI.show("Bless")
|
||||
self.UI.hide("inactiveBless")
|
||||
self.UI.show("inactiveCurse")
|
||||
self.UI.hide("Curse")
|
||||
end
|
||||
currentState = "More Bless"
|
||||
elseif numInBag.Curse > numInBag.Bless then
|
||||
if currentState ~= "More Curse" then
|
||||
self.UI.show("Curse")
|
||||
self.UI.hide("inactiveCurse")
|
||||
self.UI.show("inactiveBless")
|
||||
self.UI.hide("Bless")
|
||||
end
|
||||
currentState = "More Curse"
|
||||
elseif numInBag.Curse == 0 then
|
||||
if currentState ~= "Empty" then
|
||||
self.UI.show("inactiveBless")
|
||||
self.UI.hide("Bless")
|
||||
self.UI.show("inactiveCurse")
|
||||
self.UI.hide("Curse")
|
||||
end
|
||||
currentState = "Empty"
|
||||
else
|
||||
if currentState ~= "Equal" then
|
||||
self.UI.show("Bless")
|
||||
self.UI.hide("inactiveBless")
|
||||
self.UI.show("Curse")
|
||||
self.UI.hide("inactiveCurse")
|
||||
end
|
||||
currentState = "Equal"
|
||||
end
|
||||
end
|
||||
|
||||
function errorMessage ()
|
||||
if currentState == "Empty" then
|
||||
broadcastToAll("There are no Bless or Curse tokens in the chaos bag.","Red")
|
||||
elseif currentState == "More Bless" 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
|
@ -4,5 +4,6 @@ VALID_TOKENS = {
|
||||
|
||||
SHOW_SINGLE_RELEASE = true
|
||||
KEEP_OPEN = true
|
||||
RESOLVE_TOKEN = true
|
||||
|
||||
require("playercards/CardsThatSealTokens")
|
||||
|
@ -4,5 +4,6 @@ VALID_TOKENS = {
|
||||
|
||||
SHOW_SINGLE_RELEASE = true
|
||||
KEEP_OPEN = true
|
||||
RESOLVE_TOKEN = true
|
||||
|
||||
require("playercards/CardsThatSealTokens")
|
||||
|
@ -2,4 +2,6 @@ VALID_TOKENS = {
|
||||
["Elder Sign"] = true
|
||||
}
|
||||
|
||||
RESOLVE_TOKEN = true
|
||||
|
||||
require("playercards/CardsThatSealTokens")
|
||||
|
48
xml/playercards/BookofLivingMyths.xml
Normal file
48
xml/playercards/BookofLivingMyths.xml
Normal file
@ -0,0 +1,48 @@
|
||||
<Defaults>
|
||||
<Button padding="50 50 50 50"
|
||||
font="font_teutonic-arkham"
|
||||
fontSize="300"
|
||||
iconWidth="400"
|
||||
iconAlignment="Right"/>
|
||||
<Panel position="0 -55 -22"
|
||||
rotation="0 0 180"
|
||||
height="900" width="1400"
|
||||
scale="0.1 0.1 1"/>
|
||||
<TableLayout active="false"
|
||||
cellSpacing="80"
|
||||
cellBackgroundColor="rgba(1,1,1,0)"/>
|
||||
</Defaults>
|
||||
|
||||
<Panel>
|
||||
<TableLayout id="actives">
|
||||
<Row>
|
||||
<Cell>
|
||||
<Button id="Bless" icon="bless" textColor="White"
|
||||
onClick="resolveToken" color="#9D702CE6" iconAlignment="Right">Resolve</Button>
|
||||
</Cell>
|
||||
</Row>
|
||||
<Row>
|
||||
<Cell>
|
||||
<Button id="Curse" icon="curse" textColor="White"
|
||||
onClick="resolveToken" color="#633A84E6">Resolve</Button>
|
||||
</Cell>
|
||||
</Row>
|
||||
</TableLayout>
|
||||
</Panel>
|
||||
|
||||
<Panel>
|
||||
<TableLayout id="inactives">
|
||||
<Row>
|
||||
<Cell>
|
||||
<Button id="inactiveBless" icon="bless" textColor="#A0A0A0"
|
||||
onClick="errorMessage" color="#353535E6">Resolve</Button>
|
||||
</Cell>
|
||||
</Row>
|
||||
<Row>
|
||||
<Cell>
|
||||
<Button id="inactiveCurse" icon="curse" textColor="#A0A0A0"
|
||||
onClick="errorMessage" color="#353535E6">Resolve</Button>
|
||||
</Cell>
|
||||
</Row>
|
||||
</TableLayout>
|
||||
</Panel>
|
Loading…
x
Reference in New Issue
Block a user