Merge pull request #737 from argonui/patrice

Updated Patrice handling
This commit is contained in:
dscarpac 2024-07-02 15:23:49 -05:00 committed by GitHub
commit 6c4586704a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 20 additions and 22 deletions

View File

@ -155,10 +155,10 @@ end
function endSearch(_, _, isRightClick)
local handCards = Player[handColor].getHandObjects()
local j = 0
for i = #handCards, 1, -1 do
j = j + 1
Wait.time(function() deckLib.placeOrMergeIntoDeck(handCards[i], drawDeckPosition, setAsideRotation) end, j * 0.1)
local handCount = #handCards
for i = handCount, 1, -1 do
Wait.time(function() deckLib.placeOrMergeIntoDeck(handCards[i], drawDeckPosition, setAsideRotation) end,
(handCount - i + 1) * 0.1)
end
-- draw set aside cards (from the ground!)

View File

@ -256,13 +256,11 @@ function discardListOfObjects(objList)
else
deckLib.placeOrMergeIntoDeck(obj, ENCOUNTER_DISCARD_POSITION, { x = 0, y = -90, z = 0 })
end
-- put chaos tokens back into bag (e.g. Unrelenting)
elseif tokenChecker.isChaosToken(obj) then
-- put chaos tokens back into bag (e.g. Unrelenting)
chaosBagApi.returnChaosTokenToBag(obj)
-- don't touch locked objects (like the table etc.) or specific objects (like key tokens)
elseif not obj.getLock() and not obj.hasTag("DontDiscard") then
-- don't touch locked objects (like the table etc.) or specific objects (like key tokens)
ownedObjects.Trash.putObject(obj)
end
end
@ -390,25 +388,24 @@ function doUpkeep(_, clickedByColor, isRightClick)
local cardsToDiscard = {}
for i = 1, #handCards do
local metadata = JSON.decode(handCards[i].getGMNotes())
if metadata ~= nil and (not metadata.weakness and not metadata.hidden) then
local md = JSON.decode(handCards[i].getGMNotes())
if md ~= nil and (not md.weakness and not md.hidden and md.type ~= "Enemy") then
table.insert(cardsToDiscard, handCards[i])
end
end
local j = 0
local k = 0
for i = #cardsToDiscard, 1, -1 do
j = j + 1
Wait.time(function() deckLib.placeOrMergeIntoDeck(cardsToDiscard[i], returnGlobalDiscardPosition(), self.getRotation()) end, j * 0.1)
-- perform discarding 1 by 1
local pos = returnGlobalDiscardPosition()
local count = #cardsToDiscard
for i = count, 1, -1 do
Wait.time(function() deckLib.placeOrMergeIntoDeck(cardsToDiscard[i], pos, rot) end,
(count - i + 1) * 0.1)
end
-- add some time if there are any cards to discard, if not, draw up to 5 immediately
if j > 0 then
k = 0.7 + (j * 0.1)
else
k = 0
local k = 0
if count > 0 then
k = 0.5 + (count * 0.1)
end
Wait.time(function()
@ -577,7 +574,8 @@ function doDiscardOne()
-- get a random non-hidden card (from the "choices" table)
local num = math.random(1, #choices)
deckLib.placeOrMergeIntoDeck(hand[choices[num]], returnGlobalDiscardPosition(), self.getRotation())
broadcastToAll(getColoredName(playerColor) .. " randomly discarded card " .. choices[num] .. "/" .. #hand .. ".", "White")
broadcastToAll(getColoredName(playerColor) .. " randomly discarded card "
.. choices[num] .. "/" .. #hand .. ".", "White")
end
end

View File

@ -39,7 +39,7 @@ do
function()
obj.use_hands = true
-- this avoids a TTS bug that merges unrelated cards that are not resting
if #searchResult == 1 and searchResult[1] ~= obj then
if #searchResult == 1 and searchResult[1] ~= obj and searchResult[1] ~= nil then
-- call this with avoiding errors (physics is sometimes too fast so the object doesn't exist for the put)
pcall(function() searchResult[1].putObject(obj) end)
end