Finish some missed cleanup and fix a bug with deck size

This commit is contained in:
Buhallin 2022-11-14 02:02:18 -08:00
parent a516175177
commit fa4d1f428d
No known key found for this signature in database
GPG Key ID: DB3C362823852294
2 changed files with 13 additions and 15 deletions

View File

@ -32,7 +32,7 @@ inputParameters.width = 1200
inputParameters.height = 130
inputParameters.font_size = 107
local allCardsBag = getObjectFromGUID("15bb07")
local ALL_CARDS_GUID = "15bb07"
-- main code
function onSave() return JSON.encode({ spawnAll, searchExact, inputParameters.value }) end
@ -102,6 +102,7 @@ function search()
return
end
local allCardsBag = getObjectFromGUID(ALL_CARDS_GUID)
if allCardsBag == nil then
printToAll("Player card bag couldn't be found.", "Red")
return
@ -113,6 +114,10 @@ function search()
printToAll("No match found.", "Red")
return
end
if (#cardList > 100) then
printToAll("Matched more than 100 cards, please try a more specific search.", "Yellow")
return
end
-- sort table by name (reverse for multiple results, because bottom card spawns first)
table.sort(cardList, function(k1, k2) return spawnAll == (k1.data.Nickname > k2.data.Nickname) end)
@ -120,17 +125,4 @@ function search()
local rot = self.getRotation()
local pos = self.positionToWorld(Vector(0, 2, -0.225))
Spawner.spawnCards(cardList, pos, rot, true)
-- for _, card in ipairs(cardList) do
-- pos[2] = pos[2] + 0.1
-- spawnObjectData({
-- data = card.data,
-- position = pos,
-- rotation = rot
-- })
-- if not spawnAll then return end
-- if i == 100 then
-- printToAll("Only first 100 results of " .. #cardList .. " total results spawned.", "Yellow")
-- return
-- end
-- end
end

View File

@ -51,7 +51,6 @@ Spawner.spawn = function(cardList, pos, rot, callback)
end
-- Spawn a single card directly
if (#cardList == 1) then
log(pos)
spawnObjectData({
data = cardList[1].data,
position = pos,
@ -62,6 +61,13 @@ Spawner.spawn = function(cardList, pos, rot, callback)
end
-- For multiple cards, construct a deck and spawn that
local deck = Spawner.buildDeckDataTemplate()
-- Decks won't inherently scale to the cards in them. The card list being spawned should be all
-- the same type/size by this point, so use the first card to set the size
deck.Transform = {
scaleX = cardList[1].data.Transform.scaleX,
scaleY = 1,
scaleZ = cardList[1].data.Transform.scaleZ,
}
for _, spawnCard in ipairs(cardList) do
Spawner.addCardToDeck(deck, spawnCard.data)
end