more adjustments

This commit is contained in:
dscarpac 2024-02-14 16:46:38 -06:00
parent 73fa890eb2
commit 3be608a38c
9 changed files with 63 additions and 93 deletions

View File

@ -75,6 +75,5 @@
"Name": "curse",
"URL": "http://cloud-3.steamusercontent.com/ugc/2380784374775547135/2360372CBE9452CB7B4D135BE13BBA6D46B7D427/"
}
]
]
}

View File

@ -69,6 +69,8 @@ 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
---@param tokenType string Name of token (e.g. "Bless") to be drawn from the bag (optional)
---@param sealedToken string GUID of the sealed token to be resolved instead of drawing a token from the bag
ChaosBagApi.drawChaosToken = function(mat, drawAdditional, tokenType, cardSealedToken)
return Global.call("drawChaosToken", {mat = mat, drawAdditional = drawAdditional, tokenType = tokenType, sealedToken = guidToBeResolved})
end

View File

@ -303,34 +303,32 @@ function drawChaosToken(params)
-- add the token to the list, compute new position based on list length
tokenOffset[1] = tokenOffset[1] + (0.17 * #chaosTokens)
local tokenIndex = 0
if params.sealedToken then -- resolve a sealed token from a card
token = getObjectFromGUID(params.sealedToken)
token.setPositionSmooth(params.mat.positionToWorld(tokenOffset))
local guid = token.getGUID()
local type = token.getName()
if type == "Bless" or type == "Curse" then
blessCurseManagerApi.releasedToken(type, guid)
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
tokenIndex = i - 1
takeParameters.index = i - 1
end
end
else
tokenIndex = 0
end
token = chaosBag.takeObject({
index = tokenIndex,
position = params.mat.positionToWorld(tokenOffset),
rotation = params.mat.getRotation()
})
token = chaosBag.takeObject(takeParameters)
end
-- get data for token description

View File

@ -76,8 +76,10 @@ Thus it should be implemented like this:
local blessCurseManagerApi = require("chaosbag/BlessCurseManagerApi")
local chaosBagApi = require("chaosbag/ChaosBagApi")
local tokenArrangerApi = require("accessories/TokenArrangerApi")
local playmatApi = require("playermat/PlaymatApi")
local guidReferenceApi = require("core/GUIDReferenceApi")
sealedTokens = {}
local sealedTokens = {}
local ID_URL_MAP = {}
local tokensInBag = {}
@ -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 .. " token", 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")
guidToBeResolved = table.remove(sealedTokens)
chaosBagApi.drawChaosToken(mat, true, _, guidToBeResolved)
end

View File

@ -22,10 +22,8 @@ end
function deleteButtons()
self.UI.hide("active_bless")
self.UI.hide("inactive_bless")
self.UI.hide("inactive_curse")
self.UI.hide("active_curse")
self.UI.setAttribute("inactives", "active", false)
self.UI.setAttribute("actives", "active", false)
self.clearContextMenu()
self.addContextMenuItem("Enable Helper", createButtons)
Wait.stop(loopId)
@ -38,6 +36,10 @@ function createButtons()
self.addContextMenuItem("Clear Helper", deleteButtons)
self.UI.setAttribute("inactives", "active", true)
self.UI.setAttribute("actives", "active", true)
self.UI.show("inactive_bless")
self.UI.show("inactive_curse")
self.UI.hide("active_bless")
self.UI.hide("active_curse")
currentState = "Empty"
loopId = Wait.time(countBlessCurse, 1, -1)
end
@ -103,3 +105,13 @@ function countBlessCurse()
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

View File

@ -4,28 +4,6 @@ VALID_TOKENS = {
SHOW_SINGLE_RELEASE = true
KEEP_OPEN = true
RESOLVE_TOKEN = true
require("playercards/CardsThatSealTokens")
local playmatApi = require("playermat/PlaymatApi")
local guidReferenceApi = require("core/GUIDReferenceApi")
local chaosBagApi = require("chaosbag/ChaosBagApi")
local contextMenuAdded
function onCollisionEnter()
if contextMenuAdded then return end
contextMenuAdded = true
self.addContextMenuItem("Resolve sealed Curse", resolveSealed)
end
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")
guidToBeResolved = table.remove(sealedTokens)
chaosBagApi.drawChaosToken(mat, true, _, guidToBeResolved)
end

View File

@ -4,28 +4,6 @@ VALID_TOKENS = {
SHOW_SINGLE_RELEASE = true
KEEP_OPEN = true
RESOLVE_TOKEN = true
require("playercards/CardsThatSealTokens")
local playmatApi = require("playermat/PlaymatApi")
local guidReferenceApi = require("core/GUIDReferenceApi")
local chaosBagApi = require("chaosbag/ChaosBagApi")
local contextMenuAdded
function onCollisionEnter()
if contextMenuAdded then return end
contextMenuAdded = true
self.addContextMenuItem("Resolve sealed Bless", resolveSealed)
end
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")
guidToBeResolved = table.remove(sealedTokens)
chaosBagApi.drawChaosToken(mat, true, _, guidToBeResolved)
end

View File

@ -2,26 +2,6 @@ VALID_TOKENS = {
["Elder Sign"] = true
}
RESOLVE_TOKEN = true
require("playercards/CardsThatSealTokens")
local playmatApi = require("playermat/PlaymatApi")
local guidReferenceApi = require("core/GUIDReferenceApi")
local chaosBagApi = require("chaosbag/ChaosBagApi")
local contextMenuAdded
function onCollisionEnter()
if contextMenuAdded then return end
contextMenuAdded = true
self.addContextMenuItem("Resolve Elder Sign", resolveSealed)
end
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")
guidToBeResolved = table.remove(sealedTokens)
chaosBagApi.drawChaosToken(mat, true, _, guidToBeResolved)
end

View File

@ -13,7 +13,7 @@
<Row>
<Cell>
<Button id="active_curse" padding="50 50 50 50" icon="curse" iconWidth="400" font="font_teutonic-arkham" fontSize="300" textColor="White"
onClick="resolveCurse" color="#37232FE6" iconAlignment="Right">Resolve</Button>
onClick="resolveCurse" color="#633A84E6" iconAlignment="Right">Resolve</Button>
</Cell>
</Row>
</TableLayout>
@ -28,13 +28,13 @@
<Row>
<Cell>
<Button id="inactive_bless" padding="50 50 50 50" icon="bless" iconWidth="400" font="font_teutonic-arkham" fontSize="300" textColor="#A0A0A0"
color="#5C5C5CE6" iconAlignment="Right">Resolve</Button>
onClick="errorMessage" color="#353535E6" iconAlignment="Right">Resolve</Button>
</Cell>
</Row>
<Row>
<Cell>
<Button id="inactive_curse" padding="50 50 50 50" icon="curse" iconWidth="400" font="font_teutonic-arkham" fontSize="300" textColor="#A0A0A0"
color="#353535E6" iconAlignment="Right">Resolve</Button>
onClick="errorMessage" color="#353535E6" iconAlignment="Right">Resolve</Button>
</Cell>
</Row>
</TableLayout>