From fb0fd14e2958ba8312e19c9eb60295dd81117516 Mon Sep 17 00:00:00 2001 From: RickyRister Date: Sun, 8 Dec 2024 03:51:36 -0800 Subject: [PATCH] check card zone before applying action so that we don't nuke cards from existence when we select across multiple zones --- cockatrice/src/game/player/player.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/cockatrice/src/game/player/player.cpp b/cockatrice/src/game/player/player.cpp index ad032b458..58b2bd61b 100644 --- a/cockatrice/src/game/player/player.cpp +++ b/cockatrice/src/game/player/player.cpp @@ -3433,6 +3433,18 @@ void Player::actCardCounterTrigger() sendGameCommand(prepareGameCommand(commandList)); } +/** + * @brief returns true if the zone is a unwritable reveal zone view (eg a card reveal window) + */ +static bool isUnwritableRevealZone(CardZone *zone) +{ + if (zone && zone->getIsView()) { + auto *view = dynamic_cast(zone); + return view->getRevealZone() && !view->getWriteableRevealZone(); + } + return false; +} + void Player::actPlay() { auto *card = game->getActiveCard(); @@ -3451,7 +3463,7 @@ void Player::actHide() } for (auto &card : selectedCards) { - if (card) { + if (card && isUnwritableRevealZone(card->getZone())) { card->getZone()->removeCard(card); } }