From d2d6615d0f82159e7f4e30583d33b25ceb18dfe5 Mon Sep 17 00:00:00 2001 From: RickyRister Date: Sun, 16 Feb 2025 01:08:27 -0800 Subject: [PATCH] move card to play before creating attached token --- cockatrice/src/game/player/player.cpp | 12 ++++++++++-- cockatrice/src/game/player/player.h | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/cockatrice/src/game/player/player.cpp b/cockatrice/src/game/player/player.cpp index 71a9a0a3f..1d3fa4e7f 100644 --- a/cockatrice/src/game/player/player.cpp +++ b/cockatrice/src/game/player/player.cpp @@ -1930,7 +1930,15 @@ bool Player::createRelatedFromRelation(const CardItem *sourceCard, const CardRel createCard(sourceCard, dbName, CardRelation::DoesNotAttach, persistent); } } else { - createCard(sourceCard, dbName, cardRelation->getAttachType(), persistent); + auto attachType = cardRelation->getAttachType(); + + // move card onto table first if attaching from some other zone + // we only do this for AttachTo because cross-zone TransformInto is already handled server-side + if (attachType == CardRelation::AttachTo && sourceCard->getZone()->getName() != "table") { + playCardToTable(sourceCard, false); + } + + createCard(sourceCard, dbName, attachType, persistent); } return true; } @@ -2754,7 +2762,7 @@ void Player::playCard(CardItem *card, bool faceDown) * Like {@link Player::playCard}, but forces the card to be played to the table zone. * Cards with tablerow 3 (the stack) will be played to tablerow 1 (the noncreatures row). */ -void Player::playCardToTable(CardItem *card, bool faceDown) +void Player::playCardToTable(const CardItem *card, bool faceDown) { if (card == nullptr) { return; diff --git a/cockatrice/src/game/player/player.h b/cockatrice/src/game/player/player.h index 5404cdd96..b4b4a35b9 100644 --- a/cockatrice/src/game/player/player.h +++ b/cockatrice/src/game/player/player.h @@ -402,7 +402,7 @@ public: void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override; void playCard(CardItem *c, bool faceDown); - void playCardToTable(CardItem *c, bool faceDown); + void playCardToTable(const CardItem *c, bool faceDown); void addCard(CardItem *c); void deleteCard(CardItem *c); void addZone(CardZone *z);