Merge pull request #824 from argonui/token-spawning
Updated token offsets for 2 / 3 / 4 tokens
This commit is contained in:
commit
ee95af53d1
@ -1995,32 +1995,36 @@ end
|
||||
-- Generates the offsets for tokens on a card (clues on locations are different and have their own function)
|
||||
---@param maxTokens number Maximum amount of tokens on a card
|
||||
function TokenManager.generateOffsets(maxTokens)
|
||||
tokenOffsets = {}
|
||||
for numTokens = 1, maxTokens do
|
||||
if numTokens == 1 then
|
||||
tokenOffsets[1] = { Vector(0, 3, -0.2) }
|
||||
else
|
||||
local offsets = {}
|
||||
local rows = math.min(4, math.ceil(numTokens / 3))
|
||||
local tokensPlaced = 0
|
||||
for row = 1, rows do
|
||||
local y = 3
|
||||
local z = -0.9 + (row - 1) * 0.7
|
||||
local tokensInRow = math.min(3, numTokens - tokensPlaced)
|
||||
for col = 1, tokensInRow do
|
||||
local x = 0
|
||||
if tokensInRow == 2 then
|
||||
x = col == 1 and -0.4 or 0.4
|
||||
elseif tokensInRow == 3 then
|
||||
x = (col - 2) * 0.7
|
||||
end
|
||||
table.insert(offsets, Vector(x, y, z))
|
||||
tokensPlaced = tokensPlaced + 1
|
||||
tokenOffsets = {
|
||||
[1] = { Vector(0, 3, -0.2) },
|
||||
[2] = { Vector(0.4, 3, -0.2), Vector(-0.4, 3, -0.2) },
|
||||
[3] = { Vector(0, 3, -0.9), Vector(0.4, 3, -0.2), Vector(-0.4, 3, -0.2) },
|
||||
[4] = { Vector(0.4, 3, -0.9), Vector(-0.4, 3, -0.9), Vector(0.4, 3, -0.2), Vector(-0.4, 3, -0.2) }
|
||||
}
|
||||
|
||||
-- generate offsets for numTokens > 4 dynamically
|
||||
for numTokens = 5, maxTokens do
|
||||
local offsets = {}
|
||||
local rows = math.min(4, math.ceil(numTokens / 3))
|
||||
local tokensPlaced = 0
|
||||
for row = 1, rows do
|
||||
local y = 3
|
||||
local z = -0.9 + (row - 1) * 0.7
|
||||
local tokensInRow = math.min(3, numTokens - tokensPlaced)
|
||||
for col = 1, tokensInRow do
|
||||
local x = 0
|
||||
if tokensInRow == 2 then
|
||||
x = col == 1 and -0.4 or 0.4
|
||||
elseif tokensInRow == 3 then
|
||||
x = (col - 2) * 0.7
|
||||
end
|
||||
table.insert(offsets, Vector(x, y, z))
|
||||
tokensPlaced = tokensPlaced + 1
|
||||
end
|
||||
tokenOffsets[numTokens] = offsets
|
||||
end
|
||||
tokenOffsets[numTokens] = offsets
|
||||
end
|
||||
return tokenOffsets
|
||||
end
|
||||
|
||||
-- Spawns tokens for the card. This function is built to just throw a card at it and let it do
|
||||
|
Loading…
x
Reference in New Issue
Block a user