implemented usage of playmatapi
This commit is contained in:
parent
0b6eb32f75
commit
bdccbf707b
@ -1,5 +1,7 @@
|
||||
local MAT_GUIDS = { "8b081b", "bd0ff4", "383d8b", "0840d5" }
|
||||
|
||||
local playmatAPI = require("playermat/PlaymatApi")
|
||||
|
||||
function onLoad()
|
||||
self.addContextMenuItem("Discard 10 cards", shortSupply)
|
||||
end
|
||||
@ -7,8 +9,7 @@ end
|
||||
-- called by context menu entry
|
||||
function shortSupply(color)
|
||||
local cardPos = self.getPosition()
|
||||
local playerNumber = getPlayernumber(cardPos)
|
||||
local mat = getObjectFromGUID(MAT_GUIDS[playerNumber])
|
||||
local mat = playmatAPI.getMatbyColor(getMatColor(cardPos))
|
||||
if mat == nil then return end
|
||||
|
||||
-- get draw deck and discard pile
|
||||
@ -39,19 +40,21 @@ function shortSupply(color)
|
||||
end
|
||||
end
|
||||
|
||||
-- helper to find playernumber based on position
|
||||
function getPlayernumber(cardPos)
|
||||
-- helper to find playermat color based on position
|
||||
function getMatColor(cardPos)
|
||||
local color
|
||||
if cardPos.x < -42 then
|
||||
if cardPos.z > 0 then
|
||||
return 1
|
||||
color = "White"
|
||||
else
|
||||
return 2
|
||||
color = "Orange"
|
||||
end
|
||||
else
|
||||
if cardPos.z > 0 then
|
||||
return 3
|
||||
color = "Green"
|
||||
else
|
||||
return 4
|
||||
color = "Red"
|
||||
end
|
||||
end
|
||||
return color
|
||||
end
|
||||
|
@ -23,6 +23,12 @@ do
|
||||
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
|
||||
-- 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
|
||||
|
Loading…
x
Reference in New Issue
Block a user