[Server] Support face-down cards in all public zones (#6539)

* [Server] Support face-down cards in all public zones

* add null check

* Check using zone names instead

* add comment
This commit is contained in:
RickyRister
2026-03-03 14:17:35 -08:00
committed by GitHub
parent 9794893b63
commit 2828854d32
2 changed files with 34 additions and 4 deletions

View File

@@ -198,6 +198,35 @@ shouldDestroyOnMove(const Server_Card *card, const Server_CardZone *startZone, c
return true;
}
/**
* @brief Determines whether the moved card should be face-down
*/
static bool
shouldBeFaceDown(const MoveCardStruct &cardStruct, const Server_CardZone *startZone, const Server_CardZone *targetZone)
{
if (!targetZone) {
return false;
}
// being face-down only makes sense for public zones
if (targetZone->getType() != ServerInfo_Zone::PublicZone) {
return false;
}
// face-down property in proto takes precedence
if (cardStruct.cardToMove->has_face_down()) {
return cardStruct.cardToMove->face_down();
}
// Default to keep face-down the same if zone didn't change.
// Compare using zone names because face-down is maintained when changing controllers.
if (startZone && startZone->getName() == targetZone->getName()) {
return cardStruct.card->getFaceDown();
}
return false;
}
Response::ResponseCode Server_AbstractPlayer::moveCard(GameEventStorage &ges,
Server_CardZone *startzone,
const QList<const CardToMove *> &_cards,
@@ -257,10 +286,7 @@ Response::ResponseCode Server_AbstractPlayer::moveCard(GameEventStorage &ges,
for (auto cardStruct : cardsToMove) {
Server_Card *card = cardStruct.card;
const CardToMove *thisCardProperties = cardStruct.cardToMove;
int originalPosition = cardStruct.position;
bool faceDown = targetzone->hasCoords() &&
(thisCardProperties->has_face_down() ? thisCardProperties->face_down() : card->getFaceDown());
bool sourceBeingLookedAt;
int position = startzone->removeCard(card, sourceBeingLookedAt);
@@ -315,6 +341,8 @@ Response::ResponseCode Server_AbstractPlayer::moveCard(GameEventStorage &ges,
++xIndex;
int newX = isReversed ? targetzone->getCards().size() - xCoord + xIndex : xCoord + xIndex;
bool faceDown = shouldBeFaceDown(cardStruct, startzone, targetzone);
if (targetzone->hasCoords()) {
newX = targetzone->getFreeGridColumn(newX, yCoord, card->getName(), faceDown);
} else {

View File

@@ -6,7 +6,9 @@ message CardToMove {
// Id of the card in its current zone
optional sint32 card_id = 1 [default = -1];
// Places the card face down, hiding its name
// If true, places the card face down, hiding its name.
// If false, forcibly turns the card face up.
// If not set, defers the resulting face down state to the server.
optional bool face_down = 2;
// When moving add this value to the power/toughness field of the card