restructuring
This commit is contained in:
parent
26c65700e7
commit
ae1d538c59
@ -1,3 +1,4 @@
|
|||||||
|
local playmatApi = require("playermat/PlaymatApi")
|
||||||
fullButtonData = {
|
fullButtonData = {
|
||||||
{ id = "1", width = "84", height = "33", offsetX = "1", offsetY = "2" }, -- Act/Agenda
|
{ id = "1", width = "84", height = "33", offsetX = "1", offsetY = "2" }, -- Act/Agenda
|
||||||
{ id = "2", width = "78", height = "69", offsetX = "1", offsetY = "-62" }, -- Map
|
{ id = "2", width = "78", height = "69", offsetX = "1", offsetY = "-62" }, -- Map
|
||||||
@ -36,61 +37,6 @@ playButtonData = {
|
|||||||
{ id = "20", width = "20", height = "20", offsetX = "10", offsetY = "80" }
|
{ id = "20", width = "20", height = "20", offsetX = "10", offsetY = "80" }
|
||||||
}
|
}
|
||||||
|
|
||||||
playermatData = {
|
|
||||||
{
|
|
||||||
guid = '8b081b',
|
|
||||||
origin = { x = -55, y = 0, z = 21 },
|
|
||||||
scale = { x = 36.6, y = 5.10, z = 15 },
|
|
||||||
orientation = { x = 0, y = 270, z = 0 },
|
|
||||||
minX = -61.4,
|
|
||||||
maxX = -48.6,
|
|
||||||
minZ = -2.4,
|
|
||||||
maxZ = 24.5,
|
|
||||||
xOffset = 0.07,
|
|
||||||
zOffset = 0.02,
|
|
||||||
claims = { true, false, false, false }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
guid = 'bd0ff4',
|
|
||||||
origin = { x = -55, y = 0, z = -21 },
|
|
||||||
scale = { x = 36.6, y = 5.1, z = 15 },
|
|
||||||
orientation = { x = 0, y = 270, z = 0 },
|
|
||||||
minX = -61.4,
|
|
||||||
maxX = -48.6,
|
|
||||||
minZ = -24.5,
|
|
||||||
maxZ = 2.4,
|
|
||||||
xOffset = 0.07,
|
|
||||||
zOffset = 0.02,
|
|
||||||
claims = { false, true, false, false }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
guid = '383d8b',
|
|
||||||
origin = { x = -25, y = 0, z = 26.5 },
|
|
||||||
scale = { x = 31.5, y = 5.1, z = 15 },
|
|
||||||
orientation = { x = 0, y = 0, z = 0 },
|
|
||||||
minX = -44.43,
|
|
||||||
maxX = -17.44,
|
|
||||||
minZ = 20.17,
|
|
||||||
maxZ = 32.97,
|
|
||||||
xOffset = -0.07,
|
|
||||||
zOffset = 0.00,
|
|
||||||
claims = { false, false, true, false }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
guid = '0840d5',
|
|
||||||
origin = { x = -25, y = 0, z = -26.5 },
|
|
||||||
scale = { x = 31.5, y = 5.1, z = 15 },
|
|
||||||
orientation = { x = 0, y = 180, z = 0 },
|
|
||||||
minX = -44.43,
|
|
||||||
maxX = -17.44,
|
|
||||||
minZ = -32.97,
|
|
||||||
maxZ = -20.17,
|
|
||||||
xOffset = 0.07,
|
|
||||||
zOffset = -0.06,
|
|
||||||
claims = { false, false, false, true }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
defaultCameraParams = {
|
defaultCameraParams = {
|
||||||
{ position = { -1.626, -2.5, 0 }, pitch = 74, yaw = 90, distance = 18 }, -- 1. ActAgenda
|
{ position = { -1.626, -2.5, 0 }, pitch = 74, yaw = 90, distance = 18 }, -- 1. ActAgenda
|
||||||
{ position = { -27.822, -2.5, 0.424 }, pitch = 74, yaw = 90, distance = -1 }, -- 2. Map
|
{ position = { -27.822, -2.5, 0.424 }, pitch = 74, yaw = 90, distance = -1 }, -- 2. Map
|
||||||
@ -112,6 +58,7 @@ defaultCameraParams = {
|
|||||||
{ position = { -59.077, 1.462, -85.472 }, pitch = 74, yaw = 90, distance = 27 } -- 18. Additions
|
{ position = { -59.077, 1.462, -85.472 }, pitch = 74, yaw = 90, distance = 27 } -- 18. Additions
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local playermatData = { {}, {}, {}, {} }
|
||||||
local editing = false
|
local editing = false
|
||||||
local claiming = false
|
local claiming = false
|
||||||
|
|
||||||
@ -151,6 +98,7 @@ function onLoad(savedData)
|
|||||||
|
|
||||||
fullVisibility = { false, false, false, false }
|
fullVisibility = { false, false, false, false }
|
||||||
playVisibility = { false, false, false, false }
|
playVisibility = { false, false, false, false }
|
||||||
|
resetClaimColors()
|
||||||
end
|
end
|
||||||
|
|
||||||
createTileButtons()
|
createTileButtons()
|
||||||
@ -520,22 +468,13 @@ function loadCamera(player, _, idValue)
|
|||||||
|
|
||||||
if minX < 100 then
|
if minX < 100 then
|
||||||
local dx = maxX - minX
|
local dx = maxX - minX
|
||||||
local dz = (maxZ - minZ) / 1.6 -- screen ratio * 1.2 (for my macbook pro, no idea how to generalize this)
|
local dz = (maxZ - minZ) / 1.6 -- screen ratio * 1.2 (for my macbook pro, no idea how to generalize this)
|
||||||
local centerX = (minX + maxX) / 2 -- offset is to move it a bit up, so the cards don't block anything
|
player.lookAt({
|
||||||
local centerZ = (minZ + maxZ) / 2
|
position = { (minX + maxX) / 2, 0, (minZ + maxZ) / 2 },
|
||||||
local scale = math.max(dx, dz)
|
pitch = 74,
|
||||||
|
yaw = 90,
|
||||||
-- regression line from the following data points, seems linear
|
distance = 0.96 * math.max(dx, dz) + 5
|
||||||
-- rows 1 scale 4.5 d 12
|
})
|
||||||
-- rows 2 scale 11 d 16
|
|
||||||
-- rows 3 scale 14.5 d 19.6
|
|
||||||
-- rows 4 scale 19.6 d 25
|
|
||||||
-- rows 5 scale 23.25 d 28
|
|
||||||
-- rows 6 scale 30.8 d 34
|
|
||||||
|
|
||||||
-- modified by testing
|
|
||||||
local d = 0.96 * scale + 5
|
|
||||||
player.lookAt({ position = { centerX, 0, centerZ }, pitch = 74, yaw = 90, distance = d })
|
|
||||||
else
|
else
|
||||||
player.lookAt({ position = { -30.667, 0, 0 }, pitch = 74, yaw = 90, distance = 32 })
|
player.lookAt({ position = { -30.667, 0, 0 }, pitch = 74, yaw = 90, distance = 32 })
|
||||||
end
|
end
|
||||||
@ -552,37 +491,21 @@ function loadCamera(player, _, idValue)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if cameraParams[newMatIndex][index].distance <= 0 then
|
if cameraParams[newMatIndex][index].distance <= 0 then
|
||||||
local matObjects = Physics.cast({
|
local divisor, minX, maxX, minZ, maxZ
|
||||||
origin = playermatData[newMatIndex].origin,
|
|
||||||
direction = { x = 0, y = 1, z = 0 },
|
|
||||||
type = 3,
|
|
||||||
size = playermatData[newMatIndex].scale,
|
|
||||||
orientation = playermatData[newMatIndex].orientation
|
|
||||||
})
|
|
||||||
|
|
||||||
local minX = playermatData[newMatIndex].minX
|
for _, v in pairs(playmatApi.searchPlaymat(newMatColor)) do
|
||||||
local maxX = playermatData[newMatIndex].maxX
|
local bounds = v.hit_object.getBounds()
|
||||||
local minZ = playermatData[newMatIndex].minZ
|
local x1 = bounds['center'][1] - bounds['size'][1] / 2
|
||||||
local maxZ = playermatData[newMatIndex].maxZ
|
local x2 = bounds['center'][1] + bounds['size'][1] / 2
|
||||||
|
local z1 = bounds['center'][3] - bounds['size'][3] / 2
|
||||||
|
local z2 = bounds['center'][3] + bounds['size'][3] / 2
|
||||||
|
|
||||||
for _, v in pairs(matObjects) do
|
minX = math.min(x1, minX)
|
||||||
local obj = v.hit_object
|
maxX = math.max(x2, maxX)
|
||||||
if obj.type == 'Card' or obj.type == 'Infinite' then
|
minZ = math.min(z1, minZ)
|
||||||
local bounds = obj.getBounds()
|
maxZ = math.max(z2, maxZ)
|
||||||
local x1 = bounds['center'][1] - bounds['size'][1] / 2
|
|
||||||
local x2 = bounds['center'][1] + bounds['size'][1] / 2
|
|
||||||
local z1 = bounds['center'][3] - bounds['size'][3] / 2
|
|
||||||
local z2 = bounds['center'][3] + bounds['size'][3] / 2
|
|
||||||
|
|
||||||
minX = math.min(x1, minX)
|
|
||||||
maxX = math.max(x2, maxX)
|
|
||||||
minZ = math.min(z1, minZ)
|
|
||||||
maxZ = math.max(z2, maxZ)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
-- White/Orange
|
||||||
local divisor
|
|
||||||
|
|
||||||
-- White/Orange
|
-- White/Orange
|
||||||
if index == 3 or index == 4 then
|
if index == 3 or index == 4 then
|
||||||
divisor = {x = 1, z = 1.6 } -- screen ratio * 1.2 (for my macbook pro, no idea how to generalize this)
|
divisor = {x = 1, z = 1.6 } -- screen ratio * 1.2 (for my macbook pro, no idea how to generalize this)
|
||||||
@ -596,7 +519,7 @@ function loadCamera(player, _, idValue)
|
|||||||
function() player.lookAt({
|
function() player.lookAt({
|
||||||
position = { (minX + maxX) / 2, 0, (minZ + maxZ) / 2 },
|
position = { (minX + maxX) / 2, 0, (minZ + maxZ) / 2 },
|
||||||
pitch = 75.823,
|
pitch = 75.823,
|
||||||
yaw = playermatData[newMatIndex].orientation.y + 180,
|
yaw = playmatApi.returnRotation().y + 180,
|
||||||
distance = 0.64 * math.max((maxX - minX) / divisor.x, (maxZ - minZ) / divisor.z) + 7
|
distance = 0.64 * math.max((maxX - minX) / divisor.x, (maxZ - minZ) / divisor.z) + 7
|
||||||
})
|
})
|
||||||
end, 2)
|
end, 2)
|
||||||
@ -630,17 +553,15 @@ function updateEditCamera(params)
|
|||||||
editDistance = params[4]
|
editDistance = params[4]
|
||||||
end
|
end
|
||||||
|
|
||||||
function beginClaimColor(object, color)
|
function beginClaimColor()
|
||||||
if #getSeatedPlayers() == 0 then return end
|
if #getSeatedPlayers() == 0 then return end
|
||||||
if getIndexForPlayerColor(color) < 0 then return end
|
|
||||||
|
|
||||||
claiming = true
|
claiming = true
|
||||||
updateOverlay()
|
updateOverlay()
|
||||||
end
|
end
|
||||||
|
|
||||||
function resetClaimColors(object, color)
|
function resetClaimColors()
|
||||||
if #getSeatedPlayers() == 0 then return end
|
if #getSeatedPlayers() == 0 then return end
|
||||||
if getIndexForPlayerColor(color) < 0 then return end
|
|
||||||
|
|
||||||
for i = 1, 4 do
|
for i = 1, 4 do
|
||||||
for j = 1, 4 do
|
for j = 1, 4 do
|
||||||
|
@ -154,6 +154,10 @@ function searchArea(origin, size)
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function searchAroundSelf()
|
||||||
|
return searchArea(PLAY_ZONE_POSITION, PLAY_ZONE_SCALE)
|
||||||
|
end
|
||||||
|
|
||||||
function doNotReady(card)
|
function doNotReady(card)
|
||||||
return card.getVar("do_not_ready") or false
|
return card.getVar("do_not_ready") or false
|
||||||
end
|
end
|
||||||
@ -240,7 +244,7 @@ function doUpkeep(_, clickedByColor, isRightClick)
|
|||||||
|
|
||||||
-- unexhaust cards in play zone, flip action tokens and find forcedLearning
|
-- unexhaust cards in play zone, flip action tokens and find forcedLearning
|
||||||
local forcedLearning = false
|
local forcedLearning = false
|
||||||
for _, v in ipairs(searchArea(PLAY_ZONE_POSITION, PLAY_ZONE_SCALE)) do
|
for _, v in ipairs(searchAroundSelf()) do
|
||||||
local obj = v.hit_object
|
local obj = v.hit_object
|
||||||
if obj.getDescription() == "Action Token" and obj.is_face_down then
|
if obj.getDescription() == "Action Token" and obj.is_face_down then
|
||||||
obj.flip()
|
obj.flip()
|
||||||
@ -538,7 +542,7 @@ function replenishTokens(card, count, replenish)
|
|||||||
|
|
||||||
-- handling Runic Axe upgrade sheet for additional replenish
|
-- handling Runic Axe upgrade sheet for additional replenish
|
||||||
if card.getName() == "Runic Axe" then
|
if card.getName() == "Runic Axe" then
|
||||||
for _, v in ipairs(searchArea(PLAY_ZONE_POSITION, PLAY_ZONE_SCALE)) do
|
for _, v in ipairs(searchAroundSelf()) do
|
||||||
local obj = v.hit_object
|
local obj = v.hit_object
|
||||||
if obj.tag == "Card" then
|
if obj.tag == "Card" then
|
||||||
local notes = JSON.decode(obj.getGMNotes()) or {}
|
local notes = JSON.decode(obj.getGMNotes()) or {}
|
||||||
@ -572,7 +576,7 @@ end
|
|||||||
function syncCustomizableMetadata(card)
|
function syncCustomizableMetadata(card)
|
||||||
local cardMetadata = JSON.decode(card.getGMNotes()) or { }
|
local cardMetadata = JSON.decode(card.getGMNotes()) or { }
|
||||||
if cardMetadata ~= nil and cardMetadata.customizations ~= nil then
|
if cardMetadata ~= nil and cardMetadata.customizations ~= nil then
|
||||||
for _, collision in ipairs(searchArea(PLAY_ZONE_POSITION, PLAY_ZONE_SCALE)) do
|
for _, collision in ipairs(searchAroundSelf()) do
|
||||||
local obj = collision.hit_object
|
local obj = collision.hit_object
|
||||||
if obj.name == "Card" or obj.name == "CardCustom" then
|
if obj.name == "Card" or obj.name == "CardCustom" then
|
||||||
local notes = JSON.decode(obj.getGMNotes()) or { }
|
local notes = JSON.decode(obj.getGMNotes()) or { }
|
||||||
|
@ -59,6 +59,13 @@ do
|
|||||||
return "NOT_FOUND"
|
return "NOT_FOUND"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Returns the result of a cast in the specificed playermat's area
|
||||||
|
---@param matColor String Color of the playermat
|
||||||
|
PlaymatApi.searchPlaymat = function(matColor)
|
||||||
|
local mat = getObjectFromGUID(MAT_IDS[matColor])
|
||||||
|
return mat.call("searchAroundSelf")
|
||||||
|
end
|
||||||
|
|
||||||
-- Returns if there is the card "Dream-Enhancing Serum" on the requested playermat
|
-- Returns if there is the card "Dream-Enhancing Serum" on the requested playermat
|
||||||
---@param matColor String Color of the playermat
|
---@param matColor String Color of the playermat
|
||||||
PlaymatApi.isDES = function(matColor)
|
PlaymatApi.isDES = function(matColor)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user