Addressed PR Suggestions

This commit is contained in:
Entrox-Licher 2023-08-24 20:04:14 -04:00
parent 7cef2c93ea
commit b8bcd04b0f
12 changed files with 55 additions and 68 deletions

View File

@ -57,7 +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 checkCard = allCardsBagApi.getCardById({ id = "01001" })
local checkCard = allCardsBagApi.getCardById("01001")
if (checkCard ~= nil and checkCard.data == nil) then
return
end
@ -241,7 +241,7 @@ do
internal.maybeAddCustomizeUpgradeSheets = function(slots)
for cardId, _ in pairs(slots) do
-- upgrade sheets for customizable cards
local upgradesheet = allCardsBagApi.getCardById({ id = cardId .. "-c" })
local upgradesheet = allCardsBagApi.getCardById(cardId .. "-c")
if upgradesheet ~= nil then
slots[cardId .. "-c"] = 1
end
@ -282,7 +282,7 @@ do
local bondedCards = { }
local bondedList = { }
for cardId, cardCount in pairs(slots) do
local card = allCardsBagApi.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
@ -311,9 +311,9 @@ do
-- 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 = allCardsBagApi.getCardById({ id = cardId .. "-t" })
local tabooCard = allCardsBagApi.getCardById(cardId .. "-t")
if tabooCard == nil then
local basicCard = allCardsBagApi.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

@ -74,7 +74,7 @@ function loadCards(slots, investigatorId, bondedList, customizations, playerColo
local yPos = {}
local cardsToSpawn = {}
for cardId, cardCount in pairs(slots) do
local card = allCardsBagApi.getCardById({ id = cardId })
local card = allCardsBagApi.getCardById(cardId)
if card ~= nil then
local cardZone = getDefaultCardZone(card.metadata, bondedList)
for i = 1, cardCount do
@ -183,7 +183,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 card = allCardsBagApi.getCardById({ id = cardId })
local card = allCardsBagApi.getCardById(cardId)
if (card ~= nil) then
local name = card.data.Nickname
if (string.find(name, " %(")) then

View File

@ -219,7 +219,6 @@ function loadDecks()
-- testLoadLotsOfDecks()
-- Method in DeckImporterMain, visible due to inclusion
-- TODO: Make this use the configuration ID for the all cards bag
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})

View File

@ -50,8 +50,8 @@ do
end
-- called by playermats (by the "Draw chaos token" button)
ChaosBagApi.drawChaosToken = function(params)
return Global.call("drawChaosToken", params)
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

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

View File

@ -4,8 +4,6 @@ do
local PLAY_AREA_GUID = "721ba2"
local INVESTIGATOR_COUNTER_GUID = "f182ee"
local IMAGE_SWAPPER = "b7b45b"
-- Returns the current value of the investigator counter from the playmat
---@return Integer. Number of investigators currently set on the counter
PlayAreaApi.getInvestigatorCount = function()
@ -91,7 +89,7 @@ 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
@ -105,17 +103,5 @@ do
return getObjectFromGUID(PLAY_AREA_GUID).getVar("customDataHelper")
end
PlayAreaApi.getCustomObject = function()
return getObjectFromGUID(PLAY_AREA_GUID).getCustomObject()
end
PlayAreaApi.setCustomObject = function(customInfo)
return getObjectFromGUID(PLAY_AREA_GUID).setCustomObject(customInfo)
end
PlayAreaApi.reload = function()
return getObjectFromGUID(PLAY_AREA_GUID).reload()
end
return PlayAreaApi
end

View File

@ -1,5 +1,4 @@
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
@ -63,38 +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 customInfo = playAreaAPI.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
playAreaAPI.setCustomObject(customInfo)
-- get custom data helper and call the playarea with it after reloading
local customDataHelper = playAreaAPI.getCustomDataHelper()
local guid
if customDataHelper then guid = customDataHelper.getGUID() end
playAreaAPI.reload()
if guid ~= nil then
Wait.time(function() playAreaAPI.updateLocations({ guid }) end, 1)
end
end
-- creates the main button
function createOpenCloseButton()
buttonParameters.tooltip = (controlActive and "Close" or "Open") .. " Playmat Panel"

View File

@ -9,8 +9,8 @@ do
-- 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)
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
@ -37,11 +37,11 @@ do
-- 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:
-- @param
-- 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)
AllCardsBagApi.getCardsByName = function(name, exact)
return getObjectFromGUID(ALL_CARDS_BAG_GUID).call("getCardsByName", {name = name, exact = exact})
end
AllCardsBagApi.isBagPresent = function()
@ -49,15 +49,15 @@ do
end
-- Returns a list of cards from the bag matching a class and level (0 or upgraded)
-- @param table:
-- @param
-- class: String class to retrieve ("Guardian", "Seeker", etc)
-- isUpgraded: true for upgraded cards (Level 1-5), false for Level 0
-- 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(params)
return getObjectFromGUID(ALL_CARDS_BAG_GUID).call("getCardsByClassAndLevel", params)
AllCardsBagApi.getCardsByClassAndLevel = function(class, upgraded)
return getObjectFromGUID(ALL_CARDS_BAG_GUID).call("getCardsByClassAndLevel", {class = class, upgraded = upgraded})
end
AllCardsBagApi.getCardsByCycle = function(cycle)

View File

@ -108,7 +108,7 @@ function search()
end
-- search all objects in bag
local cardList = allCardsBagApi.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

@ -583,13 +583,13 @@ function placeClassCards(cardClass, isUpgraded)
broadcastToAll("Still loading player cards, please try again in a few seconds", {0.9, 0.2, 0.2})
return
end
local cardIdList = allCardsBagApi.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 = allCardsBagApi.getCardById({ id = cardId }).metadata
local cardMetadata = allCardsBagApi.getCardById(cardId).metadata
if (cardMetadata.type == "Skill") then
table.insert(skillList, cardId)
elseif (cardMetadata.type == "Event") then
@ -700,7 +700,7 @@ function spawnWeaknesses()
local basicWeaknessList = { }
local otherWeaknessList = { }
for i, id in ipairs(weaknessIdList) do
local cardMetadata = allCardsBagApi.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

View File

@ -92,7 +92,7 @@ do
local cardsToSpawn = { }
local cardList = spawnSpec.cards
for _, cardId in ipairs(cardList) do
local cardData = allCardsBagApi.getCardById({ id = cardId })
local cardData = allCardsBagApi.getCardById(cardId)
if (cardData ~= nil) then
table.insert(cardsToSpawn, cardData)
else

View File

@ -774,7 +774,7 @@ end
---------------------------------------------------------
function drawChaosTokenButton(_, _, isRightClick)
chaosBagApi.drawChaosToken({self, DRAWN_CHAOS_TOKEN_OFFSET, isRightClick})
chaosBagApi.drawChaosToken(self, DRAWN_CHAOS_TOKEN_OFFSET, isRightClick)
end
function drawEncountercard(_, _, isRightClick)