mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-09 11:33:25 -08:00
[Game] Move zone dump request onto ZoneViewZoneLogic per review
This commit is contained in:
parent
aabec45d2b
commit
1ab7f3666d
3 changed files with 28 additions and 5 deletions
|
|
@ -3,6 +3,8 @@
|
||||||
#include "../../client/settings/cache_settings.h"
|
#include "../../client/settings/cache_settings.h"
|
||||||
#include "../../game_graphics/board/card_item.h"
|
#include "../../game_graphics/board/card_item.h"
|
||||||
#include "../board/card_list.h"
|
#include "../board/card_list.h"
|
||||||
|
#include "../player/player_actions.h"
|
||||||
|
#include "../player/player_logic.h"
|
||||||
|
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
#include <libcockatrice/settings/interface_settings.h>
|
#include <libcockatrice/settings/interface_settings.h>
|
||||||
|
|
@ -178,3 +180,13 @@ void ZoneViewZoneLogic::setWriteableRevealZone(bool _writeableRevealZone)
|
||||||
}
|
}
|
||||||
writeableRevealZone = _writeableRevealZone;
|
writeableRevealZone = _writeableRevealZone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PendingCommand *ZoneViewZoneLogic::requestZoneDump()
|
||||||
|
{
|
||||||
|
PlayerActions *actions = getPlayer()->getPlayerActions();
|
||||||
|
PendingCommand *pend = actions->prepareZoneDump(this, numberCards);
|
||||||
|
if (pend != nullptr) {
|
||||||
|
actions->sendGameCommand(pend);
|
||||||
|
}
|
||||||
|
return pend;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@
|
||||||
|
|
||||||
class PlayerLogic;
|
class PlayerLogic;
|
||||||
class QObject;
|
class QObject;
|
||||||
|
class PendingCommand;
|
||||||
|
|
||||||
class ZoneViewZoneLogic : public CardZoneLogic
|
class ZoneViewZoneLogic : public CardZoneLogic
|
||||||
{
|
{
|
||||||
|
|
@ -73,6 +74,16 @@ public:
|
||||||
return origZone;
|
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:
|
protected:
|
||||||
void addCardImpl(CardItem *card, int x, int y) override;
|
void addCardImpl(CardItem *card, int x, int y) override;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -97,10 +97,10 @@ void ZoneViewZone::initializeCards(const QList<const ServerInfo_Card *> &cardLis
|
||||||
}
|
}
|
||||||
reorganizeCards();
|
reorganizeCards();
|
||||||
} else if (!qobject_cast<ZoneViewZoneLogic *>(getLogic())->getOriginalZone()->contentsKnown()) {
|
} else if (!qobject_cast<ZoneViewZoneLogic *>(getLogic())->getOriginalZone()->contentsKnown()) {
|
||||||
auto *playerActions = getLogic()->getPlayer()->getPlayerActions();
|
PendingCommand *pend = qobject_cast<ZoneViewZoneLogic *>(getLogic())->requestZoneDump();
|
||||||
PendingCommand *pend = playerActions->prepareZoneDump(getLogic(), numberCards);
|
if (pend != nullptr) {
|
||||||
connect(pend, &PendingCommand::finished, this, &ZoneViewZone::zoneDumpReceived);
|
connect(pend, &PendingCommand::finished, this, &ZoneViewZone::zoneDumpReceived);
|
||||||
playerActions->sendGameCommand(pend);
|
}
|
||||||
} else {
|
} else {
|
||||||
const CardList &c = qobject_cast<ZoneViewZoneLogic *>(getLogic())->getOriginalZone()->getCards();
|
const CardList &c = qobject_cast<ZoneViewZoneLogic *>(getLogic())->getOriginalZone()->getCards();
|
||||||
int number = numberCards == -1 ? c.size() : (numberCards < c.size() ? numberCards : c.size());
|
int number = numberCards == -1 ? c.size() : (numberCards < c.size() ? numberCards : c.size());
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue