implementing further usage of playmatAPI

This commit is contained in:
Chr1Z93 2022-12-30 20:25:50 +01:00
parent d974532072
commit f464e5f0ff
2 changed files with 36 additions and 33 deletions

View File

@ -6,14 +6,13 @@ end
-- called by context menu entry
function shortSupply(color)
local cardPos = self.getPosition()
local mat = playmatAPI.getMatbyPosition(cardPos)
if mat == nil then return end
local matColor = playmatAPI.getMatColorbyPosition(self.getPosition())
-- get draw deck and discard pile
mat.call("getDrawDiscardDecks")
local drawDeck = mat.getVar("drawDeck")
local discardPos = mat.getTable("DISCARD_PILE_POSITION")
-- get draw deck and discard position
local drawDeck = playmatAPI.getDrawDeck(matColor)
local discardPos = playmatAPI.getDiscardPosition(matColor)
-- error handling
if discardPos == nil then
broadcastToAll("Couldn't retrieve discard position from playermat!", "Red")
return
@ -31,9 +30,6 @@ function shortSupply(color)
discardPos.y = 0.5
for i = 1, 10 do
discardPos.y = discardPos.y + 0.05 * i
drawDeck.takeObject({
flip = true,
position = discardPos
})
drawDeck.takeObject({ flip = true, position = discardPos })
end
end

View File

@ -3,24 +3,24 @@ do
local internal = { }
local MAT_IDS = {
White = "8b081b",
White = "8b081b",
Orange = "bd0ff4",
Green = "383d8b",
Red = "0840d5"
Green = "383d8b",
Red = "0840d5"
}
local CLUE_COUNTER_GUIDS = {
White = "37be78",
White = "37be78",
Orange = "1769ed",
Green = "032300",
Red = "d86b7c"
Green = "032300",
Red = "d86b7c"
}
local CLUE_CLICKER_GUIDS = {
White = "db85d6",
White = "db85d6",
Orange = "3f22e5",
Green = "891403",
Red = "4111de"
Green = "891403",
Red = "4111de"
}
-- Returns the by color requested playermat as object
@ -34,29 +34,36 @@ do
return mat
end
-- Returns the by position requested playermat as object
-- Returns the color of the by position requested playermat as string
---@param startPos Table Position of the search, table get's roughly cut into 4 quarters to assign a playermat
PlaymatApi.getMatbyPosition = function(startPos)
local matColor
PlaymatApi.getMatColorbyPosition = function(startPos)
if startPos.x < -42 then
if startPos.z > 0 then
matColor = "White"
return "White"
else
matColor = "Orange"
return "Orange"
end
else
if startPos.z > 0 then
matColor = "Green"
return "Green"
else
matColor = "Red"
return "Red"
end
end
local mat = getObjectFromGUID(MAT_IDS[matColor])
end
if mat == nil then
broadcastToAll(playerColor .. " playermat could not be found!", "Yellow")
end
return mat
-- Returns the draw deck of the requested playmat
---@param matColor String Color of the playermat
PlaymatApi.getDrawDeck = function(matColor)
local mat = getObjectFromGUID(MAT_IDS[matColor])
mat.call("getDrawDiscardDecks")
return mat.getVar("drawDeck")
end
-- Returns the position of the discard pile of the requested playmat
---@param matColor String Color of the playermat
PlaymatApi.getDiscardPosition = function(matColor)
local mat = getObjectFromGUID(MAT_IDS[matColor])
return mat.getTable("DISCARD_PILE_POSITION")
end
-- Sets the requested playermat's snap points to limit snapping to matching card types or not. If