From 628bdde939ca608c8b09680ca81989fdaa4ceaa5 Mon Sep 17 00:00:00 2001 From: RickyRister <42636155+RickyRister@users.noreply.github.com> Date: Thu, 12 Dec 2024 20:42:53 -0800 Subject: [PATCH] hide action now applies to all selected cards (#5233) * hide action now applies to all selected cards * check card zone before applying action so that we don't nuke cards from existence when we select across multiple zones * small fixes * remove redundant loop * nullcheck view --- cockatrice/src/game/player/player.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/cockatrice/src/game/player/player.cpp b/cockatrice/src/game/player/player.cpp index 313e4c1d6..f2abe195c 100644 --- a/cockatrice/src/game/player/player.cpp +++ b/cockatrice/src/game/player/player.cpp @@ -3442,6 +3442,19 @@ void Player::actCardCounterTrigger() sendGameCommand(prepareGameCommand(commandList)); } +/** + * @brief returns true if the zone is a unwritable reveal zone view (eg a card reveal window). Will return false if zone + * is nullptr. + */ +static bool isUnwritableRevealZone(CardZone *zone) +{ + if (zone && zone->getIsView()) { + auto *view = static_cast(zone); + return view && view->getRevealZone() && !view->getWriteableRevealZone(); + } + return false; +} + void Player::actPlay() { auto *card = game->getActiveCard(); @@ -3453,9 +3466,11 @@ void Player::actPlay() void Player::actHide() { - auto *card = game->getActiveCard(); - if (card) { - card->getZone()->removeCard(card); + for (const auto &item : scene()->selectedItems()) { + auto *card = static_cast(item); + if (card && isUnwritableRevealZone(card->getZone())) { + card->getZone()->removeCard(card); + } } }