From 42ce9f4d8954578dba4eb41ceaec2cbd8d67d910 Mon Sep 17 00:00:00 2001 From: RickyRister <42636155+RickyRister@users.noreply.github.com> Date: Sat, 26 Apr 2025 16:59:59 -0700 Subject: [PATCH] Allow tokens on the stack (#5886) --- common/server_player.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/common/server_player.cpp b/common/server_player.cpp index 60ebfa3c0..eb8a9977b 100644 --- a/common/server_player.cpp +++ b/common/server_player.cpp @@ -417,6 +417,29 @@ static Event_AttachCard makeAttachCardEvent(Server_Card *attachedCard, Server_Ca return event; } +/** + * Determines whether moving the card from startZone to targetZone should cause the card to be destroyed. + */ +static bool +shouldDestroyOnMove(const Server_Card *card, const Server_CardZone *startZone, const Server_CardZone *targetZone) +{ + if (!card->getDestroyOnZoneChange()) { + return false; + } + + if (startZone->getName() == targetZone->getName()) { + return false; + } + + // Allow tokens on the stack + if ((startZone->getName() == "table" || startZone->getName() == "stack") && + (targetZone->getName() == "table" || targetZone->getName() == "stack")) { + return false; + } + + return true; +} + Response::ResponseCode Server_Player::moveCard(GameEventStorage &ges, Server_CardZone *startzone, const QList &_cards, @@ -523,7 +546,7 @@ Response::ResponseCode Server_Player::moveCard(GameEventStorage &ges, } } - if (card->getDestroyOnZoneChange() && (startzone->getName() != targetzone->getName())) { + if (shouldDestroyOnMove(card, startzone, targetzone)) { Event_DestroyCard event; event.set_zone_name(startzone->getName().toStdString()); event.set_card_id(static_cast(card->getId()));