From e37745ed9c3f2025644220d7fcb804448e92a7cc Mon Sep 17 00:00:00 2001 From: ebbit1q Date: Wed, 19 Nov 2025 14:24:50 +0100 Subject: [PATCH] reading the code explains the code --- cockatrice/src/game/board/arrow_item.cpp | 17 +++++++++++------ cockatrice/src/game/board/card_item.cpp | 2 +- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/cockatrice/src/game/board/arrow_item.cpp b/cockatrice/src/game/board/arrow_item.cpp index aba5b60e9..d5d0ebfe0 100644 --- a/cockatrice/src/game/board/arrow_item.cpp +++ b/cockatrice/src/game/board/arrow_item.cpp @@ -231,23 +231,28 @@ void ArrowDragItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) cmd.set_target_player_id(targetZone->getPlayer()->getPlayerInfo()->getId()); cmd.set_target_zone(targetZone->getName().toStdString()); cmd.set_target_card_id(targetCard->getId()); - } else { + } else { // failed to cast target to card, this means it's a player PlayerTarget *targetPlayer = qgraphicsitem_cast(targetItem); cmd.set_target_player_id(targetPlayer->getOwner()->getPlayerInfo()->getId()); } - if (startZone->getName().compare("hand") == 0) { + + // if the card is in hand then we will move the card to stack or table as part of drawing the arrow + if (startZone->getName() == "hand") { startCard->playCard(false); CardInfoPtr ci = startCard->getCard().getCardPtr(); - if (ci && ((!SettingsCache::instance().getPlayToStack() && ci->getUiAttributes().tableRow == 3) || - (SettingsCache::instance().getPlayToStack() && ci->getUiAttributes().tableRow != 0 && - startCard->getZone()->getName().toStdString() != "stack"))) + bool playToStack = SettingsCache::instance().getPlayToStack(); + if (ci && + ((!playToStack && ci->getUiAttributes().tableRow == 3) || + (playToStack && ci->getUiAttributes().tableRow != 0 && startCard->getZone()->getName() != "stack"))) cmd.set_start_zone("stack"); else - cmd.set_start_zone(SettingsCache::instance().getPlayToStack() ? "stack" : "table"); + cmd.set_start_zone(playToStack ? "stack" : "table"); } + if (deleteInPhase != 0) { cmd.set_delete_in_phase(deleteInPhase); } + player->getPlayerActions()->sendGameCommand(cmd); } delArrow(); diff --git a/cockatrice/src/game/board/card_item.cpp b/cockatrice/src/game/board/card_item.cpp index 0a4fe5396..90107abe9 100644 --- a/cockatrice/src/game/board/card_item.cpp +++ b/cockatrice/src/game/board/card_item.cpp @@ -277,7 +277,7 @@ void CardItem::drawArrow(const QColor &arrowColor) auto *game = owner->getGame(); Player *arrowOwner = game->getPlayerManager()->getActiveLocalPlayer(game->getGameState()->getActivePlayer()); - int phase = 0; // do not set phase + int phase = 0; // 0 means to not set the phase if (SettingsCache::instance().getDoNotDeleteArrowsInSubPhases()) { int currentPhase = game->getGameState()->getCurrentPhase(); phase = currentPhase + 4;