SCED/src/playermat/Zones.ttslua
2023-12-20 16:20:20 -05:00

148 lines
7.8 KiB
Plaintext

-- Sets up and returns coordinates for all possible spawn zones. Because Lua assigns tables by reference
-- and there is no built-in function to copy a table this is relatively brute force.
--
-- Positions are all relative to the player mat, and most are consistent. The
-- exception are the SetAside# zones, which are placed to the left of the mat
-- for White/Green, and the right of the mat for Orange/Red.
--
-- Investigator: Investigator card area.
-- Minicard: Placement for the investigator's minicard, just above the player mat
-- Deck, Discard: Standard locations for the deck and discard piles.
-- Blank1: used for assets that start in play (e.g. Duke)
-- Tarot, Hand1, Hand2, Ally, Blank4, Accessory, Arcane1, Arcane2, Body: Asset slot positions
-- Threat[1-4]: Threat area slots. Threat[1-3] correspond to the named threat area slots, and Threat4 is the blank threat area slot.
-- SetAside[1-3]: Column closest to the player mat, with 1 at the top and 3 at the bottom.
-- SetAside[4-6]: Column farther away from the mat, with 4 at the top and 6 at the bottom.
-- SetAside1: Permanent cards
-- SetAside2: Bonded cards
-- SetAside3: Ancestral Knowledge / Underworld Market
-- SetAside4: Upgrade sheets for customizable cards
-- SetAside5: Hunch Deck for Joe Diamond
-- SetAside6: currently unused
do
local playmatApi = require("playermat/PlaymatApi")
local Zones = { }
local commonZones = {}
commonZones["Investigator"] = { -1.177, 0, 0.002 }
commonZones["Deck"] = { -1.82, 0, 0 }
commonZones["Discard"] = { -1.82, 0, 0.61 }
commonZones["Ally"] = { -0.615, 0, 0.024 }
commonZones["Body"] = { -0.630, 0, 0.553 }
commonZones["Hand1"] = { 0.215, 0, 0.042 }
commonZones["Hand2"] = { -0.180, 0, 0.037 }
commonZones["Arcane1"] = { 0.212, 0, 0.559 }
commonZones["Arcane2"] = { -0.171, 0, 0.557 }
commonZones["Tarot"] = { 0.602, 0, 0.033 }
commonZones["Accessory"] = { 0.602, 0, 0.555 }
commonZones["Blank1"] = { 1.758, 0, 0.040 }
commonZones["Blank2"] = { 1.754, 0, 0.563 }
commonZones["Blank3"] = { 1.371, 0, 0.038 }
commonZones["Blank4"] = { 1.371, 0, 0.558 }
commonZones["Blank5"] = { 0.98, 0, 0.035 }
commonZones["Blank6"] = { 0.977, 0, 0.556 }
commonZones["Threat1"] = { -0.911, 0, -0.625 }
commonZones["Threat2"] = { -0.454, 0, -0.625 }
commonZones["Threat3"] = { 0.002, 0, -0.625 }
commonZones["Threat4"] = { 0.459, 0, -0.625 }
local zoneData = {}
zoneData["White"] = {}
zoneData["White"]["Investigator"] = commonZones["Investigator"]
zoneData["White"]["Deck"] = commonZones["Deck"]
zoneData["White"]["Discard"] = commonZones["Discard"]
zoneData["White"]["Ally"] = commonZones["Ally"]
zoneData["White"]["Body"] = commonZones["Body"]
zoneData["White"]["Hand1"] = commonZones["Hand1"]
zoneData["White"]["Hand2"] = commonZones["Hand2"]
zoneData["White"]["Arcane1"] = commonZones["Arcane1"]
zoneData["White"]["Arcane2"] = commonZones["Arcane2"]
zoneData["White"]["Tarot"] = commonZones["Tarot"]
zoneData["White"]["Accessory"] = commonZones["Accessory"]
zoneData["White"]["Blank1"] = commonZones["Blank1"]
zoneData["White"]["Blank2"] = commonZones["Blank2"]
zoneData["White"]["Blank3"] = commonZones["Blank3"]
zoneData["White"]["Blank4"] = commonZones["Blank4"]
zoneData["White"]["Blank5"] = commonZones["Blank5"]
zoneData["White"]["Blank6"] = commonZones["Blank6"]
zoneData["White"]["Threat1"] = commonZones["Threat1"]
zoneData["White"]["Threat2"] = commonZones["Threat2"]
zoneData["White"]["Threat3"] = commonZones["Threat3"]
zoneData["White"]["Threat4"] = commonZones["Threat4"]
zoneData["White"]["Minicard"] = { -1, 0, -1.45 }
zoneData["White"]["SetAside1"] = { 2.35, 0, -0.520 }
zoneData["White"]["SetAside2"] = { 2.35, 0, 0.042 }
zoneData["White"]["SetAside3"] = { 2.35, 0, 0.605 }
zoneData["White"]["UnderSetAside3"] = { 2.50, 0, 0.805 }
zoneData["White"]["SetAside4"] = { 2.78, 0, -0.520 }
zoneData["White"]["SetAside5"] = { 2.78, 0, 0.042 }
zoneData["White"]["SetAside6"] = { 2.78, 0, 0.605 }
zoneData["White"]["UnderSetAside6"] = { 2.93, 0, 0.805 }
zoneData["Orange"] = {}
zoneData["Orange"]["Investigator"] = commonZones["Investigator"]
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"]["Blank1"] = commonZones["Blank1"]
zoneData["Orange"]["Blank2"] = commonZones["Blank2"]
zoneData["Orange"]["Blank3"] = commonZones["Blank3"]
zoneData["Orange"]["Blank4"] = commonZones["Blank4"]
zoneData["Orange"]["Blank5"] = commonZones["Blank5"]
zoneData["Orange"]["Blank6"] = commonZones["Blank6"]
zoneData["Orange"]["Threat1"] = commonZones["Threat1"]
zoneData["Orange"]["Threat2"] = commonZones["Threat2"]
zoneData["Orange"]["Threat3"] = commonZones["Threat3"]
zoneData["Orange"]["Threat4"] = commonZones["Threat4"]
zoneData["Orange"]["Minicard"] = { 1, 0, -1.45 }
zoneData["Orange"]["SetAside1"] = { -2.35, 0, -0.520 }
zoneData["Orange"]["SetAside2"] = { -2.35, 0, 0.042}
zoneData["Orange"]["SetAside3"] = { -2.35, 0, 0.605 }
zoneData["Orange"]["UnderSetAside3"] = { -2.50, 0, 0.805 }
zoneData["Orange"]["SetAside4"] = { -2.78, 0, -0.520 }
zoneData["Orange"]["SetAside5"] = { -2.78, 0, 0.042 }
zoneData["Orange"]["SetAside6"] = { -2.78, 0, 0.605 }
zoneData["Orange"]["UnderSetAside6"] = { -2.93, 0, 0.805 }
-- Green positions are the same as White and Red the same as Orange
zoneData["Red"] = zoneData["Orange"]
zoneData["Green"] = zoneData["White"]
-- Gets the global position for the given zone on the specified player mat.
---@param playerColor: Color name of the player mat to get the zone position for (e.g. "Red")
---@param zoneName: Name of the zone to get the position for. See Zones object documentation for a list of valid zones.
---@return: Global position table, or nil if an invalid player color or zone is specified
Zones.getZonePosition = function(playerColor, zoneName)
if (playerColor ~= "Red"
and playerColor ~= "Orange"
and playerColor ~= "White"
and playerColor ~= "Green") then
return nil
end
return playmatApi.transformLocalPosition(zoneData[playerColor][zoneName], playerColor)
end
-- 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 cardRotation = playmatApi.returnRotation(playerColor)
if zone == "Deck" then
cardRotation = cardRotation + Vector(0, 0, 180)
end
return cardRotation
end
return Zones
end