mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-08 19:13:25 -08:00
[Refactor] Retype PlayerActions onto CardState (#7435)
* [Refactor] Retype card containers and zone logic onto CardState * [Refactor] Retype PlayerActions onto CardState --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
65e9f1b370
commit
7ca23430cd
18 changed files with 138 additions and 136 deletions
|
|
@ -86,7 +86,7 @@ CardMenu::CardMenu(PlayerGraphicsItem *_player, CardItem *_card, bool _shortcuts
|
|||
auto *gameScene = player->getGameScene();
|
||||
|
||||
// Single selection resolver used by all lambdas — called at trigger time
|
||||
auto sel = [gameScene]() { return gameScene->selectedCards(); };
|
||||
auto sel = [gameScene]() { return gameScene->selectedCardStates(); };
|
||||
|
||||
// Unified dispatcher for card menu actions
|
||||
auto invoke = [actions, sel](CardMenuActionType type) {
|
||||
|
|
@ -337,7 +337,7 @@ void CardMenu::createHandOrCustomZoneMenu(bool canModifyCard)
|
|||
initContextualPlayersMenu(revealMenu, aRevealToAll);
|
||||
|
||||
connect(revealMenu, &QMenu::triggered, this, [this](QAction *action) {
|
||||
player->getLogic()->getPlayerActions()->actReveal(player->getGameScene()->selectedCards(), action);
|
||||
player->getLogic()->getPlayerActions()->actReveal(player->getGameScene()->selectedCardStates(), action);
|
||||
});
|
||||
|
||||
addSeparator();
|
||||
|
|
@ -486,8 +486,9 @@ void CardMenu::addRelatedCardActions()
|
|||
|
||||
auto *createRelated = new QAction(text, this);
|
||||
const int relatedIndex = index++;
|
||||
connect(createRelated, &QAction::triggered, this,
|
||||
[this, playerActions, relatedIndex] { playerActions->actCreateRelatedCard(card, relatedIndex); });
|
||||
connect(createRelated, &QAction::triggered, this, [this, playerActions, relatedIndex] {
|
||||
playerActions->actCreateRelatedCard(card->getState(), relatedIndex);
|
||||
});
|
||||
addAction(createRelated);
|
||||
}
|
||||
|
||||
|
|
@ -497,7 +498,7 @@ void CardMenu::addRelatedCardActions()
|
|||
SettingsCache::instance().shortcuts().getShortcut("Player/aCreateRelatedTokens"));
|
||||
}
|
||||
connect(createRelatedCards, &QAction::triggered, this,
|
||||
[this, playerActions] { playerActions->actCreateAllRelatedCards(card); });
|
||||
[this, playerActions] { playerActions->actCreateAllRelatedCards(card->getState()); });
|
||||
addAction(createRelatedCards);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ MoveMenu::MoveMenu(PlayerGraphicsItem *player) : QMenu(tr("Move to"))
|
|||
|
||||
auto invoke = [player](CardMenuActionType type) {
|
||||
return [type, player]() {
|
||||
player->getLogic()->getPlayerActions()->cardMenuAction(player->getGameScene()->selectedCards(), type);
|
||||
player->getLogic()->getPlayerActions()->cardMenuAction(player->getGameScene()->selectedCardStates(), type);
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -15,34 +15,35 @@ PtMenu::PtMenu(PlayerGraphicsItem *player) : QMenu(tr("Power / toughness"))
|
|||
|
||||
aIncP = new QAction(this);
|
||||
connect(aIncP, &QAction::triggered, playerActions,
|
||||
[player, playerActions] { playerActions->actIncP(player->getGameScene()->selectedCards()); });
|
||||
[player, playerActions] { playerActions->actIncP(player->getGameScene()->selectedCardStates()); });
|
||||
aDecP = new QAction(this);
|
||||
connect(aDecP, &QAction::triggered, playerActions,
|
||||
[player, playerActions] { playerActions->actDecP(player->getGameScene()->selectedCards()); });
|
||||
[player, playerActions] { playerActions->actDecP(player->getGameScene()->selectedCardStates()); });
|
||||
aIncT = new QAction(this);
|
||||
connect(aIncT, &QAction::triggered, playerActions,
|
||||
[player, playerActions] { playerActions->actIncT(player->getGameScene()->selectedCards()); });
|
||||
[player, playerActions] { playerActions->actIncT(player->getGameScene()->selectedCardStates()); });
|
||||
aDecT = new QAction(this);
|
||||
connect(aDecT, &QAction::triggered, playerActions,
|
||||
[player, playerActions] { playerActions->actDecT(player->getGameScene()->selectedCards()); });
|
||||
[player, playerActions] { playerActions->actDecT(player->getGameScene()->selectedCardStates()); });
|
||||
aIncPT = new QAction(this);
|
||||
connect(aIncPT, &QAction::triggered, playerActions,
|
||||
[player, playerActions] { playerActions->actIncPT(player->getGameScene()->selectedCards()); });
|
||||
[player, playerActions] { playerActions->actIncPT(player->getGameScene()->selectedCardStates()); });
|
||||
aDecPT = new QAction(this);
|
||||
connect(aDecPT, &QAction::triggered, playerActions,
|
||||
[player, playerActions] { playerActions->actDecPT(player->getGameScene()->selectedCards()); });
|
||||
[player, playerActions] { playerActions->actDecPT(player->getGameScene()->selectedCardStates()); });
|
||||
aFlowP = new QAction(this);
|
||||
connect(aFlowP, &QAction::triggered, playerActions,
|
||||
[player, playerActions] { playerActions->actFlowP(player->getGameScene()->selectedCards()); });
|
||||
[player, playerActions] { playerActions->actFlowP(player->getGameScene()->selectedCardStates()); });
|
||||
aFlowT = new QAction(this);
|
||||
connect(aFlowT, &QAction::triggered, playerActions,
|
||||
[player, playerActions] { playerActions->actFlowT(player->getGameScene()->selectedCards()); });
|
||||
[player, playerActions] { playerActions->actFlowT(player->getGameScene()->selectedCardStates()); });
|
||||
aSetPT = new QAction(this);
|
||||
connect(aSetPT, &QAction::triggered, playerActions,
|
||||
[player, playerActions] { playerActions->actRequestSetPTDialog(player->getGameScene()->selectedCards()); });
|
||||
connect(aSetPT, &QAction::triggered, playerActions, [player, playerActions] {
|
||||
playerActions->actRequestSetPTDialog(player->getGameScene()->selectedCardStates());
|
||||
});
|
||||
aResetPT = new QAction(this);
|
||||
connect(aResetPT, &QAction::triggered, playerActions,
|
||||
[player, playerActions] { playerActions->actResetPT(player->getGameScene()->selectedCards()); });
|
||||
[player, playerActions] { playerActions->actResetPT(player->getGameScene()->selectedCardStates()); });
|
||||
|
||||
addAction(aIncP);
|
||||
addAction(aDecP);
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ UtilityMenu::UtilityMenu(PlayerGraphicsItem *_player, QMenu *playerMenu) : QMenu
|
|||
aIncrementAllCardCounters = new QAction(this);
|
||||
connect(aIncrementAllCardCounters, &QAction::triggered, playerActions, [this]() {
|
||||
player->getLogic()->getPlayerActions()->actIncrementAllCardCounters(
|
||||
player->getGameScene()->selectedCards());
|
||||
player->getGameScene()->selectedCardStates());
|
||||
});
|
||||
|
||||
createPredefinedTokenMenu = new QMenu(QString());
|
||||
|
|
|
|||
|
|
@ -197,7 +197,7 @@ void PlayerDialogs::onRollDieDialogRequested()
|
|||
playerActions->actRollDie(dlg.getDieSideCount(), dlg.getDiceToRollCount());
|
||||
}
|
||||
|
||||
void PlayerDialogs::onCreateRelatedFromRelationDialogRequested(const CardItem *sourceCard,
|
||||
void PlayerDialogs::onCreateRelatedFromRelationDialogRequested(const CardState *sourceCard,
|
||||
const CardRelation *cardRelation)
|
||||
{
|
||||
if (sourceCard == nullptr || cardRelation == nullptr) {
|
||||
|
|
@ -252,14 +252,14 @@ void PlayerDialogs::onMoveCardXCardsFromTopDialogRequested(int defaultNumberTopC
|
|||
number -= 1; // indexes start at 0
|
||||
|
||||
if (ok) {
|
||||
playerActions->actMoveCardXCardsFromTop(player->getGameScene()->selectedCards(), number);
|
||||
playerActions->actMoveCardXCardsFromTop(player->getGameScene()->selectedCardStates(), number);
|
||||
}
|
||||
}
|
||||
|
||||
void PlayerDialogs::onSetPTDialogRequested(const QString &oldPT)
|
||||
{
|
||||
bool ok;
|
||||
auto cards = player->getGameScene()->selectedCards();
|
||||
auto cards = player->getGameScene()->selectedCardStates();
|
||||
emit requestDialogSemaphore(true);
|
||||
QString pt = getTextWithMax(dialogParent(), tr("Change power/toughness"), tr("Change stats to:"), QLineEdit::Normal,
|
||||
oldPT, &ok);
|
||||
|
|
@ -274,7 +274,7 @@ void PlayerDialogs::onSetPTDialogRequested(const QString &oldPT)
|
|||
|
||||
void PlayerDialogs::onSetAnnotationDialogRequested(const QString &oldAnnotation)
|
||||
{
|
||||
auto cards = player->getGameScene()->selectedCards();
|
||||
auto cards = player->getGameScene()->selectedCardStates();
|
||||
emit requestDialogSemaphore(true);
|
||||
AnnotationDialog *dialog = new AnnotationDialog(dialogParent());
|
||||
dialog->setOptions(QInputDialog::UsePlainTextEditForTextInput);
|
||||
|
|
@ -292,7 +292,7 @@ void PlayerDialogs::onSetAnnotationDialogRequested(const QString &oldAnnotation)
|
|||
|
||||
void PlayerDialogs::onSetCardCounterDialogRequested(int counterId, const QString &oldValueForDlg)
|
||||
{
|
||||
auto cards = player->getGameScene()->selectedCards();
|
||||
auto cards = player->getGameScene()->selectedCardStates();
|
||||
emit requestDialogSemaphore(true);
|
||||
|
||||
auto &cardCounterSettings = SettingsCache::instance().cardCounters();
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ public slots:
|
|||
bool faceDown);
|
||||
void onDrawBottomCardsDialogRequested(int defaultNumberBottomCards, int maxCards);
|
||||
void onRollDieDialogRequested();
|
||||
void onCreateRelatedFromRelationDialogRequested(const CardItem *sourceCard, const CardRelation *cardRelation);
|
||||
void onCreateRelatedFromRelationDialogRequested(const CardState *sourceCard, const CardRelation *cardRelation);
|
||||
void onCreateTokenDialogRequested(const QStringList &predefinedTokens);
|
||||
void onMoveCardXCardsFromTopDialogRequested(int defaultNumberTopCardsToPlaceBelow, int deckSize);
|
||||
void onSetPTDialogRequested(const QString &oldPT);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue