diff --git a/cockatrice/src/game/zones/card_zone.cpp b/cockatrice/src/game/zones/card_zone.cpp index 0c189cd2b..0923c6b60 100644 --- a/cockatrice/src/game/zones/card_zone.cpp +++ b/cockatrice/src/game/zones/card_zone.cpp @@ -1,5 +1,6 @@ #include "card_zone.h" +#include "../board/card_drag_item.h" #include "../board/card_item.h" #include "view_zone.h" @@ -28,6 +29,22 @@ void CardZone::retranslateUi() getLogic()->getCards()[i]->retranslateUi(); } +bool CardZone::shouldDropFaceDown(const CardDragItem *item, const CardZoneLogic *startZone) const +{ + // forceFaceDown takes precedence over everything + if (item->isForceFaceDown()) { + return true; + } + + // Maintain face-down state if same zone. + // Compare using zone names so card remains face-down when you hand it over to your opponent + if (startZone->getName() == getLogic()->getName()) { + return item->getItem()->getFaceDown(); + } + + return false; +} + void CardZone::mouseDoubleClickEvent(QGraphicsSceneMouseEvent * /*event*/) { if (doubleClickAction) diff --git a/cockatrice/src/game/zones/card_zone.h b/cockatrice/src/game/zones/card_zone.h index 6fe8157e4..164539a76 100644 --- a/cockatrice/src/game/zones/card_zone.h +++ b/cockatrice/src/game/zones/card_zone.h @@ -67,6 +67,15 @@ public: doubleClickAction = _doubleClickAction; } + /** + * Checks if the dropEvent caused by the given CardDragItem should result in the face_down field of the resulting + * MoveCard command to be true. + * @param item The CardDragItem that is being dropped into this zone + * @param startZone The zone that the item came from + * @return Whether to set face_down to true + */ + bool shouldDropFaceDown(const CardDragItem *item, const CardZoneLogic *startZone) const; + private: CardZoneLogic *logic; }; diff --git a/cockatrice/src/game/zones/table_zone.cpp b/cockatrice/src/game/zones/table_zone.cpp index 86724ddb8..9aa6b2596 100644 --- a/cockatrice/src/game/zones/table_zone.cpp +++ b/cockatrice/src/game/zones/table_zone.cpp @@ -134,8 +134,9 @@ void TableZone::handleDropEventByGrid(const QList &dragItems, for (const auto &item : dragItems) { CardToMove *ctm = cmd.mutable_cards_to_move()->add_card(); ctm->set_card_id(item->getId()); - ctm->set_face_down(item->isForceFaceDown()); - if (startZone->getName() != getLogic()->getName() && !item->isForceFaceDown()) { + bool faceDown = shouldDropFaceDown(item, startZone); + ctm->set_face_down(faceDown); + if (startZone->getName() != getLogic()->getName() && !faceDown) { const auto &card = item->getItem()->getCard(); if (card) { ctm->set_pt(card.getInfo().getPowTough().toStdString());