diff --git a/cockatrice/src/game/zones/view_zone_logic.cpp b/cockatrice/src/game/zones/view_zone_logic.cpp index eb3b7715f..fbda8eaae 100644 --- a/cockatrice/src/game/zones/view_zone_logic.cpp +++ b/cockatrice/src/game/zones/view_zone_logic.cpp @@ -3,6 +3,8 @@ #include "../../client/settings/cache_settings.h" #include "../../game_graphics/board/card_item.h" #include "../board/card_list.h" +#include "../player/player_actions.h" +#include "../player/player_logic.h" #include #include @@ -177,4 +179,14 @@ void ZoneViewZoneLogic::setWriteableRevealZone(bool _writeableRevealZone) emit removeFromViews(); } writeableRevealZone = _writeableRevealZone; -} \ No newline at end of file +} + +PendingCommand *ZoneViewZoneLogic::requestZoneDump() +{ + PlayerActions *actions = getPlayer()->getPlayerActions(); + PendingCommand *pend = actions->prepareZoneDump(this, numberCards); + if (pend != nullptr) { + actions->sendGameCommand(pend); + } + return pend; +} diff --git a/cockatrice/src/game/zones/view_zone_logic.h b/cockatrice/src/game/zones/view_zone_logic.h index 6fae301e4..1abcd0516 100644 --- a/cockatrice/src/game/zones/view_zone_logic.h +++ b/cockatrice/src/game/zones/view_zone_logic.h @@ -12,6 +12,7 @@ class PlayerLogic; class QObject; +class PendingCommand; class ZoneViewZoneLogic : public CardZoneLogic { @@ -73,6 +74,16 @@ public: return origZone; } + /** + * @brief Prepares and sends the zone-dump command for this view. + * @return The pending command, or nullptr when there is no zone to dump. + * + * Keeps command construction in game/ so graphics views don't reach + * through the player into PlayerActions to set it up. The command is sent + * asynchronously, so callers connect to finished() after calling this. + */ + PendingCommand *requestZoneDump(); + protected: void addCardImpl(CardItem *card, int x, int y) override; }; diff --git a/cockatrice/src/game_graphics/zones/view_zone.cpp b/cockatrice/src/game_graphics/zones/view_zone.cpp index 256bbe4f2..716d2b963 100644 --- a/cockatrice/src/game_graphics/zones/view_zone.cpp +++ b/cockatrice/src/game_graphics/zones/view_zone.cpp @@ -97,10 +97,10 @@ void ZoneViewZone::initializeCards(const QList &cardLis } reorganizeCards(); } else if (!qobject_cast(getLogic())->getOriginalZone()->contentsKnown()) { - auto *playerActions = getLogic()->getPlayer()->getPlayerActions(); - PendingCommand *pend = playerActions->prepareZoneDump(getLogic(), numberCards); - connect(pend, &PendingCommand::finished, this, &ZoneViewZone::zoneDumpReceived); - playerActions->sendGameCommand(pend); + PendingCommand *pend = qobject_cast(getLogic())->requestZoneDump(); + if (pend != nullptr) { + connect(pend, &PendingCommand::finished, this, &ZoneViewZone::zoneDumpReceived); + } } else { const CardList &c = qobject_cast(getLogic())->getOriginalZone()->getCards(); int number = numberCards == -1 ? c.size() : (numberCards < c.size() ? numberCards : c.size());