added "return mini card" function and prelude detection
This commit is contained in:
parent
57db06c708
commit
bd1f62e73c
@ -6,6 +6,7 @@
|
|||||||
local blessCurseManagerApi = require("chaosbag/BlessCurseManagerApi")
|
local blessCurseManagerApi = require("chaosbag/BlessCurseManagerApi")
|
||||||
local chaosBagApi = require("chaosbag/ChaosBagApi")
|
local chaosBagApi = require("chaosbag/ChaosBagApi")
|
||||||
local guidReferenceApi = require("core/GUIDReferenceApi")
|
local guidReferenceApi = require("core/GUIDReferenceApi")
|
||||||
|
local mythosAreaApi = require("core/MythosAreaApi")
|
||||||
local playAreaApi = require("core/PlayAreaApi")
|
local playAreaApi = require("core/PlayAreaApi")
|
||||||
local playmatApi = require("playermat/PlaymatApi")
|
local playmatApi = require("playermat/PlaymatApi")
|
||||||
local searchLib = require("util/SearchLib")
|
local searchLib = require("util/SearchLib")
|
||||||
@ -27,6 +28,12 @@ options["importTrauma"] = true
|
|||||||
options["tidyPlayermats"] = true
|
options["tidyPlayermats"] = true
|
||||||
options["removeDrawnLines"] = false
|
options["removeDrawnLines"] = false
|
||||||
|
|
||||||
|
-- don't clean playmats for preludes
|
||||||
|
local scenarioName
|
||||||
|
local preludeList = {
|
||||||
|
["Prelude: Welcome to Hemlock Vale!"] = true
|
||||||
|
}
|
||||||
|
|
||||||
local buttonParameters = {}
|
local buttonParameters = {}
|
||||||
buttonParameters.function_owner = self
|
buttonParameters.function_owner = self
|
||||||
|
|
||||||
@ -109,6 +116,7 @@ function cleanUp(_, color)
|
|||||||
printToAll("Clean up started!", "Orange")
|
printToAll("Clean up started!", "Orange")
|
||||||
printToAll("Resetting counters...", "White")
|
printToAll("Resetting counters...", "White")
|
||||||
|
|
||||||
|
getScenarioName()
|
||||||
soundCubeApi.playSoundByName("Vacuum")
|
soundCubeApi.playSoundByName("Vacuum")
|
||||||
ignoreCustomDataHelper()
|
ignoreCustomDataHelper()
|
||||||
getTrauma()
|
getTrauma()
|
||||||
@ -119,6 +127,7 @@ function cleanUp(_, color)
|
|||||||
resetDoomCounter()
|
resetDoomCounter()
|
||||||
blessCurseManagerApi.removeAll(color)
|
blessCurseManagerApi.removeAll(color)
|
||||||
removeLines()
|
removeLines()
|
||||||
|
returnMiniCards()
|
||||||
discardHands()
|
discardHands()
|
||||||
chaosBagApi.returnChaosTokens()
|
chaosBagApi.returnChaosTokens()
|
||||||
chaosBagApi.releaseAllSealedTokens(color)
|
chaosBagApi.releaseAllSealedTokens(color)
|
||||||
@ -132,8 +141,13 @@ end
|
|||||||
-- modular functions, called by other functions
|
-- modular functions, called by other functions
|
||||||
---------------------------------------------------------
|
---------------------------------------------------------
|
||||||
|
|
||||||
|
function getScenarioName()
|
||||||
|
local tokenData = mythosAreaApi.returnTokenData()
|
||||||
|
scenarioName = tokenData.currentScenario
|
||||||
|
end
|
||||||
|
|
||||||
function updateCounters()
|
function updateCounters()
|
||||||
if not options["tidyPlayermats"] then return end
|
if not getOptionValue() then return end
|
||||||
|
|
||||||
playmatApi.updateCounter("All", "ResourceCounter", 5)
|
playmatApi.updateCounter("All", "ResourceCounter", 5)
|
||||||
playmatApi.updateCounter("All", "ClickableClueCounter", 0)
|
playmatApi.updateCounter("All", "ClickableClueCounter", 0)
|
||||||
@ -228,9 +242,33 @@ function removeLines()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- returns the mini cards back to the owning mat
|
||||||
|
function returnMiniCards()
|
||||||
|
-- stop if playermats get tidied anyway
|
||||||
|
if getOptionValue() then return end
|
||||||
|
|
||||||
|
-- get mini cards in play
|
||||||
|
local miniCardIndex = {}
|
||||||
|
for _, obj in ipairs(getObjectsWithTag("Minicard")) do
|
||||||
|
local notes = JSON.decode(obj.getGMNotes())
|
||||||
|
if notes ~= nil and notes.id then
|
||||||
|
miniCardIndex[notes.id] = obj
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- move mini cards
|
||||||
|
for _, mat in pairs(guidReferenceApi.getObjectsByType("Playermat")) do
|
||||||
|
local miniId = mat.getVar("activeInvestigatorId") .. "-m"
|
||||||
|
if miniCardIndex[miniId] then
|
||||||
|
local pos = mat.positionToWorld(Vector(-1.36, 0, -0.625)):setAt("y", 1.67)
|
||||||
|
miniCardIndex[miniId].setPosition(pos)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- discard all hand objects
|
-- discard all hand objects
|
||||||
function discardHands()
|
function discardHands()
|
||||||
if not options["tidyPlayermats"] then return end
|
if not getOptionValue() then return end
|
||||||
for i = 1, 4 do
|
for i = 1, 4 do
|
||||||
local trash = guidReferenceApi.getObjectByOwnerAndType(COLORS[i], "Trash")
|
local trash = guidReferenceApi.getObjectByOwnerAndType(COLORS[i], "Trash")
|
||||||
if trash == nil then return end
|
if trash == nil then return end
|
||||||
@ -255,6 +293,11 @@ end
|
|||||||
|
|
||||||
-- clean up for play area
|
-- clean up for play area
|
||||||
function tidyPlayareaCoroutine()
|
function tidyPlayareaCoroutine()
|
||||||
|
-- small wait to allow other operations to finish
|
||||||
|
for k = 1, 10 do
|
||||||
|
coroutine.yield(0)
|
||||||
|
end
|
||||||
|
|
||||||
local trash = guidReferenceApi.getObjectByOwnerAndType("Mythos", "Trash")
|
local trash = guidReferenceApi.getObjectByOwnerAndType("Mythos", "Trash")
|
||||||
local playAreaZone = guidReferenceApi.getObjectByOwnerAndType("Mythos", "PlayAreaZone")
|
local playAreaZone = guidReferenceApi.getObjectByOwnerAndType("Mythos", "PlayAreaZone")
|
||||||
|
|
||||||
@ -288,7 +331,7 @@ function tidyPlayerMatCoroutine()
|
|||||||
|
|
||||||
for i = 1, 5 do
|
for i = 1, 5 do
|
||||||
-- only continue for playermat (1-4) if option enabled
|
-- only continue for playermat (1-4) if option enabled
|
||||||
if options["tidyPlayermats"] or i == 5 then
|
if getOptionValue() or i == 5 then
|
||||||
-- delay for animation purpose
|
-- delay for animation purpose
|
||||||
for k = 1, 30 do
|
for k = 1, 30 do
|
||||||
coroutine.yield(0)
|
coroutine.yield(0)
|
||||||
@ -387,3 +430,13 @@ function getTekeliliHelper()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- get value with respect to override value
|
||||||
|
function getOptionValue()
|
||||||
|
-- don't clean up playermats if playing a prelude from the list
|
||||||
|
if preludeList[scenarioName] then
|
||||||
|
return false
|
||||||
|
else
|
||||||
|
return options["tidyPlayermats"]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@ -10,13 +10,13 @@ do
|
|||||||
MythosAreaApi.returnTokenData = function()
|
MythosAreaApi.returnTokenData = function()
|
||||||
return getMythosArea().call("returnTokenData")
|
return getMythosArea().call("returnTokenData")
|
||||||
end
|
end
|
||||||
|
|
||||||
---@return any: Object reference to the encounter deck
|
---@return any: Object reference to the encounter deck
|
||||||
MythosAreaApi.getEncounterDeck = function()
|
MythosAreaApi.getEncounterDeck = function()
|
||||||
return getMythosArea().call("getEncounterDeck")
|
return getMythosArea().call("getEncounterDeck")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- draw an encounter card for the requesting mat to the first empty spot from the right
|
-- draw an encounter card for the requesting mat to the first empty spot from the right
|
||||||
---@param matColor string Playermat that triggered this
|
---@param matColor string Playermat that triggered this
|
||||||
---@param position tts__Vector Position for the encounter card
|
---@param position tts__Vector Position for the encounter card
|
||||||
MythosAreaApi.drawEncounterCard = function(matColor, position)
|
MythosAreaApi.drawEncounterCard = function(matColor, position)
|
||||||
@ -27,6 +27,6 @@ do
|
|||||||
MythosAreaApi.reshuffleEncounterDeck = function()
|
MythosAreaApi.reshuffleEncounterDeck = function()
|
||||||
getMythosArea().call("reshuffleEncounterDeck")
|
getMythosArea().call("reshuffleEncounterDeck")
|
||||||
end
|
end
|
||||||
|
|
||||||
return MythosAreaApi
|
return MythosAreaApi
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user