updated shuffling

This commit is contained in:
Chr1Z93 2024-09-23 23:59:24 +02:00
parent f5bdc43667
commit e5a716a700
2 changed files with 37 additions and 3 deletions

View File

@ -550,18 +550,42 @@ function drawCards(numCards)
end
function shuffleDiscardIntoDeck(player, _, elementId)
-- update the message color if this was called via button
if player then
updateMessageColor(player.color)
end
-- get object references
local deckAreaObjects = getDeckAreaObjects()
if not deckAreaObjects.discard then
-- display a feedback message if called via button
if elementId == "shuffleDiscardButton" then
broadcastToColor("Discard pile is empty.", player.color, "Orange")
broadcastToColor("Discard pile is empty.", messageColor, "Orange")
end
return
end
-- Norman Withers handling
local harbinger
if deckAreaObjects.topCard then
harbinger = isHarbinger(deckAreaObjects.topCard.getGMNotes())
elseif deckAreaObjects.draw and not deckAreaObjects.draw.is_face_down then
local cards = deckAreaObjects.draw.getObjects()
harbinger = isHarbinger(cards[#cards].gm_notes)
end
if harbinger then
printToColor("The Harbinger is on top of your deck, not shuffling cards into your deck.", messageColor)
return
end
-- create a list of objects to shuffle
local objectsToShuffle = {}
if deckAreaObjects.topCard then
table.insert(objectsToShuffle, deckAreaObjects.topCard)
-- this will be executed after the deck merging + shuffling
Wait.time(flipTopCardFromDeck, 1)
end
table.insert(objectsToShuffle, deckAreaObjects.discard)

View File

@ -21,6 +21,16 @@ do
-- search the new position for existing card/deck
local searchResult = searchLib.atPosition(pos, "isCardOrDeck")
-- remove objects from search result that are queued
for i = #searchResult, 1, -1 do
for _, obj in ipairs(objects) do
if searchResult[i] == obj then
table.remove(searchResult, i)
end
end
end
local targetObj
-- get new position
@ -65,9 +75,9 @@ do
targetObj = obj
end
-- this is the final object, maybe shuffle
-- this is the final object, maybe shuffle (delay to look less uncanny)
if i == 1 and targetObj.type == "Deck" and shuffle then
targetObj.shuffle()
Wait.frames(function() targetObj.shuffle() end, 3)
end
end,
-- check state of the object (make sure it's not moving)