Implemented AllCardsBagApi
Caught all (hopefully) references to the AllCardsBag and refactored to utilize the new AllCardsBagApi.
This commit is contained in:
parent
1213771ef9
commit
da06070311
@ -8,7 +8,7 @@ local soundCubeApi = require("core/SoundCubeApi")
|
|||||||
local playmatApi = require("playermat/PlaymatApi")
|
local playmatApi = require("playermat/PlaymatApi")
|
||||||
local blessCurseManagerApi = require("chaosbag/BlessCurseManagerApi")
|
local blessCurseManagerApi = require("chaosbag/BlessCurseManagerApi")
|
||||||
local chaosBagApi = require("chaosbag/ChaosBagApi")
|
local chaosBagApi = require("chaosbag/ChaosBagApi")
|
||||||
local playAreaAPI = require("core/PlayAreaApi")
|
local playAreaApi = require("core/PlayAreaApi")
|
||||||
|
|
||||||
-- these objects will be ignored
|
-- these objects will be ignored
|
||||||
local IGNORE_GUIDS = {
|
local IGNORE_GUIDS = {
|
||||||
@ -231,8 +231,7 @@ end
|
|||||||
|
|
||||||
-- gets the GUID of a custom data helper (if present) and adds it to the ignore list
|
-- gets the GUID of a custom data helper (if present) and adds it to the ignore list
|
||||||
function ignoreCustomDataHelper()
|
function ignoreCustomDataHelper()
|
||||||
local playArea = getObjectFromGUID("721ba2")
|
local customDataHelper = playAreaApi.getCustomDataHelper()
|
||||||
local customDataHelper = playAreaAPI.getCustomDataHelper()
|
|
||||||
if customDataHelper then table.insert(IGNORE_GUIDS, customDataHelper.getGUID()) end
|
if customDataHelper then table.insert(IGNORE_GUIDS, customDataHelper.getGUID()) end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
do
|
do
|
||||||
local playAreaApi = require("core/PlayAreaApi")
|
local playAreaApi = require("core/PlayAreaApi")
|
||||||
|
local allCardsBagApi = require("playercards/AllCardsBagApi")
|
||||||
local ArkhamDb = { }
|
local ArkhamDb = { }
|
||||||
local internal = { }
|
local internal = { }
|
||||||
|
|
||||||
@ -56,8 +57,7 @@ do
|
|||||||
callback)
|
callback)
|
||||||
-- Get a simple card to see if the bag indexes are complete. If not, abort
|
-- 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.
|
-- the deck load. The called method will handle player notification.
|
||||||
local allCardsBag = getObjectFromGUID(configuration.card_bag_guid)
|
local checkCard = allCardsBagApi.getCardById({ id = "01001" })
|
||||||
local checkCard = allCardsBag.call("getCardById", { id = "01001" })
|
|
||||||
if (checkCard ~= nil and checkCard.data == nil) then
|
if (checkCard ~= nil and checkCard.data == nil) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -166,7 +166,6 @@ do
|
|||||||
---@param playerColor String Color of the player this deck is being loaded for. Used for broadcast
|
---@param playerColor String Color of the player this deck is being loaded for. Used for broadcast
|
||||||
--- if a weakness is added.
|
--- if a weakness is added.
|
||||||
internal.maybeDrawRandomWeakness = function(slots, playerColor)
|
internal.maybeDrawRandomWeakness = function(slots, playerColor)
|
||||||
local allCardsBag = getObjectFromGUID(configuration.card_bag_guid)
|
|
||||||
local hasRandomWeakness = false
|
local hasRandomWeakness = false
|
||||||
for cardId, cardCount in pairs(slots) do
|
for cardId, cardCount in pairs(slots) do
|
||||||
if cardId == RANDOM_WEAKNESS_ID then
|
if cardId == RANDOM_WEAKNESS_ID then
|
||||||
@ -175,7 +174,7 @@ do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
if hasRandomWeakness then
|
if hasRandomWeakness then
|
||||||
local weaknessId = allCardsBag.call("getRandomWeaknessId")
|
local weaknessId = allCardsBagApi.getRandomWeaknessId()
|
||||||
slots[weaknessId] = 1
|
slots[weaknessId] = 1
|
||||||
slots[RANDOM_WEAKNESS_ID] = nil
|
slots[RANDOM_WEAKNESS_ID] = nil
|
||||||
internal.maybePrint("Random basic weakness added to deck", playerColor)
|
internal.maybePrint("Random basic weakness added to deck", playerColor)
|
||||||
@ -240,10 +239,9 @@ do
|
|||||||
---@param slots Table The slot list for cards in this deck. Table key is the cardId, value is the number
|
---@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
|
-- of those cards which will be spawned
|
||||||
internal.maybeAddCustomizeUpgradeSheets = function(slots)
|
internal.maybeAddCustomizeUpgradeSheets = function(slots)
|
||||||
local allCardsBag = getObjectFromGUID(configuration.card_bag_guid)
|
|
||||||
for cardId, _ in pairs(slots) do
|
for cardId, _ in pairs(slots) do
|
||||||
-- upgrade sheets for customizable cards
|
-- upgrade sheets for customizable cards
|
||||||
local upgradesheet = allCardsBag.call("getCardById", { id = cardId .. "-c" })
|
local upgradesheet = allCardsBagApi.getCardById({ id = cardId .. "-c" })
|
||||||
if upgradesheet ~= nil then
|
if upgradesheet ~= nil then
|
||||||
slots[cardId .. "-c"] = 1
|
slots[cardId .. "-c"] = 1
|
||||||
end
|
end
|
||||||
@ -280,12 +278,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.
|
-- 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
|
---@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)
|
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
|
-- Create a list of bonded cards first so we don't modify slots while iterating
|
||||||
local bondedCards = { }
|
local bondedCards = { }
|
||||||
local bondedList = { }
|
local bondedList = { }
|
||||||
for cardId, cardCount in pairs(slots) do
|
for cardId, cardCount in pairs(slots) do
|
||||||
local card = allCardsBag.call("getCardById", { id = cardId })
|
local card = allCardsBagApi.getCardById({ id = cardId })
|
||||||
if (card ~= nil and card.metadata.bonded ~= nil) then
|
if (card ~= nil and card.metadata.bonded ~= nil) then
|
||||||
for _, bond in ipairs(card.metadata.bonded) do
|
for _, bond in ipairs(card.metadata.bonded) do
|
||||||
bondedCards[bond.id] = bond.count
|
bondedCards[bond.id] = bond.count
|
||||||
@ -309,15 +306,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
|
---@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)
|
internal.checkTaboos = function(tabooId, slots, playerColor)
|
||||||
if tabooId then
|
if tabooId then
|
||||||
local allCardsBag = getObjectFromGUID(configuration.card_bag_guid)
|
|
||||||
for cardId, _ in pairs(tabooList[tabooId].cards) do
|
for cardId, _ in pairs(tabooList[tabooId].cards) do
|
||||||
if slots[cardId] ~= nil then
|
if slots[cardId] ~= nil then
|
||||||
-- Make sure there's a taboo version of the card before we replace it
|
-- 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
|
-- 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
|
-- 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({ id = cardId .. "-t" })
|
||||||
if tabooCard == nil then
|
if tabooCard == nil then
|
||||||
local basicCard = allCardsBag.call("getCardById", { id = cardId })
|
local basicCard = allCardsBagApi.getCardById({ id = cardId })
|
||||||
internal.maybePrint("Taboo version for " .. basicCard.data.Nickname .. " is not available. Using standard version", playerColor)
|
internal.maybePrint("Taboo version for " .. basicCard.data.Nickname .. " is not available. Using standard version", playerColor)
|
||||||
else
|
else
|
||||||
slots[cardId .. "-t"] = slots[cardId]
|
slots[cardId .. "-t"] = slots[cardId]
|
||||||
|
@ -3,11 +3,10 @@ require("playercards/PlayerCardSpawner")
|
|||||||
|
|
||||||
local playmatApi = require("playermat/PlaymatApi")
|
local playmatApi = require("playermat/PlaymatApi")
|
||||||
local playAreaApi = require("core/PlayAreaApi")
|
local playAreaApi = require("core/PlayAreaApi")
|
||||||
|
local allCardsBagApi = require("playercards/AllCardsBagApi")
|
||||||
local arkhamDb = require("arkhamdb/ArkhamDb")
|
local arkhamDb = require("arkhamdb/ArkhamDb")
|
||||||
local zones = require("playermat/Zones")
|
local zones = require("playermat/Zones")
|
||||||
|
|
||||||
local ALL_CARDS_GUID = "15bb07"
|
|
||||||
|
|
||||||
function onLoad(script_state)
|
function onLoad(script_state)
|
||||||
initializeUi(JSON.decode(script_state))
|
initializeUi(JSON.decode(script_state))
|
||||||
math.randomseed(os.time())
|
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")
|
---@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 loadCards(slots, investigatorId, bondedList, customizations, playerColor, loadAltInvestigator)
|
||||||
function coinside()
|
function coinside()
|
||||||
local allCardsBag = getObjectFromGUID(ALL_CARDS_GUID)
|
|
||||||
local yPos = {}
|
local yPos = {}
|
||||||
local cardsToSpawn = {}
|
local cardsToSpawn = {}
|
||||||
for cardId, cardCount in pairs(slots) do
|
for cardId, cardCount in pairs(slots) do
|
||||||
local card = allCardsBag.call("getCardById", { id = cardId })
|
local card = allCardsBagApi.getCardById({ id = cardId })
|
||||||
if card ~= nil then
|
if card ~= nil then
|
||||||
local cardZone = getDefaultCardZone(card.metadata, bondedList)
|
local cardZone = getDefaultCardZone(card.metadata, bondedList)
|
||||||
for i = 1, cardCount do
|
for i = 1, cardCount do
|
||||||
@ -185,8 +183,7 @@ end
|
|||||||
-- Returns the simple name of a card given its ID. This will find the card and strip any trailing
|
-- 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)
|
-- SCED-specific suffixes such as (Taboo) or (Level)
|
||||||
function getCardName(cardId)
|
function getCardName(cardId)
|
||||||
local allCardsBag = getObjectFromGUID(ALL_CARDS_GUID)
|
local card = allCardsBagApi.getCardById({ id = cardId })
|
||||||
local card = allCardsBag.call("getCardById", { id = cardId })
|
|
||||||
if (card ~= nil) then
|
if (card ~= nil) then
|
||||||
local name = card.data.Nickname
|
local name = card.data.Nickname
|
||||||
if (string.find(name, " %(")) then
|
if (string.find(name, " %(")) then
|
||||||
|
@ -23,6 +23,8 @@ local privateDeck = true
|
|||||||
local loadNewestDeck = true
|
local loadNewestDeck = true
|
||||||
local loadInvestigators = false
|
local loadInvestigators = false
|
||||||
|
|
||||||
|
local allCardsBagApi = require("playercards/AllCardsBagApi")
|
||||||
|
|
||||||
-- Returns a table with the full state of the UI, including options and deck IDs.
|
-- 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
|
-- This can be used to persist via onSave(), or provide values for a load operation
|
||||||
-- Table values:
|
-- Table values:
|
||||||
@ -218,8 +220,7 @@ function loadDecks()
|
|||||||
-- Method in DeckImporterMain, visible due to inclusion
|
-- Method in DeckImporterMain, visible due to inclusion
|
||||||
|
|
||||||
-- TODO: Make this use the configuration ID for the all cards bag
|
-- TODO: Make this use the configuration ID for the all cards bag
|
||||||
local allCardsBag = getObjectFromGUID("15bb07")
|
local indexReady = allCardsBagApi.isIndexReady()
|
||||||
local indexReady = allCardsBag.call("isIndexReady")
|
|
||||||
if (not indexReady) then
|
if (not indexReady) then
|
||||||
broadcastToAll("Still loading player cards, please try again in a few seconds", {0.9, 0.2, 0.2})
|
broadcastToAll("Still loading player cards, please try again in a few seconds", {0.9, 0.2, 0.2})
|
||||||
return
|
return
|
||||||
|
@ -6,7 +6,9 @@
|
|||||||
-- Tells the All Cards Bag to recreate its indexes. The All Cards Bag may
|
-- 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
|
-- ignore this request; see the rebuildIndexForHotfix() method in the All Cards
|
||||||
-- Bag for details.
|
-- Bag for details.
|
||||||
|
|
||||||
|
local allCardsBagApi = require("playercards/AllCardsBagApi")
|
||||||
|
|
||||||
function onLoad()
|
function onLoad()
|
||||||
local allCardsBag = getObjectFromGUID("15bb07")
|
allCardsBagApi.rebuildIndexForHotfix()
|
||||||
allCardsBag.call("rebuildIndexForHotfix")
|
|
||||||
end
|
end
|
||||||
|
@ -2,7 +2,71 @@ do
|
|||||||
local AllCardsBagApi = {}
|
local AllCardsBagApi = {}
|
||||||
local ALL_CARDS_BAG_GUID = "15bb07"
|
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(params)
|
||||||
|
return getObjectFromGUID(ALL_CARDS_BAG_GUID).call("getCardById", params)
|
||||||
|
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 array must contain these fields to define the search:
|
||||||
|
-- name String or string fragment to search for names
|
||||||
|
-- exact Whether the name match should be exact
|
||||||
|
AllCardsBagApi.getCardsByName = function(params)
|
||||||
|
return getObjectFromGUID(ALL_CARDS_BAG_GUID).call("getCardsByName", params)
|
||||||
|
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 table:
|
||||||
|
-- class: String class to retrieve ("Guardian", "Seeker", etc)
|
||||||
|
-- isUpgraded: 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(params)
|
||||||
|
return getObjectFromGUID(ALL_CARDS_BAG_GUID).call("getCardsByClassAndLevel", params)
|
||||||
|
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
|
return AllCardsBagApi
|
||||||
end
|
end
|
@ -8,6 +8,8 @@ information = {
|
|||||||
|
|
||||||
require("playercards/PlayerCardSpawner")
|
require("playercards/PlayerCardSpawner")
|
||||||
|
|
||||||
|
local allCardsBagApi = require("playercards/AllCardsBagApi")
|
||||||
|
|
||||||
local buttonParameters = {}
|
local buttonParameters = {}
|
||||||
buttonParameters.function_owner = self
|
buttonParameters.function_owner = self
|
||||||
buttonParameters.height = 200
|
buttonParameters.height = 200
|
||||||
@ -32,8 +34,6 @@ inputParameters.width = 1200
|
|||||||
inputParameters.height = 130
|
inputParameters.height = 130
|
||||||
inputParameters.font_size = 107
|
inputParameters.font_size = 107
|
||||||
|
|
||||||
local ALL_CARDS_GUID = "15bb07"
|
|
||||||
|
|
||||||
-- main code
|
-- main code
|
||||||
function onSave() return JSON.encode({ spawnAll, searchExact, inputParameters.value }) end
|
function onSave() return JSON.encode({ spawnAll, searchExact, inputParameters.value }) end
|
||||||
|
|
||||||
@ -102,14 +102,13 @@ function search()
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local allCardsBag = getObjectFromGUID(ALL_CARDS_GUID)
|
if not allCardsBagApi.isBagPresent() then
|
||||||
if allCardsBag == nil then
|
|
||||||
printToAll("Player card bag couldn't be found.", "Red")
|
printToAll("Player card bag couldn't be found.", "Red")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- search all objects in bag
|
-- search all objects in bag
|
||||||
local cardList = allCardsBag.call("getCardsByName", { name = inputParameters.value, exact = searchExact })
|
local cardList = allCardsBagApi.getCardsByName({ name = inputParameters.value, exact = searchExact })
|
||||||
if cardList == nil or #cardList == 0 then
|
if cardList == nil or #cardList == 0 then
|
||||||
printToAll("No match found.", "Red")
|
printToAll("No match found.", "Red")
|
||||||
return
|
return
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
require("playercards/PlayerCardPanelData")
|
require("playercards/PlayerCardPanelData")
|
||||||
local spawnBag = require("playercards/SpawnBag")
|
local spawnBag = require("playercards/SpawnBag")
|
||||||
local arkhamDb = require("arkhamdb/ArkhamDb")
|
local arkhamDb = require("arkhamdb/ArkhamDb")
|
||||||
|
local allCardsBagApi = require("playercards/AllCardsBagApi")
|
||||||
|
|
||||||
-- Size and position information for the three rows of class buttons
|
-- Size and position information for the three rows of class buttons
|
||||||
local CIRCLE_BUTTON_SIZE = 250
|
local CIRCLE_BUTTON_SIZE = 250
|
||||||
@ -21,8 +22,6 @@ local CYCLE_COLUMN_COUNT = 3
|
|||||||
local CYCLE_BUTTONS_X_OFFSET = 0.267
|
local CYCLE_BUTTONS_X_OFFSET = 0.267
|
||||||
local CYCLE_BUTTONS_Z_OFFSET = 0.2665
|
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 STARTER_DECK_MODE_SELECTED_COLOR = { 0.2, 0.2, 0.2, 0.8 }
|
||||||
local TRANSPARENT = { 0, 0, 0, 0 }
|
local TRANSPARENT = { 0, 0, 0, 0 }
|
||||||
local STARTER_DECK_MODE_STARTERS = "starters"
|
local STARTER_DECK_MODE_STARTERS = "starters"
|
||||||
@ -579,19 +578,18 @@ end
|
|||||||
---@param cardClass String. Class to place ("Guardian", "Seeker", etc)
|
---@param cardClass String. Class to place ("Guardian", "Seeker", etc)
|
||||||
---@param isUpgraded Boolean. If true, spawn the Level 1-5 cards. Otherwise, Level 0.
|
---@param isUpgraded Boolean. If true, spawn the Level 1-5 cards. Otherwise, Level 0.
|
||||||
function placeClassCards(cardClass, isUpgraded)
|
function placeClassCards(cardClass, isUpgraded)
|
||||||
local allCardsBag = getObjectFromGUID(ALL_CARDS_BAG_GUID)
|
local indexReady = allCardsBagApi.isIndexReady()
|
||||||
local indexReady = allCardsBag.call("isIndexReady")
|
|
||||||
if (not indexReady) then
|
if (not indexReady) then
|
||||||
broadcastToAll("Still loading player cards, please try again in a few seconds", {0.9, 0.2, 0.2})
|
broadcastToAll("Still loading player cards, please try again in a few seconds", {0.9, 0.2, 0.2})
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local cardIdList = allCardsBag.call("getCardsByClassAndLevel", {class = cardClass, upgraded = isUpgraded})
|
local cardIdList = allCardsBagApi.getCardsByClassAndLevel({class = cardClass, upgraded = isUpgraded})
|
||||||
|
|
||||||
local skillList = { }
|
local skillList = { }
|
||||||
local eventList = { }
|
local eventList = { }
|
||||||
local assetList = { }
|
local assetList = { }
|
||||||
for _, cardId in ipairs(cardIdList) do
|
for _, cardId in ipairs(cardIdList) do
|
||||||
local cardMetadata = allCardsBag.call("getCardById", { id = cardId }).metadata
|
local cardMetadata = allCardsBagApi.getCardById({ id = cardId }).metadata
|
||||||
if (cardMetadata.type == "Skill") then
|
if (cardMetadata.type == "Skill") then
|
||||||
table.insert(skillList, cardId)
|
table.insert(skillList, cardId)
|
||||||
elseif (cardMetadata.type == "Event") then
|
elseif (cardMetadata.type == "Event") then
|
||||||
@ -640,13 +638,12 @@ end
|
|||||||
function spawnCycle(cycle)
|
function spawnCycle(cycle)
|
||||||
prepareToPlaceCards()
|
prepareToPlaceCards()
|
||||||
spawnInvestigators(cycle)
|
spawnInvestigators(cycle)
|
||||||
local allCardsBag = getObjectFromGUID(ALL_CARDS_BAG_GUID)
|
local indexReady = allCardsBagApi.isIndexReady()
|
||||||
local indexReady = allCardsBag.call("isIndexReady")
|
|
||||||
if (not indexReady) then
|
if (not indexReady) then
|
||||||
broadcastToAll("Still loading player cards, please try again in a few seconds", {0.9, 0.2, 0.2})
|
broadcastToAll("Still loading player cards, please try again in a few seconds", {0.9, 0.2, 0.2})
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local cycleCardList = allCardsBag.call("getCardsByCycle", cycle)
|
local cycleCardList = allCardsBagApi.getCardsByCycle(cycle)
|
||||||
local copiedList = { }
|
local copiedList = { }
|
||||||
for i, id in ipairs(cycleCardList) do
|
for i, id in ipairs(cycleCardList) do
|
||||||
copiedList[i] = id
|
copiedList[i] = id
|
||||||
@ -694,17 +691,16 @@ end
|
|||||||
-- Clears the current cards, and places all basic weaknesses on the table.
|
-- Clears the current cards, and places all basic weaknesses on the table.
|
||||||
function spawnWeaknesses()
|
function spawnWeaknesses()
|
||||||
prepareToPlaceCards()
|
prepareToPlaceCards()
|
||||||
local allCardsBag = getObjectFromGUID(ALL_CARDS_BAG_GUID)
|
local indexReady = allCardsBagApi.isIndexReady()
|
||||||
local indexReady = allCardsBag.call("isIndexReady")
|
|
||||||
if (not indexReady) then
|
if (not indexReady) then
|
||||||
broadcastToAll("Still loading player cards, please try again in a few seconds", {0.9, 0.2, 0.2})
|
broadcastToAll("Still loading player cards, please try again in a few seconds", {0.9, 0.2, 0.2})
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local weaknessIdList = allCardsBag.call("getUniqueWeaknesses")
|
local weaknessIdList = allCardsBagApi.getUniqueWeaknesses()
|
||||||
local basicWeaknessList = { }
|
local basicWeaknessList = { }
|
||||||
local otherWeaknessList = { }
|
local otherWeaknessList = { }
|
||||||
for i, id in ipairs(weaknessIdList) do
|
for i, id in ipairs(weaknessIdList) do
|
||||||
local cardMetadata = allCardsBag.call("getCardById", { id = id }).metadata
|
local cardMetadata = allCardsBagApi.getCardById({ id = id }).metadata
|
||||||
if cardMetadata.basicWeaknessCount ~= nil and cardMetadata.basicWeaknessCount > 0 then
|
if cardMetadata.basicWeaknessCount ~= nil and cardMetadata.basicWeaknessCount > 0 then
|
||||||
table.insert(basicWeaknessList, id)
|
table.insert(basicWeaknessList, id)
|
||||||
elseif excludedNonBasicWeaknesses[id] == nil then
|
elseif excludedNonBasicWeaknesses[id] == nil then
|
||||||
@ -742,8 +738,7 @@ end
|
|||||||
|
|
||||||
function spawnRandomWeakness()
|
function spawnRandomWeakness()
|
||||||
prepareToPlaceCards()
|
prepareToPlaceCards()
|
||||||
local allCardsBag = getObjectFromGUID(ALL_CARDS_BAG_GUID)
|
local weaknessId = allCardsBagApi.getRandomWeaknessId()
|
||||||
local weaknessId = allCardsBag.call("getRandomWeaknessId")
|
|
||||||
if (weaknessId == nil) then
|
if (weaknessId == nil) then
|
||||||
broadcastToAll("All basic weaknesses are in play!", {0.9, 0.2, 0.2})
|
broadcastToAll("All basic weaknesses are in play!", {0.9, 0.2, 0.2})
|
||||||
return
|
return
|
||||||
|
@ -29,7 +29,7 @@ do
|
|||||||
-- To assist debugging, will draw a box around the recall zone when it's set up
|
-- To assist debugging, will draw a box around the recall zone when it's set up
|
||||||
local SHOW_RECALL_ZONE = false
|
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.
|
-- Distance to expand the recall zone around any added object.
|
||||||
local RECALL_BUFFER_X = 0.9
|
local RECALL_BUFFER_X = 0.9
|
||||||
@ -90,10 +90,9 @@ do
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
local cardsToSpawn = { }
|
local cardsToSpawn = { }
|
||||||
local allCardsBag = getObjectFromGUID(ALL_CARDS_GUID)
|
|
||||||
local cardList = spawnSpec.cards
|
local cardList = spawnSpec.cards
|
||||||
for _, cardId in ipairs(cardList) do
|
for _, cardId in ipairs(cardList) do
|
||||||
local cardData = allCardsBag.call("getCardById", { id = cardId })
|
local cardData = allCardsBagApi.getCardById({ id = cardId })
|
||||||
if (cardData ~= nil) then
|
if (cardData ~= nil) then
|
||||||
table.insert(cardsToSpawn, cardData)
|
table.insert(cardsToSpawn, cardData)
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user