mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-08 11:03:25 -08:00
[Refactor] Pass the target card into PlayerActions instead of reading activeCard (#7415)
Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
93c5d85996
commit
94b91be5a2
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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue