minor update to blurse manager

This commit is contained in:
Chr1Z93 2024-01-09 16:38:44 +01:00
parent 8dcbce1542
commit 640c0dd8a2
6 changed files with 234 additions and 605 deletions

View File

@ -106,8 +106,6 @@
"AdditionalPlayerCards.2cba6b",
"BarkhamHorror.308439",
"ChaosBagStatTracker.766620",
"Blesstokens.afa06b",
"Cursetokens.bd0253",
"TokenSpawnTool.36b4ee",
"OfficialStandaloneChallengeScenarios.0ef5c8",
"TarotDeck.77f1e5",

View File

@ -1,87 +0,0 @@
{
"AltLookAngle": {
"x": 0,
"y": 0,
"z": 0
},
"Autoraise": true,
"Bag": {
"Order": 0
},
"ColorDiffuse": {
"b": 1,
"g": 1,
"r": 1
},
"ContainedObjects_order": [
"Bless.b2b7be",
"Bless.b2b7be",
"Bless.b2b7be",
"Bless.b2b7be",
"Bless.b2b7be",
"Bless.b2b7be",
"Bless.b2b7be",
"Bless.b2b7be",
"Bless.b2b7be",
"Bless.b2b7be"
],
"ContainedObjects_path": "Blesstokens.afa06b",
"CustomMesh": {
"CastShadows": true,
"ColliderURL": "",
"Convex": true,
"CustomShader": {
"FresnelStrength": 0,
"SpecularColor": {
"b": 1,
"g": 1,
"r": 1
},
"SpecularIntensity": 0,
"SpecularSharpness": 2
},
"DiffuseURL": "http://cloud-3.steamusercontent.com/ugc/1655601092778623873/C9EF4B44CE708DFC5A804FF2912C9F9B47323287/",
"MaterialIndex": 3,
"MeshURL": "https://pastebin.com/raw/ALrYhQGb",
"NormalURL": "",
"TypeIndex": 6
},
"Description": "",
"DragSelectable": true,
"GMNotes": "",
"GUID": "afa06b",
"Grid": true,
"GridProjection": false,
"Hands": false,
"HideWhenFaceDown": false,
"IgnoreFoW": false,
"LayoutGroupSortIndex": 0,
"Locked": true,
"LuaScript": "",
"LuaScriptState": "",
"MaterialIndex": -1,
"MeasureMovement": false,
"MeshIndex": -1,
"Name": "Custom_Model_Bag",
"Nickname": "Bless tokens",
"Snap": true,
"Sticky": true,
"Tags": [
"CleanUpHelper_ignore",
"displacement_excluded"
],
"Tooltip": true,
"Transform": {
"posX": 2.842,
"posY": 1.644,
"posZ": -11.239,
"rotX": 0,
"rotY": 225,
"rotZ": 0,
"scaleX": 0.7,
"scaleY": 0.7,
"scaleZ": 0.7
},
"Value": 0,
"XmlUI": ""
}

View File

@ -1,57 +0,0 @@
{
"AltLookAngle": {
"x": 0,
"y": 0,
"z": 0
},
"Autoraise": true,
"ColorDiffuse": {
"b": 0.04894,
"g": 0.32859,
"r": 0.37456
},
"CustomImage": {
"CustomTile": {
"Stackable": false,
"Stretch": true,
"Thickness": 0.1,
"Type": 2
},
"ImageScalar": 1,
"ImageSecondaryURL": "",
"ImageURL": "http://cloud-3.steamusercontent.com/ugc/1655601092778627699/339FB716CB25CA6025C338F13AFDFD9AC6FA8356/",
"WidthScale": 0
},
"Description": "",
"DragSelectable": true,
"GMNotes": "",
"GUID": "b2b7be",
"Grid": true,
"GridProjection": false,
"Hands": false,
"HideWhenFaceDown": false,
"IgnoreFoW": false,
"LayoutGroupSortIndex": 0,
"Locked": false,
"LuaScript": "",
"LuaScriptState": "",
"MeasureMovement": false,
"Name": "Custom_Tile",
"Nickname": "Bless",
"Snap": true,
"Sticky": true,
"Tooltip": true,
"Transform": {
"posX": -1.465,
"posY": 1.703,
"posZ": -26.93,
"rotX": 0,
"rotY": 90,
"rotZ": 0,
"scaleX": 0.81,
"scaleY": 1,
"scaleZ": 0.81
},
"Value": 0,
"XmlUI": ""
}

View File

@ -1,87 +0,0 @@
{
"AltLookAngle": {
"x": 0,
"y": 0,
"z": 0
},
"Autoraise": true,
"Bag": {
"Order": 0
},
"ColorDiffuse": {
"b": 1,
"g": 1,
"r": 1
},
"ContainedObjects_order": [
"Curse.678891",
"Curse.678891",
"Curse.678891",
"Curse.678891",
"Curse.678891",
"Curse.678891",
"Curse.678891",
"Curse.678891",
"Curse.678891",
"Curse.678891"
],
"ContainedObjects_path": "Cursetokens.bd0253",
"CustomMesh": {
"CastShadows": true,
"ColliderURL": "",
"Convex": true,
"CustomShader": {
"FresnelStrength": 0,
"SpecularColor": {
"b": 1,
"g": 1,
"r": 1
},
"SpecularIntensity": 0,
"SpecularSharpness": 2
},
"DiffuseURL": "http://cloud-3.steamusercontent.com/ugc/1655601092778633181/7A00AF905BCD6EB5D866F2107CECBC0A49E360F7/",
"MaterialIndex": 3,
"MeshURL": "https://pastebin.com/raw/ALrYhQGb",
"NormalURL": "",
"TypeIndex": 6
},
"Description": "",
"DragSelectable": true,
"GMNotes": "",
"GUID": "bd0253",
"Grid": true,
"GridProjection": false,
"Hands": false,
"HideWhenFaceDown": false,
"IgnoreFoW": false,
"LayoutGroupSortIndex": 0,
"Locked": true,
"LuaScript": "",
"LuaScriptState": "",
"MaterialIndex": -1,
"MeasureMovement": false,
"MeshIndex": -1,
"Name": "Custom_Model_Bag",
"Nickname": "Curse tokens",
"Snap": true,
"Sticky": true,
"Tags": [
"CleanUpHelper_ignore",
"displacement_excluded"
],
"Tooltip": true,
"Transform": {
"posX": 4.053,
"posY": 1.642,
"posZ": -12.449,
"rotX": 0,
"rotY": 225,
"rotZ": 0,
"scaleX": 0.7,
"scaleY": 0.7,
"scaleZ": 0.7
},
"Value": 0,
"XmlUI": ""
}

View File

@ -1,57 +0,0 @@
{
"AltLookAngle": {
"x": 0,
"y": 0,
"z": 0
},
"Autoraise": true,
"ColorDiffuse": {
"b": 0.44425,
"g": 0.00387,
"r": 0.27072
},
"CustomImage": {
"CustomTile": {
"Stackable": false,
"Stretch": true,
"Thickness": 0.1,
"Type": 2
},
"ImageScalar": 1,
"ImageSecondaryURL": "",
"ImageURL": "http://cloud-3.steamusercontent.com/ugc/1655601092778636039/2A25BD38E8C44701D80DD96BF0121DA21843672E/",
"WidthScale": 0
},
"Description": "",
"DragSelectable": true,
"GMNotes": "",
"GUID": "678891",
"Grid": true,
"GridProjection": false,
"Hands": false,
"HideWhenFaceDown": false,
"IgnoreFoW": false,
"LayoutGroupSortIndex": 0,
"Locked": false,
"LuaScript": "",
"LuaScriptState": "",
"MeasureMovement": false,
"Name": "Custom_Tile",
"Nickname": "Curse",
"Snap": true,
"Sticky": true,
"Tooltip": true,
"Transform": {
"posX": -46.206,
"posY": 1.789,
"posZ": -3.483,
"rotX": 0,
"rotY": 270,
"rotZ": 0,
"scaleX": 0.81,
"scaleY": 1,
"scaleZ": 0.81
},
"Value": 0,
"XmlUI": ""
}

View File

@ -8,58 +8,40 @@ buttonParamaters.color = { 0, 0, 0, 0 }
buttonParamaters.width = 700
buttonParamaters.height = 700
local altState = false
local MODE = {
[false] = "Add / Remove",
[true] = "Take / Return"
}
local BUTTON_COLOR = {
[false] = { 0.4, 0.4, 0.4 },
[true] = { 0.9, 0.9, 0.9 }
}
local FONT_COLOR = {
[false] = { 1, 1, 1 },
[true] = { 0, 0, 0 }
}
local whitespace = " "
local updating
---------------------------------------------------------
-- creating buttons and menus + initializing tables
---------------------------------------------------------
function onSave() return JSON.encode(altState) end
function onLoad(saved_state)
if saved_state ~= nil then
altState = JSON.decode(saved_state)
end
function onLoad()
-- index: 0 - bless
buttonParamaters.click_function = "clickBless"
buttonParamaters.position = { -1.03, 0.05, 0.46 }
buttonParamaters.position = { -1.03, 0, 0.46 }
buttonParamaters.tooltip = "Add / Remove Bless"
self.createButton(buttonParamaters)
-- index: 1 - curse
buttonParamaters.click_function = "clickCurse"
buttonParamaters.position[1] = -buttonParamaters.position[1]
buttonParamaters.tooltip = "Add / Remove Curse"
self.createButton(buttonParamaters)
-- index: 2 - alternative mode (take / return)
buttonParamaters.click_function = "enableAlt"
buttonParamaters.width = 900
buttonParamaters.height = 210
buttonParamaters.position = { -1.03, 0.05, -0.85 }
-- index: 2 - bless count
buttonParamaters.tooltip = ""
buttonParamaters.click_function = "none"
buttonParamaters.width = 0
buttonParamaters.height = 0
buttonParamaters.color = { 0.4, 0.4, 0.4 }
buttonParamaters.font_color = { 1, 1, 1 }
buttonParamaters.font_size = 235
buttonParamaters.position = { -1.03, 0.06, -0.8 }
self.createButton(buttonParamaters)
-- index: 3 - default mode (add / remove)
buttonParamaters.click_function = "enableDefault"
-- index: 3 - curse count
buttonParamaters.position[1] = -buttonParamaters.position[1]
self.createButton(buttonParamaters)
-- load labels, tooltips and colors
updateButtons()
-- context menu
self.addContextMenuItem("Remove all", doRemove)
self.addContextMenuItem("Reset", doReset)
@ -74,6 +56,7 @@ function resetTables()
numInPlay = { Bless = 0, Curse = 0 }
tokensTaken = { Bless = {}, Curse = {} }
sealedTokens = {}
updateButtonLabels()
end
function initializeState()
@ -105,6 +88,11 @@ function initializeState()
end
end
function updateButtonLabels()
self.editButton({ index = 2, label = formatTokenCount("Bless", true)})
self.editButton({ index = 3, label = formatTokenCount("Curse", true)})
end
function broadcastCount(token)
local count = formatTokenCount(token)
if count == "(0/0)" then return end
@ -116,7 +104,10 @@ function broadcastStatus(color)
broadcastToColor("Bless Tokens " .. formatTokenCount("Bless"), color, "White")
end
-- context menu function 1
---------------------------------------------------------
-- context menu functions
---------------------------------------------------------
function doRemove(color)
local chaosbag = chaosBagApi.findChaosBag()
@ -133,16 +124,13 @@ function doRemove(color)
end
end
broadcastToColor("Removed " .. count.Bless .. " Bless and " ..
count.Curse .. " Curse tokens from the chaos bag.", color, "White")
broadcastToColor("Removed " .. removeTakenTokens("Bless") .. " Bless and " ..
removeTakenTokens("Curse") .. " Curse tokens from play.", color, "White")
broadcastToColor("Removed " .. count.Bless .. " Bless and " .. count.Curse .. " Curse tokens from the chaos bag.", color, "White")
broadcastToColor("Removed " .. removeTakenTokens("Bless") .. " Bless and " .. removeTakenTokens("Curse") .. " Curse tokens from play.", color, "White")
resetTables()
tokenArrangerApi.layout()
end
-- context menu function 2
function doReset(color)
initializeState()
broadcastCount("Curse")
@ -150,112 +138,53 @@ function doReset(color)
tokenArrangerApi.layout()
end
-- removing tokens that were 'taken'
function removeTakenTokens(type)
local count = 0
for _, guid in ipairs(tokensTaken[type]) do
local token = getObjectFromGUID(guid)
if token ~= nil then
token.destruct()
count = count + 1
end
end
return count
end
---------------------------------------------------------
-- click functions
---------------------------------------------------------
-- click function 1
function clickBless(_, color, isRightClick)
playerColor = color
callFunctions("Bless", isRightClick)
end
-- click function 2
function clickCurse(_, color, isRightClick)
playerColor = color
callFunctions("Curse", isRightClick)
end
-- click function 3
function enableAlt()
if altState then return end
altState = not altState
updateButtons()
function callFunctions(type, isRightClick)
if not chaosBagApi.canTouchChaosTokens() then return end
if isRightClick then
removeToken(type)
else
addToken(type)
end
-- click function 4
function enableDefault()
if not altState then return end
altState = not altState
updateButtons()
tokenArrangerApi.layout()
end
---------------------------------------------------------
-- called functions
---------------------------------------------------------
function updateButtons()
self.editButton({
index = 0,
tooltip = MODE[altState] .. " Bless"
})
self.editButton({
index = 1,
tooltip = MODE[altState] .. " Curse"
})
self.editButton({
index = 2,
label = whitespace .. MODE[true] .. (altState and " ✓" or whitespace) .. " ",
color = BUTTON_COLOR[not altState],
font_color = FONT_COLOR[not altState]
})
self.editButton({
index = 3,
label = whitespace .. MODE[false] .. (altState and whitespace or " ✓") .. " ",
color = BUTTON_COLOR[altState],
font_color = FONT_COLOR[altState]
})
end
-- function that is called by click_functions 1+2 and calls the other functions
function callFunctions(token, isRightClick)
if not chaosBagApi.canTouchChaosTokens() then
return
end
local success
if not altState then
if isRightClick then
success = takeToken(token, true)
else
success = addToken(token)
end
else
if isRightClick then
success = returnToken(token)
else
success = takeToken(token, false)
end
end
if success ~= 0 then tokenArrangerApi.layout() end
end
-- returns a formatted string with information about the provided token type (bless / curse)
function formatTokenCount(type)
function formatTokenCount(type, omitBrackets)
if type == nil then type = mode end
if omitBrackets then
return (numInPlay[type] - #tokensTaken[type]) .. "/" .. #tokensTaken[type]
else
return "(" .. (numInPlay[type] - #tokensTaken[type]) .. "/" .. #tokensTaken[type] .. ")"
end
end
-- called by cards that seal bless/curse tokens
---@param param Table This contains the type and guid of the sealed token
function sealedToken(param)
table.insert(tokensTaken[param.type], param.guid)
broadcastCount(param.type)
updateButtonLabels()
end
-- called by cards that seal bless/curse tokens
@ -271,77 +200,65 @@ function releasedToken(param)
updating = true
Wait.frames(function()
broadcastCount(param.type)
updateButtonLabels()
updating = false
end, 1)
end
end
---------------------------------------------------------
-- main functions: add, take and return
-- main functions: add and remove
---------------------------------------------------------
function addToken(type)
if numInPlay[type] == 10 then
printToColor("10 tokens already in play, not adding any.", playerColor)
return 0
return
end
numInPlay[type] = numInPlay[type] + 1
printToAll("Adding " .. type .. " token " .. formatTokenCount(type))
updateButtonLabels()
return chaosBagApi.spawnChaosToken(type)
end
function takeToken(type, remove)
function removeToken(type)
local chaosbag = chaosBagApi.findChaosBag()
if not remove and not SEAL_CARD_MESSAGE then
broadcastToColor("For sealing tokens on cards try right-clicking on the card for seal options.", playerColor)
SEAL_CARD_MESSAGE = true
end
local tokens = {}
for _, v in ipairs(chaosbag.getObjects()) do
if v.name == type then
table.insert(tokens, v.guid)
end
end
if #tokens == 0 then
printToColor("No " .. type .. " tokens in the chaos bag.", playerColor)
return 0
return
end
local pos = self.getPosition() + Vector(2.25, 0, 0.85)
if type == "Curse" then pos[3] = pos[3] - 1.7 end
chaosbag.takeObject({
guid = table.remove(tokens),
position = pos,
smooth = false,
callback_function = function(obj)
if remove then
numInPlay[type] = numInPlay[type] - 1
printToAll("Removing " .. type .. " token " .. formatTokenCount(type))
updateButtonLabels()
obj.destruct()
else
table.insert(tokensTaken[type], obj.getGUID())
printToAll("Taking " .. type .. " token " .. formatTokenCount(type))
end
end
})
end
function returnToken(type)
local guid = table.remove(tokensTaken[type])
if guid == nil then
printToColor("No " .. type .. " tokens to return", playerColor)
return 0
end
-- removing tokens that were 'taken'
function removeTakenTokens(type)
local count = 0
for _, guid in ipairs(tokensTaken[type]) do
local token = getObjectFromGUID(guid)
if token == nil then
printToColor("Couldn't find token " .. guid .. ", not returning to bag", playerColor)
return 0
if token ~= nil then
token.destruct()
count = count + 1
end
local chaosbag = chaosBagApi.findChaosBag()
if chaosbag == nil then
return 0
end
chaosbag.putObject(token)
printToAll("Returning " .. type .. " token " .. formatTokenCount(type))
return count
end
---------------------------------------------------------
@ -429,3 +346,5 @@ function releaseToken(type, playerColor, enemy)
end
printToColor(type .. " token not sealed on " .. enemy.getName(), playerColor)
end
function none() end