diff --git a/cockatrice/src/game/player/menu/utility_menu.cpp b/cockatrice/src/game/player/menu/utility_menu.cpp index f6d9802ae..6b33d7bde 100644 --- a/cockatrice/src/game/player/menu/utility_menu.cpp +++ b/cockatrice/src/game/player/menu/utility_menu.cpp @@ -30,7 +30,8 @@ UtilityMenu::UtilityMenu(PlayerLogic *_player, QMenu *playerMenu) : QMenu(player aCreateAnotherToken->setEnabled(false); aIncrementAllCardCounters = new QAction(this); - connect(aIncrementAllCardCounters, &QAction::triggered, player, &PlayerLogic::incrementAllCardCounters); + connect(aIncrementAllCardCounters, &QAction::triggered, playerActions, + &PlayerActions::actIncrementAllCardCounters); createPredefinedTokenMenu = new QMenu(QString()); createPredefinedTokenMenu->setEnabled(false); diff --git a/cockatrice/src/game/player/player_actions.cpp b/cockatrice/src/game/player/player_actions.cpp index c2b9140af..1706c44dc 100644 --- a/cockatrice/src/game/player/player_actions.cpp +++ b/cockatrice/src/game/player/player_actions.cpp @@ -1559,6 +1559,42 @@ void PlayerActions::actSetCardCounter(int counterId) sendGameCommand(prepareGameCommand(commandList)); } +void PlayerActions::actIncrementAllCardCounters() +{ + auto cardsToUpdate = player->getGameScene()->selectedCards(); + if (cardsToUpdate.isEmpty()) { + // If no cards selected, update all cards on table + cardsToUpdate = static_cast>(player->getTableZone()->getCards()); + } + + QList commandList; + + for (const auto *card : cardsToUpdate) { + const auto &cardCounters = card->getCounters(); + + QMapIterator counterIterator(cardCounters); + while (counterIterator.hasNext()) { + counterIterator.next(); + int counterId = counterIterator.key(); + int currentValue = counterIterator.value(); + if (currentValue >= MAX_COUNTERS_ON_CARD) { + continue; + } + + auto cmd = std::make_unique(); + cmd->set_zone(card->getZone()->getName().toStdString()); + cmd->set_card_id(card->getId()); + cmd->set_counter_id(counterId); + cmd->set_counter_value(currentValue + 1); + commandList.append(cmd.release()); + } + } + + if (!commandList.isEmpty()) { + sendGameCommand(prepareGameCommand(commandList)); + } +} + /** * @brief returns true if the zone is a unwritable reveal zone view (eg a card reveal window). Will return false if zone * is nullptr. diff --git a/cockatrice/src/game/player/player_actions.h b/cockatrice/src/game/player/player_actions.h index d294d2c40..3b822b61a 100644 --- a/cockatrice/src/game/player/player_actions.h +++ b/cockatrice/src/game/player/player_actions.h @@ -131,6 +131,7 @@ public slots: void actRemoveCardCounter(int counterId); void actAddCardCounter(int counterId); void actSetCardCounter(int counterId); + void actIncrementAllCardCounters(); void actAttach(); void actUnattach(); void actDrawArrow(); diff --git a/cockatrice/src/game/player/player_logic.cpp b/cockatrice/src/game/player/player_logic.cpp index 7fdb48868..67c6e9519 100644 --- a/cockatrice/src/game/player/player_logic.cpp +++ b/cockatrice/src/game/player/player_logic.cpp @@ -304,42 +304,6 @@ CounterState *PlayerLogic::getLifeCounter() const return nullptr; } -void PlayerLogic::incrementAllCardCounters() -{ - auto cardsToUpdate = getGameScene()->selectedCards(); - if (cardsToUpdate.isEmpty()) { - // If no cards selected, update all cards on table - cardsToUpdate = static_cast>(getTableZone()->getCards()); - } - - QList commandList; - - for (const auto *card : cardsToUpdate) { - const auto &cardCounters = card->getCounters(); - - QMapIterator counterIterator(cardCounters); - while (counterIterator.hasNext()) { - counterIterator.next(); - int counterId = counterIterator.key(); - int currentValue = counterIterator.value(); - if (currentValue >= MAX_COUNTERS_ON_CARD) { - continue; - } - - auto cmd = std::make_unique(); - cmd->set_zone(card->getZone()->getName().toStdString()); - cmd->set_card_id(card->getId()); - cmd->set_counter_id(counterId); - cmd->set_counter_value(currentValue + 1); - commandList.append(cmd.release()); - } - } - - if (!commandList.isEmpty()) { - playerActions->sendGameCommand(playerActions->prepareGameCommand(commandList)); - } -} - bool PlayerLogic::clearCardsToDelete() { if (cardsToDelete.isEmpty()) { diff --git a/cockatrice/src/game/player/player_logic.h b/cockatrice/src/game/player/player_logic.h index fdeef49ba..5f58ca265 100644 --- a/cockatrice/src/game/player/player_logic.h +++ b/cockatrice/src/game/player/player_logic.h @@ -197,7 +197,6 @@ public: CounterState *addCounter(int id, const QString &name, const QColor &color, int radius, int value); void delCounter(int counterId); void clearCounters(); - void incrementAllCardCounters(); QMap getCounters() const {