Rename getPlayerLogic() to getLogic()

Took 1 minute

Took 6 seconds
This commit is contained in:
Lukas Brübach 2026-05-22 10:33:14 +02:00
parent 2332bc169e
commit 41b5ceeb18
14 changed files with 89 additions and 92 deletions

View file

@ -266,7 +266,7 @@ QList<PlayerLogic *> GameScene::collectActivePlayers(int &firstPlayerIndex) cons
bool firstPlayerFound = false; bool firstPlayerFound = false;
for (auto *pgItem : playerViews.values()) { for (auto *pgItem : playerViews.values()) {
PlayerLogic *p = pgItem->getPlayerLogic(); PlayerLogic *p = pgItem->getLogic();
if (p && !p->getConceded()) { if (p && !p->getConceded()) {
activePlayers.append(p); activePlayers.append(p);
if (!firstPlayerFound && p->getPlayerInfo()->getLocal()) { if (!firstPlayerFound && p->getPlayerInfo()->getLocal()) {
@ -437,7 +437,7 @@ void GameScene::onArrowCreateRequested(const ArrowData &data)
return; return;
} }
PlayerLogic *startLogic = startView->getPlayerLogic(); PlayerLogic *startLogic = startView->getLogic();
auto *startZone = startLogic->getZones().value(data.startZone); auto *startZone = startLogic->getZones().value(data.startZone);
if (!startZone) { if (!startZone) {
return; return;
@ -452,7 +452,7 @@ void GameScene::onArrowCreateRequested(const ArrowData &data)
if (data.isPlayerTargeted()) { if (data.isPlayerTargeted()) {
targetItem = targetView->getPlayerTarget(); targetItem = targetView->getPlayerTarget();
} else { } else {
auto *zone = targetView->getPlayerLogic()->getZones().value(data.targetZone); auto *zone = targetView->getLogic()->getZones().value(data.targetZone);
if (zone) { if (zone) {
targetItem = zone->getCard(data.targetCardId); targetItem = zone->getCard(data.targetCardId);
} }
@ -461,7 +461,7 @@ void GameScene::onArrowCreateRequested(const ArrowData &data)
return; return;
} }
auto *arrow = new ArrowItem(startView->getPlayerLogic(), data.id, startCard, targetItem, data.color); auto *arrow = new ArrowItem(startView->getLogic(), data.id, startCard, targetItem, data.color);
addItem(arrow); addItem(arrow);
arrowRegistry.insert(data.id, arrow); arrowRegistry.insert(data.id, arrow);
connect(arrow, &ArrowItem::requestDeletion, this, &GameScene::onArrowDeleteRequested); connect(arrow, &ArrowItem::requestDeletion, this, &GameScene::onArrowDeleteRequested);

View file

@ -30,17 +30,16 @@ static QAction *makeAction(QObject *parent, Slot &&slot, bool checkable = false,
CardMenu::CardMenu(PlayerGraphicsItem *_player, const CardItem *_card, bool _shortcutsActive) CardMenu::CardMenu(PlayerGraphicsItem *_player, const CardItem *_card, bool _shortcutsActive)
: player(_player), card(_card), shortcutsActive(_shortcutsActive) : player(_player), card(_card), shortcutsActive(_shortcutsActive)
{ {
const QList<PlayerLogic *> &players = const QList<PlayerLogic *> &players = player->getLogic()->getGame()->getPlayerManager()->getPlayers().values();
player->getPlayerLogic()->getGame()->getPlayerManager()->getPlayers().values();
for (auto playerToAdd : players) { for (auto playerToAdd : players) {
if (playerToAdd == player->getPlayerLogic()) { if (playerToAdd == player->getLogic()) {
continue; continue;
} }
playersInfo.append(qMakePair(playerToAdd->getPlayerInfo()->getName(), playerToAdd->getPlayerInfo()->getId())); playersInfo.append(qMakePair(playerToAdd->getPlayerInfo()->getName(), playerToAdd->getPlayerInfo()->getId()));
} }
auto *actions = player->getPlayerLogic()->getPlayerActions(); auto *actions = player->getLogic()->getPlayerActions();
auto *gameScene = player->getGameScene(); auto *gameScene = player->getGameScene();
// Single selection resolver used by all lambdas — called at trigger time // Single selection resolver used by all lambdas — called at trigger time
@ -100,7 +99,7 @@ CardMenu::CardMenu(PlayerGraphicsItem *_player, const CardItem *_card, bool _sho
} }
bool revealedCard = false; bool revealedCard = false;
bool writeableCard = player->getPlayerLogic()->getPlayerInfo()->getLocalOrJudge(); bool writeableCard = player->getLogic()->getPlayerInfo()->getLocalOrJudge();
if (auto *view = qobject_cast<ZoneViewZoneLogic *>(card->getZone())) { if (auto *view = qobject_cast<ZoneViewZoneLogic *>(card->getZone())) {
if (view->getRevealZone()) { if (view->getRevealZone()) {
if (view->getWriteableRevealZone()) { if (view->getWriteableRevealZone()) {
@ -285,7 +284,7 @@ void CardMenu::createHandOrCustomZoneMenu(bool canModifyCard)
initContextualPlayersMenu(revealMenu, aRevealToAll); initContextualPlayersMenu(revealMenu, aRevealToAll);
connect(revealMenu, &QMenu::triggered, this, [this](QAction *action) { connect(revealMenu, &QMenu::triggered, this, [this](QAction *action) {
player->getPlayerLogic()->getPlayerActions()->actReveal(player->getGameScene()->selectedCards(), action); player->getLogic()->getPlayerActions()->actReveal(player->getGameScene()->selectedCards(), action);
}); });
addSeparator(); addSeparator();
@ -433,7 +432,7 @@ void CardMenu::addRelatedCardActions()
auto *createRelated = new QAction(text, this); auto *createRelated = new QAction(text, this);
createRelated->setData(QVariant(index++)); createRelated->setData(QVariant(index++));
connect(createRelated, &QAction::triggered, player->getPlayerLogic()->getPlayerActions(), connect(createRelated, &QAction::triggered, player->getLogic()->getPlayerActions(),
&PlayerActions::actCreateRelatedCard); &PlayerActions::actCreateRelatedCard);
addAction(createRelated); addAction(createRelated);
} }
@ -443,7 +442,7 @@ void CardMenu::addRelatedCardActions()
createRelatedCards->setShortcuts( createRelatedCards->setShortcuts(
SettingsCache::instance().shortcuts().getShortcut("Player/aCreateRelatedTokens")); SettingsCache::instance().shortcuts().getShortcut("Player/aCreateRelatedTokens"));
} }
connect(createRelatedCards, &QAction::triggered, player->getPlayerLogic()->getPlayerActions(), connect(createRelatedCards, &QAction::triggered, player->getLogic()->getPlayerActions(),
&PlayerActions::actCreateAllRelatedCards); &PlayerActions::actCreateAllRelatedCards);
addAction(createRelatedCards); addAction(createRelatedCards);
} }

View file

@ -6,8 +6,8 @@ CustomZoneMenu::CustomZoneMenu(PlayerGraphicsItem *_player) : player(_player)
{ {
menuAction()->setVisible(false); menuAction()->setVisible(false);
connect(player->getPlayerLogic(), &PlayerLogic::clearCustomZonesMenu, this, &CustomZoneMenu::clearCustomZonesMenu); connect(player->getLogic(), &PlayerLogic::clearCustomZonesMenu, this, &CustomZoneMenu::clearCustomZonesMenu);
connect(player->getPlayerLogic(), &PlayerLogic::addViewCustomZoneActionToCustomZoneMenu, this, connect(player->getLogic(), &PlayerLogic::addViewCustomZoneActionToCustomZoneMenu, this,
&CustomZoneMenu::addViewCustomZoneActionToCustomZoneMenu); &CustomZoneMenu::addViewCustomZoneActionToCustomZoneMenu);
retranslateUi(); retranslateUi();
@ -17,7 +17,7 @@ void CustomZoneMenu::retranslateUi()
{ {
setTitle(tr("C&ustom Zones")); setTitle(tr("C&ustom Zones"));
if (player->getPlayerLogic()->getPlayerInfo()->getLocalOrJudge()) { if (player->getLogic()->getPlayerInfo()->getLocalOrJudge()) {
for (auto aViewZone : actions()) { for (auto aViewZone : actions()) {
aViewZone->setText(tr("View custom zone '%1'").arg(aViewZone->data().toString())); aViewZone->setText(tr("View custom zone '%1'").arg(aViewZone->data().toString()));
@ -37,5 +37,5 @@ void CustomZoneMenu::addViewCustomZoneActionToCustomZoneMenu(QString zoneName)
QAction *aViewZone = addAction(tr("View custom zone '%1'").arg(zoneName)); QAction *aViewZone = addAction(tr("View custom zone '%1'").arg(zoneName));
aViewZone->setData(zoneName); aViewZone->setData(zoneName);
connect(aViewZone, &QAction::triggered, this, connect(aViewZone, &QAction::triggered, this,
[zoneName, this]() { player->getGameScene()->toggleZoneView(player->getPlayerLogic(), zoneName, -1); }); [zoneName, this]() { player->getGameScene()->toggleZoneView(player->getLogic(), zoneName, -1); });
} }

View file

@ -15,7 +15,7 @@ GraveyardMenu::GraveyardMenu(PlayerGraphicsItem *_player, QWidget *parent) : Tea
addAction(aViewGraveyard); addAction(aViewGraveyard);
if (player->getPlayerLogic()->getPlayerInfo()->local || player->getPlayerLogic()->getPlayerInfo()->judge) { if (player->getLogic()->getPlayerInfo()->local || player->getLogic()->getPlayerInfo()->judge) {
mRevealRandomGraveyardCard = addMenu(QString()); mRevealRandomGraveyardCard = addMenu(QString());
connect(mRevealRandomGraveyardCard, &QMenu::aboutToShow, this, connect(mRevealRandomGraveyardCard, &QMenu::aboutToShow, this,
&GraveyardMenu::populateRevealRandomMenuWithActivePlayers); &GraveyardMenu::populateRevealRandomMenuWithActivePlayers);
@ -36,9 +36,9 @@ GraveyardMenu::GraveyardMenu(PlayerGraphicsItem *_player, QWidget *parent) : Tea
void GraveyardMenu::createMoveActions() void GraveyardMenu::createMoveActions()
{ {
auto grave = player->getPlayerLogic()->getGraveZone(); auto grave = player->getLogic()->getGraveZone();
if (player->getPlayerLogic()->getPlayerInfo()->local || player->getPlayerLogic()->getPlayerInfo()->judge) { if (player->getLogic()->getPlayerInfo()->local || player->getLogic()->getPlayerInfo()->judge) {
aMoveGraveToTopLibrary = new QAction(this); aMoveGraveToTopLibrary = new QAction(this);
aMoveGraveToTopLibrary->setData(QList<QVariant>() << ZoneNames::DECK << 0); aMoveGraveToTopLibrary->setData(QList<QVariant>() << ZoneNames::DECK << 0);
@ -60,7 +60,7 @@ void GraveyardMenu::createMoveActions()
void GraveyardMenu::createViewActions() void GraveyardMenu::createViewActions()
{ {
PlayerActions *playerActions = player->getPlayerLogic()->getPlayerActions(); PlayerActions *playerActions = player->getLogic()->getPlayerActions();
aViewGraveyard = new QAction(this); aViewGraveyard = new QAction(this);
connect(aViewGraveyard, &QAction::triggered, playerActions, &PlayerActions::actViewGraveyard); connect(aViewGraveyard, &QAction::triggered, playerActions, &PlayerActions::actViewGraveyard);
@ -76,9 +76,9 @@ void GraveyardMenu::populateRevealRandomMenuWithActivePlayers()
mRevealRandomGraveyardCard->addSeparator(); mRevealRandomGraveyardCard->addSeparator();
const auto &players = player->getPlayerLogic()->getGame()->getPlayerManager()->getPlayers().values(); const auto &players = player->getLogic()->getGame()->getPlayerManager()->getPlayers().values();
for (auto *other : players) { for (auto *other : players) {
if (other == player->getPlayerLogic()) { if (other == player->getLogic()) {
continue; continue;
} }
QAction *a = mRevealRandomGraveyardCard->addAction(other->getPlayerInfo()->getName()); QAction *a = mRevealRandomGraveyardCard->addAction(other->getPlayerInfo()->getName());
@ -90,7 +90,7 @@ void GraveyardMenu::populateRevealRandomMenuWithActivePlayers()
void GraveyardMenu::onRevealRandomTriggered() void GraveyardMenu::onRevealRandomTriggered()
{ {
if (auto *a = qobject_cast<QAction *>(sender())) { if (auto *a = qobject_cast<QAction *>(sender())) {
player->getPlayerLogic()->getPlayerActions()->actRevealRandomGraveyardCard(a->data().toInt()); player->getLogic()->getPlayerActions()->actRevealRandomGraveyardCard(a->data().toInt());
} }
} }
@ -100,7 +100,7 @@ void GraveyardMenu::retranslateUi()
aViewGraveyard->setText(tr("&View graveyard")); aViewGraveyard->setText(tr("&View graveyard"));
if (player->getPlayerLogic()->getPlayerInfo()->getLocalOrJudge()) { if (player->getLogic()->getPlayerInfo()->getLocalOrJudge()) {
moveGraveMenu->setTitle(tr("&Move graveyard to...")); moveGraveMenu->setTitle(tr("&Move graveyard to..."));
aMoveGraveToTopLibrary->setText(tr("&Top of library")); aMoveGraveToTopLibrary->setText(tr("&Top of library"));
aMoveGraveToBottomLibrary->setText(tr("&Bottom of library")); aMoveGraveToBottomLibrary->setText(tr("&Bottom of library"));

View file

@ -14,9 +14,9 @@
HandMenu::HandMenu(PlayerGraphicsItem *_player, QWidget *parent) : TearOffMenu(parent), player(_player) HandMenu::HandMenu(PlayerGraphicsItem *_player, QWidget *parent) : TearOffMenu(parent), player(_player)
{ {
auto *actions = player->getPlayerLogic()->getPlayerActions(); auto *actions = player->getLogic()->getPlayerActions();
if (player->getPlayerLogic()->getPlayerInfo()->local || player->getPlayerLogic()->getPlayerInfo()->judge) { if (player->getLogic()->getPlayerInfo()->local || player->getLogic()->getPlayerInfo()->judge) {
aViewHand = new QAction(this); aViewHand = new QAction(this);
connect(aViewHand, &QAction::triggered, actions, &PlayerActions::actViewHand); connect(aViewHand, &QAction::triggered, actions, &PlayerActions::actViewHand);
@ -79,7 +79,7 @@ HandMenu::HandMenu(PlayerGraphicsItem *_player, QWidget *parent) : TearOffMenu(p
mMoveHandMenu = addTearOffMenu(QString()); mMoveHandMenu = addTearOffMenu(QString());
if (player->getPlayerLogic()->getPlayerInfo()->local || player->getPlayerLogic()->getPlayerInfo()->judge) { if (player->getLogic()->getPlayerInfo()->local || player->getLogic()->getPlayerInfo()->judge) {
aMoveHandToTopLibrary = new QAction(this); aMoveHandToTopLibrary = new QAction(this);
aMoveHandToTopLibrary->setData(QList<QVariant>() << ZoneNames::DECK << 0); aMoveHandToTopLibrary->setData(QList<QVariant>() << ZoneNames::DECK << 0);
aMoveHandToBottomLibrary = new QAction(this); aMoveHandToBottomLibrary = new QAction(this);
@ -89,7 +89,7 @@ HandMenu::HandMenu(PlayerGraphicsItem *_player, QWidget *parent) : TearOffMenu(p
aMoveHandToRfg = new QAction(this); aMoveHandToRfg = new QAction(this);
aMoveHandToRfg->setData(QList<QVariant>() << ZoneNames::EXILE << 0); aMoveHandToRfg->setData(QList<QVariant>() << ZoneNames::EXILE << 0);
auto hand = player->getPlayerLogic()->getHandZone(); auto hand = player->getLogic()->getHandZone();
connect(aMoveHandToTopLibrary, &QAction::triggered, hand, &HandZoneLogic::moveAllToZone); connect(aMoveHandToTopLibrary, &QAction::triggered, hand, &HandZoneLogic::moveAllToZone);
connect(aMoveHandToBottomLibrary, &QAction::triggered, hand, &HandZoneLogic::moveAllToZone); connect(aMoveHandToBottomLibrary, &QAction::triggered, hand, &HandZoneLogic::moveAllToZone);
@ -111,7 +111,7 @@ void HandMenu::retranslateUi()
{ {
setTitle(tr("&Hand")); setTitle(tr("&Hand"));
if (player->getPlayerLogic()->getPlayerInfo()->getLocalOrJudge()) { if (player->getLogic()->getPlayerInfo()->getLocalOrJudge()) {
aViewHand->setText(tr("&View hand")); aViewHand->setText(tr("&View hand"));
mSortHand->setTitle(tr("Sort hand by...")); mSortHand->setTitle(tr("Sort hand by..."));
@ -170,9 +170,9 @@ void HandMenu::populateRevealHandMenuWithActivePlayers()
mRevealHand->addSeparator(); mRevealHand->addSeparator();
const auto &players = player->getPlayerLogic()->getGame()->getPlayerManager()->getPlayers().values(); const auto &players = player->getLogic()->getGame()->getPlayerManager()->getPlayers().values();
for (auto *other : players) { for (auto *other : players) {
if (other == player->getPlayerLogic()) { if (other == player->getLogic()) {
continue; continue;
} }
QAction *a = mRevealHand->addAction(other->getPlayerInfo()->getName()); QAction *a = mRevealHand->addAction(other->getPlayerInfo()->getName());
@ -189,9 +189,9 @@ void HandMenu::populateRevealRandomHandCardMenuWithActivePlayers()
mRevealRandomHandCard->addSeparator(); mRevealRandomHandCard->addSeparator();
const auto &players = player->getPlayerLogic()->getGame()->getPlayerManager()->getPlayers().values(); const auto &players = player->getLogic()->getGame()->getPlayerManager()->getPlayers().values();
for (auto *other : players) { for (auto *other : players) {
if (other == player->getPlayerLogic()) { if (other == player->getLogic()) {
continue; continue;
} }
QAction *a = mRevealRandomHandCard->addAction(other->getPlayerInfo()->getName()); QAction *a = mRevealRandomHandCard->addAction(other->getPlayerInfo()->getName());
@ -208,7 +208,7 @@ void HandMenu::onRevealHandTriggered()
} }
const int targetId = action->data().toInt(); const int targetId = action->data().toInt();
player->getPlayerLogic()->getPlayerActions()->actRevealHand(targetId); player->getLogic()->getPlayerActions()->actRevealHand(targetId);
} }
void HandMenu::onRevealRandomHandCardTriggered() void HandMenu::onRevealRandomHandCardTriggered()
@ -219,5 +219,5 @@ void HandMenu::onRevealRandomHandCardTriggered()
} }
const int targetId = action->data().toInt(); const int targetId = action->data().toInt();
player->getPlayerLogic()->getPlayerActions()->actRevealRandomHandCard(targetId); player->getLogic()->getPlayerActions()->actRevealRandomHandCard(targetId);
} }

View file

@ -76,9 +76,8 @@ LibraryMenu::LibraryMenu(PlayerGraphicsItem *_player, QWidget *parent) : TearOff
bottomLibraryMenu->addSeparator(); bottomLibraryMenu->addSeparator();
bottomLibraryMenu->addAction(aShuffleBottomCards); bottomLibraryMenu->addAction(aShuffleBottomCards);
connect(player->getPlayerLogic(), &PlayerLogic::resetTopCardMenuActions, this, connect(player->getLogic(), &PlayerLogic::resetTopCardMenuActions, this, &LibraryMenu::resetTopCardMenuActions);
&LibraryMenu::resetTopCardMenuActions); connect(player->getLogic(), &PlayerLogic::deckChanged, this, &LibraryMenu::enableOpenInDeckEditorAction);
connect(player->getPlayerLogic(), &PlayerLogic::deckChanged, this, &LibraryMenu::enableOpenInDeckEditorAction);
retranslateUi(); retranslateUi();
} }
@ -96,9 +95,9 @@ void LibraryMenu::resetTopCardMenuActions()
void LibraryMenu::createDrawActions() void LibraryMenu::createDrawActions()
{ {
PlayerActions *playerActions = player->getPlayerLogic()->getPlayerActions(); PlayerActions *playerActions = player->getLogic()->getPlayerActions();
if (player->getPlayerLogic()->getPlayerInfo()->local || player->getPlayerLogic()->getPlayerInfo()->judge) { if (player->getLogic()->getPlayerInfo()->local || player->getLogic()->getPlayerInfo()->judge) {
aDrawCard = new QAction(this); aDrawCard = new QAction(this);
connect(aDrawCard, &QAction::triggered, playerActions, &PlayerActions::actDrawCard); connect(aDrawCard, &QAction::triggered, playerActions, &PlayerActions::actDrawCard);
aDrawCards = new QAction(this); aDrawCards = new QAction(this);
@ -114,9 +113,9 @@ void LibraryMenu::createDrawActions()
void LibraryMenu::createShuffleActions() void LibraryMenu::createShuffleActions()
{ {
PlayerActions *playerActions = player->getPlayerLogic()->getPlayerActions(); PlayerActions *playerActions = player->getLogic()->getPlayerActions();
if (player->getPlayerLogic()->getPlayerInfo()->local || player->getPlayerLogic()->getPlayerInfo()->judge) { if (player->getLogic()->getPlayerInfo()->local || player->getLogic()->getPlayerInfo()->judge) {
aShuffle = new QAction(this); aShuffle = new QAction(this);
connect(aShuffle, &QAction::triggered, playerActions, &PlayerActions::actShuffle); connect(aShuffle, &QAction::triggered, playerActions, &PlayerActions::actShuffle);
aShuffleTopCards = new QAction(this); aShuffleTopCards = new QAction(this);
@ -128,9 +127,9 @@ void LibraryMenu::createShuffleActions()
void LibraryMenu::createMoveActions() void LibraryMenu::createMoveActions()
{ {
PlayerActions *playerActions = player->getPlayerLogic()->getPlayerActions(); PlayerActions *playerActions = player->getLogic()->getPlayerActions();
if (player->getPlayerLogic()->getPlayerInfo()->local || player->getPlayerLogic()->getPlayerInfo()->judge) { if (player->getLogic()->getPlayerInfo()->local || player->getLogic()->getPlayerInfo()->judge) {
aMoveTopToPlay = new QAction(this); aMoveTopToPlay = new QAction(this);
connect(aMoveTopToPlay, &QAction::triggered, playerActions, &PlayerActions::actMoveTopCardToPlay); connect(aMoveTopToPlay, &QAction::triggered, playerActions, &PlayerActions::actMoveTopCardToPlay);
aMoveTopToPlayFaceDown = new QAction(this); aMoveTopToPlayFaceDown = new QAction(this);
@ -184,9 +183,9 @@ void LibraryMenu::createMoveActions()
void LibraryMenu::createViewActions() void LibraryMenu::createViewActions()
{ {
PlayerActions *playerActions = player->getPlayerLogic()->getPlayerActions(); PlayerActions *playerActions = player->getLogic()->getPlayerActions();
if (player->getPlayerLogic()->getPlayerInfo()->local || player->getPlayerLogic()->getPlayerInfo()->judge) { if (player->getLogic()->getPlayerInfo()->local || player->getLogic()->getPlayerInfo()->judge) {
aViewLibrary = new QAction(this); aViewLibrary = new QAction(this);
connect(aViewLibrary, &QAction::triggered, playerActions, &PlayerActions::actViewLibrary); connect(aViewLibrary, &QAction::triggered, playerActions, &PlayerActions::actViewLibrary);
@ -210,7 +209,7 @@ void LibraryMenu::retranslateUi()
{ {
setTitle(tr("&Library")); setTitle(tr("&Library"));
if (player->getPlayerLogic()->getPlayerInfo()->getLocalOrJudge()) { if (player->getLogic()->getPlayerInfo()->getLocalOrJudge()) {
aViewLibrary->setText(tr("&View library")); aViewLibrary->setText(tr("&View library"));
aViewTopCards->setText(tr("View &top cards of library...")); aViewTopCards->setText(tr("View &top cards of library..."));
aViewBottomCards->setText(tr("View bottom cards of library...")); aViewBottomCards->setText(tr("View bottom cards of library..."));
@ -266,9 +265,9 @@ void LibraryMenu::populateRevealLibraryMenuWithActivePlayers()
mRevealLibrary->addSeparator(); mRevealLibrary->addSeparator();
const auto &players = player->getPlayerLogic()->getGame()->getPlayerManager()->getPlayers().values(); const auto &players = player->getLogic()->getGame()->getPlayerManager()->getPlayers().values();
for (auto *other : players) { for (auto *other : players) {
if (other == player->getPlayerLogic()) { if (other == player->getLogic()) {
continue; continue;
} }
QAction *a = mRevealLibrary->addAction(other->getPlayerInfo()->getName()); QAction *a = mRevealLibrary->addAction(other->getPlayerInfo()->getName());
@ -281,9 +280,9 @@ void LibraryMenu::populateLendLibraryMenuWithActivePlayers()
{ {
mLendLibrary->clear(); mLendLibrary->clear();
const auto &players = player->getPlayerLogic()->getGame()->getPlayerManager()->getPlayers().values(); const auto &players = player->getLogic()->getGame()->getPlayerManager()->getPlayers().values();
for (auto *other : players) { for (auto *other : players) {
if (other == player->getPlayerLogic()) { if (other == player->getLogic()) {
continue; continue;
} }
QAction *a = mLendLibrary->addAction(other->getPlayerInfo()->getName()); QAction *a = mLendLibrary->addAction(other->getPlayerInfo()->getName());
@ -302,9 +301,9 @@ void LibraryMenu::populateRevealTopCardMenuWithActivePlayers()
mRevealTopCard->addSeparator(); mRevealTopCard->addSeparator();
const auto &players = player->getPlayerLogic()->getGame()->getPlayerManager()->getPlayers().values(); const auto &players = player->getLogic()->getGame()->getPlayerManager()->getPlayers().values();
for (auto *other : players) { for (auto *other : players) {
if (other == player->getPlayerLogic()) { if (other == player->getLogic()) {
continue; continue;
} }
QAction *a = mRevealTopCard->addAction(other->getPlayerInfo()->getName()); QAction *a = mRevealTopCard->addAction(other->getPlayerInfo()->getName());
@ -316,14 +315,14 @@ void LibraryMenu::populateRevealTopCardMenuWithActivePlayers()
void LibraryMenu::onRevealLibraryTriggered() void LibraryMenu::onRevealLibraryTriggered()
{ {
if (auto *a = qobject_cast<QAction *>(sender())) { if (auto *a = qobject_cast<QAction *>(sender())) {
player->getPlayerLogic()->getPlayerActions()->actRevealLibrary(a->data().toInt()); player->getLogic()->getPlayerActions()->actRevealLibrary(a->data().toInt());
} }
} }
void LibraryMenu::onLendLibraryTriggered() void LibraryMenu::onLendLibraryTriggered()
{ {
if (auto *a = qobject_cast<QAction *>(sender())) { if (auto *a = qobject_cast<QAction *>(sender())) {
player->getPlayerLogic()->getPlayerActions()->actLendLibrary(a->data().toInt()); player->getLogic()->getPlayerActions()->actLendLibrary(a->data().toInt());
} }
} }
@ -335,14 +334,14 @@ void LibraryMenu::onRevealTopCardTriggered()
} }
if (auto *a = qobject_cast<QAction *>(sender())) { if (auto *a = qobject_cast<QAction *>(sender())) {
int deckSize = player->getPlayerLogic()->getDeckZone()->getCards().size(); int deckSize = player->getLogic()->getDeckZone()->getCards().size();
bool ok = true; bool ok = true;
int number = QInputDialog::getInt(parent, tr("Reveal top cards of library"), int number = QInputDialog::getInt(parent, tr("Reveal top cards of library"),
tr("Number of cards: (max. %1)").arg(deckSize), defaultNumberTopCards, 1, tr("Number of cards: (max. %1)").arg(deckSize), defaultNumberTopCards, 1,
deckSize, 1, &ok); deckSize, 1, &ok);
if (ok) { if (ok) {
player->getPlayerLogic()->getPlayerActions()->actRevealTopCards(a->data().toInt(), number); player->getLogic()->getPlayerActions()->actRevealTopCards(a->data().toInt(), number);
defaultNumberTopCards = number; defaultNumberTopCards = number;
} }
} }

View file

@ -20,11 +20,11 @@ MoveMenu::MoveMenu(PlayerGraphicsItem *player) : QMenu(tr("Move to"))
aMoveToExile = new QAction(this); aMoveToExile = new QAction(this);
aMoveToExile->setData(cmMoveToExile); aMoveToExile->setData(cmMoveToExile);
auto *actions = player->getPlayerLogic()->getPlayerActions(); auto *actions = player->getLogic()->getPlayerActions();
auto invoke = [player](CardMenuActionType type) { auto invoke = [player](CardMenuActionType type) {
return [type, player]() { return [type, player]() {
player->getPlayerLogic()->getPlayerActions()->cardMenuAction(player->getGameScene()->selectedCards(), type); player->getLogic()->getPlayerActions()->cardMenuAction(player->getGameScene()->selectedCards(), type);
}; };
}; };

View file

@ -12,12 +12,12 @@
PlayerMenu::PlayerMenu(PlayerGraphicsItem *_player) : QObject(_player), player(_player) PlayerMenu::PlayerMenu(PlayerGraphicsItem *_player) : QObject(_player), player(_player)
{ {
connect(player->getPlayerLogic(), &PlayerLogic::requestCardMenuUpdate, this, &PlayerMenu::updateCardMenu); connect(player->getLogic(), &PlayerLogic::requestCardMenuUpdate, this, &PlayerMenu::updateCardMenu);
connect(this, &PlayerMenu::cardInfoRequested, player, &PlayerGraphicsItem::cardInfoRequested); connect(this, &PlayerMenu::cardInfoRequested, player, &PlayerGraphicsItem::cardInfoRequested);
playerMenu = new TearOffMenu(); playerMenu = new TearOffMenu();
if (player->getPlayerLogic()->getPlayerInfo()->getLocalOrJudge()) { if (player->getLogic()->getPlayerInfo()->getLocalOrJudge()) {
handMenu = addManagedMenu<HandMenu>(player, playerMenu); handMenu = addManagedMenu<HandMenu>(player, playerMenu);
libraryMenu = addManagedMenu<LibraryMenu>(player, playerMenu); libraryMenu = addManagedMenu<LibraryMenu>(player, playerMenu);
} else { } else {
@ -28,7 +28,7 @@ PlayerMenu::PlayerMenu(PlayerGraphicsItem *_player) : QObject(_player), player(_
graveMenu = addManagedMenu<GraveyardMenu>(player, playerMenu); graveMenu = addManagedMenu<GraveyardMenu>(player, playerMenu);
rfgMenu = addManagedMenu<RfgMenu>(player, playerMenu); rfgMenu = addManagedMenu<RfgMenu>(player, playerMenu);
if (player->getPlayerLogic()->getPlayerInfo()->getLocalOrJudge()) { if (player->getLogic()->getPlayerInfo()->getLocalOrJudge()) {
sideboardMenu = addManagedMenu<SideboardMenu>(player, playerMenu); sideboardMenu = addManagedMenu<SideboardMenu>(player, playerMenu);
customZonesMenu = addManagedMenu<CustomZoneMenu>(player); customZonesMenu = addManagedMenu<CustomZoneMenu>(player);
playerMenu->addSeparator(); playerMenu->addSeparator();
@ -43,7 +43,7 @@ PlayerMenu::PlayerMenu(PlayerGraphicsItem *_player) : QObject(_player), player(_
utilityMenu = nullptr; utilityMenu = nullptr;
} }
if (player->getPlayerLogic()->getPlayerInfo()->getLocal()) { if (player->getLogic()->getPlayerInfo()->getLocal()) {
sayMenu = addManagedMenu<SayMenu>(player); sayMenu = addManagedMenu<SayMenu>(player);
} else { } else {
sayMenu = nullptr; sayMenu = nullptr;
@ -61,7 +61,7 @@ void PlayerMenu::setMenusForGraphicItems()
player->getTableZoneGraphicsItem()->setMenu(playerMenu); player->getTableZoneGraphicsItem()->setMenu(playerMenu);
player->getGraveyardZoneGraphicsItem()->setMenu(graveMenu, graveMenu->aViewGraveyard); player->getGraveyardZoneGraphicsItem()->setMenu(graveMenu, graveMenu->aViewGraveyard);
player->getRfgZoneGraphicsItem()->setMenu(rfgMenu, rfgMenu->aViewRfg); player->getRfgZoneGraphicsItem()->setMenu(rfgMenu, rfgMenu->aViewRfg);
if (player->getPlayerLogic()->getPlayerInfo()->getLocalOrJudge()) { if (player->getLogic()->getPlayerInfo()->getLocalOrJudge()) {
player->getHandZoneGraphicsItem()->setMenu(handMenu); player->getHandZoneGraphicsItem()->setMenu(handMenu);
player->getDeckZoneGraphicsItem()->setMenu(libraryMenu, libraryMenu->aDrawCard); player->getDeckZoneGraphicsItem()->setMenu(libraryMenu, libraryMenu->aDrawCard);
player->getSideboardZoneGraphicsItem()->setMenu(sideboardMenu); player->getSideboardZoneGraphicsItem()->setMenu(sideboardMenu);
@ -77,9 +77,9 @@ QMenu *PlayerMenu::updateCardMenu(const CardItem *card)
// If is spectator (as spectators don't need card menus), return // If is spectator (as spectators don't need card menus), return
// only update the menu if the card is actually selected // only update the menu if the card is actually selected
if ((player->getPlayerLogic()->getGame()->getPlayerManager()->isSpectator() && if ((player->getLogic()->getGame()->getPlayerManager()->isSpectator() &&
!player->getPlayerLogic()->getGame()->getPlayerManager()->isJudge()) || !player->getLogic()->getGame()->getPlayerManager()->isJudge()) ||
player->getPlayerLogic()->getGame()->getActiveCard() != card) { player->getLogic()->getGame()->getActiveCard() != card) {
return nullptr; return nullptr;
} }
@ -92,7 +92,7 @@ QMenu *PlayerMenu::updateCardMenu(const CardItem *card)
void PlayerMenu::retranslateUi() void PlayerMenu::retranslateUi()
{ {
playerMenu->setTitle(tr("Player \"%1\"").arg(player->getPlayerLogic()->getPlayerInfo()->getName())); playerMenu->setTitle(tr("Player \"%1\"").arg(player->getLogic()->getPlayerInfo()->getName()));
for (auto *component : managedComponents) { for (auto *component : managedComponents) {
component->retranslateUi(); component->retranslateUi();
@ -109,8 +109,8 @@ void PlayerMenu::refreshShortcuts()
{ {
if (shortcutsActive) { if (shortcutsActive) {
// Judges get access to every player's menus but only want shortcuts to be set for their own. // Judges get access to every player's menus but only want shortcuts to be set for their own.
if (player->getPlayerLogic()->getPlayerInfo()->getLocalOrJudge() && if (player->getLogic()->getPlayerInfo()->getLocalOrJudge() &&
!player->getPlayerLogic()->getPlayerInfo()->getLocal()) { !player->getLogic()->getPlayerInfo()->getLocal()) {
setShortcutsInactive(); setShortcutsInactive();
} else { } else {
setShortcutsActive(); setShortcutsActive();

View file

@ -5,7 +5,7 @@
PtMenu::PtMenu(PlayerGraphicsItem *player) : QMenu(tr("Power / toughness")) PtMenu::PtMenu(PlayerGraphicsItem *player) : QMenu(tr("Power / toughness"))
{ {
PlayerActions *playerActions = player->getPlayerLogic()->getPlayerActions(); PlayerActions *playerActions = player->getLogic()->getPlayerActions();
aIncP = new QAction(this); aIncP = new QAction(this);
connect(aIncP, &QAction::triggered, playerActions, connect(aIncP, &QAction::triggered, playerActions,

View file

@ -12,7 +12,7 @@ RfgMenu::RfgMenu(PlayerGraphicsItem *_player, QWidget *parent) : TearOffMenu(par
addAction(aViewRfg); addAction(aViewRfg);
if (player->getPlayerLogic()->getPlayerInfo()->getLocalOrJudge()) { if (player->getLogic()->getPlayerInfo()->getLocalOrJudge()) {
addSeparator(); addSeparator();
moveRfgMenu = addTearOffMenu(QString()); moveRfgMenu = addTearOffMenu(QString());
moveRfgMenu->addAction(aMoveRfgToTopLibrary); moveRfgMenu->addAction(aMoveRfgToTopLibrary);
@ -28,8 +28,8 @@ RfgMenu::RfgMenu(PlayerGraphicsItem *_player, QWidget *parent) : TearOffMenu(par
void RfgMenu::createMoveActions() void RfgMenu::createMoveActions()
{ {
if (player->getPlayerLogic()->getPlayerInfo()->getLocalOrJudge()) { if (player->getLogic()->getPlayerInfo()->getLocalOrJudge()) {
auto rfg = player->getPlayerLogic()->getRfgZone(); auto rfg = player->getLogic()->getRfgZone();
aMoveRfgToTopLibrary = new QAction(this); aMoveRfgToTopLibrary = new QAction(this);
aMoveRfgToTopLibrary->setData(QList<QVariant>() << ZoneNames::DECK << 0); aMoveRfgToTopLibrary->setData(QList<QVariant>() << ZoneNames::DECK << 0);
@ -49,7 +49,7 @@ void RfgMenu::createMoveActions()
void RfgMenu::createViewActions() void RfgMenu::createViewActions()
{ {
PlayerActions *playerActions = player->getPlayerLogic()->getPlayerActions(); PlayerActions *playerActions = player->getLogic()->getPlayerActions();
aViewRfg = new QAction(this); aViewRfg = new QAction(this);
connect(aViewRfg, &QAction::triggered, playerActions, &PlayerActions::actViewRfg); connect(aViewRfg, &QAction::triggered, playerActions, &PlayerActions::actViewRfg);
@ -61,7 +61,7 @@ void RfgMenu::retranslateUi()
aViewRfg->setText(tr("&View exile")); aViewRfg->setText(tr("&View exile"));
if (player->getPlayerLogic()->getPlayerInfo()->getLocalOrJudge()) { if (player->getLogic()->getPlayerInfo()->getLocalOrJudge()) {
moveRfgMenu->setTitle(tr("&Move exile to...")); moveRfgMenu->setTitle(tr("&Move exile to..."));
aMoveRfgToTopLibrary->setText(tr("&Top of library")); aMoveRfgToTopLibrary->setText(tr("&Top of library"));
aMoveRfgToBottomLibrary->setText(tr("&Bottom of library")); aMoveRfgToBottomLibrary->setText(tr("&Bottom of library"));

View file

@ -44,8 +44,7 @@ void SayMenu::initSayMenu()
for (int i = 0; i < count; ++i) { for (int i = 0; i < count; ++i) {
auto *newAction = new QAction(SettingsCache::instance().messages().getMessageAt(i), this); auto *newAction = new QAction(SettingsCache::instance().messages().getMessageAt(i), this);
connect(newAction, &QAction::triggered, player->getPlayerLogic()->getPlayerActions(), connect(newAction, &QAction::triggered, player->getLogic()->getPlayerActions(), &PlayerActions::actSayMessage);
&PlayerActions::actSayMessage);
addAction(newAction); addAction(newAction);
} }

View file

@ -6,10 +6,10 @@
SideboardMenu::SideboardMenu(PlayerGraphicsItem *player, QMenu *playerMenu) : QMenu(playerMenu) SideboardMenu::SideboardMenu(PlayerGraphicsItem *player, QMenu *playerMenu) : QMenu(playerMenu)
{ {
aViewSideboard = new QAction(this); aViewSideboard = new QAction(this);
connect(aViewSideboard, &QAction::triggered, player->getPlayerLogic()->getPlayerActions(), connect(aViewSideboard, &QAction::triggered, player->getLogic()->getPlayerActions(),
&PlayerActions::actViewSideboard); &PlayerActions::actViewSideboard);
if (player->getPlayerLogic()->getPlayerInfo()->getLocalOrJudge()) { if (player->getLogic()->getPlayerInfo()->getLocalOrJudge()) {
addAction(aViewSideboard); addAction(aViewSideboard);
} }

View file

@ -10,12 +10,12 @@
UtilityMenu::UtilityMenu(PlayerGraphicsItem *_player, QMenu *playerMenu) : QMenu(playerMenu), player(_player) UtilityMenu::UtilityMenu(PlayerGraphicsItem *_player, QMenu *playerMenu) : QMenu(playerMenu), player(_player)
{ {
PlayerActions *playerActions = player->getPlayerLogic()->getPlayerActions(); PlayerActions *playerActions = player->getLogic()->getPlayerActions();
connect(playerActions, &PlayerActions::requestEnableAndSetCreateAnotherTokenAction, this, connect(playerActions, &PlayerActions::requestEnableAndSetCreateAnotherTokenAction, this,
&UtilityMenu::setAndEnableCreateAnotherTokenAction); &UtilityMenu::setAndEnableCreateAnotherTokenAction);
connect(playerActions, &PlayerActions::requestSetLastToken, this, &UtilityMenu::setLastToken); connect(playerActions, &PlayerActions::requestSetLastToken, this, &UtilityMenu::setLastToken);
if (player->getPlayerLogic()->getPlayerInfo()->getLocalOrJudge()) { if (player->getLogic()->getPlayerInfo()->getLocalOrJudge()) {
aUntapAll = new QAction(this); aUntapAll = new QAction(this);
connect(aUntapAll, &QAction::triggered, playerActions, &PlayerActions::actUntapAll); connect(aUntapAll, &QAction::triggered, playerActions, &PlayerActions::actUntapAll);
@ -27,7 +27,7 @@ UtilityMenu::UtilityMenu(PlayerGraphicsItem *_player, QMenu *playerMenu) : QMenu
aCreateToken = new QAction(this); aCreateToken = new QAction(this);
connect(aCreateToken, &QAction::triggered, playerActions, [this]() { connect(aCreateToken, &QAction::triggered, playerActions, [this]() {
player->getPlayerLogic()->getPlayerActions()->actRequestCreateTokenDialog(getPredefinedTokens()); player->getLogic()->getPlayerActions()->actRequestCreateTokenDialog(getPredefinedTokens());
}); });
aCreateAnotherToken = new QAction(this); aCreateAnotherToken = new QAction(this);
@ -36,13 +36,13 @@ UtilityMenu::UtilityMenu(PlayerGraphicsItem *_player, QMenu *playerMenu) : QMenu
aIncrementAllCardCounters = new QAction(this); aIncrementAllCardCounters = new QAction(this);
connect(aIncrementAllCardCounters, &QAction::triggered, playerActions, [this]() { connect(aIncrementAllCardCounters, &QAction::triggered, playerActions, [this]() {
player->getPlayerLogic()->getPlayerActions()->actIncrementAllCardCounters( player->getLogic()->getPlayerActions()->actIncrementAllCardCounters(
player->getGameScene()->selectedCards()); player->getGameScene()->selectedCards());
}); });
createPredefinedTokenMenu = new QMenu(QString()); createPredefinedTokenMenu = new QMenu(QString());
createPredefinedTokenMenu->setEnabled(false); createPredefinedTokenMenu->setEnabled(false);
connect(player->getPlayerLogic(), &PlayerLogic::deckChanged, this, &UtilityMenu::populatePredefinedTokensMenu); connect(player->getLogic(), &PlayerLogic::deckChanged, this, &UtilityMenu::populatePredefinedTokensMenu);
playerMenu->addAction(aIncrementAllCardCounters); playerMenu->addAction(aIncrementAllCardCounters);
playerMenu->addSeparator(); playerMenu->addSeparator();
@ -73,7 +73,7 @@ void UtilityMenu::populatePredefinedTokensMenu()
clear(); clear();
setEnabled(false); setEnabled(false);
predefinedTokens.clear(); predefinedTokens.clear();
const DeckList &deckList = player->getPlayerLogic()->getDeck(); const DeckList &deckList = player->getLogic()->getDeck();
if (deckList.isEmpty()) { if (deckList.isEmpty()) {
return; return;
@ -91,7 +91,7 @@ void UtilityMenu::populatePredefinedTokensMenu()
if (i < 10) { if (i < 10) {
a->setShortcut(QKeySequence("Alt+" + QString::number((i + 1) % 10))); a->setShortcut(QKeySequence("Alt+" + QString::number((i + 1) % 10)));
} }
connect(a, &QAction::triggered, player->getPlayerLogic()->getPlayerActions(), connect(a, &QAction::triggered, player->getLogic()->getPlayerActions(),
&PlayerActions::actCreatePredefinedToken); &PlayerActions::actCreatePredefinedToken);
} }
} }
@ -103,12 +103,12 @@ void UtilityMenu::setLastToken(CardInfoPtr lastToken)
return; return;
} }
player->getPlayerLogic()->getPlayerActions()->setLastTokenInfo(lastToken); player->getLogic()->getPlayerActions()->setLastTokenInfo(lastToken);
} }
void UtilityMenu::retranslateUi() void UtilityMenu::retranslateUi()
{ {
if (player->getPlayerLogic()->getPlayerInfo()->getLocalOrJudge()) { if (player->getLogic()->getPlayerInfo()->getLocalOrJudge()) {
aIncrementAllCardCounters->setText(tr("Increment all card counters")); aIncrementAllCardCounters->setText(tr("Increment all card counters"));
aUntapAll->setText(tr("&Untap all permanents")); aUntapAll->setText(tr("&Untap all permanents"));
aRollDie->setText(tr("R&oll die...")); aRollDie->setText(tr("R&oll die..."));
@ -123,7 +123,7 @@ void UtilityMenu::setShortcutsActive()
{ {
ShortcutsSettings &shortcuts = SettingsCache::instance().shortcuts(); ShortcutsSettings &shortcuts = SettingsCache::instance().shortcuts();
if (player->getPlayerLogic()->getPlayerInfo()->getLocalOrJudge()) { if (player->getLogic()->getPlayerInfo()->getLocalOrJudge()) {
aIncrementAllCardCounters->setShortcuts(shortcuts.getShortcut("Player/aIncrementAllCardCounters")); aIncrementAllCardCounters->setShortcuts(shortcuts.getShortcut("Player/aIncrementAllCardCounters"));
aUntapAll->setShortcuts(shortcuts.getShortcut("Player/aUntapAll")); aUntapAll->setShortcuts(shortcuts.getShortcut("Player/aUntapAll"));
aRollDie->setShortcuts(shortcuts.getShortcut("Player/aRollDie")); aRollDie->setShortcuts(shortcuts.getShortcut("Player/aRollDie"));
@ -135,7 +135,7 @@ void UtilityMenu::setShortcutsActive()
void UtilityMenu::setShortcutsInactive() void UtilityMenu::setShortcutsInactive()
{ {
if (player->getPlayerLogic()->getPlayerInfo()->getLocalOrJudge()) { if (player->getLogic()->getPlayerInfo()->getLocalOrJudge()) {
aUntapAll->setShortcut(QKeySequence()); aUntapAll->setShortcut(QKeySequence());
aRollDie->setShortcut(QKeySequence()); aRollDie->setShortcut(QKeySequence());
aFlipCoin->setShortcut(QKeySequence()); aFlipCoin->setShortcut(QKeySequence());

View file

@ -56,7 +56,7 @@ public:
return static_cast<GameScene *>(scene()); return static_cast<GameScene *>(scene());
} }
PlayerLogic *getPlayerLogic() const PlayerLogic *getLogic() const
{ {
return player; return player;
} }