mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-12 00:54:53 -07:00
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:
parent
01d5e58a5f
commit
5c8d1f3cff
3 changed files with 15 additions and 4 deletions
|
|
@ -1930,7 +1930,15 @@ bool Player::createRelatedFromRelation(const CardItem *sourceCard, const CardRel
|
||||||
createCard(sourceCard, dbName, CardRelation::DoesNotAttach, persistent);
|
createCard(sourceCard, dbName, CardRelation::DoesNotAttach, persistent);
|
||||||
}
|
}
|
||||||
} else {
|
} 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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -1973,7 +1981,7 @@ void Player::createCard(const CardItem *sourceCard,
|
||||||
cmd.set_annotation("");
|
cmd.set_annotation("");
|
||||||
}
|
}
|
||||||
cmd.set_destroy_on_zone_change(!persistent);
|
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_x(gridPoint.x());
|
||||||
cmd.set_y(gridPoint.y());
|
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.
|
* 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).
|
* 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) {
|
if (card == nullptr) {
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -402,7 +402,7 @@ public:
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||||
|
|
||||||
void playCard(CardItem *c, bool faceDown);
|
void playCard(CardItem *c, bool faceDown);
|
||||||
void playCardToTable(CardItem *c, bool faceDown);
|
void playCardToTable(const CardItem *c, bool faceDown);
|
||||||
void addCard(CardItem *c);
|
void addCard(CardItem *c);
|
||||||
void deleteCard(CardItem *c);
|
void deleteCard(CardItem *c);
|
||||||
void addZone(CardZone *z);
|
void addZone(CardZone *z);
|
||||||
|
|
|
||||||
|
|
@ -1358,6 +1358,9 @@ Server_Player::cmdAttachCard(const Command_AttachCard &cmd, ResponseContainer &
|
||||||
return Response::RespNameNotFound;
|
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()) {
|
if (!startzone->hasCoords()) {
|
||||||
return Response::RespContextError;
|
return Response::RespContextError;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue