moving clue handling to playermatapi
This commit is contained in:
parent
d47bc0845a
commit
bbd9151227
@ -1,22 +1,7 @@
|
||||
local clueCounters = {}
|
||||
local clueCounterGUIDS = {
|
||||
"37be78",
|
||||
"1769ed",
|
||||
"032300",
|
||||
"d86b7c"
|
||||
}
|
||||
|
||||
local clueClickers = {}
|
||||
local clueClickerGUIDS = {
|
||||
"db85d6",
|
||||
"3f22e5",
|
||||
"891403",
|
||||
"4111de"
|
||||
}
|
||||
|
||||
count = 0
|
||||
useClickableCounters = false
|
||||
|
||||
local playmatAPI = require("playermat/PlaymatApi")
|
||||
function onSave() return JSON.encode(useClickableCounters) end
|
||||
|
||||
function onLoad(savedData)
|
||||
@ -37,41 +22,18 @@ function onLoad(savedData)
|
||||
color = { 0, 0, 0, 0 }
|
||||
})
|
||||
|
||||
-- loading object references to the clue counters / clickers via GUID
|
||||
for i = 1, 4 do
|
||||
clueCounters[i] = getObjectFromGUID(clueCounterGUIDS[i])
|
||||
clueClickers[i] = getObjectFromGUID(clueClickerGUIDS[i])
|
||||
end
|
||||
|
||||
loopID = Wait.time(sumClues, 2, -1)
|
||||
end
|
||||
|
||||
-- removes all player clues by calling the respective function from the counting bowls / clickers
|
||||
function removeAllPlayerClues()
|
||||
printToAll(count .. " clue(s) from playermats removed.", "White")
|
||||
if useClickableCounters then
|
||||
for i = 1, 4 do
|
||||
clueClickers[i].call("updateVal", 0)
|
||||
end
|
||||
else
|
||||
for i = 1, 4 do
|
||||
clueCounters[i].call("removeAllClues")
|
||||
end
|
||||
end
|
||||
playmatAPI.removeClues("All")
|
||||
self.editButton({ index = 0, label = "0" })
|
||||
end
|
||||
|
||||
-- gets the counted values from the counting bowls / clickers and sums them up
|
||||
function sumClues()
|
||||
count = 0
|
||||
if useClickableCounters then
|
||||
for i = 1, 4 do
|
||||
count = count + tonumber(clueClickers[i].getVar("val"))
|
||||
end
|
||||
else
|
||||
for i = 1, 4 do
|
||||
count = count + tonumber(clueCounters[i].getVar("exposedValue"))
|
||||
end
|
||||
end
|
||||
count = playmatAPI.getClueCount(useClickableCounters, "All")
|
||||
self.editButton({ index = 0, label = tostring(count) })
|
||||
end
|
||||
|
@ -689,7 +689,7 @@ function showDrawButton(visible)
|
||||
end
|
||||
|
||||
-- Spawns / destroys a clickable clue counter for this playmat with the correct amount of clues
|
||||
---@param showCounter Boolean. Whether the clickable clue counter should be present
|
||||
---@param showCounter Boolean Whether the clickable clue counter should be present
|
||||
function clickableClues(showCounter)
|
||||
local CLUE_COUNTER = getObjectFromGUID(CLUE_COUNTER_GUID)
|
||||
local CLUE_CLICKER = getObjectFromGUID(CLUE_CLICKER_GUID)
|
||||
@ -726,6 +726,30 @@ function clickableClues(showCounter)
|
||||
end
|
||||
end
|
||||
|
||||
-- removes all clues (moving tokens to the trash and setting counters to 0)
|
||||
function removeClues()
|
||||
local CLUE_COUNTER = getObjectFromGUID(CLUE_COUNTER_GUID)
|
||||
local CLUE_CLICKER = getObjectFromGUID(CLUE_CLICKER_GUID)
|
||||
|
||||
CLUE_COUNTER.call("removeAllClues")
|
||||
CLUE_CLICKER.call("updateVal", 0)
|
||||
end
|
||||
|
||||
-- reports the clue count
|
||||
---@param useClickableCounters Boolean Controls which type of counter is getting checked
|
||||
function getClueCount(useClickableCounters)
|
||||
local count = 0
|
||||
|
||||
if useClickableCounters then
|
||||
local CLUE_CLICKER = getObjectFromGUID(CLUE_CLICKER_GUID)
|
||||
count = tonumber(CLUE_CLICKER.getVar("val"))
|
||||
else
|
||||
local CLUE_COUNTER = getObjectFromGUID(CLUE_COUNTER_GUID)
|
||||
count = tonumber(CLUE_COUNTER.getVar("exposedValue"))
|
||||
end
|
||||
return count
|
||||
end
|
||||
|
||||
-- Sets this playermat's snap points to limit snapping to matching card types or not. If matchTypes
|
||||
-- is true, the main card slot snap points will only snap assets, while the investigator area point
|
||||
-- will only snap Investigators. If matchTypes is false, snap points will be reset to snap all
|
||||
|
@ -6,7 +6,21 @@ do
|
||||
White = "8b081b",
|
||||
Orange = "bd0ff4",
|
||||
Green = "383d8b",
|
||||
Red = "0840d5",
|
||||
Red = "0840d5"
|
||||
}
|
||||
|
||||
local CLUE_COUNTER_GUIDS = {
|
||||
White = "37be78",
|
||||
Orange = "1769ed",
|
||||
Green = "032300",
|
||||
Red = "d86b7c"
|
||||
}
|
||||
|
||||
local CLUE_CLICKER_GUIDS = {
|
||||
White = "db85d6",
|
||||
Orange = "3f22e5",
|
||||
Green = "891403",
|
||||
Red = "4111de"
|
||||
}
|
||||
|
||||
-- Sets the requested playermat's snap points to limit snapping to matching card types or not. If
|
||||
@ -23,7 +37,6 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- Sets the requested playermat's draw 1 button to visible
|
||||
---@param isDrawButtonVisible Boolean. Whether the draw 1 button should be visible or not
|
||||
---@param matColor String for one of the active player colors - White, Orange, Green, Red. Also
|
||||
@ -44,6 +57,25 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
-- Removes all clues (to the trash for tokens and counters set to 0) for the requested playermat
|
||||
---@param matColor String for one of the active player colors - White, Orange, Green, Red. Also
|
||||
-- accepts "All" as a special value which will apply the setting to all four mats.
|
||||
PlaymatApi.removeClues = function(matColor)
|
||||
for _, mat in ipairs(internal.getMatForColor(matColor)) do
|
||||
mat.call("removeClues")
|
||||
end
|
||||
end
|
||||
|
||||
-- Reports the clue count for the requested playermat
|
||||
---@param useClickableCounters Boolean Controls which type of counter is getting checked
|
||||
PlaymatApi.getClueCount = function(useClickableCounters, matColor)
|
||||
local count = 0
|
||||
for _, mat in ipairs(internal.getMatForColor(matColor)) do
|
||||
count = count + tonumber(mat.call("getClueCount", useClickableCounters))
|
||||
end
|
||||
return count
|
||||
end
|
||||
|
||||
-- Convenience function to look up a mat's object by color, or get all mats.
|
||||
---@param matColor String for one of the active player colors - White, Orange, Green, Red. Also
|
||||
-- accepts "All" as a special value which will return all four mats.
|
||||
|
@ -17,7 +17,7 @@
|
||||
<Button icon="yog-sothoth" tooltip="Extras" onClick="onClick_toggleUi(Extras)"/>
|
||||
<Button icon="elder-sign" tooltip="Investigators" onClick="onClick_toggleUi(Investigators)"/>
|
||||
<Button icon="devourer" tooltip="Community Content" onClick="onClick_toggleUi(Community Content)"/>
|
||||
<Button icon="option-gear" tooltip="Options" onClick="onClick_toggleUi(Options)" active="false"/>
|
||||
<Button icon="option-gear" tooltip="Options" onClick="onClick_toggleUi(Options)"/>
|
||||
<!--<Button icon="download" tooltip="ArkhamDB Deck Importer" onClick="onClick_toggleUi(Deck Importer)"/> -->
|
||||
</VerticalLayout>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user