mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-08 02:53:25 -08:00
[Refactor] Pass the target card into PlayerActions instead of reading activeCard
This commit is contained in:
parent
86e08db9ff
commit
2c80763d99
3 changed files with 21 additions and 30 deletions
|
|
@ -757,9 +757,8 @@ static void selectCardsInZone(
|
|||
}
|
||||
}
|
||||
|
||||
void PlayerActions::actSelectAll()
|
||||
void PlayerActions::actSelectAll(const CardItem *card)
|
||||
{
|
||||
const CardItem *card = player->getGame()->getActiveCard();
|
||||
if (!card) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -767,9 +766,8 @@ void PlayerActions::actSelectAll()
|
|||
selectCardsInZone(card->getZone());
|
||||
}
|
||||
|
||||
void PlayerActions::actSelectRow()
|
||||
void PlayerActions::actSelectRow(const CardItem *card)
|
||||
{
|
||||
const CardItem *card = player->getGame()->getActiveCard();
|
||||
if (!card) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -780,9 +778,8 @@ void PlayerActions::actSelectRow()
|
|||
selectCardsInZone(card->getZone(), isSameRow);
|
||||
}
|
||||
|
||||
void PlayerActions::actSelectColumn()
|
||||
void PlayerActions::actSelectColumn(const CardItem *card)
|
||||
{
|
||||
const CardItem *card = player->getGame()->getActiveCard();
|
||||
if (!card) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -996,25 +993,20 @@ void PlayerActions::actCreatePredefinedToken()
|
|||
actCreateAnotherToken();
|
||||
}
|
||||
|
||||
void PlayerActions::actCreateRelatedCard()
|
||||
void PlayerActions::actCreateRelatedCard(const CardItem *sourceCard, int index)
|
||||
{
|
||||
const CardItem *sourceCard = player->getGame()->getActiveCard();
|
||||
|
||||
if (!sourceCard) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto *action = static_cast<QAction *>(sender());
|
||||
// If there is a better way of passing a CardRelation through a QAction, please add it here.
|
||||
auto relatedCards = sourceCard->getCardInfo().getAllRelatedCards();
|
||||
|
||||
CardRelation *cardRelation = relatedCards.at(action->data().toInt());
|
||||
CardRelation *cardRelation = relatedCards.at(index);
|
||||
actRequestCreateRelatedFromRelationDialog(sourceCard, cardRelation);
|
||||
}
|
||||
|
||||
void PlayerActions::actCreateAllRelatedCards()
|
||||
void PlayerActions::actCreateAllRelatedCards(const CardItem *sourceCard)
|
||||
{
|
||||
const CardItem *sourceCard = player->getGame()->getActiveCard();
|
||||
if (!sourceCard) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -164,9 +164,9 @@ public slots:
|
|||
void actRequestMoveBottomCardsToDialog(const QString &targetZone, const QString &zoneDisplayName, bool faceDown);
|
||||
void moveBottomCardsTo(int number, const QString &targetZone, bool faceDown);
|
||||
|
||||
void actSelectAll();
|
||||
void actSelectRow();
|
||||
void actSelectColumn();
|
||||
void actSelectAll(const CardItem *card);
|
||||
void actSelectRow(const CardItem *card);
|
||||
void actSelectColumn(const CardItem *card);
|
||||
|
||||
void actViewLibrary();
|
||||
void actViewHand();
|
||||
|
|
@ -187,8 +187,8 @@ public slots:
|
|||
|
||||
void actOpenDeckInDeckEditor();
|
||||
void actCreatePredefinedToken();
|
||||
void actCreateRelatedCard();
|
||||
void actCreateAllRelatedCards();
|
||||
void actCreateRelatedCard(const CardItem *sourceCard, int index);
|
||||
void actCreateAllRelatedCards(const CardItem *sourceCard);
|
||||
|
||||
void actRequestMoveCardXCardsFromTopDialog();
|
||||
void actMoveCardXCardsFromTop(QList<CardItem *> selectedCards, int number);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue