create related token if you press the 'Token:' button (#2455)

* create related token if you press the 'Token:' button

* function set
This commit is contained in:
Zach H 2017-03-12 06:51:59 -04:00 committed by ctrlaltca
parent b2f2e9db8a
commit bd850fa3ff
2 changed files with 31 additions and 7 deletions

View file

@ -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<QAction *>(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);
}

View file

@ -5,6 +5,7 @@
#include <QPoint>
#include <QMap>
#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