ah_sce_unpacked/unpacked/Custom_Model_Bag Additional Player Cards 2cba6b.ttslua

214 lines
8.3 KiB
Plaintext
Raw Normal View History

2024-02-04 10:51:51 -05:00
-- Bundled by luabundle {"version":"1.6.0"}
local __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)
local loadingPlaceholder = {[{}] = true}
local register
local modules = {}
local require
local loaded = {}
register = function(name, body)
if not modules[name] then
modules[name] = body
end
end
require = function(name)
local loadedModule = loaded[name]
if loadedModule then
if loadedModule == loadingPlaceholder then
return nil
end
else
if not modules[name] then
if not superRequire then
local identifier = type(name) == 'string' and '\"' .. name .. '\"' or tostring(name)
error('Tried to require ' .. identifier .. ', but no such module has been registered')
else
return superRequire(name)
end
end
loaded[name] = loadingPlaceholder
loadedModule = modules[name](require, loaded, register, modules)
loaded[name] = loadedModule
end
return loadedModule
end
return require, loaded, register, modules
end)(nil)
2024-07-27 21:47:52 -04:00
__bundle_register("__root", function(require, _LOADED, __bundle_register, __bundle_modules)
require("arkhamdb/HotfixBag")
end)
2024-02-04 10:51:51 -05:00
__bundle_register("arkhamdb/HotfixBag", function(require, _LOADED, __bundle_register, __bundle_modules)
-- A Hotfix bag contains replacement cards for the All Cards Bag, and should
-- have the 'AllCardsHotfix' tag on the object. Code for the All Cards Bag will
-- find these bags during indexing, and use them to replace cards from the
-- actual bag.
-- 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()
allCardsBagApi.rebuildIndexForHotfix()
self.addContextMenuItem("Update card index", function() allCardsBagApi.rebuildIndexForHotfix() end)
end
end)
__bundle_register("playercards/AllCardsBagApi", function(require, _LOADED, __bundle_register, __bundle_modules)
do
local AllCardsBagApi = {}
local guidReferenceApi = require("core/GUIDReferenceApi")
local function getAllCardsBag()
return guidReferenceApi.getObjectByOwnerAndType("Mythos", "AllCardsBag")
end
2024-07-27 21:47:52 -04:00
-- internal function to create a copy of the table to avoid operating on variables owned by different objects
local function returnCopyOfList(data)
local copiedList = {}
for _, id in ipairs(data) do
table.insert(copiedList, id)
end
return copiedList
end
2024-02-04 10:51:51 -05:00
-- Returns a specific card from the bag, based on ArkhamDB ID
2024-07-27 21:47:52 -04:00
---@param id string ID of the card to retrieve
---@return table: If the indexes are still being constructed, returns an empty table.
-- Otherwise, a single table with the following fields
-- data: TTS object data, suitable for spawning the card
-- metadata: Table of parsed metadata
2024-02-04 10:51:51 -05:00
AllCardsBagApi.getCardById = function(id)
2024-07-27 21:47:52 -04:00
return getAllCardsBag().call("getCardById", { id = id })
2024-02-04 10:51:51 -05:00
end
2024-07-27 21:47:52 -04:00
-- 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
2024-02-04 10:51:51 -05:00
AllCardsBagApi.getRandomWeaknessId = function()
return getAllCardsBag().call("getRandomWeaknessId")
end
AllCardsBagApi.isIndexReady = function()
return getAllCardsBag().call("isIndexReady")
end
2024-07-27 21:47:52 -04:00
-- Called by Hotfix bags when they load. If we are still loading indexes, then
2024-02-04 10:51:51 -05:00
-- the all cards and hotfix bags are being loaded together, and we can ignore
2024-07-27 21:47:52 -04:00
-- this call as the hotfix will be included in the initial indexing. If it is
2024-02-04 10:51:51 -05:00
-- 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()
2024-07-27 21:47:52 -04:00
getAllCardsBag().call("rebuildIndexForHotfix")
2024-02-04 10:51:51 -05:00
end
2024-07-27 21:47:52 -04:00
-- 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.
2024-02-17 19:48:30 -05:00
---@param name string or string fragment to search for names
---@param exact boolean Whether the name match should be exact
2024-02-04 10:51:51 -05:00
AllCardsBagApi.getCardsByName = function(name, exact)
2024-07-27 21:47:52 -04:00
return returnCopyOfList(getAllCardsBag().call("getCardsByName", { name = name, exact = exact }))
2024-02-04 10:51:51 -05:00
end
AllCardsBagApi.isBagPresent = function()
return getAllCardsBag() and true
end
-- Returns a list of cards from the bag matching a class and level (0 or upgraded)
2024-02-17 19:48:30 -05:00
---@param class string class to retrieve ("Guardian", "Seeker", etc)
2024-07-27 21:47:52 -04:00
---@param upgraded boolean True for upgraded cards (Level 1-5), false for Level 0
2024-02-17 19:48:30 -05:00
---@return table: If the indexes are still being constructed, returns an empty table.
2024-07-27 21:47:52 -04:00
-- Otherwise, a list of tables, each with the following fields
-- data: TTS object data, suitable for spawning the card
-- metadata: Table of parsed metadata
2024-02-04 10:51:51 -05:00
AllCardsBagApi.getCardsByClassAndLevel = function(class, upgraded)
2024-07-27 21:47:52 -04:00
return returnCopyOfList(getAllCardsBag().call("getCardsByClassAndLevel", { class = class, upgraded = upgraded }))
2024-02-04 10:51:51 -05:00
end
2024-07-27 21:47:52 -04:00
-- Returns a list of cards from the bag matching a cycle
---@param cycle string Cycle to retrieve ("The Scarlet Keys" etc.)
---@param sortByMetadata boolean If true, sorts the table by metadata instead of ID
---@return table: If the indexes are still being constructed, returns an empty table.
-- Otherwise, a list of tables, each with the following fields
-- data: TTS object data, suitable for spawning the card
-- metadata: Table of parsed metadata
AllCardsBagApi.getCardsByCycle = function(cycle, sortByMetadata)
return returnCopyOfList(getAllCardsBag().call("getCardsByCycle", { cycle = cycle, sortByMetadata = sortByMetadata }))
end
-- Constructs a list of available basic weaknesses by starting with the full pool of basic
-- weaknesses then removing any which are currently in the play or deck construction areas
---@param traits? string Trait(s) to use as filter
---@return table: Array of weakness IDs which are valid to choose from
AllCardsBagApi.buildAvailableWeaknesses = function(traits)
return returnCopyOfList(getAllCardsBag().call("buildAvailableWeaknesses", traits))
2024-02-04 10:51:51 -05:00
end
AllCardsBagApi.getUniqueWeaknesses = function()
2024-07-27 21:47:52 -04:00
return returnCopyOfList(getAllCardsBag().call("getUniqueWeaknesses"))
2024-02-04 10:51:51 -05:00
end
return AllCardsBagApi
end
end)
2024-06-09 10:10:21 -04:00
__bundle_register("core/GUIDReferenceApi", function(require, _LOADED, __bundle_register, __bundle_modules)
do
local GUIDReferenceApi = {}
local function getGuidHandler()
return getObjectFromGUID("123456")
end
-- Returns the matching object
---@param owner string Parent object for this search
---@param type string Type of object to search for
---@return any: Object reference to the matching object
GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)
return getGuidHandler().call("getObjectByOwnerAndType", { owner = owner, type = type })
end
-- Returns all matching objects as a table with references
---@param type string Type of object to search for
---@return table: List of object references to matching objects
GUIDReferenceApi.getObjectsByType = function(type)
return getGuidHandler().call("getObjectsByType", type)
end
-- Returns all matching objects as a table with references
---@param owner string Parent object for this search
---@return table: List of object references to matching objects
GUIDReferenceApi.getObjectsByOwner = function(owner)
return getGuidHandler().call("getObjectsByOwner", owner)
end
-- Sends new information to the reference handler to edit the main index
---@param owner string Parent of the object
---@param type string Type of the object
---@param guid string GUID of the object
GUIDReferenceApi.editIndex = function(owner, type, guid)
return getGuidHandler().call("editIndex", {
owner = owner,
type = type,
guid = guid
})
end
-- Returns the owner of an object or the object it's located on
---@param object tts__GameObject Object for this search
---@return string: Parent of the object or object it's located on
GUIDReferenceApi.getOwnerOfObject = function(object)
return getGuidHandler().call("getOwnerOfObject", object)
end
return GUIDReferenceApi
end
end)
2024-02-04 10:51:51 -05:00
return __bundle_require("__root")