Merge pull request #91 from argonui/require-refactor
Refactor some required files to function as modules
This commit is contained in:
commit
b0ba445767
@ -1,9 +1,10 @@
|
|||||||
require("playermat/Zones")
|
|
||||||
require("arkhamdb/LoaderUi")
|
require("arkhamdb/LoaderUi")
|
||||||
require("playercards/PlayerCardSpawner")
|
require("playercards/PlayerCardSpawner")
|
||||||
|
|
||||||
local bondedList = {}
|
local zones = require("playermat/Zones")
|
||||||
local customizationRowsWithFields = {}
|
|
||||||
|
local bondedList = { }
|
||||||
|
local customizationRowsWithFields = { }
|
||||||
-- inputMap maps from (our 1-indexes) customization row index to inputValue table index
|
-- inputMap maps from (our 1-indexes) customization row index to inputValue table index
|
||||||
-- The Raven Quill
|
-- The Raven Quill
|
||||||
customizationRowsWithFields["09042"] = {}
|
customizationRowsWithFields["09042"] = {}
|
||||||
@ -384,7 +385,7 @@ function loadCards(slots, investigatorId, customizations, playerColor, commandMa
|
|||||||
local zoneDecks = buildZoneLists(cardsToSpawn)
|
local zoneDecks = buildZoneLists(cardsToSpawn)
|
||||||
-- Spawn the list for each zone
|
-- Spawn the list for each zone
|
||||||
for zone, zoneCards in pairs(zoneDecks) do
|
for zone, zoneCards in pairs(zoneDecks) do
|
||||||
local deckPos = Zones.getZonePosition(playerColor, zone)
|
local deckPos = zones.getZonePosition(playerColor, zone)
|
||||||
deckPos.y = 3
|
deckPos.y = 3
|
||||||
|
|
||||||
local callback = nil
|
local callback = nil
|
||||||
@ -406,7 +407,7 @@ function loadCards(slots, investigatorId, customizations, playerColor, commandMa
|
|||||||
Spawner.spawnCards(
|
Spawner.spawnCards(
|
||||||
zoneCards,
|
zoneCards,
|
||||||
deckPos,
|
deckPos,
|
||||||
Zones.getDefaultCardRotation(playerColor, zone),
|
zones.getDefaultCardRotation(playerColor, zone),
|
||||||
true, -- Sort deck
|
true, -- Sort deck
|
||||||
callback)
|
callback)
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
require("playercards/spawnbag/SpawnBag")
|
local spawnBag = require("playercards/spawnbag/SpawnBag")
|
||||||
|
|
||||||
SPAWN_SPEC = {
|
SPAWN_SPEC = {
|
||||||
name = "BondedCards",
|
name = "BondedCards",
|
||||||
@ -27,7 +27,7 @@ function onLoad(savedData)
|
|||||||
if (savedData ~= nil) then
|
if (savedData ~= nil) then
|
||||||
local saveState = JSON.decode(savedData)
|
local saveState = JSON.decode(savedData)
|
||||||
if (saveState.spawnBagState ~= nil) then
|
if (saveState.spawnBagState ~= nil) then
|
||||||
SpawnBag.loadFromSave(saveState.spawnBagState)
|
spawnBag.loadFromSave(saveState.spawnBagState)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
createActionButtons()
|
createActionButtons()
|
||||||
@ -35,7 +35,7 @@ end
|
|||||||
|
|
||||||
function onSave()
|
function onSave()
|
||||||
local saveState = {
|
local saveState = {
|
||||||
spawnBagState = SpawnBag.getStateForSave(),
|
spawnBagState = spawnBag.getStateForSave(),
|
||||||
}
|
}
|
||||||
return JSON.encode(saveState)
|
return JSON.encode(saveState)
|
||||||
end
|
end
|
||||||
@ -68,10 +68,10 @@ function createActionButtons()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function buttonClick_place()
|
function buttonClick_place()
|
||||||
SpawnBag.spawn(SPAWN_SPEC)
|
spawnBag.spawn(SPAWN_SPEC)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Recalls objects to bag from table
|
-- Recalls objects to bag from table
|
||||||
function buttonClick_recall()
|
function buttonClick_recall()
|
||||||
SpawnBag.recall()
|
spawnBag.recall()
|
||||||
end
|
end
|
||||||
|
@ -19,181 +19,184 @@ require("playercards/PlayerCardSpawner")
|
|||||||
-- will be moved a predefined distance
|
-- will be moved a predefined distance
|
||||||
-- }
|
-- }
|
||||||
-- See BondedBag.ttslua for an example
|
-- See BondedBag.ttslua for an example
|
||||||
|
do
|
||||||
|
local SpawnBag = { }
|
||||||
|
|
||||||
SpawnBag = { }
|
-- To assist debugging, will draw a box around the recall zone when it's set up
|
||||||
|
local SHOW_RECALL_ZONE = false
|
||||||
|
|
||||||
-- To assist debugging, will draw a box around the recall zone when it's set up
|
local ALL_CARDS_GUID = "15bb07"
|
||||||
local SHOW_RECALL_ZONE = false
|
|
||||||
|
|
||||||
local ALL_CARDS_GUID = "15bb07"
|
-- Distance to expand the recall zone around any added object.
|
||||||
|
local RECALL_BUFFER_X = 0.9
|
||||||
|
local RECALL_BUFFER_Z = 0.5
|
||||||
|
|
||||||
-- Distance to expand the recall zone around any added object.
|
-- In order to mimic the behavior of the previous memory buttons we use a temporary bag when
|
||||||
local RECALL_BUFFER_X = 0.9
|
-- recalling objects. This bag is tiny and transparent, and will be placed at the same location as
|
||||||
local RECALL_BUFFER_Z = 0.5
|
-- this object. Once all placed cards are recalled bag to this bag, it will be destroyed
|
||||||
|
local RECALL_BAG = {
|
||||||
-- In order to mimic the behavior of the previous memory buttons we use a temporary bag when
|
Name = "Bag",
|
||||||
-- recalling objects. This bag is tiny and transparent, and will be placed at the same location as
|
Transform = {
|
||||||
-- this object. Once all placed cards are recalled bag to this bag, it will be destroyed
|
scaleX = 0.01,
|
||||||
local RECALL_BAG = {
|
scaleY = 0.01,
|
||||||
Name = "Bag",
|
scaleZ = 0.01,
|
||||||
Transform = {
|
},
|
||||||
scaleX = 0.01,
|
ColorDiffuse = {
|
||||||
scaleY = 0.01,
|
r = 0,
|
||||||
scaleZ = 0.01,
|
g = 0,
|
||||||
},
|
b = 0,
|
||||||
ColorDiffuse = {
|
a = 0,
|
||||||
r = 0,
|
},
|
||||||
g = 0,
|
Locked = true,
|
||||||
b = 0,
|
Grid = true,
|
||||||
a = 0,
|
Snap = false,
|
||||||
},
|
Tooltip = false,
|
||||||
Locked = true,
|
|
||||||
Grid = true,
|
|
||||||
Snap = false,
|
|
||||||
Tooltip = false,
|
|
||||||
}
|
|
||||||
|
|
||||||
-- Tracks what has been placed by this "bag" so they can be recalled
|
|
||||||
local placedSpecs = { }
|
|
||||||
local placedObjectGuids = { }
|
|
||||||
local recallZone = nil
|
|
||||||
|
|
||||||
-- Loads a table of saved state, extracted during the parent object's onLoad
|
|
||||||
SpawnBag.loadFromSave = function(saveTable)
|
|
||||||
placedSpecs = saveTable.placed
|
|
||||||
placedObjectGuids = saveTable.placedObjects
|
|
||||||
recallZone = saveTable.recall
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Generates a table of save state that can be included in the parent object's onSave
|
|
||||||
SpawnBag.getStateForSave = function()
|
|
||||||
return {
|
|
||||||
placed = placedSpecs,
|
|
||||||
placedObjects = placedObjectGuids,
|
|
||||||
recall = recallZone,
|
|
||||||
}
|
}
|
||||||
end
|
|
||||||
|
|
||||||
-- Places the given spawnSpec on the table. See SpawnBag.ttslua header for spawnSpec table data and
|
-- Tracks what has been placed by this "bag" so they can be recalled
|
||||||
-- examples
|
local placedSpecs = { }
|
||||||
SpawnBag.spawn = function(spawnSpec)
|
local placedObjectGuids = { }
|
||||||
-- Limit to one placement at a time
|
local recallZone = nil
|
||||||
if (placedSpecs[spawnSpec.name]) then
|
|
||||||
return
|
-- Loads a table of saved state, extracted during the parent object's onLoad
|
||||||
|
SpawnBag.loadFromSave = function(saveTable)
|
||||||
|
placedSpecs = saveTable.placed
|
||||||
|
placedObjectGuids = saveTable.placedObjects
|
||||||
|
recallZone = saveTable.recall
|
||||||
end
|
end
|
||||||
if (spawnSpec == nil) then
|
|
||||||
-- TODO: error here
|
-- Generates a table of save state that can be included in the parent object's onSave
|
||||||
return
|
SpawnBag.getStateForSave = function()
|
||||||
|
return {
|
||||||
|
placed = placedSpecs,
|
||||||
|
placedObjects = placedObjectGuids,
|
||||||
|
recall = recallZone,
|
||||||
|
}
|
||||||
end
|
end
|
||||||
local cardsToSpawn = { }
|
|
||||||
local allCardsBag = getObjectFromGUID(ALL_CARDS_GUID)
|
-- Places the given spawnSpec on the table. See SpawnBag.ttslua header for spawnSpec table data and
|
||||||
for _, cardId in ipairs(spawnSpec.cards) do
|
-- examples
|
||||||
local cardData = allCardsBag.call("getCardById", { id = cardId })
|
SpawnBag.spawn = function(spawnSpec)
|
||||||
if (cardData ~= nil) then
|
-- Limit to one placement at a time
|
||||||
table.insert(cardsToSpawn, cardData)
|
if (placedSpecs[spawnSpec.name]) then
|
||||||
else
|
return
|
||||||
|
end
|
||||||
|
if (spawnSpec == nil) then
|
||||||
-- TODO: error here
|
-- TODO: error here
|
||||||
|
return
|
||||||
end
|
end
|
||||||
end
|
local cardsToSpawn = { }
|
||||||
if (spawnSpec.spread) then
|
local allCardsBag = getObjectFromGUID(ALL_CARDS_GUID)
|
||||||
Spawner.spawnCardSpread(cardsToSpawn, spawnSpec.globalPos, spawnSpec.rotation, false, recordPlacedObject)
|
for _, cardId in ipairs(spawnSpec.cards) do
|
||||||
else
|
local cardData = allCardsBag.call("getCardById", { id = cardId })
|
||||||
Spawner.spawnCards(cardsToSpawn, spawnSpec.globalPos, spawnSpec.rotation, false, recordPlacedObject)
|
if (cardData ~= nil) then
|
||||||
end
|
table.insert(cardsToSpawn, cardData)
|
||||||
placedSpecs[spawnSpec.name] = true
|
else
|
||||||
end
|
-- TODO: error here
|
||||||
|
|
||||||
-- Recalls all spawned objects to the bag, and clears the placedObjectGuids list
|
|
||||||
SpawnBag.recall = function()
|
|
||||||
local trash = spawnObjectData({data = RECALL_BAG, position = self.getPosition()})
|
|
||||||
for guid, _ in pairs(placedObjectGuids) do
|
|
||||||
local obj = getObjectFromGUID(guid)
|
|
||||||
if (obj ~= nil) then
|
|
||||||
if (isInRecallZone(obj)) then
|
|
||||||
trash.putObject(obj)
|
|
||||||
end
|
end
|
||||||
placedObjectGuids[guid] = nil
|
end
|
||||||
|
if (spawnSpec.spread) then
|
||||||
|
Spawner.spawnCardSpread(cardsToSpawn, spawnSpec.globalPos, spawnSpec.rotation, false, recordPlacedObject)
|
||||||
|
else
|
||||||
|
Spawner.spawnCards(cardsToSpawn, spawnSpec.globalPos, spawnSpec.rotation, false, recordPlacedObject)
|
||||||
|
end
|
||||||
|
placedSpecs[spawnSpec.name] = true
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Recalls all spawned objects to the bag, and clears the placedObjectGuids list
|
||||||
|
SpawnBag.recall = function()
|
||||||
|
local trash = spawnObjectData({data = RECALL_BAG, position = self.getPosition()})
|
||||||
|
for guid, _ in pairs(placedObjectGuids) do
|
||||||
|
local obj = getObjectFromGUID(guid)
|
||||||
|
if (obj ~= nil) then
|
||||||
|
if (isInRecallZone(obj)) then
|
||||||
|
trash.putObject(obj)
|
||||||
|
end
|
||||||
|
placedObjectGuids[guid] = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
trash.destruct()
|
||||||
|
-- We've recalled everything we can, some cards may have been moved out of the
|
||||||
|
-- card area. Just reset at this point.
|
||||||
|
placedSpecs = { }
|
||||||
|
placedObjectGuids = { }
|
||||||
|
recallZone = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Callback for when an object has been spawned. Tracks the object for later recall and updates the
|
||||||
|
-- recall zone.
|
||||||
|
function recordPlacedObject(spawned)
|
||||||
|
placedObjectGuids[spawned.getGUID()] = true
|
||||||
|
expandRecallZone(spawned)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Expands the current recall zone based on the position of the given object. The recall zone will
|
||||||
|
-- be maintained as the bounding box of the extreme object positions, plus a small amount of buffer
|
||||||
|
function expandRecallZone(spawnedCard)
|
||||||
|
local pos = spawnedCard.getPosition()
|
||||||
|
if (recallZone == nil) then
|
||||||
|
-- First card out of the bag, initialize surrounding that
|
||||||
|
recallZone = { }
|
||||||
|
recallZone.upperLeft = { x = pos.x + RECALL_BUFFER_X, z = pos.z + RECALL_BUFFER_Z }
|
||||||
|
recallZone.lowerRight = { x = pos.x - RECALL_BUFFER_X, z = pos.z - RECALL_BUFFER_Z }
|
||||||
|
return
|
||||||
|
else
|
||||||
|
if (pos.x > recallZone.upperLeft.x) then
|
||||||
|
recallZone.upperLeft.x = pos.x + RECALL_BUFFER_X
|
||||||
|
end
|
||||||
|
if (pos.x < recallZone.lowerRight.x) then
|
||||||
|
recallZone.lowerRight.x = pos.x - RECALL_BUFFER_X
|
||||||
|
end
|
||||||
|
if (pos.z > recallZone.upperLeft.z) then
|
||||||
|
recallZone.upperLeft.z = pos.z + RECALL_BUFFER_Z
|
||||||
|
end
|
||||||
|
if (pos.z < recallZone.lowerRight.z) then
|
||||||
|
recallZone.lowerRight.z = pos.z - RECALL_BUFFER_Z
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if (SHOW_RECALL_ZONE) then
|
||||||
|
local y = 1.5
|
||||||
|
local thick = 0.05
|
||||||
|
Global.setVectorLines({
|
||||||
|
{
|
||||||
|
points = { {recallZone.upperLeft.x,y,recallZone.upperLeft.z}, {recallZone.upperLeft.x,y,recallZone.lowerRight.z} },
|
||||||
|
color = {1,0,0},
|
||||||
|
thickness = thick,
|
||||||
|
rotation = {0,0,0},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
points = { {recallZone.upperLeft.x,y,recallZone.lowerRight.z}, {recallZone.lowerRight.x,y,recallZone.lowerRight.z} },
|
||||||
|
color = {1,0,0},
|
||||||
|
thickness = thick,
|
||||||
|
rotation = {0,0,0},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
points = { {recallZone.lowerRight.x,y,recallZone.lowerRight.z}, {recallZone.lowerRight.x,y,recallZone.upperLeft.z} },
|
||||||
|
color = {1,0,0},
|
||||||
|
thickness = thick,
|
||||||
|
rotation = {0,0,0},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
points = { {recallZone.lowerRight.x,y,recallZone.upperLeft.z}, {recallZone.upperLeft.x,y,recallZone.upperLeft.z} },
|
||||||
|
color = {1,0,0},
|
||||||
|
thickness = thick,
|
||||||
|
rotation = {0,0,0},
|
||||||
|
},
|
||||||
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
trash.destruct()
|
-- Checks to see if the given object is in the current recall zone. If there isn't a recall zone,
|
||||||
-- We've recalled everything we can, some cards may have been moved out of the
|
-- will return true so that everything can be easily cleaned up.
|
||||||
-- card area. Just reset at this point.
|
function isInRecallZone(obj)
|
||||||
placedSpecs = { }
|
if (recallZone == nil) then
|
||||||
placedObjectGuids = { }
|
return true
|
||||||
recallZone = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Callback for when an object has been spawned. Tracks the object for later recall and updates the
|
|
||||||
-- recall zone.
|
|
||||||
function recordPlacedObject(spawned)
|
|
||||||
placedObjectGuids[spawned.getGUID()] = true
|
|
||||||
expandRecallZone(spawned)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Expands the current recall zone based on the position of the given object. The recall zone will
|
|
||||||
-- be maintained as the bounding box of the extreme object positions, plus a small amount of buffer
|
|
||||||
function expandRecallZone(spawnedCard)
|
|
||||||
local pos = spawnedCard.getPosition()
|
|
||||||
if (recallZone == nil) then
|
|
||||||
-- First card out of the bag, initialize surrounding that
|
|
||||||
recallZone = { }
|
|
||||||
recallZone.upperLeft = { x = pos.x + RECALL_BUFFER_X, z = pos.z + RECALL_BUFFER_Z }
|
|
||||||
recallZone.lowerRight = { x = pos.x - RECALL_BUFFER_X, z = pos.z - RECALL_BUFFER_Z }
|
|
||||||
return
|
|
||||||
else
|
|
||||||
if (pos.x > recallZone.upperLeft.x) then
|
|
||||||
recallZone.upperLeft.x = pos.x + RECALL_BUFFER_X
|
|
||||||
end
|
|
||||||
if (pos.x < recallZone.lowerRight.x) then
|
|
||||||
recallZone.lowerRight.x = pos.x - RECALL_BUFFER_X
|
|
||||||
end
|
|
||||||
if (pos.z > recallZone.upperLeft.z) then
|
|
||||||
recallZone.upperLeft.z = pos.z + RECALL_BUFFER_Z
|
|
||||||
end
|
|
||||||
if (pos.z < recallZone.lowerRight.z) then
|
|
||||||
recallZone.lowerRight.z = pos.z - RECALL_BUFFER_Z
|
|
||||||
end
|
end
|
||||||
|
local pos = obj.getPosition()
|
||||||
|
return (pos.x < recallZone.upperLeft.x and pos.x > recallZone.lowerRight.x
|
||||||
|
and pos.z < recallZone.upperLeft.z and pos.z > recallZone.lowerRight.z)
|
||||||
end
|
end
|
||||||
if (SHOW_RECALL_ZONE) then
|
|
||||||
local y = 1.5
|
|
||||||
local thick = 0.05
|
|
||||||
Global.setVectorLines({
|
|
||||||
{
|
|
||||||
points = { {recallZone.upperLeft.x,y,recallZone.upperLeft.z}, {recallZone.upperLeft.x,y,recallZone.lowerRight.z} },
|
|
||||||
color = {1,0,0},
|
|
||||||
thickness = thick,
|
|
||||||
rotation = {0,0,0},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
points = { {recallZone.upperLeft.x,y,recallZone.lowerRight.z}, {recallZone.lowerRight.x,y,recallZone.lowerRight.z} },
|
|
||||||
color = {1,0,0},
|
|
||||||
thickness = thick,
|
|
||||||
rotation = {0,0,0},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
points = { {recallZone.lowerRight.x,y,recallZone.lowerRight.z}, {recallZone.lowerRight.x,y,recallZone.upperLeft.z} },
|
|
||||||
color = {1,0,0},
|
|
||||||
thickness = thick,
|
|
||||||
rotation = {0,0,0},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
points = { {recallZone.lowerRight.x,y,recallZone.upperLeft.z}, {recallZone.upperLeft.x,y,recallZone.upperLeft.z} },
|
|
||||||
color = {1,0,0},
|
|
||||||
thickness = thick,
|
|
||||||
rotation = {0,0,0},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Checks to see if the given object is in the current recall zone. If there isn't a recall zone,
|
return SpawnBag
|
||||||
-- will return true so that everything can be easily cleaned up.
|
|
||||||
function isInRecallZone(obj)
|
|
||||||
if (recallZone == nil) then
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
local pos = obj.getPosition()
|
|
||||||
return (pos.x < recallZone.upperLeft.x and pos.x > recallZone.lowerRight.x
|
|
||||||
and pos.z < recallZone.upperLeft.z and pos.z > recallZone.lowerRight.z)
|
|
||||||
end
|
end
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
require("playercards/spawnbag/SpawnBag")
|
local spawnBag = require("playercards/spawnbag/SpawnBag")
|
||||||
|
|
||||||
local UPGRADES_SPEC = {
|
local UPGRADES_SPEC = {
|
||||||
name = "UpgradeSheets",
|
name = "UpgradeSheets",
|
||||||
@ -37,7 +37,7 @@ function onLoad(savedData)
|
|||||||
if (savedData ~= nil) then
|
if (savedData ~= nil) then
|
||||||
local saveState = JSON.decode(savedData)
|
local saveState = JSON.decode(savedData)
|
||||||
if (saveState.spawnBagState ~= nil) then
|
if (saveState.spawnBagState ~= nil) then
|
||||||
SpawnBag.loadFromSave(saveState.spawnBagState)
|
spawnBag.loadFromSave(saveState.spawnBagState)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
createActionButtons()
|
createActionButtons()
|
||||||
@ -45,7 +45,7 @@ end
|
|||||||
|
|
||||||
function onSave()
|
function onSave()
|
||||||
local saveState = {
|
local saveState = {
|
||||||
spawnBagState = SpawnBag.getStateForSave(),
|
spawnBagState = spawnBag.getStateForSave(),
|
||||||
}
|
}
|
||||||
return JSON.encode(saveState)
|
return JSON.encode(saveState)
|
||||||
end
|
end
|
||||||
@ -78,11 +78,11 @@ function createActionButtons()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function buttonClick_place()
|
function buttonClick_place()
|
||||||
SpawnBag.spawn(UPGRADES_SPEC)
|
spawnBag.spawn(UPGRADES_SPEC)
|
||||||
SpawnBag.spawn(SERVITOR_SPEC)
|
spawnBag.spawn(SERVITOR_SPEC)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Recalls objects to bag from table
|
-- Recalls objects to bag from table
|
||||||
function buttonClick_recall()
|
function buttonClick_recall()
|
||||||
SpawnBag.recall()
|
spawnBag.recall()
|
||||||
end
|
end
|
||||||
|
@ -19,119 +19,125 @@
|
|||||||
-- SetAside4: Upgrade sheets for customizable cards
|
-- SetAside4: Upgrade sheets for customizable cards
|
||||||
-- SetAside5: Hunch Deck for Joe Diamond
|
-- SetAside5: Hunch Deck for Joe Diamond
|
||||||
-- SetAside6: currently unused
|
-- SetAside6: currently unused
|
||||||
local playerMatGuids = {}
|
do
|
||||||
playerMatGuids["Red"] = "0840d5"
|
local Zones = { }
|
||||||
playerMatGuids["Orange"] = "bd0ff4"
|
|
||||||
playerMatGuids["White"] = "8b081b"
|
|
||||||
playerMatGuids["Green"] = "383d8b"
|
|
||||||
|
|
||||||
commonZones = {}
|
local playerMatGuids = {}
|
||||||
commonZones["Investigator"] = { -1.17702, 0, 0.00209 }
|
playerMatGuids["Red"] = "0840d5"
|
||||||
commonZones["Minicard"] = { -0.16, 0, -1.222326 }
|
playerMatGuids["Orange"] = "bd0ff4"
|
||||||
commonZones["Deck"] = { -1.822724, 0, -0.02940192 }
|
playerMatGuids["White"] = "8b081b"
|
||||||
commonZones["Discard"] = { -1.822451, 0, 0.6092291 }
|
playerMatGuids["Green"] = "383d8b"
|
||||||
commonZones["Ally"] = { -0.6157398, 0, 0.02435675 }
|
|
||||||
commonZones["Body"] = { -0.6306521, 0, 0.553170 }
|
|
||||||
commonZones["Hand1"] = { 0.2155387, 0, 0.04257287 }
|
|
||||||
commonZones["Hand2"] = { -0.1803701, 0, 0.03745948 }
|
|
||||||
commonZones["Arcane1"] = { 0.2124223, 0, 0.5596902 }
|
|
||||||
commonZones["Arcane2"] = { -0.1711275, 0, 0.5567944 }
|
|
||||||
commonZones["Tarot"] = { 0.6016169, 0, 0.03273106 }
|
|
||||||
commonZones["Accessory"] = { 0.6049907, 0, 0.5546234 }
|
|
||||||
commonZones["BlankTop"] = { 1.758446, 0, 0.03965336 }
|
|
||||||
commonZones["BlankBottom"] = { 1.754469, 0, 0.5634764 }
|
|
||||||
commonZones["Threat1"] = { -0.9116555, 0, -0.6446251 }
|
|
||||||
commonZones["Threat2"] = { -0.4544126, 0, -0.6428719 }
|
|
||||||
commonZones["Threat3"] = { 0.002246313, 0, -0.6430681 }
|
|
||||||
commonZones["Threat4"] = { 0.4590618, 0, -0.6432732 }
|
|
||||||
|
|
||||||
Zones = {}
|
local commonZones = {}
|
||||||
Zones["White"] = {}
|
commonZones["Investigator"] = { -1.17702, 0, 0.00209 }
|
||||||
Zones["White"]["Investigator"] = commonZones["Investigator"]
|
commonZones["Minicard"] = { -0.16, 0, -1.222326 }
|
||||||
Zones["White"]["Minicard"] = commonZones["Minicard"]
|
commonZones["Deck"] = { -1.822724, 0, -0.02940192 }
|
||||||
Zones["White"]["Deck"] = commonZones["Deck"]
|
commonZones["Discard"] = { -1.822451, 0, 0.6092291 }
|
||||||
Zones["White"]["Discard"] = commonZones["Discard"]
|
commonZones["Ally"] = { -0.6157398, 0, 0.02435675 }
|
||||||
Zones["White"]["Ally"] = commonZones["Ally"]
|
commonZones["Body"] = { -0.6306521, 0, 0.553170 }
|
||||||
Zones["White"]["Body"] = commonZones["Body"]
|
commonZones["Hand1"] = { 0.2155387, 0, 0.04257287 }
|
||||||
Zones["White"]["Hand1"] = commonZones["Hand1"]
|
commonZones["Hand2"] = { -0.1803701, 0, 0.03745948 }
|
||||||
Zones["White"]["Hand2"] = commonZones["Hand2"]
|
commonZones["Arcane1"] = { 0.2124223, 0, 0.5596902 }
|
||||||
Zones["White"]["Arcane1"] = commonZones["Arcane1"]
|
commonZones["Arcane2"] = { -0.1711275, 0, 0.5567944 }
|
||||||
Zones["White"]["Arcane2"] = commonZones["Arcane2"]
|
commonZones["Tarot"] = { 0.6016169, 0, 0.03273106 }
|
||||||
Zones["White"]["Tarot"] = commonZones["Tarot"]
|
commonZones["Accessory"] = { 0.6049907, 0, 0.5546234 }
|
||||||
Zones["White"]["Accessory"] = commonZones["Accessory"]
|
commonZones["BlankTop"] = { 1.758446, 0, 0.03965336 }
|
||||||
Zones["White"]["BlankTop"] = commonZones["BlankTop"]
|
commonZones["BlankBottom"] = { 1.754469, 0, 0.5634764 }
|
||||||
Zones["White"]["BlankBottom"] = commonZones["BlankBottom"]
|
commonZones["Threat1"] = { -0.9116555, 0, -0.6446251 }
|
||||||
Zones["White"]["Threat1"] = commonZones["Threat1"]
|
commonZones["Threat2"] = { -0.4544126, 0, -0.6428719 }
|
||||||
Zones["White"]["Threat2"] = commonZones["Threat2"]
|
commonZones["Threat3"] = { 0.002246313, 0, -0.6430681 }
|
||||||
Zones["White"]["Threat3"] = commonZones["Threat3"]
|
commonZones["Threat4"] = { 0.4590618, 0, -0.6432732 }
|
||||||
Zones["White"]["Threat4"] = commonZones["Threat4"]
|
|
||||||
Zones["White"]["SetAside1"] = { 2.345893, 0, -0.520315 }
|
|
||||||
Zones["White"]["SetAside2"] = { 2.345893, 0, 0.042552 }
|
|
||||||
Zones["White"]["SetAside3"] = { 2.345893, 0, 0.605419 }
|
|
||||||
Zones["White"]["UnderSetAside3"] = { 2.495893, 0, 0.805419 }
|
|
||||||
Zones["White"]["SetAside4"] = { 2.775893, 0, -0.520315 }
|
|
||||||
Zones["White"]["SetAside5"] = { 2.775893, 0, 0.042552 }
|
|
||||||
Zones["White"]["SetAside6"] = { 2.775893, 0, 0.605419 }
|
|
||||||
Zones["White"]["UnderSetAside6"] = { 2.925893, 0, 0.805419 }
|
|
||||||
|
|
||||||
Zones["Orange"] = {}
|
local zoneData = {}
|
||||||
Zones["Orange"]["Investigator"] = commonZones["Investigator"]
|
zoneData["White"] = {}
|
||||||
Zones["Orange"]["Minicard"] = commonZones["Minicard"]
|
zoneData["White"]["Investigator"] = commonZones["Investigator"]
|
||||||
Zones["Orange"]["Deck"] = commonZones["Deck"]
|
zoneData["White"]["Minicard"] = commonZones["Minicard"]
|
||||||
Zones["Orange"]["Discard"] = commonZones["Discard"]
|
zoneData["White"]["Deck"] = commonZones["Deck"]
|
||||||
Zones["Orange"]["Ally"] = commonZones["Ally"]
|
zoneData["White"]["Discard"] = commonZones["Discard"]
|
||||||
Zones["Orange"]["Body"] = commonZones["Body"]
|
zoneData["White"]["Ally"] = commonZones["Ally"]
|
||||||
Zones["Orange"]["Hand1"] = commonZones["Hand1"]
|
zoneData["White"]["Body"] = commonZones["Body"]
|
||||||
Zones["Orange"]["Hand2"] = commonZones["Hand2"]
|
zoneData["White"]["Hand1"] = commonZones["Hand1"]
|
||||||
Zones["Orange"]["Arcane1"] = commonZones["Arcane1"]
|
zoneData["White"]["Hand2"] = commonZones["Hand2"]
|
||||||
Zones["Orange"]["Arcane2"] = commonZones["Arcane2"]
|
zoneData["White"]["Arcane1"] = commonZones["Arcane1"]
|
||||||
Zones["Orange"]["Tarot"] = commonZones["Tarot"]
|
zoneData["White"]["Arcane2"] = commonZones["Arcane2"]
|
||||||
Zones["Orange"]["Accessory"] = commonZones["Accessory"]
|
zoneData["White"]["Tarot"] = commonZones["Tarot"]
|
||||||
Zones["Orange"]["BlankTop"] = commonZones["BlankTop"]
|
zoneData["White"]["Accessory"] = commonZones["Accessory"]
|
||||||
Zones["Orange"]["BlankBottom"] = commonZones["BlankBottom"]
|
zoneData["White"]["BlankTop"] = commonZones["BlankTop"]
|
||||||
Zones["Orange"]["Threat1"] = commonZones["Threat1"]
|
zoneData["White"]["BlankBottom"] = commonZones["BlankBottom"]
|
||||||
Zones["Orange"]["Threat2"] = commonZones["Threat2"]
|
zoneData["White"]["Threat1"] = commonZones["Threat1"]
|
||||||
Zones["Orange"]["Threat3"] = commonZones["Threat3"]
|
zoneData["White"]["Threat2"] = commonZones["Threat2"]
|
||||||
Zones["Orange"]["Threat4"] = commonZones["Threat4"]
|
zoneData["White"]["Threat3"] = commonZones["Threat3"]
|
||||||
Zones["Orange"]["SetAside1"] = { -2.350362, 0, -0.520315 }
|
zoneData["White"]["Threat4"] = commonZones["Threat4"]
|
||||||
Zones["Orange"]["SetAside2"] = { -2.350362, 0, 0.042552 }
|
zoneData["White"]["SetAside1"] = { 2.345893, 0, -0.520315 }
|
||||||
Zones["Orange"]["SetAside3"] = { -2.350362, 0, 0.605419 }
|
zoneData["White"]["SetAside2"] = { 2.345893, 0, 0.042552 }
|
||||||
Zones["Orange"]["UnderSetAside3"] = { -2.500362, 0, 0.80419 }
|
zoneData["White"]["SetAside3"] = { 2.345893, 0, 0.605419 }
|
||||||
Zones["Orange"]["SetAside4"] = { -2.7803627, 0, -0.520315 }
|
zoneData["White"]["UnderSetAside3"] = { 2.495893, 0, 0.805419 }
|
||||||
Zones["Orange"]["SetAside5"] = { -2.7803627, 0, 0.042552 }
|
zoneData["White"]["SetAside4"] = { 2.775893, 0, -0.520315 }
|
||||||
Zones["Orange"]["SetAside6"] = { -2.7803627, 0, 0.605419 }
|
zoneData["White"]["SetAside5"] = { 2.775893, 0, 0.042552 }
|
||||||
Zones["Orange"]["UnderSetAside6"] = { -2.9303627, 0, 0.80419 }
|
zoneData["White"]["SetAside6"] = { 2.775893, 0, 0.605419 }
|
||||||
|
zoneData["White"]["UnderSetAside6"] = { 2.925893, 0, 0.805419 }
|
||||||
|
|
||||||
-- Green positions are the same as White and Red the same as Orange
|
zoneData["Orange"] = {}
|
||||||
Zones["Red"] = Zones["Orange"]
|
zoneData["Orange"]["Investigator"] = commonZones["Investigator"]
|
||||||
Zones["Green"] = Zones["White"]
|
zoneData["Orange"]["Minicard"] = commonZones["Minicard"]
|
||||||
|
zoneData["Orange"]["Deck"] = commonZones["Deck"]
|
||||||
|
zoneData["Orange"]["Discard"] = commonZones["Discard"]
|
||||||
|
zoneData["Orange"]["Ally"] = commonZones["Ally"]
|
||||||
|
zoneData["Orange"]["Body"] = commonZones["Body"]
|
||||||
|
zoneData["Orange"]["Hand1"] = commonZones["Hand1"]
|
||||||
|
zoneData["Orange"]["Hand2"] = commonZones["Hand2"]
|
||||||
|
zoneData["Orange"]["Arcane1"] = commonZones["Arcane1"]
|
||||||
|
zoneData["Orange"]["Arcane2"] = commonZones["Arcane2"]
|
||||||
|
zoneData["Orange"]["Tarot"] = commonZones["Tarot"]
|
||||||
|
zoneData["Orange"]["Accessory"] = commonZones["Accessory"]
|
||||||
|
zoneData["Orange"]["BlankTop"] = commonZones["BlankTop"]
|
||||||
|
zoneData["Orange"]["BlankBottom"] = commonZones["BlankBottom"]
|
||||||
|
zoneData["Orange"]["Threat1"] = commonZones["Threat1"]
|
||||||
|
zoneData["Orange"]["Threat2"] = commonZones["Threat2"]
|
||||||
|
zoneData["Orange"]["Threat3"] = commonZones["Threat3"]
|
||||||
|
zoneData["Orange"]["Threat4"] = commonZones["Threat4"]
|
||||||
|
zoneData["Orange"]["SetAside1"] = { -2.350362, 0, -0.520315 }
|
||||||
|
zoneData["Orange"]["SetAside2"] = { -2.350362, 0, 0.042552 }
|
||||||
|
zoneData["Orange"]["SetAside3"] = { -2.350362, 0, 0.605419 }
|
||||||
|
zoneData["Orange"]["UnderSetAside3"] = { -2.500362, 0, 0.80419 }
|
||||||
|
zoneData["Orange"]["SetAside4"] = { -2.7803627, 0, -0.520315 }
|
||||||
|
zoneData["Orange"]["SetAside5"] = { -2.7803627, 0, 0.042552 }
|
||||||
|
zoneData["Orange"]["SetAside6"] = { -2.7803627, 0, 0.605419 }
|
||||||
|
zoneData["Orange"]["UnderSetAside6"] = { -2.9303627, 0, 0.80419 }
|
||||||
|
|
||||||
-- Gets the global position for the given zone on the specified player mat.
|
-- Green positions are the same as White and Red the same as Orange
|
||||||
---@param playerColor: Color name of the player mat to get the zone position for (e.g. "Red")
|
zoneData["Red"] = zoneData["Orange"]
|
||||||
---@param zoneName: Name of the zone to get the position for. See Zones object documentation for a list of valid zones.
|
zoneData["Green"] = zoneData["White"]
|
||||||
---@return: Global position table, or nil if an invalid player color or zone is specified
|
|
||||||
function Zones.getZonePosition(playerColor, zoneName)
|
|
||||||
if (playerColor ~= "Red"
|
|
||||||
and playerColor ~= "Orange"
|
|
||||||
and playerColor ~= "White"
|
|
||||||
and playerColor ~= "Green") then
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
return getObjectFromGUID(playerMatGuids[playerColor]).positionToWorld(Zones[playerColor][zoneName])
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Return the global rotation for a card on the given player mat, based on its metadata.
|
-- Gets the global position for the given zone on the specified player mat.
|
||||||
---@param playerColor: Color name of the player mat to get the rotation for (e.g. "Red")
|
---@param playerColor: Color name of the player mat to get the zone position for (e.g. "Red")
|
||||||
---@param cardMetadata: Table of card metadata. Metadata fields type and permanent are required; all others are optional.
|
---@param zoneName: Name of the zone to get the position for. See Zones object documentation for a list of valid zones.
|
||||||
---@return: Global rotation vector for the given card. This will include the
|
---@return: Global position table, or nil if an invalid player color or zone is specified
|
||||||
-- Y rotation to orient the card on the given player mat as well as a
|
Zones.getZonePosition = function(playerColor, zoneName)
|
||||||
-- Z rotation to place the card face up or face down.
|
if (playerColor ~= "Red"
|
||||||
function Zones.getDefaultCardRotation(playerColor, zone)
|
and playerColor ~= "Orange"
|
||||||
local deckRotation = getObjectFromGUID(playerMatGuids[playerColor]).getRotation()
|
and playerColor ~= "White"
|
||||||
|
and playerColor ~= "Green") then
|
||||||
if zone == "Deck" then
|
return nil
|
||||||
deckRotation = deckRotation + Vector(0, 0, 180)
|
end
|
||||||
|
return getObjectFromGUID(playerMatGuids[playerColor]).positionToWorld(zoneData[playerColor][zoneName])
|
||||||
end
|
end
|
||||||
|
|
||||||
return deckRotation
|
-- Return the global rotation for a card on the given player mat, based on its metadata.
|
||||||
|
---@param playerColor: Color name of the player mat to get the rotation for (e.g. "Red")
|
||||||
|
---@param cardMetadata: Table of card metadata. Metadata fields type and permanent are required; all others are optional.
|
||||||
|
---@return: Global rotation vector for the given card. This will include the
|
||||||
|
-- Y rotation to orient the card on the given player mat as well as a
|
||||||
|
-- Z rotation to place the card face up or face down.
|
||||||
|
Zones.getDefaultCardRotation = function(playerColor, zone)
|
||||||
|
local deckRotation = getObjectFromGUID(playerMatGuids[playerColor]).getRotation()
|
||||||
|
|
||||||
|
if zone == "Deck" then
|
||||||
|
deckRotation = deckRotation + Vector(0, 0, 180)
|
||||||
|
end
|
||||||
|
|
||||||
|
return deckRotation
|
||||||
|
end
|
||||||
|
|
||||||
|
return Zones
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user