Merge branch 'main' into token-arranger

This commit is contained in:
Chr1Z 2023-09-01 23:39:53 +02:00 committed by GitHub
commit fb8b45eef1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
54 changed files with 414 additions and 215 deletions

View File

@ -1,3 +1,3 @@
# Finn considered to be code owner of all files
# until Finn gets added as a github user, argonui will serve as code owner
* @argonui @Chr1Z93 @Tikatoy @BootleggerFinn
* @argonui @Chr1Z93 @Tikatoy @BootleggerFinn @Entrox-Licher

View File

@ -1534,7 +1534,19 @@
"InspectorFlint.8247a5",
"AgentAriQuinn.d61c6a",
"DeckofPossibilities.fefdfa",
"IsamaraOrdoez.860cd7"
"IsamaraOrdoez.860cd7",
"LongShot.dc8c4d",
"ChemistrySet.da9727",
"PushedtotheLimit.e0f396",
"UncannyGrowth.6543e6",
"Microscope.48be49",
"Well-Funded.96fbfa",
"DrCharlesWestIII.72efed",
"RavenousMyconid.0aa967",
"StallforTime.7b6ed1",
"WrongPlaceRightTime.d5944e",
"SparrowMask.975d79",
"Pitchfork.45a724"
],
"ContainedObjects_path": "AllPlayerCards.15bb07",
"Description": "",

View File

@ -13,7 +13,7 @@
},
"CustomDeck": {
"1": {
"BackIsHidden": false,
"BackIsHidden": true,
"BackURL": "https://i.imgur.com/EcbhVuh.jpg/",
"FaceURL": "http://cloud-3.steamusercontent.com/ugc/2021607169641060708/B263E98D28E301D8EF45EB001FEBCE98DA25354B/",
"NumHeight": 2,
@ -24,7 +24,7 @@
},
"Description": "",
"DragSelectable": true,
"GMNotes_path": "LeakedItems.42cd6e/ChemistrySet.da9727.gmnotes",
"GMNotes_path": "AllPlayerCards.15bb07/ChemistrySet.da9727.gmnotes",
"GUID": "da9727",
"Grid": true,
"GridProjection": false,
@ -47,9 +47,9 @@
],
"Tooltip": true,
"Transform": {
"posX": -44.346,
"posY": 3.23,
"posZ": -101.422,
"posX": 79.306,
"posY": 3.209,
"posZ": 20.574,
"rotX": 0,
"rotY": 270,
"rotZ": 0,

View File

@ -13,7 +13,7 @@
},
"CustomDeck": {
"1": {
"BackIsHidden": false,
"BackIsHidden": true,
"BackURL": "https://i.imgur.com/EcbhVuh.jpg/",
"FaceURL": "http://cloud-3.steamusercontent.com/ugc/2021607169641060708/B263E98D28E301D8EF45EB001FEBCE98DA25354B/",
"NumHeight": 2,
@ -24,7 +24,7 @@
},
"Description": "Knows His Purpose",
"DragSelectable": true,
"GMNotes_path": "LeakedItems.42cd6e/DrCharlesWestIII.72efed.gmnotes",
"GMNotes_path": "AllPlayerCards.15bb07/DrCharlesWestIII.72efed.gmnotes",
"GUID": "72efed",
"Grid": true,
"GridProjection": false,
@ -47,9 +47,9 @@
],
"Tooltip": true,
"Transform": {
"posX": -44.346,
"posY": 3.23,
"posZ": -103.674,
"posX": 79.306,
"posY": 3.209,
"posZ": 18.322,
"rotX": 0,
"rotY": 270,
"rotZ": 0,

View File

@ -13,7 +13,7 @@
},
"CustomDeck": {
"1": {
"BackIsHidden": false,
"BackIsHidden": true,
"BackURL": "https://i.imgur.com/EcbhVuh.jpg/",
"FaceURL": "http://cloud-3.steamusercontent.com/ugc/2021607169641060708/B263E98D28E301D8EF45EB001FEBCE98DA25354B/",
"NumHeight": 2,
@ -24,7 +24,7 @@
},
"Description": "",
"DragSelectable": true,
"GMNotes_path": "LeakedItems.42cd6e/LongShot.dc8c4d.gmnotes",
"GMNotes_path": "AllPlayerCards.15bb07/LongShot.dc8c4d.gmnotes",
"GUID": "dc8c4d",
"Grid": true,
"GridProjection": false,
@ -46,12 +46,12 @@
],
"Tooltip": true,
"Transform": {
"posX": -41.183,
"posY": 3.23,
"posZ": -105.927,
"rotX": 0,
"posX": 79.306,
"posY": 3.22,
"posZ": 27.331,
"rotX": 359,
"rotY": 270,
"rotZ": 0,
"rotZ": 359,
"scaleX": 1,
"scaleY": 1,
"scaleZ": 1

View File

@ -13,7 +13,7 @@
},
"CustomDeck": {
"1": {
"BackIsHidden": false,
"BackIsHidden": true,
"BackURL": "https://i.imgur.com/EcbhVuh.jpg/",
"FaceURL": "http://cloud-3.steamusercontent.com/ugc/2021607169641060708/B263E98D28E301D8EF45EB001FEBCE98DA25354B/",
"NumHeight": 2,
@ -24,7 +24,7 @@
},
"Description": "",
"DragSelectable": true,
"GMNotes_path": "LeakedItems.42cd6e/Microscope.48be49.gmnotes",
"GMNotes_path": "AllPlayerCards.15bb07/Microscope.48be49.gmnotes",
"GUID": "48be49",
"Grid": true,
"GridProjection": false,
@ -47,9 +47,9 @@
],
"Tooltip": true,
"Transform": {
"posX": -44.346,
"posY": 3.23,
"posZ": -105.927,
"posX": 82.468,
"posY": 3.209,
"posZ": 20.574,
"rotX": 0,
"rotY": 270,
"rotZ": 0,

View File

@ -13,7 +13,7 @@
},
"CustomDeck": {
"1": {
"BackIsHidden": false,
"BackIsHidden": true,
"BackURL": "https://i.imgur.com/EcbhVuh.jpg/",
"FaceURL": "http://cloud-3.steamusercontent.com/ugc/2021607169641060708/B263E98D28E301D8EF45EB001FEBCE98DA25354B/",
"NumHeight": 2,
@ -24,7 +24,7 @@
},
"Description": "",
"DragSelectable": true,
"GMNotes_path": "LeakedItems.42cd6e/Pitchfork.45a724.gmnotes",
"GMNotes_path": "AllPlayerCards.15bb07/Pitchfork.45a724.gmnotes",
"GUID": "45a724",
"Grid": true,
"GridProjection": false,
@ -47,9 +47,9 @@
],
"Tooltip": true,
"Transform": {
"posX": -41.183,
"posY": 3.23,
"posZ": -108.179,
"posX": 82.468,
"posY": 3.209,
"posZ": 25.078,
"rotX": 0,
"rotY": 270,
"rotZ": 0,

View File

@ -13,7 +13,7 @@
},
"CustomDeck": {
"1": {
"BackIsHidden": false,
"BackIsHidden": true,
"BackURL": "https://i.imgur.com/EcbhVuh.jpg/",
"FaceURL": "http://cloud-3.steamusercontent.com/ugc/2021607169641060708/B263E98D28E301D8EF45EB001FEBCE98DA25354B/",
"NumHeight": 2,
@ -24,7 +24,7 @@
},
"Description": "",
"DragSelectable": true,
"GMNotes_path": "LeakedItems.42cd6e/PushedtotheLimit.e0f396.gmnotes",
"GMNotes_path": "AllPlayerCards.15bb07/PushedtotheLimit.e0f396.gmnotes",
"GUID": "e0f396",
"Grid": true,
"GridProjection": false,
@ -46,9 +46,9 @@
],
"Tooltip": true,
"Transform": {
"posX": -41.183,
"posY": 3.23,
"posZ": -112.683,
"posX": 82.468,
"posY": 3.209,
"posZ": 27.331,
"rotX": 0,
"rotY": 270,
"rotZ": 0,

View File

@ -13,7 +13,7 @@
},
"CustomDeck": {
"1": {
"BackIsHidden": false,
"BackIsHidden": true,
"BackURL": "https://i.imgur.com/EcbhVuh.jpg/",
"FaceURL": "http://cloud-3.steamusercontent.com/ugc/2021607169641060708/B263E98D28E301D8EF45EB001FEBCE98DA25354B/",
"NumHeight": 2,
@ -24,7 +24,7 @@
},
"Description": "Unidentified",
"DragSelectable": true,
"GMNotes_path": "LeakedItems.42cd6e/RavenousMyconid.0aa967.gmnotes",
"GMNotes_path": "AllPlayerCards.15bb07/RavenousMyconid.0aa967.gmnotes",
"GUID": "0aa967",
"Grid": true,
"GridProjection": false,
@ -47,9 +47,9 @@
],
"Tooltip": true,
"Transform": {
"posX": -44.346,
"posY": 3.23,
"posZ": -108.179,
"posX": 79.306,
"posY": 3.209,
"posZ": 22.826,
"rotX": 0,
"rotY": 270,
"rotZ": 0,

View File

@ -13,7 +13,7 @@
},
"CustomDeck": {
"1": {
"BackIsHidden": false,
"BackIsHidden": true,
"BackURL": "https://i.imgur.com/EcbhVuh.jpg/",
"FaceURL": "http://cloud-3.steamusercontent.com/ugc/2021607169641060708/B263E98D28E301D8EF45EB001FEBCE98DA25354B/",
"NumHeight": 2,
@ -24,7 +24,7 @@
},
"Description": "The Wanderer's Companion",
"DragSelectable": true,
"GMNotes_path": "LeakedItems.42cd6e/SparrowMask.975d79.gmnotes",
"GMNotes_path": "AllPlayerCards.15bb07/SparrowMask.975d79.gmnotes",
"GUID": "975d79",
"Grid": true,
"GridProjection": false,
@ -47,9 +47,9 @@
],
"Tooltip": true,
"Transform": {
"posX": -41.183,
"posY": 3.23,
"posZ": -110.431,
"posX": 82.468,
"posY": 3.209,
"posZ": 18.322,
"rotX": 0,
"rotY": 270,
"rotZ": 0,

View File

@ -13,7 +13,7 @@
},
"CustomDeck": {
"1": {
"BackIsHidden": false,
"BackIsHidden": true,
"BackURL": "https://i.imgur.com/EcbhVuh.jpg/",
"FaceURL": "http://cloud-3.steamusercontent.com/ugc/2021607169641060708/B263E98D28E301D8EF45EB001FEBCE98DA25354B/",
"NumHeight": 2,
@ -24,7 +24,7 @@
},
"Description": "",
"DragSelectable": true,
"GMNotes_path": "LeakedItems.42cd6e/StallforTime.7b6ed1.gmnotes",
"GMNotes_path": "AllPlayerCards.15bb07/StallforTime.7b6ed1.gmnotes",
"GUID": "7b6ed1",
"Grid": true,
"GridProjection": false,
@ -46,9 +46,9 @@
],
"Tooltip": true,
"Transform": {
"posX": -41.183,
"posY": 3.23,
"posZ": -101.422,
"posX": 79.306,
"posY": 3.209,
"posZ": 25.078,
"rotX": 0,
"rotY": 270,
"rotZ": 0,

View File

@ -13,7 +13,7 @@
},
"CustomDeck": {
"1": {
"BackIsHidden": false,
"BackIsHidden": true,
"BackURL": "https://i.imgur.com/EcbhVuh.jpg/",
"FaceURL": "http://cloud-3.steamusercontent.com/ugc/2021607169641060708/B263E98D28E301D8EF45EB001FEBCE98DA25354B/",
"NumHeight": 2,
@ -24,7 +24,7 @@
},
"Description": "",
"DragSelectable": true,
"GMNotes_path": "LeakedItems.42cd6e/UncannyGrowth.6543e6.gmnotes",
"GMNotes_path": "AllPlayerCards.15bb07/UncannyGrowth.6543e6.gmnotes",
"GUID": "6543e6",
"Grid": true,
"GridProjection": false,
@ -46,9 +46,9 @@
],
"Tooltip": true,
"Transform": {
"posX": -44.346,
"posY": 3.23,
"posZ": -110.431,
"posX": 82.468,
"posY": 3.209,
"posZ": 22.826,
"rotX": 0,
"rotY": 270,
"rotZ": 0,

View File

@ -13,7 +13,7 @@
},
"CustomDeck": {
"1": {
"BackIsHidden": false,
"BackIsHidden": true,
"BackURL": "https://i.imgur.com/EcbhVuh.jpg/",
"FaceURL": "http://cloud-3.steamusercontent.com/ugc/2021607169641060708/B263E98D28E301D8EF45EB001FEBCE98DA25354B/",
"NumHeight": 2,
@ -24,7 +24,7 @@
},
"Description": "",
"DragSelectable": true,
"GMNotes_path": "LeakedItems.42cd6e/Well-Funded.96fbfa.gmnotes",
"GMNotes_path": "AllPlayerCards.15bb07/Well-Funded.96fbfa.gmnotes",
"GUID": "96fbfa",
"Grid": true,
"GridProjection": false,
@ -46,9 +46,9 @@
],
"Tooltip": true,
"Transform": {
"posX": -44.346,
"posY": 3.23,
"posZ": -112.683,
"posX": 79.306,
"posY": 3.209,
"posZ": 16.069,
"rotX": 0,
"rotY": 270,
"rotZ": 0,

View File

@ -33,7 +33,7 @@
"IgnoreFoW": false,
"LayoutGroupSortIndex": 0,
"Locked": false,
"LuaScript": "",
"LuaScript": "require(\"playercards/cards/WellConnected\")",
"LuaScriptState": "",
"MeasureMovement": false,
"Name": "Card",

View File

@ -33,7 +33,7 @@
"IgnoreFoW": false,
"LayoutGroupSortIndex": 0,
"Locked": false,
"LuaScript": "",
"LuaScript": "require(\"playercards/cards/WellConnected\")",
"LuaScriptState": "",
"MeasureMovement": false,
"Name": "Card",

View File

@ -13,7 +13,7 @@
},
"CustomDeck": {
"1": {
"BackIsHidden": false,
"BackIsHidden": true,
"BackURL": "https://i.imgur.com/EcbhVuh.jpg/",
"FaceURL": "http://cloud-3.steamusercontent.com/ugc/2021607169641060708/B263E98D28E301D8EF45EB001FEBCE98DA25354B/",
"NumHeight": 2,
@ -24,7 +24,7 @@
},
"Description": "",
"DragSelectable": true,
"GMNotes_path": "LeakedItems.42cd6e/WrongPlaceRightTime.d5944e.gmnotes",
"GMNotes_path": "AllPlayerCards.15bb07/WrongPlaceRightTime.d5944e.gmnotes",
"GUID": "d5944e",
"Grid": true,
"GridProjection": false,
@ -46,9 +46,9 @@
],
"Tooltip": true,
"Transform": {
"posX": -41.183,
"posY": 3.23,
"posZ": -103.674,
"posX": 82.469,
"posY": 3.209,
"posZ": 16.069,
"rotX": 0,
"rotY": 270,
"rotZ": 0,

View File

@ -14,18 +14,6 @@
"r": 1
},
"ContainedObjects_order": [
"Well-Funded.96fbfa",
"UncannyGrowth.6543e6",
"RavenousMyconid.0aa967",
"Microscope.48be49",
"DrCharlesWestIII.72efed",
"ChemistrySet.da9727",
"PushedtotheLimit.e0f396",
"SparrowMask.975d79",
"Pitchfork.45a724",
"LongShot.dc8c4d",
"WrongPlaceRightTime.d5944e",
"StallforTime.7b6ed1",
"AliceLuxley2.94f23b",
"DragonPole3.a20aef",
"FineClothes3.5cb973",

View File

@ -18,8 +18,8 @@
"Type": 3
},
"ImageScalar": 1,
"ImageSecondaryURL": "https://i.imgur.com/s5H1THb.jpg",
"ImageURL": "https://i.imgur.com/s5H1THb.jpg",
"ImageSecondaryURL": "",
"ImageURL": "http://cloud-3.steamusercontent.com/ugc/2021607169641075457/C12E95AE17A6C6043118449CB8012F8509828325/",
"WidthScale": 0
},
"Description": "",

View File

@ -34,6 +34,7 @@ buttonParameters.height = 300
local name
local tokens = {}
local chaosBagApi = require("chaosbag/ChaosBagApi")
function onLoad()
-- create buttons for tokens
@ -60,11 +61,11 @@ function buttonClick(index, isRightClick)
local tokenId = TOKEN_IDS[index]
if isRightClick then
Global.call("removeChaosToken", tokenId)
chaosBagApi.removeChaosToken(tokenId)
else
local tokens = {}
local name = BUTTON_TOOLTIP[index]
local chaosbag = Global.call("findChaosBag")
local chaosbag = chaosBagApi.findChaosBag()
for _, v in ipairs(chaosbag.getObjects()) do
if v.name == name then table.insert(tokens, v.guid) end
@ -76,7 +77,7 @@ function buttonClick(index, isRightClick)
return
end
Global.call("spawnChaosToken", tokenId)
chaosBagApi.spawnChaosToken(tokenId)
printToAll("Adding " .. name .. " token (in bag: " .. #tokens + 1 .. ")", "White")
end
end

View File

@ -8,6 +8,7 @@ local soundCubeApi = require("core/SoundCubeApi")
local playmatApi = require("playermat/PlaymatApi")
local blessCurseManagerApi = require("chaosbag/BlessCurseManagerApi")
local chaosBagApi = require("chaosbag/ChaosBagApi")
local playAreaApi = require("core/PlayAreaApi")
-- these objects will be ignored
local IGNORE_GUIDS = {
@ -230,8 +231,7 @@ end
-- gets the GUID of a custom data helper (if present) and adds it to the ignore list
function ignoreCustomDataHelper()
local playArea = getObjectFromGUID("721ba2")
local customDataHelper = playArea.getVar("customDataHelper")
local customDataHelper = playAreaApi.getCustomDataHelper()
if customDataHelper then table.insert(IGNORE_GUIDS, customDataHelper.getGUID()) end
end

View File

@ -1,4 +1,5 @@
local mythosAreaApi = require("core/MythosAreaApi")
local chaosBagApi = require("chaosbag/ChaosBagApi")
-- common parameters
local buttonParameters = {}
@ -278,7 +279,7 @@ function layout(_, _, isRightClick)
end
-- get ChaosBag and stop if not found
local chaosBag = Global.call("findChaosBag")
local chaosBag = chaosBagApi.findChaosBag()
if not chaosBag then
updating = false
return

View File

@ -1,5 +1,6 @@
do
local playAreaApi = require("core/PlayAreaApi")
local allCardsBagApi = require("playercards/AllCardsBagApi")
local ArkhamDb = { }
local internal = { }
@ -56,8 +57,7 @@ do
callback)
-- Get a simple card to see if the bag indexes are complete. If not, abort
-- the deck load. The called method will handle player notification.
local allCardsBag = getObjectFromGUID(configuration.card_bag_guid)
local checkCard = allCardsBag.call("getCardById", { id = "01001" })
local checkCard = allCardsBagApi.getCardById("01001")
if (checkCard ~= nil and checkCard.data == nil) then
return
end
@ -167,13 +167,12 @@ do
---@param playerColor String Color of the player this deck is being loaded for. Used for broadcast
--- if a weakness is added.
internal.maybeDrawRandomWeakness = function(slots, playerColor)
local allCardsBag = getObjectFromGUID(configuration.card_bag_guid)
local randomWeaknessAmount = slots[RANDOM_WEAKNESS_ID] or 0
slots[RANDOM_WEAKNESS_ID] = nil
if randomWeaknessAmount ~= 0 then
for i=1, randomWeaknessAmount do
local weaknessId = allCardsBag.call("getRandomWeaknessId")
local weaknessId = allCardsBagApi.getRandomWeaknessId()
slots[weaknessId] = (slots[weaknessId] or 0) + 1
end
internal.maybePrint("Added " .. randomWeaknessAmount .. " random basic weakness(es) to deck", playerColor)
@ -239,10 +238,9 @@ do
---@param slots Table The slot list for cards in this deck. Table key is the cardId, value is the number
-- of those cards which will be spawned
internal.maybeAddCustomizeUpgradeSheets = function(slots)
local allCardsBag = getObjectFromGUID(configuration.card_bag_guid)
for cardId, _ in pairs(slots) do
-- upgrade sheets for customizable cards
local upgradesheet = allCardsBag.call("getCardById", { id = cardId .. "-c" })
local upgradesheet = allCardsBagApi.getCardById(cardId .. "-c")
if upgradesheet ~= nil then
slots[cardId .. "-c"] = 1
end
@ -288,12 +286,11 @@ do
-- Process the slot list and looks for any cards which are bonded to those in the deck. Adds those cards to the slot list.
---@param slots Table The slot list for cards in this deck. Table key is the cardId, value is the number of those cards which will be spawned
internal.extractBondedCards = function(slots)
local allCardsBag = getObjectFromGUID(configuration.card_bag_guid)
-- Create a list of bonded cards first so we don't modify slots while iterating
local bondedCards = { }
local bondedList = { }
for cardId, cardCount in pairs(slots) do
local card = allCardsBag.call("getCardById", { id = cardId })
local card = allCardsBagApi.getCardById(cardId)
if (card ~= nil and card.metadata.bonded ~= nil) then
for _, bond in ipairs(card.metadata.bonded) do
bondedCards[bond.id] = bond.count
@ -317,15 +314,14 @@ do
---@param slots Table The slot list for cards in this deck. Table key is the cardId, value is the number of those cards which will be spawned
internal.checkTaboos = function(tabooId, slots, playerColor)
if tabooId then
local allCardsBag = getObjectFromGUID(configuration.card_bag_guid)
for cardId, _ in pairs(tabooList[tabooId].cards) do
if slots[cardId] ~= nil then
-- Make sure there's a taboo version of the card before we replace it
-- SCED only maintains the most recent taboo cards. If a deck is using
-- an older taboo list it's possible the card isn't a taboo any more
local tabooCard = allCardsBag.call("getCardById", { id = cardId .. "-t" })
local tabooCard = allCardsBagApi.getCardById(cardId .. "-t")
if tabooCard == nil then
local basicCard = allCardsBag.call("getCardById", { id = cardId })
local basicCard = allCardsBagApi.getCardById(cardId)
internal.maybePrint("Taboo version for " .. basicCard.data.Nickname .. " is not available. Using standard version", playerColor)
else
slots[cardId .. "-t"] = slots[cardId]

View File

@ -3,11 +3,10 @@ require("playercards/PlayerCardSpawner")
local playmatApi = require("playermat/PlaymatApi")
local playAreaApi = require("core/PlayAreaApi")
local allCardsBagApi = require("playercards/AllCardsBagApi")
local arkhamDb = require("arkhamdb/ArkhamDb")
local zones = require("playermat/Zones")
local ALL_CARDS_GUID = "15bb07"
function onLoad(script_state)
initializeUi(JSON.decode(script_state))
math.randomseed(os.time())
@ -72,11 +71,10 @@ end
---@param loadAltInvestigator String Contains the name of alternative art for the investigator ("normal", "revised" or "promo")
function loadCards(slots, investigatorId, bondedList, customizations, playerColor, loadAltInvestigator)
function coinside()
local allCardsBag = getObjectFromGUID(ALL_CARDS_GUID)
local yPos = {}
local cardsToSpawn = {}
for cardId, cardCount in pairs(slots) do
local card = allCardsBag.call("getCardById", { id = cardId })
local card = allCardsBagApi.getCardById(cardId)
if card ~= nil then
local cardZone = getDefaultCardZone(card.metadata, bondedList)
for i = 1, cardCount do
@ -186,8 +184,7 @@ end
-- Returns the simple name of a card given its ID. This will find the card and strip any trailing
-- SCED-specific suffixes such as (Taboo) or (Level)
function getCardName(cardId)
local allCardsBag = getObjectFromGUID(ALL_CARDS_GUID)
local card = allCardsBag.call("getCardById", { id = cardId })
local card = allCardsBagApi.getCardById(cardId)
if (card ~= nil) then
local name = card.data.Nickname
if (string.find(name, " %(")) then

View File

@ -23,6 +23,8 @@ local privateDeck = true
local loadNewestDeck = true
local loadInvestigators = false
local allCardsBagApi = require("playercards/AllCardsBagApi")
-- Returns a table with the full state of the UI, including options and deck IDs.
-- This can be used to persist via onSave(), or provide values for a load operation
-- Table values:
@ -217,9 +219,7 @@ function loadDecks()
-- testLoadLotsOfDecks()
-- Method in DeckImporterMain, visible due to inclusion
-- TODO: Make this use the configuration ID for the all cards bag
local allCardsBag = getObjectFromGUID("15bb07")
local indexReady = allCardsBag.call("isIndexReady")
local indexReady = allCardsBagApi.isIndexReady()
if (not indexReady) then
broadcastToAll("Still loading player cards, please try again in a few seconds", {0.9, 0.2, 0.2})
return

View File

@ -6,7 +6,9 @@
-- Tells the All Cards Bag to recreate its indexes. The All Cards Bag may
-- ignore this request; see the rebuildIndexForHotfix() method in the All Cards
-- Bag for details.
local allCardsBagApi = require("playercards/AllCardsBagApi")
function onLoad()
local allCardsBag = getObjectFromGUID("15bb07")
allCardsBag.call("rebuildIndexForHotfix")
allCardsBagApi.rebuildIndexForHotfix()
end

View File

@ -23,6 +23,8 @@ local FONT_COLOR = {
local whitespace = " "
local updating
local chaosBagApi = require("chaosbag/ChaosBagApi")
---------------------------------------------------------
-- creating buttons and menus + initializing tables
---------------------------------------------------------
@ -79,7 +81,7 @@ function initializeState()
resetTables()
-- count tokens in the bag
local chaosbag = Global.call("findChaosBag")
local chaosbag = chaosBagApi.findChaosBag()
local tokens = {}
for _, v in ipairs(chaosbag.getObjects()) do
if v.name == "Bless" then
@ -117,7 +119,7 @@ end
-- context menu function 1
function doRemove(color)
local chaosbag = Global.call("findChaosBag")
local chaosbag = chaosBagApi.findChaosBag()
-- remove tokens from chaos bag
local count = { Bless = 0, Curse = 0 }
@ -224,7 +226,7 @@ end
-- function that is called by click_functions 1+2 and calls the other functions
function callFunctions(token, isRightClick)
if not Global.call("canTouchChaosTokens") then
if not chaosBagApi.canTouchChaosTokens() then
return
end
local success
@ -286,11 +288,11 @@ function addToken(type)
end
numInPlay[type] = numInPlay[type] + 1
printToAll("Adding " .. type .. " token " .. formatTokenCount(type))
return Global.call("spawnChaosToken", type)
return chaosBagApi.spawnChaosToken(type)
end
function takeToken(type, remove)
local chaosbag = Global.call("findChaosBag")
local chaosbag = chaosBagApi.findChaosBag()
if not remove and not SEAL_CARD_MESSAGE then
broadcastToColor("For sealing tokens on cards try right-clicking on the card for seal options.", playerColor)
SEAL_CARD_MESSAGE = true
@ -335,7 +337,7 @@ function returnToken(type)
printToColor("Couldn't find token " .. guid .. ", not returning to bag", playerColor)
return 0
end
local chaosbag = Global.call("findChaosBag")
local chaosbag = chaosBagApi.findChaosBag()
if chaosbag == nil then
return 0
end
@ -382,7 +384,7 @@ function addMenuOptions(parameters)
end
function sealToken(type, playerColor, enemy)
local chaosbag = Global.call("findChaosBag")
local chaosbag = chaosBagApi.findChaosBag()
if chaosbag == nil then return end
local pos = enemy.getPosition()
@ -407,7 +409,7 @@ function sealToken(type, playerColor, enemy)
end
function releaseToken(type, playerColor, enemy)
local chaosbag = Global.call("findChaosBag")
local chaosbag = chaosBagApi.findChaosBag()
if chaosbag == nil then return end
local tokens = sealedTokens[enemy.getGUID()]
if tokens == nil or #tokens == 0 then return end

View File

@ -28,5 +28,37 @@ do
return Global.call("releaseAllSealedTokens", playerColor)
end
-- removes the specified chaos token from the chaos bag
---@param id String ID of the chaos token
ChaosBagApi.removeChaosToken = function(id)
return Global.call("removeChaosToken", id)
end
-- spawns the specified chaos token and puts it into the chaos bag
---@param id String ID of the chaos token
ChaosBagApi.spawnChaosToken = function(id)
return Global.call("spawnChaosToken", id)
end
-- Checks to see if the chaos bag can be manipulated. If a player is searching the bag when tokens
-- are drawn or replaced a TTS bug can cause those tokens to vanish. Any functions which change the
-- contents of the bag should check this method before doing so.
-- This method will broadcast a message to all players if the bag is being searched.
---@return Boolean. True if the bag is manipulated, false if it should be blocked.
ChaosBagApi.canTouchChaosTokens = function()
return Global.call("canTouchChaosTokens")
end
-- called by playermats (by the "Draw chaos token" button)
ChaosBagApi.drawChaosToken = function(mat, tokenOffset, isRightClick)
return Global.call("drawChaosToken", {mat, tokenOffset, isRightClick})
end
-- returns a Table List of chaos token ids in the current chaos bag
-- requires copying the data into a new table because TTS is weird about handling table return values in Global
ChaosBagApi.getIdUrlMap = function()
return Global.getTable("ID_URL_MAP")
end
return ChaosBagApi
end

View File

@ -1,6 +1,7 @@
local blessCurseManagerApi = require("chaosbag/BlessCurseManagerApi")
local playmatApi = require("playermat/PlaymatApi")
local victoryDisplayApi = require("core/VictoryDisplayApi")
local optionPanelApi = require("core/OptionPanelApi")
function onLoad()
addHotkey("Add Doom to Agenda", addDoomToAgenda)
@ -98,14 +99,18 @@ function takeClueFromLocation(playerColor, hoveredObject)
return
end
local clickableClues = optionPanelApi.getOptions()["useClueClickers"]
local playerName = Player[playerColor].steam_name
local matColor = playmatApi.getMatColor(playerColor)
local pos = playmatApi.transformLocalPosition({x = -1.12, y = 0.05, z = 0.7}, matColor)
local rot = playmatApi.returnRotation(matColor)
if cardName == "" or cardName == nil then
cardName = "nameless card"
local matColor = playmatApi.getMatColor(playerColor)
local pos = nil
if clickableClues then
pos = {x = 0.49, y = 2.66, z = 0.00}
playmatApi.updateClueClicker(playerColor, playmatApi.getClueCount(clickableClues, playerColor) + 1)
else
pos = playmatApi.transformLocalPosition({x = -1.12, y = 0.05, z = 0.7}, matColor)
end
local rot = playmatApi.returnRotation(matColor)
-- check if found clue is a stack or single token
if clue.getQuantity() > 1 then

View File

@ -28,6 +28,8 @@ local collisionEnabled = false
-- used for recreating the link to a custom data helper after image change
customDataHelper = nil
local DEFAULT_URL = "http://cloud-3.steamusercontent.com/ugc/998015670465071049/FFAE162920D67CF38045EFBD3B85AD0F916147B2/"
local SHIFT_OFFSETS = {
left = { x = 0.00, y = 0, z = 7.67 },
right = { x = 0.00, y = 0, z = -7.67 },
@ -94,6 +96,29 @@ function updateLocations(args)
end
end
function updateSurface(newURL)
local customInfo = self.getCustomObject()
if newURL ~= "" and newURL ~= nil and newURL ~= DEFAULT_URL then
customInfo.image = newURL
broadcastToAll("New Playmat Image Applied", { 0.2, 0.9, 0.2 })
else
customInfo.image = DEFAULT_URL
broadcastToAll("Default Playmat Image Applied", { 0.2, 0.9, 0.2 })
end
self.setCustomObject(customInfo)
local guid = nil
if customDataHelper then guid = customDataHelper.getGUID() end
self.reload()
if guid ~= nil then
Wait.time(function() updateLocations({ guid }) end, 1)
end
end
function onCollisionEnter(collisionInfo)
local obj = collisionInfo.collision_object
local objType = obj.name
@ -504,20 +529,6 @@ function shiftContents(playerColor, direction)
Wait.time(drawBaseConnections, 0.1)
end
-- Returns the current value of the investigator counter from the playmat
---@return. Number of investigators currently set on the counter
function getInvestigatorCount()
local investigatorCounter = getObjectFromGUID("f182ee")
return investigatorCounter.getVar("val")
end
-- Updates the current value of the investigator counter from the playmat
---@param count Number of investigators to set on the counter
function setInvestigatorCount(count)
local investigatorCounter = getObjectFromGUID("f182ee")
return investigatorCounter.call("updateVal", count)
end
-- Check to see if the given object is within the bounds of the play area, based solely on the X and
-- Z coordinates, ignoring height
---@param object Object Object to check

View File

@ -2,19 +2,18 @@ do
local PlayAreaApi = { }
local PLAY_AREA_GUID = "721ba2"
local IMAGE_SWAPPER = "b7b45b"
local INVESTIGATOR_COUNTER_GUID = "f182ee"
-- Returns the current value of the investigator counter from the playmat
---@return Integer. Number of investigators currently set on the counter
PlayAreaApi.getInvestigatorCount = function()
return getObjectFromGUID(PLAY_AREA_GUID).call("getInvestigatorCount")
return getObjectFromGUID(INVESTIGATOR_COUNTER_GUID).getVar("val")
end
-- Updates the current value of the investigator counter from the playmat
---@param count Number of investigators to set on the counter
PlayAreaApi.setInvestigatorCount = function(count)
return getObjectFromGUID(PLAY_AREA_GUID).call("setInvestigatorCount", count)
return getObjectFromGUID(INVESTIGATOR_COUNTER_GUID).call("updateVal", count)
end
-- Move all contents on the play area (cards, tokens, etc) one slot in the given direction. Certain
@ -90,7 +89,18 @@ do
end
PlayAreaApi.updateSurface = function(url)
return getObjectFromGUID(IMAGE_SWAPPER).call("updateSurface", url)
return getObjectFromGUID(PLAY_AREA_GUID).call("updateSurface", url)
end
-- Called by Custom Data Helpers to push their location data into the Data Helper. This adds the
-- data to the local token manager instance.
---@param args Table Single-value array holding the GUID of the Custom Data Helper making the call
PlayAreaApi.updateLocations = function(args)
getObjectFromGUID(PLAY_AREA_GUID).call("updateLocations", args)
end
PlayAreaApi.getCustomDataHelper = function()
return getObjectFromGUID(PLAY_AREA_GUID).getVar("customDataHelper")
end
return PlayAreaApi

View File

@ -1,5 +1,5 @@
local controlActive = false
local DEFAULT_URL = "http://cloud-3.steamusercontent.com/ugc/998015670465071049/FFAE162920D67CF38045EFBD3B85AD0F916147B2/"
local playAreaApi = require("core/PlayAreaApi")
-- parameters for open/close button for reusing
local buttonParameters = {}
@ -62,39 +62,16 @@ end
-- click function for apply button
function click_applySurface(_, _, isRightClick)
updateSurface(isRightClick and "" or self.getInputs()[1].value)
playAreaApi.updateSurface(isRightClick and "" or self.getInputs()[1].value)
end
function updateSurface(newURL)
playAreaApi.updateSurface(newURL)
end
-- input function for the input box
function none() end
-- main function (can be called by other objects)
function updateSurface(newURL)
local playArea = getObjectFromGUID("721ba2")
local customInfo = playArea.getCustomObject()
if newURL ~= "" and newURL ~= nil and newURL ~= DEFAULT_URL then
customInfo.image = newURL
broadcastToAll("New Playmat Image Applied", { 0.2, 0.9, 0.2 })
else
customInfo.image = DEFAULT_URL
broadcastToAll("Default Playmat Image Applied", { 0.2, 0.9, 0.2 })
end
playArea.setCustomObject(customInfo)
-- get custom data helper and call the playarea with it after reloading
local customDataHelper = playArea.getVar("customDataHelper")
local guid
if customDataHelper then guid = customDataHelper.getGUID() end
playArea = playArea.reload()
if guid ~= nil then
Wait.time(function() playArea.call("updateLocations", { guid }) end, 1)
end
end
-- creates the main button
function createOpenCloseButton()
buttonParameters.tooltip = (controlActive and "Close" or "Open") .. " Playmat Panel"

View File

@ -8,6 +8,7 @@ local highlightMissing = false
local highlightCounted = false
local TRASHCAN
local TRASHCAN_GUID = "70b9f6"
local chaosBagApi = require("chaosbag/ChaosBagApi")
-- button creation when loading the game
function onLoad()
@ -276,7 +277,7 @@ function placeCard(card)
if obj.tag == "Deck" or obj.tag == "Card" then
-- put chaos tokens back into bag
elseif tokenChecker.isChaosToken(obj) then
local chaosBag = Global.call("findChaosBag")
local chaosBag = chaosBagApi.findChaosBag()
chaosBag.putObject(obj)
elseif obj.memo ~= nil and obj.getLock() == false then
TRASHCAN.putObject(obj)

View File

@ -1,6 +1,7 @@
do
local tokenSpawnTracker = require("core/token/TokenSpawnTrackerApi")
local playArea = require("core/PlayAreaApi")
local tokenSpawnTrackerApi = require("core/token/TokenSpawnTrackerApi")
local playAreaApi = require("core/PlayAreaApi")
local optionPanelApi = require("core/OptionPanelApi")
local PLAYER_CARD_TOKEN_OFFSETS = {
[1] = {
@ -141,7 +142,7 @@ do
---@param extraUses Table A table of <use type>=<count> which will modify the number of tokens
--- spawned for that type. e.g. Akachi's playmat should pass "Charge"=1
TokenManager.spawnForCard = function(card, extraUses)
if tokenSpawnTracker.hasSpawnedTokens(card.getGUID()) then
if tokenSpawnTrackerApi.hasSpawnedTokens(card.getGUID()) then
return
end
local metadata = JSON.decode(card.getGMNotes())
@ -161,7 +162,7 @@ do
---@param shiftDown Number An offset for the z-value of this group of tokens
---@param subType Number Subtype of token to spawn. This will only differ from the tokenName for resource tokens
TokenManager.spawnTokenGroup = function(card, tokenType, tokenCount, shiftDown, subType)
local optionPanel = Global.getTable("optionPanel")
local optionPanel = optionPanelApi.getOptions()
if tokenType == "damage" or tokenType == "horror" then
TokenManager.spawnCounterToken(card, tokenType, tokenCount, shiftDown)
@ -303,7 +304,7 @@ do
-- callers.
---@param card Object Card object to reset the tokens for
TokenManager.resetTokensSpawned = function(card)
tokenSpawnTracker.resetTokensSpawned(card.getGUID())
tokenSpawnTrackerApi.resetTokensSpawned(card.getGUID())
end
-- Pushes new player card data into the local copy of the Data Helper player data.
@ -369,14 +370,14 @@ do
type = useInfo.type
token = useInfo.token
tokenCount = (useInfo.count or 0)
+ (useInfo.countPerInvestigator or 0) * playArea.getInvestigatorCount()
+ (useInfo.countPerInvestigator or 0) * playAreaApi.getInvestigatorCount()
if extraUses ~= nil and extraUses[type] ~= nil then
tokenCount = tokenCount + extraUses[type]
end
-- Shift each spawned group after the first down so they don't pile on each other
TokenManager.spawnTokenGroup(card, token, tokenCount, (i - 1) * 0.8, type)
end
tokenSpawnTracker.markTokensSpawned(card.getGUID())
tokenSpawnTrackerApi.markTokensSpawned(card.getGUID())
end
-- Spawn tokens for a card based on the data helper data. This will consider the face up/down state
@ -403,7 +404,7 @@ do
tokenCount = playerData.tokenCount
--log("Spawning data helper tokens for "..card.getName()..'['..card.getDescription()..']: '..tokenCount.."x "..token)
TokenManager.spawnTokenGroup(card, token, tokenCount)
tokenSpawnTracker.markTokensSpawned(card.getGUID())
tokenSpawnTrackerApi.markTokensSpawned(card.getGUID())
end
-- Spawn tokens for a location using data retrieved from the Data Helper.
@ -414,7 +415,7 @@ do
local clueCount = internal.getClueCountFromData(card, locationData)
if clueCount > 0 then
TokenManager.spawnTokenGroup(card, "clue", clueCount)
tokenSpawnTracker.markTokensSpawned(card.getGUID())
tokenSpawnTrackerApi.markTokensSpawned(card.getGUID())
end
end
@ -440,7 +441,7 @@ do
if locationData.type == 'fixed' then
return locationData.value
elseif locationData.type == 'perPlayer' then
return locationData.value * playArea.getInvestigatorCount()
return locationData.value * playAreaApi.getInvestigatorCount()
end
error('unexpected location type: ' .. locationData.type)
end

View File

@ -0,0 +1,72 @@
do
local AllCardsBagApi = {}
local ALL_CARDS_BAG_GUID = "15bb07"
-- Returns a specific card from the bag, based on ArkhamDB ID
-- @param table:
-- id: String ID of the card to retrieve
-- @return: If the indexes are still being constructed, an empty table is
-- returned. Otherwise, a single table with the following fields
-- cardData: TTS object data, suitable for spawning the card
-- cardMetadata: Table of parsed metadata
AllCardsBagApi.getCardById = function(id)
return getObjectFromGUID(ALL_CARDS_BAG_GUID).call("getCardById", {id = id})
end
-- Gets a random basic weakness from the bag. Once a given ID has been returned
-- it will be removed from the list and cannot be selected again until a reload
-- occurs or the indexes are rebuilt, which will refresh the list to include all
-- weaknesses.
-- @return: String ID of the selected weakness.
AllCardsBagApi.getRandomWeaknessId = function()
return getObjectFromGUID(ALL_CARDS_BAG_GUID).call("getRandomWeaknessId")
end
AllCardsBagApi.isIndexReady = function()
return getObjectFromGUID(ALL_CARDS_BAG_GUID).call("isIndexReady")
end
-- Called by Hotfix bags when they load. If we are still loading indexes, then
-- the all cards and hotfix bags are being loaded together, and we can ignore
-- this call as the hotfix will be included in the initial indexing. If it is
-- called once indexing is complete it means the hotfix bag has been added
-- later, and we should rebuild the index to integrate the hotfix bag.
AllCardsBagApi.rebuildIndexForHotfix = function()
return getObjectFromGUID(ALL_CARDS_BAG_GUID).call("rebuildIndexForHotfix")
end
-- Searches the bag for cards which match the given name and returns a list. Note that this is
-- an O(n) search without index support. It may be slow.
-- @param
-- name String or string fragment to search for names
-- exact Whether the name match should be exact
AllCardsBagApi.getCardsByName = function(name, exact)
return getObjectFromGUID(ALL_CARDS_BAG_GUID).call("getCardsByName", {name = name, exact = exact})
end
AllCardsBagApi.isBagPresent = function()
return getObjectFromGUID(ALL_CARDS_BAG_GUID) and true
end
-- Returns a list of cards from the bag matching a class and level (0 or upgraded)
-- @param
-- class: String class to retrieve ("Guardian", "Seeker", etc)
-- upgraded: true for upgraded cards (Level 1-5), false for Level 0
-- @return: If the indexes are still being constructed, returns an empty table.
-- Otherwise, a list of tables, each with the following fields
-- cardData: TTS object data, suitable for spawning the card
-- cardMetadata: Table of parsed metadata
AllCardsBagApi.getCardsByClassAndLevel = function(class, upgraded)
return getObjectFromGUID(ALL_CARDS_BAG_GUID).call("getCardsByClassAndLevel", {class = class, upgraded = upgraded})
end
AllCardsBagApi.getCardsByCycle = function(cycle)
return getObjectFromGUID(ALL_CARDS_BAG_GUID).call("getCardsByCycle", cycle)
end
AllCardsBagApi.getUniqueWeaknesses = function()
return getObjectFromGUID(ALL_CARDS_BAG_GUID).call("getUniqueWeaknesses")
end
return AllCardsBagApi
end

View File

@ -8,6 +8,8 @@ information = {
require("playercards/PlayerCardSpawner")
local allCardsBagApi = require("playercards/AllCardsBagApi")
local buttonParameters = {}
buttonParameters.function_owner = self
buttonParameters.height = 200
@ -32,8 +34,6 @@ inputParameters.width = 1200
inputParameters.height = 130
inputParameters.font_size = 107
local ALL_CARDS_GUID = "15bb07"
-- main code
function onSave() return JSON.encode({ spawnAll, searchExact, inputParameters.value }) end
@ -101,15 +101,14 @@ function search()
printToAll("Please enter a longer search string.", "Yellow")
return
end
local allCardsBag = getObjectFromGUID(ALL_CARDS_GUID)
if allCardsBag == nil then
if not allCardsBagApi.isBagPresent() then
printToAll("Player card bag couldn't be found.", "Red")
return
end
-- search all objects in bag
local cardList = allCardsBag.call("getCardsByName", { name = inputParameters.value, exact = searchExact })
local cardList = allCardsBagApi.getCardsByName(inputParameters.value, searchExact)
if cardList == nil or #cardList == 0 then
printToAll("No match found.", "Red")
return

View File

@ -70,6 +70,7 @@ Thus it should be implemented like this:
local blessCurseManagerApi = require("chaosbag/BlessCurseManagerApi")
local tokenArrangerApi = require("accessories/TokenArrangerApi")
local chaosBagApi = require("chaosbag/ChaosBagApi")
local sealedTokens = {}
local ID_URL_MAP = {}
local tokensInBag = {}
@ -78,7 +79,7 @@ function onSave() return JSON.encode(sealedTokens) end
function onLoad(savedData)
sealedTokens = JSON.decode(savedData) or {}
ID_URL_MAP = Global.getTable("ID_URL_MAP")
ID_URL_MAP = chaosBagApi.getIdUrlMap()
generateContextMenu()
self.addTag("CardThatSeals")
end
@ -129,7 +130,7 @@ end
-- generates a list of chaos tokens that is in the chaos bag
function readBag()
local chaosbag = Global.call("findChaosBag")
local chaosbag = chaosBagApi.findChaosBag()
tokensInBag = {}
for _, token in ipairs(chaosbag.getObjects()) do
@ -148,8 +149,8 @@ end
-- seals the named token on this card
function sealToken(name, playerColor)
if not Global.call("canTouchChaosTokens") then return end
local chaosbag = Global.call("findChaosBag")
if not chaosBagApi.canTouchChaosTokens() then return end
local chaosbag = chaosBagApi.findChaosBag()
for i, obj in ipairs(chaosbag.getObjects()) do
if obj.name == name then
chaosbag.takeObject({
@ -174,7 +175,7 @@ end
-- release the last sealed token
function releaseOneToken(playerColor)
if not Global.call("canTouchChaosTokens") then return end
if not chaosBagApi.canTouchChaosTokens() then return end
if #sealedTokens == 0 then
printToColor("No sealed token(s) found", playerColor)
else
@ -197,7 +198,7 @@ end
-- releases all sealed tokens
function releaseAllTokens(playerColor)
if not Global.call("canTouchChaosTokens") then return end
if not chaosBagApi.canTouchChaosTokens() then return end
if #sealedTokens == 0 then
printToColor("No sealed token(s) found", playerColor)
else
@ -215,7 +216,7 @@ function putTokenAway(guid)
if not token then return end
local name = token.getName()
local chaosbag = Global.call("findChaosBag")
local chaosbag = chaosBagApi.findChaosBag()
chaosbag.putObject(token)
tokenArrangerApi.layout()
if name == "Bless" or name == "Curse" then

View File

@ -1,6 +1,7 @@
require("playercards/PlayerCardPanelData")
local spawnBag = require("playercards/SpawnBag")
local arkhamDb = require("arkhamdb/ArkhamDb")
local allCardsBagApi = require("playercards/AllCardsBagApi")
-- Size and position information for the three rows of class buttons
local CIRCLE_BUTTON_SIZE = 250
@ -21,8 +22,6 @@ local CYCLE_COLUMN_COUNT = 3
local CYCLE_BUTTONS_X_OFFSET = 0.267
local CYCLE_BUTTONS_Z_OFFSET = 0.2665
local ALL_CARDS_BAG_GUID = "15bb07"
local STARTER_DECK_MODE_SELECTED_COLOR = { 0.2, 0.2, 0.2, 0.8 }
local TRANSPARENT = { 0, 0, 0, 0 }
local STARTER_DECK_MODE_STARTERS = "starters"
@ -88,6 +87,7 @@ local CYCLE_LIST = {
"The Innsmouth Conspiracy",
"Edge of the Earth",
"The Scarlet Keys",
"The Feast of Hemlock Vale",
"Investigator Packs"
}
@ -280,8 +280,11 @@ function createCycleButtons()
colCount = 0
buttonPos.z = buttonPos.z + CYCLE_BUTTONS_Z_OFFSET * rowCount
if rowCount == 3 then
-- Account for centered button on the final row
-- Account for two centered buttons on the final row
buttonPos.x = buttonPos.x + CYCLE_BUTTONS_X_OFFSET / 2
--[[ Account for centered button on the final row
buttonPos.x = buttonPos.x + CYCLE_BUTTONS_X_OFFSET
]]
end
else
buttonPos.x = buttonPos.x + CYCLE_BUTTONS_X_OFFSET
@ -579,19 +582,18 @@ end
---@param cardClass String. Class to place ("Guardian", "Seeker", etc)
---@param isUpgraded Boolean. If true, spawn the Level 1-5 cards. Otherwise, Level 0.
function placeClassCards(cardClass, isUpgraded)
local allCardsBag = getObjectFromGUID(ALL_CARDS_BAG_GUID)
local indexReady = allCardsBag.call("isIndexReady")
local indexReady = allCardsBagApi.isIndexReady()
if (not indexReady) then
broadcastToAll("Still loading player cards, please try again in a few seconds", {0.9, 0.2, 0.2})
return
end
local cardIdList = allCardsBag.call("getCardsByClassAndLevel", {class = cardClass, upgraded = isUpgraded})
local cardIdList = allCardsBagApi.getCardsByClassAndLevel(cardClass, isUpgraded)
local skillList = { }
local eventList = { }
local assetList = { }
for _, cardId in ipairs(cardIdList) do
local cardMetadata = allCardsBag.call("getCardById", { id = cardId }).metadata
local cardMetadata = allCardsBagApi.getCardById(cardId).metadata
if (cardMetadata.type == "Skill") then
table.insert(skillList, cardId)
elseif (cardMetadata.type == "Event") then
@ -640,13 +642,12 @@ end
function spawnCycle(cycle)
prepareToPlaceCards()
spawnInvestigators(cycle)
local allCardsBag = getObjectFromGUID(ALL_CARDS_BAG_GUID)
local indexReady = allCardsBag.call("isIndexReady")
local indexReady = allCardsBagApi.isIndexReady()
if (not indexReady) then
broadcastToAll("Still loading player cards, please try again in a few seconds", {0.9, 0.2, 0.2})
return
end
local cycleCardList = allCardsBag.call("getCardsByCycle", cycle)
local cycleCardList = allCardsBagApi.getCardsByCycle(cycle)
local copiedList = { }
for i, id in ipairs(cycleCardList) do
copiedList[i] = id
@ -694,17 +695,16 @@ end
-- Clears the current cards, and places all basic weaknesses on the table.
function spawnWeaknesses()
prepareToPlaceCards()
local allCardsBag = getObjectFromGUID(ALL_CARDS_BAG_GUID)
local indexReady = allCardsBag.call("isIndexReady")
local indexReady = allCardsBagApi.isIndexReady()
if (not indexReady) then
broadcastToAll("Still loading player cards, please try again in a few seconds", {0.9, 0.2, 0.2})
return
end
local weaknessIdList = allCardsBag.call("getUniqueWeaknesses")
local weaknessIdList = allCardsBagApi.getUniqueWeaknesses()
local basicWeaknessList = { }
local otherWeaknessList = { }
for i, id in ipairs(weaknessIdList) do
local cardMetadata = allCardsBag.call("getCardById", { id = id }).metadata
local cardMetadata = allCardsBagApi.getCardById(id).metadata
if cardMetadata.basicWeaknessCount ~= nil and cardMetadata.basicWeaknessCount > 0 then
table.insert(basicWeaknessList, id)
elseif excludedNonBasicWeaknesses[id] == nil then
@ -742,8 +742,7 @@ end
function spawnRandomWeakness()
prepareToPlaceCards()
local allCardsBag = getObjectFromGUID(ALL_CARDS_BAG_GUID)
local weaknessId = allCardsBag.call("getRandomWeaknessId")
local weaknessId = allCardsBagApi.getRandomWeaknessId()
if (weaknessId == nil) then
broadcastToAll("All basic weaknesses are in play!", {0.9, 0.2, 0.2})
return

View File

@ -13,6 +13,7 @@ BONDED_CARD_LIST = {
"06033", -- Augur
"06331", -- Dream Parasite
"06015a", -- Dream-Gate
"10045" -- Uncanny Growth
}
UPGRADE_SHEET_LIST = {
@ -184,6 +185,9 @@ INVESTIGATOR_GROUPS = {
"Amina Zidane",
"Darrell Simmons",
"Charlie Kane"
},
["The Feast of Hemlock Vale"] = {
-- placeholder for future addition of investigators once we have their backs
}
}

View File

@ -29,7 +29,7 @@ do
-- To assist debugging, will draw a box around the recall zone when it's set up
local SHOW_RECALL_ZONE = false
local ALL_CARDS_GUID = "15bb07"
local allCardsBagApi = require("playercards/AllCardsBagApi")
-- Distance to expand the recall zone around any added object.
local RECALL_BUFFER_X = 0.9
@ -90,10 +90,9 @@ do
return
end
local cardsToSpawn = { }
local allCardsBag = getObjectFromGUID(ALL_CARDS_GUID)
local cardList = spawnSpec.cards
for _, cardId in ipairs(cardList) do
local cardData = allCardsBag.call("getCardById", { id = cardId })
local cardData = allCardsBagApi.getCardById(cardId)
if (cardData ~= nil) then
table.insert(cardsToSpawn, cardData)
else

View File

@ -0,0 +1,72 @@
-- this script is shared between both the level 0 and the upgraded level 3 version of the card
local playmatApi = require("playermat/PlaymatApi")
local display = false
local count = 0
local modValue = 5 -- level 0 Well Connected
local loopId = nil
local b_display = {
click_function = "toggleCounter",
function_owner = self,
position = {0.88,0.5,-1.33},
font_size = 150,
width = 175,
height = 175
}
function onLoad(saved_data)
local notes = JSON.decode(self.getGMNotes())
if notes.id == "54006" then -- hardcoded card id for upgraded Well Connected (3)
modValue = 4 -- Well Connected (3)
end
if saved_data != '' then
local loaded_data = JSON.decode(saved_data)
display = not loaded_data.saved_display
self.clearButtons()
toggleCounter()
end
self.addContextMenuItem('Toggle Counter', toggleCounter)
end
function onSave()
return JSON.encode({saved_display = display})
end
function toggleCounter()
display = not display
if display then
createUpdateDisplay()
loopId = Wait.time(|| createUpdateDisplay(), 2, -1)
else
if loopId ~= nil then
Wait.stop(loopId)
end
self.clearButtons()
loopId = nil
end
end
function createUpdateDisplay()
count = math.max(math.floor(getPlayerResources() / modValue), 0)
b_display.label = tostring(count)
if loopId == nil then
self.createButton(b_display)
else
self.editButton(b_display)
end
end
function getPlayerResources()
local matColor = playmatApi.getMatColorByPosition(self.getPosition())
return playmatApi.getResourceCount(matColor)
end

View File

@ -56,6 +56,8 @@ local TRASHCAN
local STAT_TRACKER
local RESOURCE_COUNTER
local chaosBagApi = require("chaosbag/ChaosBagApi")
-- global variable so it can be reset by the Clean Up Helper
activeInvestigatorId = "00000"
local isDrawButtonVisible = false
@ -210,7 +212,7 @@ function makeDiscardHandlerFor(searchPosition, discardPosition)
end
-- put chaos tokens back into bag (e.g. Unrelenting)
elseif tokenChecker.isChaosToken(obj) then
local chaosBag = Global.call("findChaosBag")
local chaosBag = chaosBagApi.findChaosBag()
chaosBag.putObject(obj)
-- don't touch the table or this playmat itself
elseif obj.guid ~= "4ee1f2" and obj ~= self then
@ -359,6 +361,11 @@ function gainResources(amount)
RESOURCE_COUNTER.call("updateVal", count + add)
end
-- returns the resource counter amount
function getResourceCount()
return RESOURCE_COUNTER.getVar("val")
end
-- function for "draw 1 button" (that can be added via option panel)
function doDrawOne(_, color)
-- send messages to player who clicked button if no seated player found
@ -772,7 +779,7 @@ end
---------------------------------------------------------
function drawChaosTokenButton(_, _, isRightClick)
Global.call("drawChaosToken", {self, DRAWN_CHAOS_TOKEN_OFFSET, isRightClick})
chaosBagApi.drawChaosToken(self, DRAWN_CHAOS_TOKEN_OFFSET, isRightClick)
end
function drawEncountercard(_, _, isRightClick)

View File

@ -178,6 +178,12 @@ do
end
end
-- Returns the resource counter amount for the requested playermat
PlaymatApi.getResourceCount = function(matColor)
local mat = getObjectFromGUID(MAT_IDS[matColor])
return mat.call("getResourceCount")
end
-- Discard a non-hidden card from the corresponding player's hand
PlaymatApi.doDiscardOne = function(matColor)
for _, mat in ipairs(internal.getMatForColor(matColor)) do
@ -191,6 +197,10 @@ do
end
end
PlaymatApi.updateClueClicker = function(playerColor, val)
return getObjectFromGUID(CLUE_CLICKER_GUIDS[playerColor]).call("updateVal", val)
end
-- Convenience function to look up a mat's object by color, or get all mats.
---@param matColor String for one of the active player colors - White, Orange, Green, Red. Also
-- accepts "All" as a special value which will return all four mats.