added releasing on discarding
This commit is contained in:
parent
f90257e03c
commit
1d74a84851
@ -40,7 +40,7 @@
|
|||||||
"Decoration-Coin.180a23",
|
"Decoration-Coin.180a23",
|
||||||
"Panel.463022",
|
"Panel.463022",
|
||||||
"TentacleStand.7bff34",
|
"TentacleStand.7bff34",
|
||||||
"ScriptingTrigger.83ef06",
|
"ChaosBagZone.83ef06",
|
||||||
"Cluetokens.11e0cf",
|
"Cluetokens.11e0cf",
|
||||||
"Doomtokens.b015d8",
|
"Doomtokens.b015d8",
|
||||||
"DoomCounter.85c4c6",
|
"DoomCounter.85c4c6",
|
||||||
|
@ -26,19 +26,19 @@
|
|||||||
"LuaScriptState": "",
|
"LuaScriptState": "",
|
||||||
"MeasureMovement": false,
|
"MeasureMovement": false,
|
||||||
"Name": "ScriptingTrigger",
|
"Name": "ScriptingTrigger",
|
||||||
"Nickname": "",
|
"Nickname": "ChaosBagZone",
|
||||||
"Snap": true,
|
"Snap": true,
|
||||||
"Sticky": true,
|
"Sticky": true,
|
||||||
"Tooltip": true,
|
"Tooltip": true,
|
||||||
"Transform": {
|
"Transform": {
|
||||||
"posX": 1.4,
|
"posX": 1.6,
|
||||||
"posY": 2.866,
|
"posY": 4.5,
|
||||||
"posZ": -13.4,
|
"posZ": -13.75,
|
||||||
"rotX": 0,
|
"rotX": 0,
|
||||||
"rotY": 90,
|
"rotY": 0,
|
||||||
"rotZ": 0,
|
"rotZ": 0,
|
||||||
"scaleX": 6,
|
"scaleX": 6,
|
||||||
"scaleY": 2,
|
"scaleY": 7,
|
||||||
"scaleZ": 6
|
"scaleZ": 6
|
||||||
},
|
},
|
||||||
"Value": 0,
|
"Value": 0,
|
@ -62,9 +62,9 @@ function initializeState()
|
|||||||
resetTables()
|
resetTables()
|
||||||
|
|
||||||
-- count tokens in the bag
|
-- count tokens in the bag
|
||||||
local chaosbag = chaosBagApi.findChaosBag()
|
local chaosBag = chaosBagApi.findChaosBag()
|
||||||
local tokens = {}
|
local tokens = {}
|
||||||
for _, v in ipairs(chaosbag.getObjects()) do
|
for _, v in ipairs(chaosBag.getObjects()) do
|
||||||
if v.name == "Bless" then
|
if v.name == "Bless" then
|
||||||
numInPlay.Bless = numInPlay.Bless + 1
|
numInPlay.Bless = numInPlay.Bless + 1
|
||||||
elseif v.name == "Curse" then
|
elseif v.name == "Curse" then
|
||||||
@ -113,8 +113,14 @@ end
|
|||||||
function onObjectDrop(_, object)
|
function onObjectDrop(_, object)
|
||||||
if not isBlurseToken(object) then return end
|
if not isBlurseToken(object) then return end
|
||||||
|
|
||||||
|
-- check if object was dropped in chaos bag area
|
||||||
|
for _, zone in ipairs(object.getZones()) do
|
||||||
|
if zone.getName() == "ChaosBagZone" then
|
||||||
trackBagChange = true
|
trackBagChange = true
|
||||||
Wait.time(function() trackBagChange = false end, 1)
|
Wait.time(function() trackBagChange = false end, 1)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- handle manual returning of bless / curse tokens
|
-- handle manual returning of bless / curse tokens
|
||||||
@ -140,13 +146,13 @@ end
|
|||||||
---------------------------------------------------------
|
---------------------------------------------------------
|
||||||
|
|
||||||
function doRemove(color)
|
function doRemove(color)
|
||||||
local chaosbag = chaosBagApi.findChaosBag()
|
local chaosBag = chaosBagApi.findChaosBag()
|
||||||
|
|
||||||
-- remove tokens from chaos bag
|
-- remove tokens from chaos bag
|
||||||
local count = { Bless = 0, Curse = 0 }
|
local count = { Bless = 0, Curse = 0 }
|
||||||
for _, v in ipairs(chaosbag.getObjects()) do
|
for _, v in ipairs(chaosBag.getObjects()) do
|
||||||
if v.name == "Bless" or v.name == "Curse" then
|
if v.name == "Bless" or v.name == "Curse" then
|
||||||
chaosbag.takeObject({
|
chaosBag.takeObject({
|
||||||
guid = v.guid,
|
guid = v.guid,
|
||||||
position = { 0, 5, 0 },
|
position = { 0, 5, 0 },
|
||||||
callback_function = function(obj) obj.destruct() end
|
callback_function = function(obj) obj.destruct() end
|
||||||
@ -228,14 +234,7 @@ function releasedToken(param)
|
|||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if not updating then
|
updateDisplayAndBroadcast(param.type)
|
||||||
updating = true
|
|
||||||
Wait.frames(function()
|
|
||||||
broadcastCount(param.type)
|
|
||||||
updateButtonLabels()
|
|
||||||
updating = false
|
|
||||||
end, 1)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- removes a token (called by cards that seal bless/curse tokens)
|
-- removes a token (called by cards that seal bless/curse tokens)
|
||||||
@ -248,13 +247,17 @@ function returnedToken(param)
|
|||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
updateDisplayAndBroadcast(param.type)
|
||||||
|
end
|
||||||
|
|
||||||
|
function updateDisplayAndBroadcast(type)
|
||||||
if not updating then
|
if not updating then
|
||||||
updating = true
|
updating = true
|
||||||
Wait.frames(function()
|
Wait.frames(function()
|
||||||
broadcastCount(param.type)
|
broadcastCount(type)
|
||||||
updateButtonLabels()
|
updateButtonLabels()
|
||||||
updating = false
|
updating = false
|
||||||
end, 1)
|
end, 5)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -274,10 +277,10 @@ function addToken(type)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function removeToken(type)
|
function removeToken(type)
|
||||||
local chaosbag = chaosBagApi.findChaosBag()
|
local chaosBag = chaosBagApi.findChaosBag()
|
||||||
local tokens = {}
|
local tokens = {}
|
||||||
|
|
||||||
for _, v in ipairs(chaosbag.getObjects()) do
|
for _, v in ipairs(chaosBag.getObjects()) do
|
||||||
if v.name == type then
|
if v.name == type then
|
||||||
table.insert(tokens, v.guid)
|
table.insert(tokens, v.guid)
|
||||||
end
|
end
|
||||||
@ -288,7 +291,7 @@ function removeToken(type)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
chaosbag.takeObject({
|
chaosBag.takeObject({
|
||||||
guid = table.remove(tokens),
|
guid = table.remove(tokens),
|
||||||
smooth = false,
|
smooth = false,
|
||||||
callback_function = function(obj)
|
callback_function = function(obj)
|
||||||
@ -353,52 +356,48 @@ function addMenuOptions(parameters)
|
|||||||
sealedTokens[hoveredObject.getGUID()] = {}
|
sealedTokens[hoveredObject.getGUID()] = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
function sealToken(type, playerColor, enemy)
|
function sealToken(type, playerColor, hoveredObject)
|
||||||
local chaosbag = chaosBagApi.findChaosBag()
|
local chaosBag = chaosBagApi.findChaosBag()
|
||||||
if chaosbag == nil then return end
|
|
||||||
local pos = enemy.getPosition()
|
|
||||||
|
|
||||||
for i, token in ipairs(chaosbag.getObjects()) do
|
for i, token in ipairs(chaosBag.getObjects()) do
|
||||||
if token.name == type then
|
if token.name == type then
|
||||||
chaosbag.takeObject({
|
return chaosBag.takeObject({
|
||||||
position = { pos.x, pos.y + 1, pos.z },
|
position = hoveredObject.getPosition() + Vector(0, 1, 0),
|
||||||
index = i - 1,
|
index = i - 1,
|
||||||
smooth = false,
|
smooth = false,
|
||||||
callback_function = function(obj)
|
callback_function = function(obj)
|
||||||
Wait.frames(function()
|
table.insert(sealedTokens[hoveredObject.getGUID()], obj)
|
||||||
table.insert(sealedTokens[enemy.getGUID()], obj)
|
|
||||||
table.insert(tokensTaken[type], obj.getGUID())
|
table.insert(tokensTaken[type], obj.getGUID())
|
||||||
printToColor("Sealing " .. type .. " token " .. formatTokenCount(type), playerColor)
|
tokenArrangerApi.layout()
|
||||||
end, 1)
|
updateDisplayAndBroadcast(type)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
return
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
printToColor(type .. " token not found in bag", playerColor)
|
printToColor(type .. " token not found in bag", playerColor)
|
||||||
end
|
end
|
||||||
|
|
||||||
function releaseToken(type, playerColor, enemy)
|
function releaseToken(type, playerColor, hoveredObject)
|
||||||
local chaosbag = chaosBagApi.findChaosBag()
|
local chaosBag = chaosBagApi.findChaosBag()
|
||||||
if chaosbag == nil then return end
|
local tokens = sealedTokens[hoveredObject.getGUID()]
|
||||||
local tokens = sealedTokens[enemy.getGUID()]
|
|
||||||
if tokens == nil or #tokens == 0 then return end
|
if tokens == nil or #tokens == 0 then return end
|
||||||
|
|
||||||
for i, token in ipairs(tokens) do
|
for i, token in ipairs(tokens) do
|
||||||
if token ~= nil and token.getName() == type then
|
if token ~= nil and token.getName() == type then
|
||||||
local guid = token.getGUID()
|
local guid = token.getGUID()
|
||||||
chaosbag.putObject(token)
|
chaosBag.putObject(token)
|
||||||
for j, v in ipairs(tokensTaken[type]) do
|
for j, v in ipairs(tokensTaken[type]) do
|
||||||
if v == guid then
|
if v == guid then
|
||||||
table.remove(tokensTaken[type], j)
|
table.remove(tokensTaken[type], j)
|
||||||
table.remove(tokens, i)
|
table.remove(tokens, i)
|
||||||
printToColor("Releasing " .. type .. " token" .. formatTokenCount(type), playerColor)
|
tokenArrangerApi.layout()
|
||||||
|
updateDisplayAndBroadcast(type)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
printToColor(type .. " token not sealed on " .. enemy.getName(), playerColor)
|
printToColor(type .. " token not sealed on " .. hoveredObject.getName(), playerColor)
|
||||||
end
|
end
|
||||||
|
|
||||||
function none() end
|
function none() end
|
||||||
|
@ -44,6 +44,12 @@ do
|
|||||||
return Global.call("removeChaosToken", id)
|
return Global.call("removeChaosToken", id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- returns a chaos token to the bag and calls all relevant functions
|
||||||
|
---@param token TTSObject Chaos Token to return
|
||||||
|
ChaosBagApi.returnChaosTokenToBag = function(token)
|
||||||
|
return Global.call("returnChaosTokenToBag", token)
|
||||||
|
end
|
||||||
|
|
||||||
-- spawns the specified chaos token and puts it into the chaos bag
|
-- spawns the specified chaos token and puts it into the chaos bag
|
||||||
---@param id String ID of the chaos token
|
---@param id String ID of the chaos token
|
||||||
ChaosBagApi.spawnChaosToken = function(id)
|
ChaosBagApi.spawnChaosToken = function(id)
|
||||||
|
@ -252,6 +252,18 @@ function returnChaosTokens()
|
|||||||
chaosTokens = {}
|
chaosTokens = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- returns a single chaos token to the bag and calls respective functions
|
||||||
|
function returnChaosTokenToBag(token)
|
||||||
|
local name = token.getName()
|
||||||
|
local guid = token.getGUID()
|
||||||
|
local chaosBag = findChaosBag()
|
||||||
|
chaosBag.putObject(token)
|
||||||
|
tokenArrangerApi.layout()
|
||||||
|
if name == "Bless" or name == "Curse" then
|
||||||
|
blessCurseManagerApi.releasedToken(name, guid)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens
|
-- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens
|
||||||
-- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the
|
-- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the
|
||||||
-- contents of the bag should check this method before doing so.
|
-- contents of the bag should check this method before doing so.
|
||||||
|
@ -149,6 +149,10 @@ function readBag()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function resetSealedTokens()
|
||||||
|
sealedTokens = {}
|
||||||
|
end
|
||||||
|
|
||||||
-- native event from TTS - used to update the context menu for cards like "Unrelenting"
|
-- native event from TTS - used to update the context menu for cards like "Unrelenting"
|
||||||
function onHover()
|
function onHover()
|
||||||
if UPDATE_ON_HOVER then
|
if UPDATE_ON_HOVER then
|
||||||
|
@ -213,8 +213,7 @@ function discardListOfObjects(objList)
|
|||||||
end
|
end
|
||||||
-- put chaos tokens back into bag (e.g. Unrelenting)
|
-- put chaos tokens back into bag (e.g. Unrelenting)
|
||||||
elseif tokenChecker.isChaosToken(obj) then
|
elseif tokenChecker.isChaosToken(obj) then
|
||||||
local chaosBag = chaosBagApi.findChaosBag()
|
chaosBagApi.returnChaosTokenToBag(obj)
|
||||||
chaosBag.putObject(obj)
|
|
||||||
-- don't touch locked objects (like the table etc.)
|
-- don't touch locked objects (like the table etc.)
|
||||||
elseif not obj.getLock() then
|
elseif not obj.getLock() then
|
||||||
ownedObjects.Trash.putObject(obj)
|
ownedObjects.Trash.putObject(obj)
|
||||||
@ -660,15 +659,23 @@ end
|
|||||||
|
|
||||||
-- removes tokens from the provided card/deck
|
-- removes tokens from the provided card/deck
|
||||||
function removeTokensFromObject(object)
|
function removeTokensFromObject(object)
|
||||||
|
if object.hasTag("CardThatSeals") then
|
||||||
|
local func = object.getVar("resetSealedTokens") -- check if function exists (it won't for older custom content)
|
||||||
|
if func ~= nil then
|
||||||
|
object.call("resetSealedTokens")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
for _, obj in ipairs(searchLib.onObject(object)) do
|
for _, obj in ipairs(searchLib.onObject(object)) do
|
||||||
if obj.getGUID() ~= "4ee1f2" and -- table
|
if tokenChecker.isChaosToken(obj) then
|
||||||
|
chaosBagApi.returnChaosTokenToBag(obj)
|
||||||
|
elseif obj.getGUID() ~= "4ee1f2" and -- table
|
||||||
obj ~= self and
|
obj ~= self and
|
||||||
obj.type ~= "Deck" and
|
obj.type ~= "Deck" and
|
||||||
obj.type ~= "Card" and
|
obj.type ~= "Card" and
|
||||||
obj.memo ~= nil and
|
obj.memo ~= nil and
|
||||||
obj.getLock() == false and
|
obj.getLock() == false and
|
||||||
obj.getDescription() ~= "Action Token" and
|
obj.getDescription() ~= "Action Token" then
|
||||||
not tokenChecker.isChaosToken(obj) then
|
|
||||||
ownedObjects.Trash.putObject(obj)
|
ownedObjects.Trash.putObject(obj)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user