implemented usage of playmatapi

This commit is contained in:
Chr1Z93 2022-12-22 13:35:59 +01:00
parent 0b6eb32f75
commit bdccbf707b
2 changed files with 17 additions and 8 deletions

View File

@ -1,5 +1,7 @@
local MAT_GUIDS = { "8b081b", "bd0ff4", "383d8b", "0840d5" } local MAT_GUIDS = { "8b081b", "bd0ff4", "383d8b", "0840d5" }
local playmatAPI = require("playermat/PlaymatApi")
function onLoad() function onLoad()
self.addContextMenuItem("Discard 10 cards", shortSupply) self.addContextMenuItem("Discard 10 cards", shortSupply)
end end
@ -7,8 +9,7 @@ end
-- called by context menu entry -- called by context menu entry
function shortSupply(color) function shortSupply(color)
local cardPos = self.getPosition() local cardPos = self.getPosition()
local playerNumber = getPlayernumber(cardPos) local mat = playmatAPI.getMatbyColor(getMatColor(cardPos))
local mat = getObjectFromGUID(MAT_GUIDS[playerNumber])
if mat == nil then return end if mat == nil then return end
-- get draw deck and discard pile -- get draw deck and discard pile
@ -39,19 +40,21 @@ function shortSupply(color)
end end
end end
-- helper to find playernumber based on position -- helper to find playermat color based on position
function getPlayernumber(cardPos) function getMatColor(cardPos)
local color
if cardPos.x < -42 then if cardPos.x < -42 then
if cardPos.z > 0 then if cardPos.z > 0 then
return 1 color = "White"
else else
return 2 color = "Orange"
end end
else else
if cardPos.z > 0 then if cardPos.z > 0 then
return 3 color = "Green"
else else
return 4 color = "Red"
end end
end end
return color
end end

View File

@ -23,6 +23,12 @@ do
Red = "4111de" Red = "4111de"
} }
-- Returns the by color requested playermat as object
---@param matColor String Color of the playermat to return
PlaymatApi.getMatbyColor = function(matColor)
return getObjectFromGUID(MAT_IDS[matColor])
end
-- Sets the requested playermat's snap points to limit snapping to matching card types or not. If -- Sets the requested 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 -- 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 -- investigator area point will only snap Investigators. If matchTypes is false, snap points will