mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
Allow tokens on the stack (#5886)
This commit is contained in:
parent
1409dcc2e8
commit
42ce9f4d89
1 changed files with 24 additions and 1 deletions
|
|
@ -417,6 +417,29 @@ static Event_AttachCard makeAttachCardEvent(Server_Card *attachedCard, Server_Ca
|
|||
return event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether moving the card from startZone to targetZone should cause the card to be destroyed.
|
||||
*/
|
||||
static bool
|
||||
shouldDestroyOnMove(const Server_Card *card, const Server_CardZone *startZone, const Server_CardZone *targetZone)
|
||||
{
|
||||
if (!card->getDestroyOnZoneChange()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (startZone->getName() == targetZone->getName()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Allow tokens on the stack
|
||||
if ((startZone->getName() == "table" || startZone->getName() == "stack") &&
|
||||
(targetZone->getName() == "table" || targetZone->getName() == "stack")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Response::ResponseCode Server_Player::moveCard(GameEventStorage &ges,
|
||||
Server_CardZone *startzone,
|
||||
const QList<const CardToMove *> &_cards,
|
||||
|
|
@ -523,7 +546,7 @@ Response::ResponseCode Server_Player::moveCard(GameEventStorage &ges,
|
|||
}
|
||||
}
|
||||
|
||||
if (card->getDestroyOnZoneChange() && (startzone->getName() != targetzone->getName())) {
|
||||
if (shouldDestroyOnMove(card, startzone, targetzone)) {
|
||||
Event_DestroyCard event;
|
||||
event.set_zone_name(startzone->getName().toStdString());
|
||||
event.set_card_id(static_cast<google::protobuf::uint32>(card->getId()));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue