Make AttachTo tokens work from non-table zones (#5629)

* move card to play before creating attached token

* leave comment

* hardcode createCard target zone to table

To get attached token from graveyard/exile to work
This commit is contained in:
RickyRister 2025-02-16 14:02:45 -08:00 committed by GitHub
parent 01d5e58a5f
commit 5c8d1f3cff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 15 additions and 4 deletions

View file

@ -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;
}
@ -1973,7 +1981,7 @@ void Player::createCard(const CardItem *sourceCard,
cmd.set_annotation("");
}
cmd.set_destroy_on_zone_change(!persistent);
cmd.set_target_zone(sourceCard->getZone()->getName().toStdString());
cmd.set_target_zone("table"); // we currently only support creating tokens on the table
cmd.set_x(gridPoint.x());
cmd.set_y(gridPoint.y());
@ -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;

View file

@ -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);

View file

@ -1358,6 +1358,9 @@ Server_Player::cmdAttachCard(const Command_AttachCard &cmd, ResponseContainer &
return Response::RespNameNotFound;
}
}
// prevent attaching from non-table zones
// (attaching from non-table zones is handled client-side by moving the card to table zone first)
if (!startzone->hasCoords()) {
return Response::RespContextError;
}