From bd850fa3ff50d248b49d172c6fd59655c5973852 Mon Sep 17 00:00:00 2001 From: Zach H Date: Sun, 12 Mar 2017 06:51:59 -0400 Subject: [PATCH] create related token if you press the 'Token:' button (#2455) * create related token if you press the 'Token:' button * function set --- cockatrice/src/player.cpp | 36 +++++++++++++++++++++++++++++------- cockatrice/src/player.h | 2 ++ 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/cockatrice/src/player.cpp b/cockatrice/src/player.cpp index c6e6617b..d55aac63 100644 --- a/cockatrice/src/player.cpp +++ b/cockatrice/src/player.cpp @@ -1083,13 +1083,7 @@ void Player::actCreatePredefinedToken() if(!cardInfo) return; - lastTokenName = cardInfo->getName(); - lastTokenColor = cardInfo->getColors().isEmpty() ? QString() : cardInfo->getColors().first().toLower(); - lastTokenPT = cardInfo->getPowTough(); - lastTokenAnnotation = settingsCache->getAnnotateTokens() ? cardInfo->getText() : ""; - lastTokenTableRow = table->clampValidTableRow(2 - cardInfo->getTableRow()); - lastTokenDestroy = true; - aCreateAnotherToken->setEnabled(true); + setLastToken(cardInfo); actCreateAnotherToken(); } @@ -1103,6 +1097,13 @@ void Player::actCreateRelatedCard() QAction *action = static_cast(sender()); const QString &actionDisplayName = action->text(); createCard(sourceCard, dbNameFromTokenDisplayName(actionDisplayName)); + + /* + * If we made a token via "Token: TokenName" + * then lets allow it to be created via create another + */ + CardInfo *cardInfo = db->getCard(dbNameFromTokenDisplayName(actionDisplayName)); + setLastToken(cardInfo); } void Player::actCreateAllRelatedCards() @@ -1119,6 +1120,16 @@ void Player::actCreateAllRelatedCards() { createCard(sourceCard, dbNameFromTokenDisplayName(tokenName)); } + + /* + * If we made a token via "Token: TokenName" + * then lets allow it to be created via create another + */ + if (relatedCards.length() == 1) + { + CardInfo *cardInfo = db->getCard(dbNameFromTokenDisplayName(relatedCards.at(0))); + setLastToken(cardInfo); + } } void Player::createCard(const CardItem *sourceCard, const QString &dbCardName) { @@ -2521,3 +2532,14 @@ void Player::processSceneSizeChange(int newPlayerWidth) table->setWidth(tableWidth); hand->setWidth(tableWidth + stack->boundingRect().width()); } + +void Player::setLastToken(CardInfo *cardInfo) +{ + lastTokenName = cardInfo->getName(); + lastTokenColor = cardInfo->getColors().isEmpty() ? QString() : cardInfo->getColors().first().toLower(); + lastTokenPT = cardInfo->getPowTough(); + lastTokenAnnotation = settingsCache->getAnnotateTokens() ? cardInfo->getText() : ""; + lastTokenTableRow = table->clampValidTableRow(2 - cardInfo->getTableRow()); + lastTokenDestroy = true; + aCreateAnotherToken->setEnabled(true); +} \ No newline at end of file diff --git a/cockatrice/src/player.h b/cockatrice/src/player.h index f5f30723..032f3918 100644 --- a/cockatrice/src/player.h +++ b/cockatrice/src/player.h @@ -5,6 +5,7 @@ #include #include #include "abstractgraphicsitem.h" +#include "carddatabase.h" #include "pb/game_event.pb.h" #include "pb/card_attributes.pb.h" @@ -311,6 +312,7 @@ public: void sendGameCommand(PendingCommand *pend); void sendGameCommand(const google::protobuf::Message &command); + void setLastToken(CardInfo *cardInfo); }; #endif