[Player] Rename player to player logic (#6913)

Took 13 minutes

Took 6 seconds

Took 2 minutes

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
BruebachL 2026-05-19 12:36:31 +02:00 committed by GitHub
parent 71790d8e10
commit 5219cffa6b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
79 changed files with 397 additions and 386 deletions

View file

@ -95,13 +95,13 @@ set(cockatrice_SOURCES
src/game/player/menu/say_menu.cpp src/game/player/menu/say_menu.cpp
src/game/player/menu/sideboard_menu.cpp src/game/player/menu/sideboard_menu.cpp
src/game/player/menu/utility_menu.cpp src/game/player/menu/utility_menu.cpp
src/game/player/player.cpp
src/game/player/player_actions.cpp src/game/player/player_actions.cpp
src/game/player/player_area.cpp src/game/player/player_area.cpp
src/game/player/player_event_handler.cpp src/game/player/player_event_handler.cpp
src/game/player/player_graphics_item.cpp src/game/player/player_graphics_item.cpp
src/game/player/player_info.cpp src/game/player/player_info.cpp
src/game/player/player_list_widget.cpp src/game/player/player_list_widget.cpp
src/game/player/player_logic.cpp
src/game/player/player_manager.cpp src/game/player/player_manager.cpp
src/game/player/player_target.cpp src/game/player/player_target.cpp
src/game/replay.cpp src/game/replay.cpp

View file

@ -1,7 +1,7 @@
#include "abstract_game.h" #include "abstract_game.h"
#include "../interface/widgets/tabs/tab_game.h" #include "../interface/widgets/tabs/tab_game.h"
#include "player/player.h" #include "player/player_logic.h"
AbstractGame::AbstractGame(TabGame *_tab) : QObject(_tab), tab(_tab) AbstractGame::AbstractGame(TabGame *_tab) : QObject(_tab), tab(_tab)
{ {
@ -44,7 +44,7 @@ void AbstractGame::setActiveCard(CardItem *card)
CardItem *AbstractGame::getCard(int playerId, const QString &zoneName, int cardId) const CardItem *AbstractGame::getCard(int playerId, const QString &zoneName, int cardId) const
{ {
Player *player = playerManager->getPlayer(playerId); PlayerLogic *player = playerManager->getPlayer(playerId);
if (!player) { if (!player) {
return nullptr; return nullptr;
} }

View file

@ -13,7 +13,7 @@
#include <libcockatrice/card/database/card_database.h> #include <libcockatrice/card/database/card_database.h>
#include <libcockatrice/card/database/card_database_manager.h> #include <libcockatrice/card/database/card_database_manager.h>
AbstractCardItem::AbstractCardItem(QGraphicsItem *parent, const CardRef &cardRef, Player *_owner, int _id) AbstractCardItem::AbstractCardItem(QGraphicsItem *parent, const CardRef &cardRef, PlayerLogic *_owner, int _id)
: ArrowTarget(_owner, parent), id(_id), cardRef(cardRef), tapped(false), facedown(false), tapAngle(0), : ArrowTarget(_owner, parent), id(_id), cardRef(cardRef), tapped(false), facedown(false), tapAngle(0),
bgColor(Qt::transparent), isHovered(false), realZValue(0) bgColor(Qt::transparent), isHovered(false), realZValue(0)
{ {

View file

@ -14,7 +14,7 @@
#include <libcockatrice/card/printing/exact_card.h> #include <libcockatrice/card/printing/exact_card.h>
#include <libcockatrice/utility/card_ref.h> #include <libcockatrice/utility/card_ref.h>
class Player; class PlayerLogic;
class AbstractCardItem : public ArrowTarget class AbstractCardItem : public ArrowTarget
{ {
@ -56,7 +56,7 @@ public:
} }
explicit AbstractCardItem(QGraphicsItem *parent = nullptr, explicit AbstractCardItem(QGraphicsItem *parent = nullptr,
const CardRef &cardRef = {}, const CardRef &cardRef = {},
Player *_owner = nullptr, PlayerLogic *_owner = nullptr,
int _id = -1); int _id = -1);
~AbstractCardItem() override; ~AbstractCardItem() override;
QRectF boundingRect() const override; QRectF boundingRect() const override;

View file

@ -2,8 +2,8 @@
#include "../../client/settings/cache_settings.h" #include "../../client/settings/cache_settings.h"
#include "../../interface/widgets/tabs/tab_game.h" #include "../../interface/widgets/tabs/tab_game.h"
#include "../player/player.h"
#include "../player/player_actions.h" #include "../player/player_actions.h"
#include "../player/player_logic.h"
#include "translate_counter_name.h" #include "translate_counter_name.h"
#include <QAction> #include <QAction>
@ -16,7 +16,7 @@
#include <libcockatrice/protocol/pb/command_set_counter.pb.h> #include <libcockatrice/protocol/pb/command_set_counter.pb.h>
#include <libcockatrice/utility/expression.h> #include <libcockatrice/utility/expression.h>
AbstractCounter::AbstractCounter(Player *_player, AbstractCounter::AbstractCounter(PlayerLogic *_player,
int _id, int _id,
const QString &_name, const QString &_name,
bool _shownInCounterArea, bool _shownInCounterArea,

View file

@ -13,7 +13,7 @@
#include <QGraphicsItem> #include <QGraphicsItem>
#include <QInputDialog> #include <QInputDialog>
class Player; class PlayerLogic;
class QAction; class QAction;
class QKeyEvent; class QKeyEvent;
class QMenu; class QMenu;
@ -25,7 +25,7 @@ class AbstractCounter : public QObject, public QGraphicsItem, public AbstractPla
Q_INTERFACES(QGraphicsItem) Q_INTERFACES(QGraphicsItem)
protected: protected:
Player *player; PlayerLogic *player;
int id; int id;
QString name; QString name;
int value; int value;
@ -48,7 +48,7 @@ private slots:
void setCounter(); void setCounter();
public: public:
AbstractCounter(Player *_player, AbstractCounter(PlayerLogic *_player,
int _id, int _id,
const QString &_name, const QString &_name,
bool _shownInCounterArea, bool _shownInCounterArea,

View file

@ -3,8 +3,8 @@
#include "../../client/settings/cache_settings.h" #include "../../client/settings/cache_settings.h"
#include "../../game_graphics/zones/card_zone.h" #include "../../game_graphics/zones/card_zone.h"
#include "../player/player.h"
#include "../player/player_actions.h" #include "../player/player_actions.h"
#include "../player/player_logic.h"
#include "../player/player_target.h" #include "../player/player_target.h"
#include "../z_values.h" #include "../z_values.h"
#include "card_item.h" #include "card_item.h"
@ -21,7 +21,11 @@
#include <libcockatrice/utility/color.h> #include <libcockatrice/utility/color.h>
#include <libcockatrice/utility/zone_names.h> #include <libcockatrice/utility/zone_names.h>
ArrowItem::ArrowItem(Player *_player, int _id, ArrowTarget *_startItem, ArrowTarget *_targetItem, const QColor &_color) ArrowItem::ArrowItem(PlayerLogic *_player,
int _id,
ArrowTarget *_startItem,
ArrowTarget *_targetItem,
const QColor &_color)
: QGraphicsItem(), player(_player), id(_id), startItem(_startItem), targetItem(_targetItem), targetLocked(false), : QGraphicsItem(), player(_player), id(_id), startItem(_startItem), targetItem(_targetItem), targetLocked(false),
color(_color), fullColor(true) color(_color), fullColor(true)
{ {
@ -160,7 +164,7 @@ void ArrowItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
} }
} }
ArrowDragItem::ArrowDragItem(Player *_owner, ArrowTarget *_startItem, const QColor &_color, int _deleteInPhase) ArrowDragItem::ArrowDragItem(PlayerLogic *_owner, ArrowTarget *_startItem, const QColor &_color, int _deleteInPhase)
: ArrowItem(_owner, -1, _startItem, 0, _color), deleteInPhase(_deleteInPhase) : ArrowItem(_owner, -1, _startItem, 0, _color), deleteInPhase(_deleteInPhase)
{ {
} }

View file

@ -12,7 +12,7 @@
class CardItem; class CardItem;
class QGraphicsSceneMouseEvent; class QGraphicsSceneMouseEvent;
class QMenu; class QMenu;
class Player; class PlayerLogic;
class ArrowTarget; class ArrowTarget;
class ArrowItem : public QObject, public QGraphicsItem class ArrowItem : public QObject, public QGraphicsItem
@ -24,7 +24,7 @@ private:
QMenu *menu; QMenu *menu;
protected: protected:
Player *player; PlayerLogic *player;
int id; int id;
ArrowTarget *startItem, *targetItem; ArrowTarget *startItem, *targetItem;
bool targetLocked; bool targetLocked;
@ -33,7 +33,7 @@ protected:
void mousePressEvent(QGraphicsSceneMouseEvent *event) override; void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
public: public:
ArrowItem(Player *_player, int _id, ArrowTarget *_startItem, ArrowTarget *_targetItem, const QColor &color); ArrowItem(PlayerLogic *_player, int _id, ArrowTarget *_startItem, ArrowTarget *_targetItem, const QColor &color);
~ArrowItem() override; ~ArrowItem() override;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override; void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
[[nodiscard]] QRectF boundingRect() const override [[nodiscard]] QRectF boundingRect() const override
@ -51,7 +51,7 @@ public:
{ {
return id; return id;
} }
[[nodiscard]] Player *getPlayer() const [[nodiscard]] PlayerLogic *getPlayer() const
{ {
return player; return player;
} }
@ -86,7 +86,7 @@ private:
QList<ArrowDragItem *> childArrows; QList<ArrowDragItem *> childArrows;
public: public:
ArrowDragItem(Player *_owner, ArrowTarget *_startItem, const QColor &_color, int _deleteInPhase); ArrowDragItem(PlayerLogic *_owner, ArrowTarget *_startItem, const QColor &_color, int _deleteInPhase);
void addChildArrow(ArrowDragItem *childArrow); void addChildArrow(ArrowDragItem *childArrow);
protected: protected:

View file

@ -1,9 +1,9 @@
#include "arrow_target.h" #include "arrow_target.h"
#include "../player/player.h" #include "../player/player_logic.h"
#include "arrow_item.h" #include "arrow_item.h"
ArrowTarget::ArrowTarget(Player *_owner, QGraphicsItem *parent) ArrowTarget::ArrowTarget(PlayerLogic *_owner, QGraphicsItem *parent)
: AbstractGraphicsItem(parent), owner(_owner), beingPointedAt(false) : AbstractGraphicsItem(parent), owner(_owner), beingPointedAt(false)
{ {
setFlag(ItemSendsScenePositionChanges); setFlag(ItemSendsScenePositionChanges);

View file

@ -11,24 +11,24 @@
#include <QList> #include <QList>
class Player; class PlayerLogic;
class ArrowItem; class ArrowItem;
class ArrowTarget : public AbstractGraphicsItem class ArrowTarget : public AbstractGraphicsItem
{ {
Q_OBJECT Q_OBJECT
protected: protected:
Player *owner; PlayerLogic *owner;
private: private:
bool beingPointedAt; bool beingPointedAt;
QList<ArrowItem *> arrowsFrom, arrowsTo; QList<ArrowItem *> arrowsFrom, arrowsTo;
public: public:
explicit ArrowTarget(Player *_owner, QGraphicsItem *parent = nullptr); explicit ArrowTarget(PlayerLogic *_owner, QGraphicsItem *parent = nullptr);
~ArrowTarget() override; ~ArrowTarget() override;
[[nodiscard]] Player *getOwner() const [[nodiscard]] PlayerLogic *getOwner() const
{ {
return owner; return owner;
} }

View file

@ -6,8 +6,8 @@
#include "../../interface/widgets/tabs/tab_game.h" #include "../../interface/widgets/tabs/tab_game.h"
#include "../game_scene.h" #include "../game_scene.h"
#include "../phase.h" #include "../phase.h"
#include "../player/player.h"
#include "../player/player_actions.h" #include "../player/player_actions.h"
#include "../player/player_logic.h"
#include "../zones/view_zone_logic.h" #include "../zones/view_zone_logic.h"
#include "arrow_item.h" #include "arrow_item.h"
#include "card_drag_item.h" #include "card_drag_item.h"
@ -20,7 +20,11 @@
#include <libcockatrice/card/card_info.h> #include <libcockatrice/card/card_info.h>
#include <libcockatrice/protocol/pb/serverinfo_card.pb.h> #include <libcockatrice/protocol/pb/serverinfo_card.pb.h>
CardItem::CardItem(Player *_owner, QGraphicsItem *parent, const CardRef &cardRef, int _cardid, CardZoneLogic *_zone) CardItem::CardItem(PlayerLogic *_owner,
QGraphicsItem *parent,
const CardRef &cardRef,
int _cardid,
CardZoneLogic *_zone)
: AbstractCardItem(parent, cardRef, _owner, _cardid), state(new CardState(this, _zone)), dragItem(nullptr) : AbstractCardItem(parent, cardRef, _owner, _cardid), state(new CardState(this, _zone)), dragItem(nullptr)
{ {
owner->addCard(this); owner->addCard(this);
@ -273,7 +277,7 @@ void CardItem::drawArrow(const QColor &arrowColor)
} }
auto *game = owner->getGame(); auto *game = owner->getGame();
Player *arrowOwner = game->getPlayerManager()->getActiveLocalPlayer(game->getGameState()->getActivePlayer()); PlayerLogic *arrowOwner = game->getPlayerManager()->getActiveLocalPlayer(game->getGameState()->getActivePlayer());
int phase = 0; // 0 means to not set the phase int phase = 0; // 0 means to not set the phase
if (SettingsCache::instance().getDoNotDeleteArrowsInSubPhases()) { if (SettingsCache::instance().getDoNotDeleteArrowsInSubPhases()) {
int currentPhase = game->getGameState()->getCurrentPhase(); int currentPhase = game->getGameState()->getCurrentPhase();

View file

@ -17,7 +17,7 @@ class CardDatabase;
class CardDragItem; class CardDragItem;
class CardZone; class CardZone;
class ServerInfo_Card; class ServerInfo_Card;
class Player; class PlayerLogic;
class QAction; class QAction;
class QColor; class QColor;
@ -48,7 +48,7 @@ public:
{ {
return Type; return Type;
} }
explicit CardItem(Player *_owner, explicit CardItem(PlayerLogic *_owner,
QGraphicsItem *parent = nullptr, QGraphicsItem *parent = nullptr,
const CardRef &cardRef = {}, const CardRef &cardRef = {},
int _cardid = -1, int _cardid = -1,
@ -73,11 +73,11 @@ public:
{ {
return gridPoint; return gridPoint;
} }
[[nodiscard]] Player *getOwner() const [[nodiscard]] PlayerLogic *getOwner() const
{ {
return owner; return owner;
} }
void setOwner(Player *_owner) void setOwner(PlayerLogic *_owner)
{ {
owner = _owner; owner = _owner;
} }

View file

@ -5,7 +5,7 @@
#include <QPainter> #include <QPainter>
GeneralCounter::GeneralCounter(Player *_player, GeneralCounter::GeneralCounter(PlayerLogic *_player,
int _id, int _id,
const QString &_name, const QString &_name,
const QColor &_color, const QColor &_color,

View file

@ -17,7 +17,7 @@ private:
int radius; int radius;
public: public:
GeneralCounter(Player *_player, GeneralCounter(PlayerLogic *_player,
int _id, int _id,
const QString &_name, const QString &_name,
const QColor &_color, const QColor &_color,

View file

@ -99,7 +99,7 @@ void GameEventHandler::processGameEventContainer(const GameEventContainer &cont,
if (cont.has_forced_by_judge()) { if (cont.has_forced_by_judge()) {
auto id = cont.forced_by_judge(); auto id = cont.forced_by_judge();
Player *judgep = game->getPlayerManager()->getPlayers().value(id, nullptr); PlayerLogic *judgep = game->getPlayerManager()->getPlayers().value(id, nullptr);
if (judgep) { if (judgep) {
emit setContextJudgeName(judgep->getPlayerInfo()->getName()); emit setContextJudgeName(judgep->getPlayerInfo()->getName());
} else if (game->getPlayerManager()->getSpectators().contains(id)) { } else if (game->getPlayerManager()->getSpectators().contains(id)) {
@ -160,7 +160,7 @@ void GameEventHandler::processGameEventContainer(const GameEventContainer &cont,
break; break;
default: { default: {
Player *player = game->getPlayerManager()->getPlayers().value(playerId, 0); PlayerLogic *player = game->getPlayerManager()->getPlayers().value(playerId, 0);
if (!player) { if (!player) {
qCWarning(GameEventHandlerLog) << "unhandled game event: invalid player id"; qCWarning(GameEventHandlerLog) << "unhandled game event: invalid player id";
break; break;
@ -261,7 +261,7 @@ void GameEventHandler::eventGameStateChanged(const Event_GameStateChanged &event
emit spectatorJoined(prop); emit spectatorJoined(prop);
} }
} else { } else {
Player *player = game->getPlayerManager()->getPlayers().value(playerId, 0); PlayerLogic *player = game->getPlayerManager()->getPlayers().value(playerId, 0);
if (!player) { if (!player) {
player = game->getPlayerManager()->addPlayer(playerId, prop.user_info()); player = game->getPlayerManager()->addPlayer(playerId, prop.user_info());
emit playerJoined(prop); emit playerJoined(prop);
@ -310,7 +310,7 @@ void GameEventHandler::processCardAttachmentsForPlayers(const Event_GameStateCha
const ServerInfo_Player &playerInfo = event.player_list(i); const ServerInfo_Player &playerInfo = event.player_list(i);
const ServerInfo_PlayerProperties &prop = playerInfo.properties(); const ServerInfo_PlayerProperties &prop = playerInfo.properties();
if (!prop.spectator()) { if (!prop.spectator()) {
Player *player = game->getPlayerManager()->getPlayers().value(prop.player_id(), 0); PlayerLogic *player = game->getPlayerManager()->getPlayers().value(prop.player_id(), 0);
if (!player) { if (!player) {
continue; continue;
} }
@ -323,7 +323,7 @@ void GameEventHandler::eventPlayerPropertiesChanged(const Event_PlayerProperties
int eventPlayerId, int eventPlayerId,
const GameEventContext &context) const GameEventContext &context)
{ {
Player *player = game->getPlayerManager()->getPlayers().value(eventPlayerId, 0); PlayerLogic *player = game->getPlayerManager()->getPlayers().value(eventPlayerId, 0);
if (!player) { if (!player) {
return; return;
} }
@ -347,7 +347,7 @@ void GameEventHandler::eventPlayerPropertiesChanged(const Event_PlayerProperties
case GameEventContext::CONCEDE: { case GameEventContext::CONCEDE: {
player->setConceded(true); player->setConceded(true);
QMapIterator<int, Player *> playerIterator(game->getPlayerManager()->getPlayers()); QMapIterator<int, PlayerLogic *> playerIterator(game->getPlayerManager()->getPlayers());
while (playerIterator.hasNext()) { while (playerIterator.hasNext()) {
playerIterator.next().value()->updateZones(); playerIterator.next().value()->updateZones();
} }
@ -359,7 +359,7 @@ void GameEventHandler::eventPlayerPropertiesChanged(const Event_PlayerProperties
case GameEventContext::UNCONCEDE: { case GameEventContext::UNCONCEDE: {
player->setConceded(false); player->setConceded(false);
QMapIterator<int, Player *> playerIterator(game->getPlayerManager()->getPlayers()); QMapIterator<int, PlayerLogic *> playerIterator(game->getPlayerManager()->getPlayers());
while (playerIterator.hasNext()) { while (playerIterator.hasNext()) {
playerIterator.next().value()->updateZones(); playerIterator.next().value()->updateZones();
} }
@ -409,7 +409,7 @@ void GameEventHandler::eventJoin(const Event_Join &event, int /*eventPlayerId*/,
emit logJoinSpectator(playerName); emit logJoinSpectator(playerName);
emit spectatorJoined(playerInfo); emit spectatorJoined(playerInfo);
} else { } else {
Player *newPlayer = game->getPlayerManager()->addPlayer(playerId, playerInfo.user_info()); PlayerLogic *newPlayer = game->getPlayerManager()->addPlayer(playerId, playerInfo.user_info());
emit logJoinPlayer(newPlayer); emit logJoinPlayer(newPlayer);
emit playerJoined(playerInfo); emit playerJoined(playerInfo);
} }
@ -437,7 +437,7 @@ QString GameEventHandler::getLeaveReason(Event_Leave::LeaveReason reason)
} }
void GameEventHandler::eventLeave(const Event_Leave &event, int eventPlayerId, const GameEventContext & /*context*/) void GameEventHandler::eventLeave(const Event_Leave &event, int eventPlayerId, const GameEventContext & /*context*/)
{ {
Player *player = game->getPlayerManager()->getPlayers().value(eventPlayerId, 0); PlayerLogic *player = game->getPlayerManager()->getPlayers().value(eventPlayerId, 0);
if (!player) { if (!player) {
return; return;
} }
@ -452,7 +452,7 @@ void GameEventHandler::eventLeave(const Event_Leave &event, int eventPlayerId, c
player->deleteLater(); player->deleteLater();
// Rearrange all remaining zones so that attachment relationship updates take place // Rearrange all remaining zones so that attachment relationship updates take place
QMapIterator<int, Player *> playerIterator(game->getPlayerManager()->getPlayers()); QMapIterator<int, PlayerLogic *> playerIterator(game->getPlayerManager()->getPlayers());
while (playerIterator.hasNext()) { while (playerIterator.hasNext()) {
playerIterator.next().value()->updateZones(); playerIterator.next().value()->updateZones();
} }
@ -474,7 +474,7 @@ void GameEventHandler::eventReverseTurn(const Event_ReverseTurn &event,
int eventPlayerId, int eventPlayerId,
const GameEventContext & /*context*/) const GameEventContext & /*context*/)
{ {
Player *player = game->getPlayerManager()->getPlayers().value(eventPlayerId, 0); PlayerLogic *player = game->getPlayerManager()->getPlayers().value(eventPlayerId, 0);
if (!player) { if (!player) {
return; return;
} }
@ -505,7 +505,7 @@ void GameEventHandler::eventSetActivePlayer(const Event_SetActivePlayer &event,
const GameEventContext & /*context*/) const GameEventContext & /*context*/)
{ {
game->getGameState()->setActivePlayer(event.active_player_id()); game->getGameState()->setActivePlayer(event.active_player_id());
Player *player = game->getPlayerManager()->getPlayer(event.active_player_id()); PlayerLogic *player = game->getPlayerManager()->getPlayer(event.active_player_id());
if (!player) { if (!player) {
return; return;
} }

View file

@ -38,7 +38,7 @@ class Event_Kicked;
class Event_ReverseTurn; class Event_ReverseTurn;
class AbstractGame; class AbstractGame;
class PendingCommand; class PendingCommand;
class Player; class PlayerLogic;
inline Q_LOGGING_CATEGORY(GameEventHandlerLog, "game_event_handler"); inline Q_LOGGING_CATEGORY(GameEventHandlerLog, "game_event_handler");
@ -95,7 +95,7 @@ public slots:
signals: signals:
void emitUserEvent(); void emitUserEvent();
void addPlayerToAutoCompleteList(QString playerName); void addPlayerToAutoCompleteList(QString playerName);
void localPlayerDeckSelected(Player *localPlayer, int playerId, ServerInfo_Player playerInfo); void localPlayerDeckSelected(PlayerLogic *localPlayer, int playerId, ServerInfo_Player playerInfo);
void remotePlayerDeckSelected(QString deckList, int playerId, QString playerName); void remotePlayerDeckSelected(QString deckList, int playerId, QString playerName);
void remotePlayersDecksSelected(QVector<QPair<int, QPair<QString, QString>>> opponentDecks); void remotePlayersDecksSelected(QVector<QPair<int, QPair<QString, QString>>> opponentDecks);
void localPlayerSideboardLocked(int playerId, bool sideboardLocked); void localPlayerSideboardLocked(int playerId, bool sideboardLocked);
@ -115,18 +115,18 @@ signals:
void logSpectatorSay(ServerInfo_User userInfo, QString message); void logSpectatorSay(ServerInfo_User userInfo, QString message);
void logSpectatorLeave(QString name, QString reason); void logSpectatorLeave(QString name, QString reason);
void logGameStart(); void logGameStart();
void logReadyStart(Player *player); void logReadyStart(PlayerLogic *player);
void logNotReadyStart(Player *player); void logNotReadyStart(PlayerLogic *player);
void logDeckSelect(Player *player, QString deckHash, int sideboardSize); void logDeckSelect(PlayerLogic *player, QString deckHash, int sideboardSize);
void logSideboardLockSet(Player *player, bool sideboardLocked); void logSideboardLockSet(PlayerLogic *player, bool sideboardLocked);
void logConnectionStateChanged(Player *player, bool connected); void logConnectionStateChanged(PlayerLogic *player, bool connected);
void logJoinSpectator(QString spectatorName); void logJoinSpectator(QString spectatorName);
void logJoinPlayer(Player *player); void logJoinPlayer(PlayerLogic *player);
void logLeave(Player *player, QString reason); void logLeave(PlayerLogic *player, QString reason);
void logKicked(); void logKicked();
void logTurnReversed(Player *player, bool reversed); void logTurnReversed(PlayerLogic *player, bool reversed);
void logGameClosed(); void logGameClosed();
void logActivePlayer(Player *activePlayer); void logActivePlayer(PlayerLogic *activePlayer);
void logActivePhaseChanged(int activePhase); void logActivePhaseChanged(int activePhase);
void logConcede(int playerId); void logConcede(int playerId);
void logUnconcede(int playerId); void logUnconcede(int playerId);

View file

@ -6,8 +6,8 @@
#include "../game_graphics/zones/view_zone_widget.h" #include "../game_graphics/zones/view_zone_widget.h"
#include "board/card_item.h" #include "board/card_item.h"
#include "phases_toolbar.h" #include "phases_toolbar.h"
#include "player/player.h"
#include "player/player_graphics_item.h" #include "player/player_graphics_item.h"
#include "player/player_logic.h"
#include <QBasicTimer> #include <QBasicTimer>
#include <QDebug> #include <QDebug>
@ -78,7 +78,7 @@ QList<CardItem *> GameScene::selectedCards() const
* *
* Connects to the player's sizeChanged signal to recompute layout on resize. * Connects to the player's sizeChanged signal to recompute layout on resize.
*/ */
void GameScene::addPlayer(Player *player) void GameScene::addPlayer(PlayerLogic *player)
{ {
qCInfo(GameScenePlayerAdditionRemovalLog) << "GameScene::addPlayer name=" << player->getPlayerInfo()->getName(); qCInfo(GameScenePlayerAdditionRemovalLog) << "GameScene::addPlayer name=" << player->getPlayerInfo()->getName();
@ -93,7 +93,7 @@ void GameScene::addPlayer(Player *player)
* *
* Closes any zone views associated with the player and recomputes layout. * Closes any zone views associated with the player and recomputes layout.
*/ */
void GameScene::removePlayer(Player *player) void GameScene::removePlayer(PlayerLogic *player)
{ {
qCInfo(GameScenePlayerAdditionRemovalLog) << "GameScene::removePlayer name=" << player->getPlayerInfo()->getName(); qCInfo(GameScenePlayerAdditionRemovalLog) << "GameScene::removePlayer name=" << player->getPlayerInfo()->getName();
@ -178,14 +178,14 @@ void GameScene::processViewSizeChange(const QSize &newSize)
* *
* Used to determine rotation and layout order. * Used to determine rotation and layout order.
*/ */
QList<Player *> GameScene::collectActivePlayers(int &firstPlayerIndex) const QList<PlayerLogic *> GameScene::collectActivePlayers(int &firstPlayerIndex) const
{ {
QList<Player *> activePlayers; QList<PlayerLogic *> activePlayers;
firstPlayerIndex = 0; firstPlayerIndex = 0;
bool firstPlayerFound = false; bool firstPlayerFound = false;
for (auto *pgItem : players) { for (auto *pgItem : players) {
Player *p = pgItem->getPlayer(); PlayerLogic *p = pgItem->getPlayer();
if (p && !p->getConceded()) { if (p && !p->getConceded()) {
activePlayers.append(p); activePlayers.append(p);
if (!firstPlayerFound && p->getPlayerInfo()->getLocal()) { if (!firstPlayerFound && p->getPlayerInfo()->getLocal()) {
@ -205,9 +205,9 @@ QList<Player *> GameScene::collectActivePlayers(int &firstPlayerIndex) const
* *
* Applies rotation offset and ensures the list wraps correctly. * Applies rotation offset and ensures the list wraps correctly.
*/ */
QList<Player *> GameScene::rotatePlayers(const QList<Player *> &activePlayers, int firstPlayerIndex) const QList<PlayerLogic *> GameScene::rotatePlayers(const QList<PlayerLogic *> &activePlayers, int firstPlayerIndex) const
{ {
QList<Player *> rotated = activePlayers; QList<PlayerLogic *> rotated = activePlayers;
if (!rotated.isEmpty()) { if (!rotated.isEmpty()) {
int totalRotation = firstPlayerIndex + playerRotation; int totalRotation = firstPlayerIndex + playerRotation;
while (totalRotation < 0) { while (totalRotation < 0) {
@ -238,7 +238,7 @@ int GameScene::determineColumnCount(int playerCount)
* - Position players in columns with spacing. * - Position players in columns with spacing.
* - Mirror graphics for visual balance. * - Mirror graphics for visual balance.
*/ */
QSizeF GameScene::computeSceneSizeAndPlayerLayout(const QList<Player *> &playersPlaying, int columns) QSizeF GameScene::computeSceneSizeAndPlayerLayout(const QList<PlayerLogic *> &playersPlaying, int columns)
{ {
playersByColumn.clear(); playersByColumn.clear();
@ -246,7 +246,7 @@ QSizeF GameScene::computeSceneSizeAndPlayerLayout(const QList<Player *> &players
qreal sceneHeight = 0, sceneWidth = -playerAreaSpacing; qreal sceneHeight = 0, sceneWidth = -playerAreaSpacing;
QList<int> columnWidth; QList<int> columnWidth;
QListIterator<Player *> playersIter(playersPlaying); QListIterator<PlayerLogic *> playersIter(playersPlaying);
for (int col = 0; col < columns; ++col) { for (int col = 0; col < columns; ++col) {
playersByColumn.append(QList<PlayerGraphicsItem *>()); playersByColumn.append(QList<PlayerGraphicsItem *>());
columnWidth.append(0); columnWidth.append(0);
@ -254,7 +254,7 @@ QSizeF GameScene::computeSceneSizeAndPlayerLayout(const QList<Player *> &players
int rowsInColumn = rows - (playersPlaying.size() % columns) * col; // Adjust rows for uneven columns int rowsInColumn = rows - (playersPlaying.size() % columns) * col; // Adjust rows for uneven columns
for (int j = 0; j < rowsInColumn; ++j) { for (int j = 0; j < rowsInColumn; ++j) {
Player *player = playersIter.next(); PlayerLogic *player = playersIter.next();
if (col == 0) { if (col == 0) {
playersByColumn[col].prepend(player->getGraphicsItem()); playersByColumn[col].prepend(player->getGraphicsItem());
} else { } else {
@ -435,7 +435,7 @@ CardItem *GameScene::findTopmostCardInZone(const QList<QGraphicsItem *> &items,
* If an identical view exists, it is closed. Otherwise, a new ZoneViewWidget is created * If an identical view exists, it is closed. Otherwise, a new ZoneViewWidget is created
* and positioned based on zone type. * and positioned based on zone type.
*/ */
void GameScene::toggleZoneView(Player *player, const QString &zoneName, int numberCards, bool isReversed) void GameScene::toggleZoneView(PlayerLogic *player, const QString &zoneName, int numberCards, bool isReversed)
{ {
for (auto &view : zoneViews) { for (auto &view : zoneViews) {
ZoneViewZone *temp = view->getZone(); ZoneViewZone *temp = view->getZone();
@ -468,7 +468,7 @@ void GameScene::toggleZoneView(Player *player, const QString &zoneName, int numb
* @param cardList List of cards to show. * @param cardList List of cards to show.
* @param withWritePermission Whether edits are allowed. * @param withWritePermission Whether edits are allowed.
*/ */
void GameScene::addRevealedZoneView(Player *player, void GameScene::addRevealedZoneView(PlayerLogic *player,
CardZoneLogic *zone, CardZoneLogic *zone,
const QList<const ServerInfo_Card *> &cardList, const QList<const ServerInfo_Card *> &cardList,
bool withWritePermission) bool withWritePermission)

View file

@ -12,7 +12,7 @@
inline Q_LOGGING_CATEGORY(GameSceneLog, "game_scene"); inline Q_LOGGING_CATEGORY(GameSceneLog, "game_scene");
inline Q_LOGGING_CATEGORY(GameScenePlayerAdditionRemovalLog, "game_scene.player_addition_removal"); inline Q_LOGGING_CATEGORY(GameScenePlayerAdditionRemovalLog, "game_scene.player_addition_removal");
class Player; class PlayerLogic;
class PlayerGraphicsItem; class PlayerGraphicsItem;
class ZoneViewWidget; class ZoneViewWidget;
class CardZone; class CardZone;
@ -83,13 +83,13 @@ public:
* @brief Adds a player to the scene and stores their graphics item. * @brief Adds a player to the scene and stores their graphics item.
* @param player Player to add. * @param player Player to add.
*/ */
void addPlayer(Player *player); void addPlayer(PlayerLogic *player);
/** /**
* @brief Removes a player from the scene. * @brief Removes a player from the scene.
* @param player Player to remove. * @param player Player to remove.
*/ */
void removePlayer(Player *player); void removePlayer(PlayerLogic *player);
/** /**
* @brief Adjusts the global rotation offset for player layout. * @brief Adjusts the global rotation offset for player layout.
@ -111,7 +111,7 @@ public:
* @param firstPlayerIndex Output index of first local player. * @param firstPlayerIndex Output index of first local player.
* @return List of active players. * @return List of active players.
*/ */
QList<Player *> collectActivePlayers(int &firstPlayerIndex) const; QList<PlayerLogic *> collectActivePlayers(int &firstPlayerIndex) const;
/** /**
* @brief Rotates the list of players for layout. * @brief Rotates the list of players for layout.
@ -119,7 +119,7 @@ public:
* @param firstPlayerIndex Index of first local player. * @param firstPlayerIndex Index of first local player.
* @return Rotated list. * @return Rotated list.
*/ */
QList<Player *> rotatePlayers(const QList<Player *> &players, int firstPlayerIndex) const; QList<PlayerLogic *> rotatePlayers(const QList<PlayerLogic *> &players, int firstPlayerIndex) const;
/** /**
* @brief Determines the number of columns to display players in. * @brief Determines the number of columns to display players in.
@ -134,7 +134,7 @@ public:
* @param columns Number of columns to split into. * @param columns Number of columns to split into.
* @return Calculated scene size. * @return Calculated scene size.
*/ */
QSizeF computeSceneSizeAndPlayerLayout(const QList<Player *> &playersPlaying, int columns); QSizeF computeSceneSizeAndPlayerLayout(const QList<PlayerLogic *> &playersPlaying, int columns);
/** /**
* @brief Computes the minimum width for each column based on player minimum widths. * @brief Computes the minimum width for each column based on player minimum widths.
@ -177,10 +177,10 @@ public:
public slots: public slots:
/** Toggles a zone view for a player. */ /** Toggles a zone view for a player. */
void toggleZoneView(Player *player, const QString &zoneName, int numberCards, bool isReversed = false); void toggleZoneView(PlayerLogic *player, const QString &zoneName, int numberCards, bool isReversed = false);
/** Adds a revealed zone view (for shown cards). */ /** Adds a revealed zone view (for shown cards). */
void addRevealedZoneView(Player *player, void addRevealedZoneView(PlayerLogic *player,
CardZoneLogic *zone, CardZoneLogic *zone,
const QList<const ServerInfo_Card *> &cardList, const QList<const ServerInfo_Card *> &cardList,
bool withWritePermission); bool withWritePermission);

View file

@ -5,7 +5,7 @@
#include "../board/card_item.h" #include "../board/card_item.h"
#include "../board/translate_counter_name.h" #include "../board/translate_counter_name.h"
#include "../phase.h" #include "../phase.h"
#include "../player/player.h" #include "../player/player_logic.h"
#include <../../client/settings/card_counter_settings.h> #include <../../client/settings/card_counter_settings.h>
#include <libcockatrice/protocol/pb/context_move_card.pb.h> #include <libcockatrice/protocol/pb/context_move_card.pb.h>
@ -105,7 +105,7 @@ void MessageLogWidget::containerProcessingStarted(const GameEventContext &contex
} }
} }
void MessageLogWidget::logAlwaysRevealTopCard(Player *player, CardZoneLogic *zone, bool reveal) void MessageLogWidget::logAlwaysRevealTopCard(PlayerLogic *player, CardZoneLogic *zone, bool reveal)
{ {
appendHtmlServerMessage((reveal ? tr("%1 is now keeping the top card %2 revealed.") appendHtmlServerMessage((reveal ? tr("%1 is now keeping the top card %2 revealed.")
: tr("%1 is not revealing the top card %2 any longer.")) : tr("%1 is not revealing the top card %2 any longer."))
@ -113,7 +113,7 @@ void MessageLogWidget::logAlwaysRevealTopCard(Player *player, CardZoneLogic *zon
.arg(zone->getTranslatedName(true, CaseTopCardsOfZone))); .arg(zone->getTranslatedName(true, CaseTopCardsOfZone)));
} }
void MessageLogWidget::logAlwaysLookAtTopCard(Player *player, CardZoneLogic *zone, bool reveal) void MessageLogWidget::logAlwaysLookAtTopCard(PlayerLogic *player, CardZoneLogic *zone, bool reveal)
{ {
appendHtmlServerMessage((reveal ? tr("%1 can now look at top card %2 at any time.") appendHtmlServerMessage((reveal ? tr("%1 can now look at top card %2 at any time.")
: tr("%1 no longer can look at top card %2 at any time.")) : tr("%1 no longer can look at top card %2 at any time."))
@ -121,7 +121,10 @@ void MessageLogWidget::logAlwaysLookAtTopCard(Player *player, CardZoneLogic *zon
.arg(zone->getTranslatedName(true, CaseTopCardsOfZone))); .arg(zone->getTranslatedName(true, CaseTopCardsOfZone)));
} }
void MessageLogWidget::logAttachCard(Player *player, QString cardName, Player *targetPlayer, QString targetCardName) void MessageLogWidget::logAttachCard(PlayerLogic *player,
QString cardName,
PlayerLogic *targetPlayer,
QString targetCardName)
{ {
appendHtmlServerMessage(tr("%1 attaches %2 to %3's %4.") appendHtmlServerMessage(tr("%1 attaches %2 to %3's %4.")
.arg(sanitizeHtml(player->getPlayerInfo()->getName())) .arg(sanitizeHtml(player->getPlayerInfo()->getName()))
@ -148,7 +151,7 @@ void MessageLogWidget::logUnconcede(int playerId)
true); true);
} }
void MessageLogWidget::logConnectionStateChanged(Player *player, bool connectionState) void MessageLogWidget::logConnectionStateChanged(PlayerLogic *player, bool connectionState)
{ {
if (connectionState) { if (connectionState) {
soundEngine->playSound("player_reconnect"); soundEngine->playSound("player_reconnect");
@ -161,10 +164,10 @@ void MessageLogWidget::logConnectionStateChanged(Player *player, bool connection
} }
} }
void MessageLogWidget::logCreateArrow(Player *player, void MessageLogWidget::logCreateArrow(PlayerLogic *player,
Player *startPlayer, PlayerLogic *startPlayer,
QString startCard, QString startCard,
Player *targetPlayer, PlayerLogic *targetPlayer,
QString targetCard, QString targetCard,
bool playerTarget) bool playerTarget)
{ {
@ -220,7 +223,7 @@ void MessageLogWidget::logCreateArrow(Player *player,
} }
} }
void MessageLogWidget::logCreateToken(Player *player, QString cardName, QString pt, bool faceDown) void MessageLogWidget::logCreateToken(PlayerLogic *player, QString cardName, QString pt, bool faceDown)
{ {
if (faceDown) { if (faceDown) {
appendHtmlServerMessage( appendHtmlServerMessage(
@ -233,7 +236,7 @@ void MessageLogWidget::logCreateToken(Player *player, QString cardName, QString
} }
} }
void MessageLogWidget::logDeckSelect(Player *player, QString deckHash, int sideboardSize) void MessageLogWidget::logDeckSelect(PlayerLogic *player, QString deckHash, int sideboardSize)
{ {
if (sideboardSize < 0) { if (sideboardSize < 0) {
appendHtmlServerMessage( appendHtmlServerMessage(
@ -246,13 +249,13 @@ void MessageLogWidget::logDeckSelect(Player *player, QString deckHash, int sideb
} }
} }
void MessageLogWidget::logDestroyCard(Player *player, QString cardName) void MessageLogWidget::logDestroyCard(PlayerLogic *player, QString cardName)
{ {
appendHtmlServerMessage( appendHtmlServerMessage(
tr("%1 destroys %2.").arg(sanitizeHtml(player->getPlayerInfo()->getName())).arg(cardLink(std::move(cardName)))); tr("%1 destroys %2.").arg(sanitizeHtml(player->getPlayerInfo()->getName())).arg(cardLink(std::move(cardName))));
} }
void MessageLogWidget::logMoveCard(Player *player, void MessageLogWidget::logMoveCard(PlayerLogic *player,
CardItem *card, CardItem *card,
CardZoneLogic *startZone, CardZoneLogic *startZone,
int oldX, int oldX,
@ -359,7 +362,7 @@ void MessageLogWidget::logMoveCard(Player *player,
appendHtmlServerMessage(message); appendHtmlServerMessage(message);
} }
void MessageLogWidget::logDrawCards(Player *player, int number, bool deckIsEmpty) void MessageLogWidget::logDrawCards(PlayerLogic *player, int number, bool deckIsEmpty)
{ {
soundEngine->playSound("draw_card"); soundEngine->playSound("draw_card");
if (currentContext == MessageContext_Mulligan) { if (currentContext == MessageContext_Mulligan) {
@ -376,7 +379,7 @@ void MessageLogWidget::logDrawCards(Player *player, int number, bool deckIsEmpty
} }
} }
void MessageLogWidget::logDumpZone(Player *player, CardZoneLogic *zone, int numberCards, bool isReversed) void MessageLogWidget::logDumpZone(PlayerLogic *player, CardZoneLogic *zone, int numberCards, bool isReversed)
{ {
if (numberCards == -1) { if (numberCards == -1) {
appendHtmlServerMessage(tr("%1 is looking at %2.") appendHtmlServerMessage(tr("%1 is looking at %2.")
@ -392,7 +395,7 @@ void MessageLogWidget::logDumpZone(Player *player, CardZoneLogic *zone, int numb
} }
} }
void MessageLogWidget::logFlipCard(Player *player, QString cardName, bool faceDown) void MessageLogWidget::logFlipCard(PlayerLogic *player, QString cardName, bool faceDown)
{ {
if (faceDown) { if (faceDown) {
appendHtmlServerMessage( appendHtmlServerMessage(
@ -418,7 +421,7 @@ void MessageLogWidget::logGameFlooded()
appendMessage(tr("You are flooding the game. Please wait a couple of seconds.")); appendMessage(tr("You are flooding the game. Please wait a couple of seconds."));
} }
void MessageLogWidget::logJoin(Player *player) void MessageLogWidget::logJoin(PlayerLogic *player)
{ {
soundEngine->playSound("player_join"); soundEngine->playSound("player_join");
appendHtmlServerMessage(tr("%1 has joined the game.").arg(sanitizeHtml(player->getPlayerInfo()->getName()))); appendHtmlServerMessage(tr("%1 has joined the game.").arg(sanitizeHtml(player->getPlayerInfo()->getName())));
@ -435,7 +438,7 @@ void MessageLogWidget::logKicked()
appendHtmlServerMessage(tr("You have been kicked out of the game."), true); appendHtmlServerMessage(tr("You have been kicked out of the game."), true);
} }
void MessageLogWidget::logLeave(Player *player, QString reason) void MessageLogWidget::logLeave(PlayerLogic *player, QString reason)
{ {
soundEngine->playSound("player_leave"); soundEngine->playSound("player_leave");
appendHtmlServerMessage(tr("%1 has left the game (%2).") appendHtmlServerMessage(tr("%1 has left the game (%2).")
@ -450,13 +453,13 @@ void MessageLogWidget::logLeaveSpectator(QString name, QString reason)
.arg(sanitizeHtml(std::move(name)), sanitizeHtml(std::move(reason)))); .arg(sanitizeHtml(std::move(name)), sanitizeHtml(std::move(reason))));
} }
void MessageLogWidget::logNotReadyStart(Player *player) void MessageLogWidget::logNotReadyStart(PlayerLogic *player)
{ {
appendHtmlServerMessage( appendHtmlServerMessage(
tr("%1 is not ready to start the game any more.").arg(sanitizeHtml(player->getPlayerInfo()->getName()))); tr("%1 is not ready to start the game any more.").arg(sanitizeHtml(player->getPlayerInfo()->getName())));
} }
void MessageLogWidget::logMulligan(Player *player, int number) void MessageLogWidget::logMulligan(PlayerLogic *player, int number)
{ {
if (!player) { if (!player) {
return; return;
@ -476,16 +479,16 @@ void MessageLogWidget::logReplayStarted(int gameId)
appendHtmlServerMessage(tr("You are watching a replay of game #%1.").arg(gameId)); appendHtmlServerMessage(tr("You are watching a replay of game #%1.").arg(gameId));
} }
void MessageLogWidget::logReadyStart(Player *player) void MessageLogWidget::logReadyStart(PlayerLogic *player)
{ {
appendHtmlServerMessage(tr("%1 is ready to start the game.").arg(sanitizeHtml(player->getPlayerInfo()->getName()))); appendHtmlServerMessage(tr("%1 is ready to start the game.").arg(sanitizeHtml(player->getPlayerInfo()->getName())));
} }
void MessageLogWidget::logRevealCards(Player *player, void MessageLogWidget::logRevealCards(PlayerLogic *player,
CardZoneLogic *zone, CardZoneLogic *zone,
int cardId, int cardId,
QString cardName, QString cardName,
Player *otherPlayer, PlayerLogic *otherPlayer,
bool faceDown, bool faceDown,
int amount, int amount,
bool isLentToAnotherPlayer) bool isLentToAnotherPlayer)
@ -568,14 +571,14 @@ void MessageLogWidget::logRevealCards(Player *player,
} }
} }
void MessageLogWidget::logReverseTurn(Player *player, bool reversed) void MessageLogWidget::logReverseTurn(PlayerLogic *player, bool reversed)
{ {
appendHtmlServerMessage(tr("%1 reversed turn order, now it's %2.") appendHtmlServerMessage(tr("%1 reversed turn order, now it's %2.")
.arg(sanitizeHtml(player->getPlayerInfo()->getName())) .arg(sanitizeHtml(player->getPlayerInfo()->getName()))
.arg(reversed ? tr("reversed") : tr("normal"))); .arg(reversed ? tr("reversed") : tr("normal")));
} }
void MessageLogWidget::logRollDie(Player *player, int sides, const QList<uint> &rolls) void MessageLogWidget::logRollDie(PlayerLogic *player, int sides, const QList<uint> &rolls)
{ {
if (rolls.length() == 1) { if (rolls.length() == 1) {
const auto roll = rolls.at(0); const auto roll = rolls.at(0);
@ -612,7 +615,7 @@ void MessageLogWidget::logRollDie(Player *player, int sides, const QList<uint> &
soundEngine->playSound("roll_dice"); soundEngine->playSound("roll_dice");
} }
void MessageLogWidget::logSay(Player *player, QString message) void MessageLogWidget::logSay(PlayerLogic *player, QString message)
{ {
appendMessage(std::move(message), {}, *player->getPlayerInfo()->getUserInfo(), true); appendMessage(std::move(message), {}, *player->getPlayerInfo()->getUserInfo(), true);
} }
@ -627,13 +630,13 @@ void MessageLogWidget::logSetActivePhase(int phaseNumber)
phase.getName() + "</b></font>"); phase.getName() + "</b></font>");
} }
void MessageLogWidget::logSetActivePlayer(Player *player) void MessageLogWidget::logSetActivePlayer(PlayerLogic *player)
{ {
appendHtml("<br><font color=\"green\"><b>" + QDateTime::currentDateTime().toString("[hh:mm:ss] ") + appendHtml("<br><font color=\"green\"><b>" + QDateTime::currentDateTime().toString("[hh:mm:ss] ") +
QString(tr("%1's turn.")).arg(player->getPlayerInfo()->getName()) + "</b></font><br>"); QString(tr("%1's turn.")).arg(player->getPlayerInfo()->getName()) + "</b></font><br>");
} }
void MessageLogWidget::logSetAnnotation(Player *player, CardItem *card, QString newAnnotation) void MessageLogWidget::logSetAnnotation(PlayerLogic *player, CardItem *card, QString newAnnotation)
{ {
appendHtmlServerMessage( appendHtmlServerMessage(
QString(tr("%1 sets annotation of %2 to %3.")) QString(tr("%1 sets annotation of %2 to %3."))
@ -642,7 +645,7 @@ void MessageLogWidget::logSetAnnotation(Player *player, CardItem *card, QString
.arg(QString("&quot;<font class=\"blue\">%1</font>&quot;").arg(sanitizeHtml(std::move(newAnnotation))))); .arg(QString("&quot;<font class=\"blue\">%1</font>&quot;").arg(sanitizeHtml(std::move(newAnnotation)))));
} }
void MessageLogWidget::logSetCardCounter(Player *player, QString cardName, int counterId, int value, int oldValue) void MessageLogWidget::logSetCardCounter(PlayerLogic *player, QString cardName, int counterId, int value, int oldValue)
{ {
QString finalStr; QString finalStr;
int delta = abs(oldValue - value); int delta = abs(oldValue - value);
@ -660,7 +663,7 @@ void MessageLogWidget::logSetCardCounter(Player *player, QString cardName, int c
.arg(value)); .arg(value));
} }
void MessageLogWidget::logSetCounter(Player *player, QString counterName, int value, int oldValue) void MessageLogWidget::logSetCounter(PlayerLogic *player, QString counterName, int value, int oldValue)
{ {
if (counterName == "life") { if (counterName == "life") {
soundEngine->playSound("life_change"); soundEngine->playSound("life_change");
@ -675,7 +678,7 @@ void MessageLogWidget::logSetCounter(Player *player, QString counterName, int va
.arg(value - oldValue)); .arg(value - oldValue));
} }
void MessageLogWidget::logSetDoesntUntap(Player *player, CardItem *card, bool doesntUntap) void MessageLogWidget::logSetDoesntUntap(PlayerLogic *player, CardItem *card, bool doesntUntap)
{ {
QString str; QString str;
if (doesntUntap) { if (doesntUntap) {
@ -686,7 +689,7 @@ void MessageLogWidget::logSetDoesntUntap(Player *player, CardItem *card, bool do
appendHtmlServerMessage(str.arg(sanitizeHtml(player->getPlayerInfo()->getName())).arg(cardLink(card->getName()))); appendHtmlServerMessage(str.arg(sanitizeHtml(player->getPlayerInfo()->getName())).arg(cardLink(card->getName())));
} }
void MessageLogWidget::logSetPT(Player *player, CardItem *card, QString newPT) void MessageLogWidget::logSetPT(PlayerLogic *player, CardItem *card, QString newPT)
{ {
if (currentContext == MessageContext_MoveCard) { if (currentContext == MessageContext_MoveCard) {
return; return;
@ -713,7 +716,7 @@ void MessageLogWidget::logSetPT(Player *player, CardItem *card, QString newPT)
} }
} }
void MessageLogWidget::logSetSideboardLock(Player *player, bool locked) void MessageLogWidget::logSetSideboardLock(PlayerLogic *player, bool locked)
{ {
if (locked) { if (locked) {
appendHtmlServerMessage( appendHtmlServerMessage(
@ -724,7 +727,7 @@ void MessageLogWidget::logSetSideboardLock(Player *player, bool locked)
} }
} }
void MessageLogWidget::logSetTapped(Player *player, CardItem *card, bool tapped) void MessageLogWidget::logSetTapped(PlayerLogic *player, CardItem *card, bool tapped)
{ {
if (currentContext == MessageContext_MoveCard) { if (currentContext == MessageContext_MoveCard) {
return; return;
@ -747,7 +750,7 @@ void MessageLogWidget::logSetTapped(Player *player, CardItem *card, bool tapped)
} }
} }
void MessageLogWidget::logShuffle(Player *player, CardZoneLogic *zone, int start, int end) void MessageLogWidget::logShuffle(PlayerLogic *player, CardZoneLogic *zone, int start, int end)
{ {
if (currentContext == MessageContext_Mulligan) { if (currentContext == MessageContext_Mulligan) {
return; return;
@ -784,14 +787,14 @@ void MessageLogWidget::logSpectatorSay(const ServerInfo_User &spectator, QString
appendMessage(std::move(message), {}, spectator, false); appendMessage(std::move(message), {}, spectator, false);
} }
void MessageLogWidget::logUnattachCard(Player *player, QString cardName) void MessageLogWidget::logUnattachCard(PlayerLogic *player, QString cardName)
{ {
appendHtmlServerMessage(tr("%1 unattaches %2.") appendHtmlServerMessage(tr("%1 unattaches %2.")
.arg(sanitizeHtml(player->getPlayerInfo()->getName())) .arg(sanitizeHtml(player->getPlayerInfo()->getName()))
.arg(cardLink(std::move(cardName)))); .arg(cardLink(std::move(cardName))));
} }
void MessageLogWidget::logUndoDraw(Player *player, QString cardName) void MessageLogWidget::logUndoDraw(PlayerLogic *player, QString cardName)
{ {
if (cardName.isEmpty()) { if (cardName.isEmpty()) {
appendHtmlServerMessage(tr("%1 undoes their last draw.").arg(sanitizeHtml(player->getPlayerInfo()->getName()))); appendHtmlServerMessage(tr("%1 undoes their last draw.").arg(sanitizeHtml(player->getPlayerInfo()->getName())));

View file

@ -13,7 +13,7 @@
class AbstractGame; class AbstractGame;
class CardItem; class CardItem;
class GameEventContext; class GameEventContext;
class Player; class PlayerLogic;
class PlayerEventHandler; class PlayerEventHandler;
class MessageLogWidget : public ChatView class MessageLogWidget : public ChatView
@ -39,66 +39,66 @@ public:
public slots: public slots:
void containerProcessingDone(); void containerProcessingDone();
void containerProcessingStarted(const GameEventContext &context); void containerProcessingStarted(const GameEventContext &context);
void logAlwaysRevealTopCard(Player *player, CardZoneLogic *zone, bool reveal); void logAlwaysRevealTopCard(PlayerLogic *player, CardZoneLogic *zone, bool reveal);
void logAlwaysLookAtTopCard(Player *player, CardZoneLogic *zone, bool reveal); void logAlwaysLookAtTopCard(PlayerLogic *player, CardZoneLogic *zone, bool reveal);
void logAttachCard(Player *player, QString cardName, Player *targetPlayer, QString targetCardName); void logAttachCard(PlayerLogic *player, QString cardName, PlayerLogic *targetPlayer, QString targetCardName);
void logConcede(int playerId); void logConcede(int playerId);
void logUnconcede(int playerId); void logUnconcede(int playerId);
void logConnectionStateChanged(Player *player, bool connectionState); void logConnectionStateChanged(PlayerLogic *player, bool connectionState);
void logCreateArrow(Player *player, void logCreateArrow(PlayerLogic *player,
Player *startPlayer, PlayerLogic *startPlayer,
QString startCard, QString startCard,
Player *targetPlayer, PlayerLogic *targetPlayer,
QString targetCard, QString targetCard,
bool playerTarget); bool playerTarget);
void logCreateToken(Player *player, QString cardName, QString pt, bool faceDown); void logCreateToken(PlayerLogic *player, QString cardName, QString pt, bool faceDown);
void logDeckSelect(Player *player, QString deckHash, int sideboardSize); void logDeckSelect(PlayerLogic *player, QString deckHash, int sideboardSize);
void logDestroyCard(Player *player, QString cardName); void logDestroyCard(PlayerLogic *player, QString cardName);
void logDrawCards(Player *player, int number, bool deckIsEmpty); void logDrawCards(PlayerLogic *player, int number, bool deckIsEmpty);
void logDumpZone(Player *player, CardZoneLogic *zone, int numberCards, bool isReversed = false); void logDumpZone(PlayerLogic *player, CardZoneLogic *zone, int numberCards, bool isReversed = false);
void logFlipCard(Player *player, QString cardName, bool faceDown); void logFlipCard(PlayerLogic *player, QString cardName, bool faceDown);
void logGameClosed(); void logGameClosed();
void logGameStart(); void logGameStart();
void logGameFlooded(); void logGameFlooded();
void logJoin(Player *player); void logJoin(PlayerLogic *player);
void logJoinSpectator(QString name); void logJoinSpectator(QString name);
void logKicked(); void logKicked();
void logLeave(Player *player, QString reason); void logLeave(PlayerLogic *player, QString reason);
void logLeaveSpectator(QString name, QString reason); void logLeaveSpectator(QString name, QString reason);
void logNotReadyStart(Player *player); void logNotReadyStart(PlayerLogic *player);
void logMoveCard(Player *player, void logMoveCard(PlayerLogic *player,
CardItem *card, CardItem *card,
CardZoneLogic *startZone, CardZoneLogic *startZone,
int oldX, int oldX,
CardZoneLogic *targetZone, CardZoneLogic *targetZone,
int newX); int newX);
void logMulligan(Player *player, int number); void logMulligan(PlayerLogic *player, int number);
void logReplayStarted(int gameId); void logReplayStarted(int gameId);
void logReadyStart(Player *player); void logReadyStart(PlayerLogic *player);
void logRevealCards(Player *player, void logRevealCards(PlayerLogic *player,
CardZoneLogic *zone, CardZoneLogic *zone,
int cardId, int cardId,
QString cardName, QString cardName,
Player *otherPlayer, PlayerLogic *otherPlayer,
bool faceDown, bool faceDown,
int amount, int amount,
bool isLentToAnotherPlayer); bool isLentToAnotherPlayer);
void logReverseTurn(Player *player, bool reversed); void logReverseTurn(PlayerLogic *player, bool reversed);
void logRollDie(Player *player, int sides, const QList<uint> &rolls); void logRollDie(PlayerLogic *player, int sides, const QList<uint> &rolls);
void logSay(Player *player, QString message); void logSay(PlayerLogic *player, QString message);
void logSetActivePhase(int phase); void logSetActivePhase(int phase);
void logSetActivePlayer(Player *player); void logSetActivePlayer(PlayerLogic *player);
void logSetAnnotation(Player *player, CardItem *card, QString newAnnotation); void logSetAnnotation(PlayerLogic *player, CardItem *card, QString newAnnotation);
void logSetCardCounter(Player *player, QString cardName, int counterId, int value, int oldValue); void logSetCardCounter(PlayerLogic *player, QString cardName, int counterId, int value, int oldValue);
void logSetCounter(Player *player, QString counterName, int value, int oldValue); void logSetCounter(PlayerLogic *player, QString counterName, int value, int oldValue);
void logSetDoesntUntap(Player *player, CardItem *card, bool doesntUntap); void logSetDoesntUntap(PlayerLogic *player, CardItem *card, bool doesntUntap);
void logSetPT(Player *player, CardItem *card, QString newPT); void logSetPT(PlayerLogic *player, CardItem *card, QString newPT);
void logSetSideboardLock(Player *player, bool locked); void logSetSideboardLock(PlayerLogic *player, bool locked);
void logSetTapped(Player *player, CardItem *card, bool tapped); void logSetTapped(PlayerLogic *player, CardItem *card, bool tapped);
void logShuffle(Player *player, CardZoneLogic *zone, int start, int end); void logShuffle(PlayerLogic *player, CardZoneLogic *zone, int start, int end);
void logSpectatorSay(const ServerInfo_User &spectator, QString message); void logSpectatorSay(const ServerInfo_User &spectator, QString message);
void logUnattachCard(Player *player, QString cardName); void logUnattachCard(PlayerLogic *player, QString cardName);
void logUndoDraw(Player *player, QString cardName); void logUndoDraw(PlayerLogic *player, QString cardName);
void setContextJudgeName(QString player); void setContextJudgeName(QString player);
void appendHtmlServerMessage(const QString &html, void appendHtmlServerMessage(const QString &html,
bool optionalIsBold = false, bool optionalIsBold = false,

View file

@ -21,7 +21,7 @@ namespace protobuf
class Message; class Message;
} }
} // namespace google } // namespace google
class Player; class PlayerLogic;
class GameCommand; class GameCommand;
class PhaseButton : public QObject, public QGraphicsItem class PhaseButton : public QObject, public QGraphicsItem

View file

@ -5,8 +5,8 @@
#include "../../board/card_item.h" #include "../../board/card_item.h"
#include "../../zones/view_zone_logic.h" #include "../../zones/view_zone_logic.h"
#include "../card_menu_action_type.h" #include "../card_menu_action_type.h"
#include "../player.h"
#include "../player_actions.h" #include "../player_actions.h"
#include "../player_logic.h"
#include "move_menu.h" #include "move_menu.h"
#include "pt_menu.h" #include "pt_menu.h"
@ -14,12 +14,12 @@
#include <libcockatrice/card/relation/card_relation.h> #include <libcockatrice/card/relation/card_relation.h>
#include <libcockatrice/utility/zone_names.h> #include <libcockatrice/utility/zone_names.h>
CardMenu::CardMenu(Player *_player, const CardItem *_card, bool _shortcutsActive) CardMenu::CardMenu(PlayerLogic *_player, const CardItem *_card, bool _shortcutsActive)
: player(_player), card(_card), shortcutsActive(_shortcutsActive) : player(_player), card(_card), shortcutsActive(_shortcutsActive)
{ {
auto playerActions = player->getPlayerActions(); auto playerActions = player->getPlayerActions();
const QList<Player *> &players = player->getGame()->getPlayerManager()->getPlayers().values(); const QList<PlayerLogic *> &players = player->getGame()->getPlayerManager()->getPlayers().values();
for (auto playerToAdd : players) { for (auto playerToAdd : players) {
if (playerToAdd == player) { if (playerToAdd == player) {
@ -137,7 +137,7 @@ CardMenu::CardMenu(Player *_player, const CardItem *_card, bool _shortcutsActive
} }
} }
void CardMenu::removePlayer(Player *playerToRemove) void CardMenu::removePlayer(PlayerLogic *playerToRemove)
{ {
for (auto it = playersInfo.begin(); it != playersInfo.end();) { for (auto it = playersInfo.begin(); it != playersInfo.end();) {
if (it->second == playerToRemove->getPlayerInfo()->getId()) { if (it->second == playerToRemove->getPlayerInfo()->getId()) {

View file

@ -10,14 +10,14 @@
#include <QMenu> #include <QMenu>
class CardItem; class CardItem;
class Player; class PlayerLogic;
class CardMenu : public QMenu class CardMenu : public QMenu
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit CardMenu(Player *player, const CardItem *card, bool shortcutsActive); explicit CardMenu(PlayerLogic *player, const CardItem *card, bool shortcutsActive);
void removePlayer(Player *playerToRemove); void removePlayer(PlayerLogic *playerToRemove);
void createTableMenu(bool canModifyCard); void createTableMenu(bool canModifyCard);
void createStackMenu(bool canModifyCard); void createStackMenu(bool canModifyCard);
void createGraveyardOrExileMenu(bool canModifyCard); void createGraveyardOrExileMenu(bool canModifyCard);
@ -41,7 +41,7 @@ public:
QList<QAction *> aAddCounter, aSetCounter, aRemoveCounter; QList<QAction *> aAddCounter, aSetCounter, aRemoveCounter;
private: private:
Player *player; PlayerLogic *player;
const CardItem *card; const CardItem *card;
QList<QPair<QString, int>> playersInfo; QList<QPair<QString, int>> playersInfo;
bool shortcutsActive; bool shortcutsActive;

View file

@ -1,13 +1,13 @@
#include "custom_zone_menu.h" #include "custom_zone_menu.h"
#include "../player.h" #include "../player_logic.h"
CustomZoneMenu::CustomZoneMenu(Player *_player) : player(_player) CustomZoneMenu::CustomZoneMenu(PlayerLogic *_player) : player(_player)
{ {
menuAction()->setVisible(false); menuAction()->setVisible(false);
connect(player, &Player::clearCustomZonesMenu, this, &CustomZoneMenu::clearCustomZonesMenu); connect(player, &PlayerLogic::clearCustomZonesMenu, this, &CustomZoneMenu::clearCustomZonesMenu);
connect(player, &Player::addViewCustomZoneActionToCustomZoneMenu, this, connect(player, &PlayerLogic::addViewCustomZoneActionToCustomZoneMenu, this,
&CustomZoneMenu::addViewCustomZoneActionToCustomZoneMenu); &CustomZoneMenu::addViewCustomZoneActionToCustomZoneMenu);
retranslateUi(); retranslateUi();

View file

@ -11,12 +11,12 @@
#include <QMenu> #include <QMenu>
class Player; class PlayerLogic;
class CustomZoneMenu : public QMenu, public AbstractPlayerComponent class CustomZoneMenu : public QMenu, public AbstractPlayerComponent
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit CustomZoneMenu(Player *player); explicit CustomZoneMenu(PlayerLogic *player);
void retranslateUi() override; void retranslateUi() override;
void setShortcutsActive() override void setShortcutsActive() override
{ {
@ -26,7 +26,7 @@ public:
} }
private: private:
Player *player; PlayerLogic *player;
private slots: private slots:
void clearCustomZonesMenu(); void clearCustomZonesMenu();
void addViewCustomZoneActionToCustomZoneMenu(QString zoneName); void addViewCustomZoneActionToCustomZoneMenu(QString zoneName);

View file

@ -1,14 +1,14 @@
#include "grave_menu.h" #include "grave_menu.h"
#include "../../abstract_game.h" #include "../../abstract_game.h"
#include "../player.h"
#include "../player_actions.h" #include "../player_actions.h"
#include "../player_logic.h"
#include <QAction> #include <QAction>
#include <QMenu> #include <QMenu>
#include <libcockatrice/utility/zone_names.h> #include <libcockatrice/utility/zone_names.h>
GraveyardMenu::GraveyardMenu(Player *_player, QWidget *parent) : TearOffMenu(parent), player(_player) GraveyardMenu::GraveyardMenu(PlayerLogic *_player, QWidget *parent) : TearOffMenu(parent), player(_player)
{ {
createMoveActions(); createMoveActions();
createViewActions(); createViewActions();

View file

@ -13,7 +13,7 @@
#include <QAction> #include <QAction>
#include <QMenu> #include <QMenu>
class Player; class PlayerLogic;
class GraveyardMenu : public TearOffMenu, public AbstractPlayerComponent class GraveyardMenu : public TearOffMenu, public AbstractPlayerComponent
{ {
Q_OBJECT Q_OBJECT
@ -21,7 +21,7 @@ signals:
void newPlayerActionCreated(QAction *action); void newPlayerActionCreated(QAction *action);
public: public:
explicit GraveyardMenu(Player *player, QWidget *parent = nullptr); explicit GraveyardMenu(PlayerLogic *player, QWidget *parent = nullptr);
void createMoveActions(); void createMoveActions();
void createViewActions(); void createViewActions();
void populateRevealRandomMenuWithActivePlayers(); void populateRevealRandomMenuWithActivePlayers();
@ -40,7 +40,7 @@ public:
QAction *aMoveGraveToRfg = nullptr; QAction *aMoveGraveToRfg = nullptr;
private: private:
Player *player; PlayerLogic *player;
}; };
#endif // COCKATRICE_GRAVE_MENU_H #endif // COCKATRICE_GRAVE_MENU_H

View file

@ -4,14 +4,14 @@
#include "../../../client/settings/shortcuts_settings.h" #include "../../../client/settings/shortcuts_settings.h"
#include "../../../game_graphics/zones/hand_zone.h" #include "../../../game_graphics/zones/hand_zone.h"
#include "../../abstract_game.h" #include "../../abstract_game.h"
#include "../player.h"
#include "../player_actions.h" #include "../player_actions.h"
#include "../player_logic.h"
#include <QAction> #include <QAction>
#include <QMenu> #include <QMenu>
#include <libcockatrice/utility/zone_names.h> #include <libcockatrice/utility/zone_names.h>
HandMenu::HandMenu(Player *_player, PlayerActions *actions, QWidget *parent) : TearOffMenu(parent), player(_player) HandMenu::HandMenu(PlayerLogic *_player, PlayerActions *actions, QWidget *parent) : TearOffMenu(parent), player(_player)
{ {
if (player->getPlayerInfo()->local || player->getPlayerInfo()->judge) { if (player->getPlayerInfo()->local || player->getPlayerInfo()->judge) {
aViewHand = new QAction(this); aViewHand = new QAction(this);

View file

@ -13,7 +13,7 @@
#include <QAction> #include <QAction>
#include <QMenu> #include <QMenu>
class Player; class PlayerLogic;
class PlayerActions; class PlayerActions;
class HandMenu : public TearOffMenu, public AbstractPlayerComponent class HandMenu : public TearOffMenu, public AbstractPlayerComponent
@ -21,7 +21,7 @@ class HandMenu : public TearOffMenu, public AbstractPlayerComponent
Q_OBJECT Q_OBJECT
public: public:
HandMenu(Player *player, PlayerActions *actions, QWidget *parent = nullptr); HandMenu(PlayerLogic *player, PlayerActions *actions, QWidget *parent = nullptr);
QMenu *revealHandMenu() const QMenu *revealHandMenu() const
{ {
@ -43,7 +43,7 @@ private slots:
void onRevealRandomHandCardTriggered(); void onRevealRandomHandCardTriggered();
private: private:
Player *player; PlayerLogic *player;
QAction *aViewHand = nullptr; QAction *aViewHand = nullptr;
QAction *aMulligan = nullptr; QAction *aMulligan = nullptr;

View file

@ -4,13 +4,13 @@
#include "../../../client/settings/shortcuts_settings.h" #include "../../../client/settings/shortcuts_settings.h"
#include "../../../interface/widgets/tabs/tab_game.h" #include "../../../interface/widgets/tabs/tab_game.h"
#include "../../abstract_game.h" #include "../../abstract_game.h"
#include "../player.h"
#include "../player_actions.h" #include "../player_actions.h"
#include "../player_logic.h"
#include <QAction> #include <QAction>
#include <QMenu> #include <QMenu>
LibraryMenu::LibraryMenu(Player *_player, QWidget *parent) : TearOffMenu(parent), player(_player) LibraryMenu::LibraryMenu(PlayerLogic *_player, QWidget *parent) : TearOffMenu(parent), player(_player)
{ {
createDrawActions(); createDrawActions();
createShuffleActions(); createShuffleActions();
@ -75,8 +75,8 @@ LibraryMenu::LibraryMenu(Player *_player, QWidget *parent) : TearOffMenu(parent)
bottomLibraryMenu->addSeparator(); bottomLibraryMenu->addSeparator();
bottomLibraryMenu->addAction(aShuffleBottomCards); bottomLibraryMenu->addAction(aShuffleBottomCards);
connect(player, &Player::resetTopCardMenuActions, this, &LibraryMenu::resetTopCardMenuActions); connect(player, &PlayerLogic::resetTopCardMenuActions, this, &LibraryMenu::resetTopCardMenuActions);
connect(player, &Player::deckChanged, this, &LibraryMenu::enableOpenInDeckEditorAction); connect(player, &PlayerLogic::deckChanged, this, &LibraryMenu::enableOpenInDeckEditorAction);
retranslateUi(); retranslateUi();
} }

View file

@ -13,7 +13,7 @@
#include <QAction> #include <QAction>
#include <QMenu> #include <QMenu>
class Player; class PlayerLogic;
class PlayerActions; class PlayerActions;
class LibraryMenu : public TearOffMenu, public AbstractPlayerComponent class LibraryMenu : public TearOffMenu, public AbstractPlayerComponent
@ -24,7 +24,7 @@ public slots:
void resetTopCardMenuActions(); void resetTopCardMenuActions();
public: public:
LibraryMenu(Player *player, QWidget *parent = nullptr); LibraryMenu(PlayerLogic *player, QWidget *parent = nullptr);
void createDrawActions(); void createDrawActions();
void createShuffleActions(); void createShuffleActions();
void createMoveActions(); void createMoveActions();
@ -111,7 +111,7 @@ public:
int defaultNumberTopCards = 1; int defaultNumberTopCards = 1;
private: private:
Player *player; PlayerLogic *player;
}; };
#endif // COCKATRICE_LIBRARY_MENU_H #endif // COCKATRICE_LIBRARY_MENU_H

View file

@ -1,10 +1,10 @@
#include "move_menu.h" #include "move_menu.h"
#include "../card_menu_action_type.h" #include "../card_menu_action_type.h"
#include "../player.h"
#include "../player_actions.h" #include "../player_actions.h"
#include "../player_logic.h"
MoveMenu::MoveMenu(Player *player) : QMenu(tr("Move to")) MoveMenu::MoveMenu(PlayerLogic *player) : QMenu(tr("Move to"))
{ {
aMoveToTopLibrary = new QAction(this); aMoveToTopLibrary = new QAction(this);
aMoveToTopLibrary->setData(cmMoveToTopLibrary); aMoveToTopLibrary->setData(cmMoveToTopLibrary);

View file

@ -8,13 +8,13 @@
#define COCKATRICE_MOVE_MENU_H #define COCKATRICE_MOVE_MENU_H
#include <QMenu> #include <QMenu>
class Player; class PlayerLogic;
class MoveMenu : public QMenu class MoveMenu : public QMenu
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit MoveMenu(Player *player); explicit MoveMenu(PlayerLogic *player);
void setShortcutsActive(); void setShortcutsActive();
void retranslateUi(); void retranslateUi();

View file

@ -10,7 +10,7 @@
#include <libcockatrice/protocol/pb/command_reveal_cards.pb.h> #include <libcockatrice/protocol/pb/command_reveal_cards.pb.h>
PlayerMenu::PlayerMenu(Player *_player) : QObject(_player), player(_player) PlayerMenu::PlayerMenu(PlayerLogic *_player) : QObject(_player), player(_player)
{ {
playerMenu = new TearOffMenu(); playerMenu = new TearOffMenu();

View file

@ -8,7 +8,7 @@
#define COCKATRICE_PLAYER_MENU_H #define COCKATRICE_PLAYER_MENU_H
#include "../../../interface/widgets/menus/tearoff_menu.h" #include "../../../interface/widgets/menus/tearoff_menu.h"
#include "../player.h" #include "../player_logic.h"
#include "custom_zone_menu.h" #include "custom_zone_menu.h"
#include "grave_menu.h" #include "grave_menu.h"
#include "hand_menu.h" #include "hand_menu.h"
@ -37,7 +37,7 @@ private slots:
void refreshShortcuts(); void refreshShortcuts();
public: public:
explicit PlayerMenu(Player *player); explicit PlayerMenu(PlayerLogic *player);
/// Lifecycle methods: delegate to all managedComponents, plus counters separately via player->getCounters(). /// Lifecycle methods: delegate to all managedComponents, plus counters separately via player->getCounters().
void retranslateUi(); void retranslateUi();
@ -74,7 +74,7 @@ public:
void setShortcutsInactive(); void setShortcutsInactive();
private: private:
Player *player; PlayerLogic *player;
TearOffMenu *playerMenu; TearOffMenu *playerMenu;
QMenu *countersMenu; QMenu *countersMenu;
HandMenu *handMenu; HandMenu *handMenu;

View file

@ -1,9 +1,9 @@
#include "pt_menu.h" #include "pt_menu.h"
#include "../player.h"
#include "../player_actions.h" #include "../player_actions.h"
#include "../player_logic.h"
PtMenu::PtMenu(Player *player) : QMenu(tr("Power / toughness")) PtMenu::PtMenu(PlayerLogic *player) : QMenu(tr("Power / toughness"))
{ {
PlayerActions *playerActions = player->getPlayerActions(); PlayerActions *playerActions = player->getPlayerActions();

View file

@ -8,14 +8,14 @@
#define COCKATRICE_PT_MENU_H #define COCKATRICE_PT_MENU_H
#include <QMenu> #include <QMenu>
class Player; class PlayerLogic;
class PtMenu : public QMenu class PtMenu : public QMenu
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit PtMenu(Player *player); explicit PtMenu(PlayerLogic *player);
void retranslateUi(); void retranslateUi();
void setShortcutsActive(); void setShortcutsActive();

View file

@ -1,11 +1,11 @@
#include "rfg_menu.h" #include "rfg_menu.h"
#include "../player.h"
#include "../player_actions.h" #include "../player_actions.h"
#include "../player_logic.h"
#include <libcockatrice/utility/zone_names.h> #include <libcockatrice/utility/zone_names.h>
RfgMenu::RfgMenu(Player *_player, QWidget *parent) : TearOffMenu(parent), player(_player) RfgMenu::RfgMenu(PlayerLogic *_player, QWidget *parent) : TearOffMenu(parent), player(_player)
{ {
createMoveActions(); createMoveActions();
createViewActions(); createViewActions();

View file

@ -13,12 +13,12 @@
#include <QAction> #include <QAction>
#include <QMenu> #include <QMenu>
class Player; class PlayerLogic;
class RfgMenu : public TearOffMenu, public AbstractPlayerComponent class RfgMenu : public TearOffMenu, public AbstractPlayerComponent
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit RfgMenu(Player *player, QWidget *parent = nullptr); explicit RfgMenu(PlayerLogic *player, QWidget *parent = nullptr);
void createMoveActions(); void createMoveActions();
void createViewActions(); void createViewActions();
void retranslateUi() override; void retranslateUi() override;
@ -38,7 +38,7 @@ public:
QAction *aMoveRfgToGrave = nullptr; QAction *aMoveRfgToGrave = nullptr;
private: private:
Player *player; PlayerLogic *player;
}; };
#endif // COCKATRICE_RFG_MENU_H #endif // COCKATRICE_RFG_MENU_H

View file

@ -1,10 +1,10 @@
#include "say_menu.h" #include "say_menu.h"
#include "../../../client/settings/cache_settings.h" #include "../../../client/settings/cache_settings.h"
#include "../player.h"
#include "../player_actions.h" #include "../player_actions.h"
#include "../player_logic.h"
SayMenu::SayMenu(Player *_player) : player(_player) SayMenu::SayMenu(PlayerLogic *_player) : player(_player)
{ {
connect(&SettingsCache::instance().messages(), &MessageSettings::messageMacrosChanged, this, &SayMenu::initSayMenu); connect(&SettingsCache::instance().messages(), &MessageSettings::messageMacrosChanged, this, &SayMenu::initSayMenu);
initSayMenu(); initSayMenu();

View file

@ -11,12 +11,12 @@
#include <QMenu> #include <QMenu>
class Player; class PlayerLogic;
class SayMenu : public QMenu, public AbstractPlayerComponent class SayMenu : public QMenu, public AbstractPlayerComponent
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit SayMenu(Player *player); explicit SayMenu(PlayerLogic *player);
void retranslateUi() override; void retranslateUi() override;
void setShortcutsActive() override; void setShortcutsActive() override;
@ -26,7 +26,7 @@ private slots:
void initSayMenu(); void initSayMenu();
private: private:
Player *player; PlayerLogic *player;
bool shortcutsActive = false; bool shortcutsActive = false;
}; };

View file

@ -1,9 +1,9 @@
#include "sideboard_menu.h" #include "sideboard_menu.h"
#include "../player.h"
#include "../player_actions.h" #include "../player_actions.h"
#include "../player_logic.h"
SideboardMenu::SideboardMenu(Player *player, QMenu *playerMenu) : QMenu(playerMenu) SideboardMenu::SideboardMenu(PlayerLogic *player, QMenu *playerMenu) : QMenu(playerMenu)
{ {
aViewSideboard = new QAction(this); aViewSideboard = new QAction(this);
connect(aViewSideboard, &QAction::triggered, player->getPlayerActions(), &PlayerActions::actViewSideboard); connect(aViewSideboard, &QAction::triggered, player->getPlayerActions(), &PlayerActions::actViewSideboard);

View file

@ -11,19 +11,19 @@
#include <QMenu> #include <QMenu>
class Player; class PlayerLogic;
class SideboardMenu : public QMenu, public AbstractPlayerComponent class SideboardMenu : public QMenu, public AbstractPlayerComponent
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit SideboardMenu(Player *player, QMenu *playerMenu); explicit SideboardMenu(PlayerLogic *player, QMenu *playerMenu);
void retranslateUi() override; void retranslateUi() override;
void setShortcutsActive() override; void setShortcutsActive() override;
void setShortcutsInactive() override; void setShortcutsInactive() override;
private: private:
Player *player; PlayerLogic *player;
QAction *aViewSideboard; QAction *aViewSideboard;
}; };

View file

@ -1,14 +1,14 @@
#include "utility_menu.h" #include "utility_menu.h"
#include "../../../interface/deck_loader/deck_loader.h" #include "../../../interface/deck_loader/deck_loader.h"
#include "../player.h"
#include "../player_actions.h" #include "../player_actions.h"
#include "../player_logic.h"
#include "player_menu.h" #include "player_menu.h"
#include <libcockatrice/deck_list/tree/deck_list_card_node.h> #include <libcockatrice/deck_list/tree/deck_list_card_node.h>
#include <libcockatrice/deck_list/tree/inner_deck_list_node.h> #include <libcockatrice/deck_list/tree/inner_deck_list_node.h>
UtilityMenu::UtilityMenu(Player *_player, QMenu *playerMenu) : QMenu(playerMenu), player(_player) UtilityMenu::UtilityMenu(PlayerLogic *_player, QMenu *playerMenu) : QMenu(playerMenu), player(_player)
{ {
PlayerActions *playerActions = player->getPlayerActions(); PlayerActions *playerActions = player->getPlayerActions();
@ -30,11 +30,11 @@ UtilityMenu::UtilityMenu(Player *_player, QMenu *playerMenu) : QMenu(playerMenu)
aCreateAnotherToken->setEnabled(false); aCreateAnotherToken->setEnabled(false);
aIncrementAllCardCounters = new QAction(this); aIncrementAllCardCounters = new QAction(this);
connect(aIncrementAllCardCounters, &QAction::triggered, player, &Player::incrementAllCardCounters); connect(aIncrementAllCardCounters, &QAction::triggered, player, &PlayerLogic::incrementAllCardCounters);
createPredefinedTokenMenu = new QMenu(QString()); createPredefinedTokenMenu = new QMenu(QString());
createPredefinedTokenMenu->setEnabled(false); createPredefinedTokenMenu->setEnabled(false);
connect(player, &Player::deckChanged, this, &UtilityMenu::populatePredefinedTokensMenu); connect(player, &PlayerLogic::deckChanged, this, &UtilityMenu::populatePredefinedTokensMenu);
playerMenu->addAction(aIncrementAllCardCounters); playerMenu->addAction(aIncrementAllCardCounters);
playerMenu->addSeparator(); playerMenu->addSeparator();

View file

@ -11,7 +11,7 @@
#include <QMenu> #include <QMenu>
class Player; class PlayerLogic;
class UtilityMenu : public QMenu, public AbstractPlayerComponent class UtilityMenu : public QMenu, public AbstractPlayerComponent
{ {
Q_OBJECT Q_OBJECT
@ -22,7 +22,7 @@ public slots:
void setShortcutsInactive() override; void setShortcutsInactive() override;
public: public:
explicit UtilityMenu(Player *player, QMenu *playerMenu); explicit UtilityMenu(PlayerLogic *player, QMenu *playerMenu);
[[nodiscard]] bool createAnotherTokenActionExists() const [[nodiscard]] bool createAnotherTokenActionExists() const
{ {
@ -41,7 +41,7 @@ public:
} }
private: private:
Player *player; PlayerLogic *player;
QStringList predefinedTokens; QStringList predefinedTokens;
QMenu *createPredefinedTokenMenu; QMenu *createPredefinedTokenMenu;

View file

@ -36,7 +36,7 @@
// milliseconds in between triggers of the move top cards until action // milliseconds in between triggers of the move top cards until action
static constexpr int MOVE_TOP_CARD_UNTIL_INTERVAL = 100; static constexpr int MOVE_TOP_CARD_UNTIL_INTERVAL = 100;
PlayerActions::PlayerActions(Player *_player) PlayerActions::PlayerActions(PlayerLogic *_player)
: QObject(_player), player(_player), lastTokenTableRow(0), movingCardsUntil(false) : QObject(_player), player(_player), lastTokenTableRow(0), movingCardsUntil(false)
{ {
moveTopCardTimer = new QTimer(this); moveTopCardTimer = new QTimer(this);
@ -1770,7 +1770,7 @@ void PlayerActions::cardMenuAction()
return; return;
} }
Player *startPlayer = zone->getPlayer(); PlayerLogic *startPlayer = zone->getPlayer();
if (!startPlayer) { if (!startPlayer) {
return; return;
} }

View file

@ -10,7 +10,7 @@
#include "../dialogs/dlg_create_token.h" #include "../dialogs/dlg_create_token.h"
#include "../dialogs/dlg_move_top_cards_until.h" #include "../dialogs/dlg_move_top_cards_until.h"
#include "event_processing_options.h" #include "event_processing_options.h"
#include "player.h" #include "player_logic.h"
#include <QMenu> #include <QMenu>
#include <QObject> #include <QObject>
@ -29,7 +29,7 @@ class CardItem;
class Command_MoveCard; class Command_MoveCard;
class GameEventContext; class GameEventContext;
class PendingCommand; class PendingCommand;
class Player; class PlayerLogic;
class PlayerActions : public QObject class PlayerActions : public QObject
{ {
Q_OBJECT Q_OBJECT
@ -40,7 +40,7 @@ public:
RANDOM_CARD_FROM_ZONE = -2 RANDOM_CARD_FROM_ZONE = -2
}; };
explicit PlayerActions(Player *player); explicit PlayerActions(PlayerLogic *player);
void sendGameCommand(PendingCommand *pend); void sendGameCommand(PendingCommand *pend);
void sendGameCommand(const google::protobuf::Message &command); void sendGameCommand(const google::protobuf::Message &command);
@ -159,7 +159,7 @@ public slots:
void cardMenuAction(); void cardMenuAction();
private: private:
Player *player; PlayerLogic *player;
int defaultNumberTopCards = 1; int defaultNumberTopCards = 1;
int defaultNumberTopCardsToPlaceBelow = 1; int defaultNumberTopCardsToPlaceBelow = 1;

View file

@ -5,8 +5,8 @@
#include "../board/arrow_item.h" #include "../board/arrow_item.h"
#include "../board/card_item.h" #include "../board/card_item.h"
#include "../board/card_list.h" #include "../board/card_list.h"
#include "player.h"
#include "player_actions.h" #include "player_actions.h"
#include "player_logic.h"
#include <libcockatrice/protocol/pb/command_set_card_attr.pb.h> #include <libcockatrice/protocol/pb/command_set_card_attr.pb.h>
#include <libcockatrice/protocol/pb/context_move_card.pb.h> #include <libcockatrice/protocol/pb/context_move_card.pb.h>
@ -32,7 +32,7 @@
#include <libcockatrice/protocol/pb/event_shuffle.pb.h> #include <libcockatrice/protocol/pb/event_shuffle.pb.h>
#include <libcockatrice/utility/zone_names.h> #include <libcockatrice/utility/zone_names.h>
PlayerEventHandler::PlayerEventHandler(Player *_player) : QObject(_player), player(_player) PlayerEventHandler::PlayerEventHandler(PlayerLogic *_player) : QObject(_player), player(_player)
{ {
} }
@ -261,7 +261,7 @@ void PlayerEventHandler::eventDelCounter(const Event_DelCounter &event)
void PlayerEventHandler::eventDumpZone(const Event_DumpZone &event) void PlayerEventHandler::eventDumpZone(const Event_DumpZone &event)
{ {
Player *zoneOwner = player->getGame()->getPlayerManager()->getPlayers().value(event.zone_owner_id(), 0); PlayerLogic *zoneOwner = player->getGame()->getPlayerManager()->getPlayers().value(event.zone_owner_id(), 0);
if (!zoneOwner) { if (!zoneOwner) {
return; return;
} }
@ -274,13 +274,13 @@ void PlayerEventHandler::eventDumpZone(const Event_DumpZone &event)
void PlayerEventHandler::eventMoveCard(const Event_MoveCard &event, const GameEventContext &context) void PlayerEventHandler::eventMoveCard(const Event_MoveCard &event, const GameEventContext &context)
{ {
Player *startPlayer = player->getGame()->getPlayerManager()->getPlayers().value(event.start_player_id()); PlayerLogic *startPlayer = player->getGame()->getPlayerManager()->getPlayers().value(event.start_player_id());
if (!startPlayer) { if (!startPlayer) {
return; return;
} }
QString startZoneString = QString::fromStdString(event.start_zone()); QString startZoneString = QString::fromStdString(event.start_zone());
CardZoneLogic *startZone = startPlayer->getZones().value(startZoneString, 0); CardZoneLogic *startZone = startPlayer->getZones().value(startZoneString, 0);
Player *targetPlayer = player->getGame()->getPlayerManager()->getPlayers().value(event.target_player_id()); PlayerLogic *targetPlayer = player->getGame()->getPlayerManager()->getPlayers().value(event.target_player_id());
if (!targetPlayer) { if (!targetPlayer) {
return; return;
} }
@ -353,9 +353,9 @@ void PlayerEventHandler::eventMoveCard(const Event_MoveCard &event, const GameEv
// Look at all arrows from and to the card. // Look at all arrows from and to the card.
// If the card was moved to another zone, delete the arrows, otherwise update them. // If the card was moved to another zone, delete the arrows, otherwise update them.
QMapIterator<int, Player *> playerIterator(player->getGame()->getPlayerManager()->getPlayers()); QMapIterator<int, PlayerLogic *> playerIterator(player->getGame()->getPlayerManager()->getPlayers());
while (playerIterator.hasNext()) { while (playerIterator.hasNext()) {
Player *p = playerIterator.next().value(); PlayerLogic *p = playerIterator.next().value();
QList<ArrowItem *> arrowsToDelete; QList<ArrowItem *> arrowsToDelete;
QMapIterator<int, ArrowItem *> arrowIterator(p->getArrows()); QMapIterator<int, ArrowItem *> arrowIterator(p->getArrows());
@ -428,8 +428,8 @@ void PlayerEventHandler::eventDestroyCard(const Event_DestroyCard &event)
void PlayerEventHandler::eventAttachCard(const Event_AttachCard &event) void PlayerEventHandler::eventAttachCard(const Event_AttachCard &event)
{ {
const QMap<int, Player *> &playerList = player->getGame()->getPlayerManager()->getPlayers(); const QMap<int, PlayerLogic *> &playerList = player->getGame()->getPlayerManager()->getPlayers();
Player *targetPlayer = nullptr; PlayerLogic *targetPlayer = nullptr;
CardZoneLogic *targetZone = nullptr; CardZoneLogic *targetZone = nullptr;
CardItem *targetCard = nullptr; CardItem *targetCard = nullptr;
if (event.has_target_player_id()) { if (event.has_target_player_id()) {
@ -506,7 +506,7 @@ void PlayerEventHandler::eventRevealCards(const Event_RevealCards &event, EventP
if (!zone) { if (!zone) {
return; return;
} }
Player *otherPlayer = nullptr; PlayerLogic *otherPlayer = nullptr;
if (event.has_other_player_id()) { if (event.has_other_player_id()) {
otherPlayer = player->getGame()->getPlayerManager()->getPlayers().value(event.other_player_id()); otherPlayer = player->getGame()->getPlayerManager()->getPlayers().value(event.other_player_id());
if (!otherPlayer) { if (!otherPlayer) {

View file

@ -15,7 +15,7 @@
class CardItem; class CardItem;
class CardZoneLogic; class CardZoneLogic;
class Player; class PlayerLogic;
class Event_AttachCard; class Event_AttachCard;
class Event_ChangeZoneProperties; class Event_ChangeZoneProperties;
class Event_CreateArrow; class Event_CreateArrow;
@ -40,48 +40,48 @@ class PlayerEventHandler : public QObject
Q_OBJECT Q_OBJECT
signals: signals:
void logSay(Player *player, QString message); void logSay(PlayerLogic *player, QString message);
void logShuffle(Player *player, CardZoneLogic *zone, int start, int end); void logShuffle(PlayerLogic *player, CardZoneLogic *zone, int start, int end);
void logRollDie(Player *player, int sides, const QList<uint> &rolls); void logRollDie(PlayerLogic *player, int sides, const QList<uint> &rolls);
void logCreateArrow(Player *player, void logCreateArrow(PlayerLogic *player,
Player *startPlayer, PlayerLogic *startPlayer,
QString startCard, QString startCard,
Player *targetPlayer, PlayerLogic *targetPlayer,
QString targetCard, QString targetCard,
bool _playerTarget); bool _playerTarget);
void logCreateToken(Player *player, QString cardName, QString pt, bool faceDown); void logCreateToken(PlayerLogic *player, QString cardName, QString pt, bool faceDown);
void logDrawCards(Player *player, int number, bool deckIsEmpty); void logDrawCards(PlayerLogic *player, int number, bool deckIsEmpty);
void logUndoDraw(Player *player, QString cardName); void logUndoDraw(PlayerLogic *player, QString cardName);
void logMoveCard(Player *player, void logMoveCard(PlayerLogic *player,
CardItem *card, CardItem *card,
CardZoneLogic *startZone, CardZoneLogic *startZone,
int oldX, int oldX,
CardZoneLogic *targetZone, CardZoneLogic *targetZone,
int newX); int newX);
void logFlipCard(Player *player, QString cardName, bool faceDown); void logFlipCard(PlayerLogic *player, QString cardName, bool faceDown);
void logDestroyCard(Player *player, QString cardName); void logDestroyCard(PlayerLogic *player, QString cardName);
void logAttachCard(Player *player, QString cardName, Player *targetPlayer, QString targetCardName); void logAttachCard(PlayerLogic *player, QString cardName, PlayerLogic *targetPlayer, QString targetCardName);
void logUnattachCard(Player *player, QString cardName); void logUnattachCard(PlayerLogic *player, QString cardName);
void logSetCardCounter(Player *player, QString cardName, int counterId, int value, int oldValue); void logSetCardCounter(PlayerLogic *player, QString cardName, int counterId, int value, int oldValue);
void logSetTapped(Player *player, CardItem *card, bool tapped); void logSetTapped(PlayerLogic *player, CardItem *card, bool tapped);
void logSetCounter(Player *player, QString counterName, int value, int oldValue); void logSetCounter(PlayerLogic *player, QString counterName, int value, int oldValue);
void logSetDoesntUntap(Player *player, CardItem *card, bool doesntUntap); void logSetDoesntUntap(PlayerLogic *player, CardItem *card, bool doesntUntap);
void logSetPT(Player *player, CardItem *card, QString newPT); void logSetPT(PlayerLogic *player, CardItem *card, QString newPT);
void logSetAnnotation(Player *player, CardItem *card, QString newAnnotation); void logSetAnnotation(PlayerLogic *player, CardItem *card, QString newAnnotation);
void logDumpZone(Player *player, CardZoneLogic *zone, int numberCards, bool isReversed = false); void logDumpZone(PlayerLogic *player, CardZoneLogic *zone, int numberCards, bool isReversed = false);
void logRevealCards(Player *player, void logRevealCards(PlayerLogic *player,
CardZoneLogic *zone, CardZoneLogic *zone,
int cardId, int cardId,
QString cardName, QString cardName,
Player *otherPlayer, PlayerLogic *otherPlayer,
bool faceDown, bool faceDown,
int amount, int amount,
bool isLentToAnotherPlayer = false); bool isLentToAnotherPlayer = false);
void logAlwaysRevealTopCard(Player *player, CardZoneLogic *zone, bool reveal); void logAlwaysRevealTopCard(PlayerLogic *player, CardZoneLogic *zone, bool reveal);
void logAlwaysLookAtTopCard(Player *player, CardZoneLogic *zone, bool reveal); void logAlwaysLookAtTopCard(PlayerLogic *player, CardZoneLogic *zone, bool reveal);
public: public:
PlayerEventHandler(Player *player); PlayerEventHandler(PlayerLogic *player);
void processGameEvent(GameEvent::GameEventType type, void processGameEvent(GameEvent::GameEventType type,
const GameEvent &event, const GameEvent &event,
@ -110,7 +110,7 @@ public:
void eventChangeZoneProperties(const Event_ChangeZoneProperties &event); void eventChangeZoneProperties(const Event_ChangeZoneProperties &event);
private: private:
Player *player; PlayerLogic *player;
void setCardAttrHelper(const GameEventContext &context, void setCardAttrHelper(const GameEventContext &context,
CardItem *card, CardItem *card,

View file

@ -8,15 +8,15 @@
#include "../board/abstract_card_item.h" #include "../board/abstract_card_item.h"
#include "../hand_counter.h" #include "../hand_counter.h"
PlayerGraphicsItem::PlayerGraphicsItem(Player *_player) : player(_player) PlayerGraphicsItem::PlayerGraphicsItem(PlayerLogic *_player) : player(_player)
{ {
connect(&SettingsCache::instance(), &SettingsCache::horizontalHandChanged, this, connect(&SettingsCache::instance(), &SettingsCache::horizontalHandChanged, this,
&PlayerGraphicsItem::rearrangeZones); &PlayerGraphicsItem::rearrangeZones);
connect(&SettingsCache::instance(), &SettingsCache::handJustificationChanged, this, connect(&SettingsCache::instance(), &SettingsCache::handJustificationChanged, this,
&PlayerGraphicsItem::rearrangeZones); &PlayerGraphicsItem::rearrangeZones);
connect(player, &Player::rearrangeCounters, this, &PlayerGraphicsItem::rearrangeCounters); connect(player, &PlayerLogic::rearrangeCounters, this, &PlayerGraphicsItem::rearrangeCounters);
connect(player, &Player::concededChanged, this, [this](int, bool c) { setVisible(!c); }); connect(player, &PlayerLogic::concededChanged, this, [this](int, bool c) { setVisible(!c); });
connect(player, &Player::zoneIdChanged, this, [this](int id) { playerArea->setPlayerZoneId(id); }); connect(player, &PlayerLogic::zoneIdChanged, this, [this](int id) { playerArea->setPlayerZoneId(id); });
playerArea = new PlayerArea(this); playerArea = new PlayerArea(this);

View file

@ -7,7 +7,7 @@
#ifndef COCKATRICE_PLAYER_GRAPHICS_ITEM_H #ifndef COCKATRICE_PLAYER_GRAPHICS_ITEM_H
#define COCKATRICE_PLAYER_GRAPHICS_ITEM_H #define COCKATRICE_PLAYER_GRAPHICS_ITEM_H
#include "../game_scene.h" #include "../game_scene.h"
#include "player.h" #include "player_logic.h"
#include <QGraphicsObject> #include <QGraphicsObject>
@ -34,7 +34,7 @@ public:
static constexpr int counterAreaWidth = 55; static constexpr int counterAreaWidth = 55;
explicit PlayerGraphicsItem(Player *player); explicit PlayerGraphicsItem(PlayerLogic *player);
void initializeZones(); void initializeZones();
[[nodiscard]] QRectF boundingRect() const override; [[nodiscard]] QRectF boundingRect() const override;
@ -54,7 +54,7 @@ public:
return static_cast<GameScene *>(scene()); return static_cast<GameScene *>(scene());
} }
Player *getPlayer() const PlayerLogic *getPlayer() const
{ {
return player; return player;
} }
@ -109,7 +109,7 @@ signals:
void playerCountChanged(); void playerCountChanged();
private: private:
Player *player; PlayerLogic *player;
PlayerArea *playerArea; PlayerArea *playerArea;
PlayerTarget *playerTarget; PlayerTarget *playerTarget;
PileZone *deckZoneGraphicsItem; PileZone *deckZoneGraphicsItem;

View file

@ -7,7 +7,7 @@
#ifndef PLAYERLISTWIDGET_H #ifndef PLAYERLISTWIDGET_H
#define PLAYERLISTWIDGET_H #define PLAYERLISTWIDGET_H
#include "player.h" #include "player_logic.h"
#include <QIcon> #include <QIcon>
#include <QMap> #include <QMap>

View file

@ -1,4 +1,4 @@
#include "player.h" #include "player_logic.h"
#include "../../game_graphics/zones/hand_zone.h" #include "../../game_graphics/zones/hand_zone.h"
#include "../../game_graphics/zones/pile_zone.h" #include "../../game_graphics/zones/pile_zone.h"
@ -29,7 +29,7 @@
#include <libcockatrice/protocol/pb/serverinfo_zone.pb.h> #include <libcockatrice/protocol/pb/serverinfo_zone.pb.h>
#include <libcockatrice/utility/color.h> #include <libcockatrice/utility/color.h>
Player::Player(const ServerInfo_User &info, int _id, bool _local, bool _judge, AbstractGame *_parent) PlayerLogic::PlayerLogic(const ServerInfo_User &info, int _id, bool _local, bool _judge, AbstractGame *_parent)
: QObject(_parent), game(_parent), playerInfo(new PlayerInfo(info, _id, _local, _judge)), : QObject(_parent), game(_parent), playerInfo(new PlayerInfo(info, _id, _local, _judge)),
playerEventHandler(new PlayerEventHandler(this)), playerActions(new PlayerActions(this)), active(false), playerEventHandler(new PlayerEventHandler(this)), playerActions(new PlayerActions(this)), active(false),
conceded(false), zoneId(0), dialogSemaphore(false) conceded(false), zoneId(0), dialogSemaphore(false)
@ -40,12 +40,12 @@ Player::Player(const ServerInfo_User &info, int _id, bool _local, bool _judge, A
graphicsItem = new PlayerGraphicsItem(this); graphicsItem = new PlayerGraphicsItem(this);
playerMenu->setMenusForGraphicItems(); playerMenu->setMenusForGraphicItems();
connect(this, &Player::activeChanged, graphicsItem, &PlayerGraphicsItem::onPlayerActiveChanged); connect(this, &PlayerLogic::activeChanged, graphicsItem, &PlayerGraphicsItem::onPlayerActiveChanged);
connect(this, &Player::openDeckEditor, game->getTab(), &TabGame::openDeckEditor); connect(this, &PlayerLogic::openDeckEditor, game->getTab(), &TabGame::openDeckEditor);
} }
void Player::initializeZones() void PlayerLogic::initializeZones()
{ {
addZone(new PileZoneLogic(this, ZoneNames::DECK, false, true, false, this)); addZone(new PileZoneLogic(this, ZoneNames::DECK, false, true, false, this));
addZone(new PileZoneLogic(this, ZoneNames::GRAVE, false, false, true, this)); addZone(new PileZoneLogic(this, ZoneNames::GRAVE, false, false, true, this));
@ -58,7 +58,7 @@ void Player::initializeZones()
addZone(new HandZoneLogic(this, ZoneNames::HAND, false, false, visibleHand, this)); addZone(new HandZoneLogic(this, ZoneNames::HAND, false, false, visibleHand, this));
} }
Player::~Player() PlayerLogic::~PlayerLogic()
{ {
qCInfo(PlayerLog) << "Player destructor:" << getPlayerInfo()->getName(); qCInfo(PlayerLog) << "Player destructor:" << getPlayerInfo()->getName();
@ -72,7 +72,7 @@ Player::~Player()
delete getPlayerInfo()->userInfo; delete getPlayerInfo()->userInfo;
} }
void Player::clear() void PlayerLogic::clear()
{ {
clearArrows(); clearArrows();
@ -84,7 +84,7 @@ void Player::clear()
clearCounters(); clearCounters();
} }
void Player::setConceded(bool _conceded) void PlayerLogic::setConceded(bool _conceded)
{ {
if (conceded != _conceded) { if (conceded != _conceded) {
conceded = _conceded; conceded = _conceded;
@ -96,7 +96,7 @@ void Player::setConceded(bool _conceded)
} }
} }
void Player::setZoneId(int _zoneId) void PlayerLogic::setZoneId(int _zoneId)
{ {
if (zoneId != _zoneId) { if (zoneId != _zoneId) {
zoneId = _zoneId; zoneId = _zoneId;
@ -104,7 +104,7 @@ void Player::setZoneId(int _zoneId)
} }
} }
void Player::processPlayerInfo(const ServerInfo_Player &info) void PlayerLogic::processPlayerInfo(const ServerInfo_Player &info)
{ {
static QSet<QString> builtinZones{/* PileZones */ static QSet<QString> builtinZones{/* PileZones */
ZoneNames::DECK, ZoneNames::GRAVE, ZoneNames::EXILE, ZoneNames::SIDEBOARD, ZoneNames::DECK, ZoneNames::GRAVE, ZoneNames::EXILE, ZoneNames::SIDEBOARD,
@ -202,7 +202,7 @@ void Player::processPlayerInfo(const ServerInfo_Player &info)
setConceded(info.properties().conceded()); setConceded(info.properties().conceded());
} }
void Player::processCardAttachment(const ServerInfo_Player &info) void PlayerLogic::processCardAttachment(const ServerInfo_Player &info)
{ {
const int zoneListSize = info.zone_list_size(); const int zoneListSize = info.zone_list_size();
for (int i = 0; i < zoneListSize; ++i) { for (int i = 0; i < zoneListSize; ++i) {
@ -235,12 +235,12 @@ void Player::processCardAttachment(const ServerInfo_Player &info)
} }
} }
void Player::addCard(CardItem *card) void PlayerLogic::addCard(CardItem *card)
{ {
emit newCardAdded(card); emit newCardAdded(card);
} }
void Player::deleteCard(CardItem *card) void PlayerLogic::deleteCard(CardItem *card)
{ {
if (card == nullptr) { if (card == nullptr) {
return; return;
@ -251,20 +251,20 @@ void Player::deleteCard(CardItem *card)
} }
} }
void Player::setDeck(const DeckList &_deck) void PlayerLogic::setDeck(const DeckList &_deck)
{ {
deck = _deck; deck = _deck;
emit deckChanged(); emit deckChanged();
} }
AbstractCounter *Player::addCounter(const ServerInfo_Counter &counter) AbstractCounter *PlayerLogic::addCounter(const ServerInfo_Counter &counter)
{ {
return addCounter(counter.id(), QString::fromStdString(counter.name()), return addCounter(counter.id(), QString::fromStdString(counter.name()),
convertColorToQColor(counter.counter_color()), counter.radius(), counter.count()); convertColorToQColor(counter.counter_color()), counter.radius(), counter.count());
} }
AbstractCounter *Player::addCounter(int counterId, const QString &name, QColor color, int radius, int value) AbstractCounter *PlayerLogic::addCounter(int counterId, const QString &name, QColor color, int radius, int value)
{ {
if (counters.contains(counterId)) { if (counters.contains(counterId)) {
return nullptr; return nullptr;
@ -288,7 +288,7 @@ AbstractCounter *Player::addCounter(int counterId, const QString &name, QColor c
return ctr; return ctr;
} }
void Player::delCounter(int counterId) void PlayerLogic::delCounter(int counterId)
{ {
AbstractCounter *ctr = counters.value(counterId, 0); AbstractCounter *ctr = counters.value(counterId, 0);
if (!ctr) { if (!ctr) {
@ -300,7 +300,7 @@ void Player::delCounter(int counterId)
emit rearrangeCounters(); emit rearrangeCounters();
} }
void Player::clearCounters() void PlayerLogic::clearCounters()
{ {
QMapIterator<int, AbstractCounter *> counterIterator(counters); QMapIterator<int, AbstractCounter *> counterIterator(counters);
while (counterIterator.hasNext()) { while (counterIterator.hasNext()) {
@ -309,7 +309,7 @@ void Player::clearCounters()
counters.clear(); counters.clear();
} }
void Player::incrementAllCardCounters() void PlayerLogic::incrementAllCardCounters()
{ {
auto cardsToUpdate = getGameScene()->selectedCards(); auto cardsToUpdate = getGameScene()->selectedCards();
if (cardsToUpdate.isEmpty()) { if (cardsToUpdate.isEmpty()) {
@ -345,7 +345,7 @@ void Player::incrementAllCardCounters()
} }
} }
AbstractCounter *Player::getLifeCounter() const AbstractCounter *PlayerLogic::getLifeCounter() const
{ {
for (auto counter : counters.values()) { for (auto counter : counters.values()) {
if (counter->getName() == "life") { if (counter->getName() == "life") {
@ -355,11 +355,11 @@ AbstractCounter *Player::getLifeCounter() const
return nullptr; return nullptr;
} }
ArrowItem *Player::addArrow(const ServerInfo_Arrow &arrow) ArrowItem *PlayerLogic::addArrow(const ServerInfo_Arrow &arrow)
{ {
const QMap<int, Player *> &playerList = game->getPlayerManager()->getPlayers(); const QMap<int, PlayerLogic *> &playerList = game->getPlayerManager()->getPlayers();
Player *startPlayer = playerList.value(arrow.start_player_id(), 0); PlayerLogic *startPlayer = playerList.value(arrow.start_player_id(), 0);
Player *targetPlayer = playerList.value(arrow.target_player_id(), 0); PlayerLogic *targetPlayer = playerList.value(arrow.target_player_id(), 0);
if (!startPlayer || !targetPlayer) { if (!startPlayer || !targetPlayer) {
return nullptr; return nullptr;
} }
@ -390,7 +390,7 @@ ArrowItem *Player::addArrow(const ServerInfo_Arrow &arrow)
} }
} }
ArrowItem *Player::addArrow(int arrowId, CardItem *startCard, ArrowTarget *targetItem, const QColor &color) ArrowItem *PlayerLogic::addArrow(int arrowId, CardItem *startCard, ArrowTarget *targetItem, const QColor &color)
{ {
auto *arrow = new ArrowItem(this, arrowId, startCard, targetItem, color); auto *arrow = new ArrowItem(this, arrowId, startCard, targetItem, color);
arrows.insert(arrowId, arrow); arrows.insert(arrowId, arrow);
@ -399,7 +399,7 @@ ArrowItem *Player::addArrow(int arrowId, CardItem *startCard, ArrowTarget *targe
return arrow; return arrow;
} }
void Player::delArrow(int arrowId) void PlayerLogic::delArrow(int arrowId)
{ {
ArrowItem *arr = arrows.value(arrowId, 0); ArrowItem *arr = arrows.value(arrowId, 0);
if (!arr) { if (!arr) {
@ -408,14 +408,14 @@ void Player::delArrow(int arrowId)
arr->delArrow(); arr->delArrow();
} }
void Player::removeArrow(ArrowItem *arrow) void PlayerLogic::removeArrow(ArrowItem *arrow)
{ {
if (arrow->getId() != -1) { if (arrow->getId() != -1) {
arrows.remove(arrow->getId()); arrows.remove(arrow->getId());
} }
} }
void Player::clearArrows() void PlayerLogic::clearArrows()
{ {
QMapIterator<int, ArrowItem *> arrowIterator(arrows); QMapIterator<int, ArrowItem *> arrowIterator(arrows);
while (arrowIterator.hasNext()) { while (arrowIterator.hasNext()) {
@ -424,7 +424,7 @@ void Player::clearArrows()
arrows.clear(); arrows.clear();
} }
bool Player::clearCardsToDelete() bool PlayerLogic::clearCardsToDelete()
{ {
if (cardsToDelete.isEmpty()) { if (cardsToDelete.isEmpty()) {
return false; return false;
@ -440,28 +440,28 @@ bool Player::clearCardsToDelete()
return true; return true;
} }
void Player::setActive(bool _active) void PlayerLogic::setActive(bool _active)
{ {
active = _active; active = _active;
emit activeChanged(active); emit activeChanged(active);
} }
void Player::updateZones() void PlayerLogic::updateZones()
{ {
getTableZone()->reorganizeCards(); getTableZone()->reorganizeCards();
} }
PlayerGraphicsItem *Player::getGraphicsItem() PlayerGraphicsItem *PlayerLogic::getGraphicsItem()
{ {
return graphicsItem; return graphicsItem;
} }
GameScene *Player::getGameScene() GameScene *PlayerLogic::getGameScene()
{ {
return getGraphicsItem()->getGameScene(); return getGraphicsItem()->getGameScene();
} }
void Player::setGameStarted() void PlayerLogic::setGameStarted()
{ {
if (playerInfo->local) { if (playerInfo->local) {
emit resetTopCardMenuActions(); emit resetTopCardMenuActions();

View file

@ -62,7 +62,7 @@ class TabGame;
const int MAX_TOKENS_PER_DIALOG = 99; const int MAX_TOKENS_PER_DIALOG = 99;
class Player : public QObject class PlayerLogic : public QObject
{ {
Q_OBJECT Q_OBJECT
@ -82,8 +82,8 @@ public slots:
void setActive(bool _active); void setActive(bool _active);
public: public:
Player(const ServerInfo_User &info, int _id, bool _local, bool _judge, AbstractGame *_parent); PlayerLogic(const ServerInfo_User &info, int _id, bool _local, bool _judge, AbstractGame *_parent);
~Player() override; ~PlayerLogic() override;
void initializeZones(); void initializeZones();
void updateZones(); void updateZones();

View file

@ -1,35 +1,35 @@
#include "player_manager.h" #include "player_manager.h"
#include "../abstract_game.h" #include "../abstract_game.h"
#include "player.h" #include "player_logic.h"
PlayerManager::PlayerManager(AbstractGame *_game, PlayerManager::PlayerManager(AbstractGame *_game,
int _localPlayerId, int _localPlayerId,
bool _localPlayerIsJudge, bool _localPlayerIsJudge,
bool localPlayerIsSpectator) bool localPlayerIsSpectator)
: QObject(_game), game(_game), players(QMap<int, Player *>()), localPlayerId(_localPlayerId), : QObject(_game), game(_game), players(QMap<int, PlayerLogic *>()), localPlayerId(_localPlayerId),
localPlayerIsJudge(_localPlayerIsJudge), localPlayerIsSpectator(localPlayerIsSpectator) localPlayerIsJudge(_localPlayerIsJudge), localPlayerIsSpectator(localPlayerIsSpectator)
{ {
} }
bool PlayerManager::isMainPlayerConceded() const bool PlayerManager::isMainPlayerConceded() const
{ {
Player *player = players.value(localPlayerId, nullptr); PlayerLogic *player = players.value(localPlayerId, nullptr);
return player && player->getConceded(); return player && player->getConceded();
} }
Player *PlayerManager::getActiveLocalPlayer(int activePlayer) const PlayerLogic *PlayerManager::getActiveLocalPlayer(int activePlayer) const
{ {
Player *active = players.value(activePlayer, 0); PlayerLogic *active = players.value(activePlayer, 0);
if (active) { if (active) {
if (active->getPlayerInfo()->getLocal()) { if (active->getPlayerInfo()->getLocal()) {
return active; return active;
} }
} }
QMapIterator<int, Player *> playerIterator(players); QMapIterator<int, PlayerLogic *> playerIterator(players);
while (playerIterator.hasNext()) { while (playerIterator.hasNext()) {
Player *temp = playerIterator.next().value(); PlayerLogic *temp = playerIterator.next().value();
if (temp->getPlayerInfo()->getLocal()) { if (temp->getPlayerInfo()->getLocal()) {
return temp; return temp;
} }
@ -43,11 +43,11 @@ bool PlayerManager::isLocalPlayer(int playerId)
return game->getGameState()->getIsLocalGame() || playerId == localPlayerId; return game->getGameState()->getIsLocalGame() || playerId == localPlayerId;
} }
Player *PlayerManager::addPlayer(int playerId, const ServerInfo_User &info) PlayerLogic *PlayerManager::addPlayer(int playerId, const ServerInfo_User &info)
{ {
auto *newPlayer = new Player(info, playerId, isLocalPlayer(playerId) || game->getGameState()->getIsLocalGame(), auto *newPlayer = new PlayerLogic(info, playerId, isLocalPlayer(playerId) || game->getGameState()->getIsLocalGame(),
isJudge(), getGame()); isJudge(), getGame());
connect(newPlayer, &Player::concededChanged, this, &PlayerManager::onPlayerConceded); connect(newPlayer, &PlayerLogic::concededChanged, this, &PlayerManager::onPlayerConceded);
players.insert(playerId, newPlayer); players.insert(playerId, newPlayer);
emit playerAdded(newPlayer); emit playerAdded(newPlayer);
emit playerCountChanged(); emit playerCountChanged();
@ -56,7 +56,7 @@ Player *PlayerManager::addPlayer(int playerId, const ServerInfo_User &info)
void PlayerManager::removePlayer(int playerId) void PlayerManager::removePlayer(int playerId)
{ {
Player *player = getPlayer(playerId); PlayerLogic *player = getPlayer(playerId);
if (!player) { if (!player) {
return; return;
} }
@ -66,9 +66,9 @@ void PlayerManager::removePlayer(int playerId)
player->deleteLater(); player->deleteLater();
} }
Player *PlayerManager::getPlayer(int playerId) const PlayerLogic *PlayerManager::getPlayer(int playerId) const
{ {
Player *player = players.value(playerId, 0); PlayerLogic *player = players.value(playerId, 0);
if (!player) { if (!player) {
return nullptr; return nullptr;
} }

View file

@ -12,7 +12,7 @@
#include <libcockatrice/protocol/pb/serverinfo_playerproperties.pb.h> #include <libcockatrice/protocol/pb/serverinfo_playerproperties.pb.h>
class AbstractGame; class AbstractGame;
class Player; class PlayerLogic;
class PlayerManager : public QObject class PlayerManager : public QObject
{ {
Q_OBJECT Q_OBJECT
@ -21,7 +21,7 @@ public:
PlayerManager(AbstractGame *_game, int _localPlayerId, bool _localPlayerIsJudge, bool localPlayerIsSpectator); PlayerManager(AbstractGame *_game, int _localPlayerId, bool _localPlayerIsJudge, bool localPlayerIsSpectator);
AbstractGame *game; AbstractGame *game;
QMap<int, Player *> players; QMap<int, PlayerLogic *> players;
int localPlayerId; int localPlayerId;
bool localPlayerIsJudge; bool localPlayerIsJudge;
bool localPlayerIsSpectator; bool localPlayerIsSpectator;
@ -42,7 +42,7 @@ public:
return localPlayerId; return localPlayerId;
} }
[[nodiscard]] const QMap<int, Player *> &getPlayers() const [[nodiscard]] const QMap<int, PlayerLogic *> &getPlayers() const
{ {
return players; return players;
} }
@ -52,14 +52,14 @@ public:
return players.size(); return players.size();
} }
[[nodiscard]] Player *getActiveLocalPlayer(int activePlayer) const; [[nodiscard]] PlayerLogic *getActiveLocalPlayer(int activePlayer) const;
bool isLocalPlayer(int playerId); bool isLocalPlayer(int playerId);
Player *addPlayer(int playerId, const ServerInfo_User &info); PlayerLogic *addPlayer(int playerId, const ServerInfo_User &info);
void removePlayer(int playerId); void removePlayer(int playerId);
[[nodiscard]] Player *getPlayer(int playerId) const; [[nodiscard]] PlayerLogic *getPlayer(int playerId) const;
void onPlayerConceded(int playerId, bool conceded); void onPlayerConceded(int playerId, bool conceded);
@ -106,8 +106,8 @@ public:
} }
signals: signals:
void playerAdded(Player *player); void playerAdded(PlayerLogic *player);
void playerRemoved(Player *player); void playerRemoved(PlayerLogic *player);
void activeLocalPlayerConceded(); void activeLocalPlayerConceded();
void activeLocalPlayerUnconceded(); void activeLocalPlayerUnconceded();
void playerConceded(int playerId); void playerConceded(int playerId);

View file

@ -1,7 +1,7 @@
#include "player_target.h" #include "player_target.h"
#include "../../interface/pixel_map_generator.h" #include "../../interface/pixel_map_generator.h"
#include "player.h" #include "player_logic.h"
#include <QDebug> #include <QDebug>
#include <QPainter> #include <QPainter>
@ -9,7 +9,7 @@
#include <QtMath> #include <QtMath>
#include <libcockatrice/protocol/pb/serverinfo_user.pb.h> #include <libcockatrice/protocol/pb/serverinfo_user.pb.h>
PlayerCounter::PlayerCounter(Player *_player, int _id, const QString &_name, int _value, QGraphicsItem *parent) PlayerCounter::PlayerCounter(PlayerLogic *_player, int _id, const QString &_name, int _value, QGraphicsItem *parent)
: AbstractCounter(_player, _id, _name, false, _value, false, parent) : AbstractCounter(_player, _id, _name, false, _value, false, parent)
{ {
} }
@ -47,7 +47,7 @@ void PlayerCounter::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*
painter->drawText(translatedRect, Qt::AlignCenter, QString::number(value)); painter->drawText(translatedRect, Qt::AlignCenter, QString::number(value));
} }
PlayerTarget::PlayerTarget(Player *_owner, QGraphicsItem *parentItem) PlayerTarget::PlayerTarget(PlayerLogic *_owner, QGraphicsItem *parentItem)
: ArrowTarget(_owner, parentItem), playerCounter(nullptr) : ArrowTarget(_owner, parentItem), playerCounter(nullptr)
{ {
setCacheMode(DeviceCoordinateCache); setCacheMode(DeviceCoordinateCache);

View file

@ -13,13 +13,13 @@
#include <QPixmap> #include <QPixmap>
class Player; class PlayerLogic;
class PlayerCounter : public AbstractCounter class PlayerCounter : public AbstractCounter
{ {
Q_OBJECT Q_OBJECT
public: public:
PlayerCounter(Player *_player, int _id, const QString &_name, int _value, QGraphicsItem *parent = nullptr); PlayerCounter(PlayerLogic *_player, int _id, const QString &_name, int _value, QGraphicsItem *parent = nullptr);
QRectF boundingRect() const override; QRectF boundingRect() const override;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override; void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
}; };
@ -43,7 +43,7 @@ public:
return Type; return Type;
} }
explicit PlayerTarget(Player *_player = nullptr, QGraphicsItem *parentItem = nullptr); explicit PlayerTarget(PlayerLogic *_player = nullptr, QGraphicsItem *parentItem = nullptr);
~PlayerTarget() override; ~PlayerTarget() override;
QRectF boundingRect() const override; QRectF boundingRect() const override;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override; void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;

View file

@ -2,8 +2,8 @@
#include "../../game_graphics/zones/view_zone.h" #include "../../game_graphics/zones/view_zone.h"
#include "../board/card_item.h" #include "../board/card_item.h"
#include "../player/player.h"
#include "../player/player_actions.h" #include "../player/player_actions.h"
#include "../player/player_logic.h"
#include "view_zone_logic.h" #include "view_zone_logic.h"
#include <QAction> #include <QAction>
@ -20,7 +20,7 @@
* @param _contentsKnown whether the cards in the zone are known to the client * @param _contentsKnown whether the cards in the zone are known to the client
* @param parent the parent QObject. * @param parent the parent QObject.
*/ */
CardZoneLogic::CardZoneLogic(Player *_player, CardZoneLogic::CardZoneLogic(PlayerLogic *_player,
const QString &_name, const QString &_name,
bool _hasCardAttr, bool _hasCardAttr,
bool _isShufflable, bool _isShufflable,

View file

@ -15,7 +15,7 @@
inline Q_LOGGING_CATEGORY(CardZoneLogicLog, "card_zone_logic"); inline Q_LOGGING_CATEGORY(CardZoneLogicLog, "card_zone_logic");
class Player; class PlayerLogic;
class ZoneViewZone; class ZoneViewZone;
class QMenu; class QMenu;
class QAction; class QAction;
@ -35,7 +35,7 @@ signals:
void retranslateUi(); void retranslateUi();
public: public:
explicit CardZoneLogic(Player *_player, explicit CardZoneLogic(PlayerLogic *_player,
const QString &_name, const QString &_name,
bool _hasCardAttr, bool _hasCardAttr,
bool _isShufflable, bool _isShufflable,
@ -68,7 +68,7 @@ public:
return name; return name;
} }
[[nodiscard]] QString getTranslatedName(bool theirOwn, GrammaticalCase gc) const; [[nodiscard]] QString getTranslatedName(bool theirOwn, GrammaticalCase gc) const;
[[nodiscard]] Player *getPlayer() const [[nodiscard]] PlayerLogic *getPlayer() const
{ {
return player; return player;
} }
@ -105,7 +105,7 @@ private slots:
void refreshCardInfos(); void refreshCardInfos();
protected: protected:
Player *player; PlayerLogic *player;
QString name; QString name;
CardList cards; CardList cards;
QList<ZoneViewZone *> views; QList<ZoneViewZone *> views;

View file

@ -3,7 +3,7 @@
#include "../board/card_item.h" #include "../board/card_item.h"
#include "card_zone_algorithms.h" #include "card_zone_algorithms.h"
HandZoneLogic::HandZoneLogic(Player *_player, HandZoneLogic::HandZoneLogic(PlayerLogic *_player,
const QString &_name, const QString &_name,
bool _hasCardAttr, bool _hasCardAttr,
bool _isShufflable, bool _isShufflable,

View file

@ -12,7 +12,7 @@ class HandZoneLogic : public CardZoneLogic
{ {
Q_OBJECT Q_OBJECT
public: public:
HandZoneLogic(Player *_player, HandZoneLogic(PlayerLogic *_player,
const QString &_name, const QString &_name,
bool _hasCardAttr, bool _hasCardAttr,
bool _isShufflable, bool _isShufflable,

View file

@ -2,7 +2,7 @@
#include "../board/card_item.h" #include "../board/card_item.h"
PileZoneLogic::PileZoneLogic(Player *_player, PileZoneLogic::PileZoneLogic(PlayerLogic *_player,
const QString &_name, const QString &_name,
bool _hasCardAttr, bool _hasCardAttr,
bool _isShufflable, bool _isShufflable,

View file

@ -17,7 +17,7 @@ signals:
void callUpdate(); void callUpdate();
public: public:
PileZoneLogic(Player *_player, PileZoneLogic(PlayerLogic *_player,
const QString &_name, const QString &_name,
bool _hasCardAttr, bool _hasCardAttr,
bool _isShufflable, bool _isShufflable,

View file

@ -3,7 +3,7 @@
#include "../board/card_item.h" #include "../board/card_item.h"
#include "card_zone_algorithms.h" #include "card_zone_algorithms.h"
StackZoneLogic::StackZoneLogic(Player *_player, StackZoneLogic::StackZoneLogic(PlayerLogic *_player,
const QString &_name, const QString &_name,
bool _hasCardAttr, bool _hasCardAttr,
bool _isShufflable, bool _isShufflable,

View file

@ -12,7 +12,7 @@ class StackZoneLogic : public CardZoneLogic
{ {
Q_OBJECT Q_OBJECT
public: public:
StackZoneLogic(Player *_player, StackZoneLogic(PlayerLogic *_player,
const QString &_name, const QString &_name,
bool _hasCardAttr, bool _hasCardAttr,
bool _isShufflable, bool _isShufflable,

View file

@ -2,7 +2,7 @@
#include "../board/card_item.h" #include "../board/card_item.h"
TableZoneLogic::TableZoneLogic(Player *_player, TableZoneLogic::TableZoneLogic(PlayerLogic *_player,
const QString &_name, const QString &_name,
bool _hasCardAttr, bool _hasCardAttr,
bool _isShufflable, bool _isShufflable,

View file

@ -16,7 +16,7 @@ signals:
void toggleTapped(); void toggleTapped();
public: public:
TableZoneLogic(Player *_player, TableZoneLogic(PlayerLogic *_player,
const QString &_name, const QString &_name,
bool _hasCardAttr, bool _hasCardAttr,
bool _isShufflable, bool _isShufflable,

View file

@ -9,7 +9,7 @@
* @param _revealZone if false, the cards will be face down. * @param _revealZone if false, the cards will be face down.
* @param _writeableRevealZone whether the player can interact with the revealed cards. * @param _writeableRevealZone whether the player can interact with the revealed cards.
*/ */
ZoneViewZoneLogic::ZoneViewZoneLogic(Player *_player, ZoneViewZoneLogic::ZoneViewZoneLogic(PlayerLogic *_player,
CardZoneLogic *_origZone, CardZoneLogic *_origZone,
int _numberCards, int _numberCards,
bool _revealZone, bool _revealZone,

View file

@ -30,7 +30,7 @@ public:
REMOVE_CARD REMOVE_CARD
}; };
ZoneViewZoneLogic(Player *_player, ZoneViewZoneLogic(PlayerLogic *_player,
CardZoneLogic *_origZone, CardZoneLogic *_origZone,
int _numberCards, int _numberCards,
bool _revealZone, bool _revealZone,

View file

@ -3,8 +3,8 @@
#include "../../client/settings/cache_settings.h" #include "../../client/settings/cache_settings.h"
#include "../../game/board/card_drag_item.h" #include "../../game/board/card_drag_item.h"
#include "../../game/board/card_item.h" #include "../../game/board/card_item.h"
#include "../../game/player/player.h"
#include "../../game/player/player_actions.h" #include "../../game/player/player_actions.h"
#include "../../game/player/player_logic.h"
#include "../../interface/theme_manager.h" #include "../../interface/theme_manager.h"
#include <QPainter> #include <QPainter>

View file

@ -2,8 +2,8 @@
#include "../../game/board/card_drag_item.h" #include "../../game/board/card_drag_item.h"
#include "../../game/board/card_item.h" #include "../../game/board/card_item.h"
#include "../../game/player/player.h"
#include "../../game/player/player_actions.h" #include "../../game/player/player_actions.h"
#include "../../game/player/player_logic.h"
#include "../../game/zones/pile_zone_logic.h" #include "../../game/zones/pile_zone_logic.h"
#include "view_zone.h" #include "view_zone.h"

View file

@ -3,8 +3,8 @@
#include "../../game/board/card_drag_item.h" #include "../../game/board/card_drag_item.h"
#include "../../game/board/card_item.h" #include "../../game/board/card_item.h"
#include "../../game/card_dimensions.h" #include "../../game/card_dimensions.h"
#include "../../game/player/player.h"
#include "../../game/player/player_actions.h" #include "../../game/player/player_actions.h"
#include "../../game/player/player_logic.h"
#include "../../game/zones/stack_zone_logic.h" #include "../../game/zones/stack_zone_logic.h"
#include "../../interface/theme_manager.h" #include "../../interface/theme_manager.h"

View file

@ -4,8 +4,8 @@
#include "../../game/board/arrow_item.h" #include "../../game/board/arrow_item.h"
#include "../../game/board/card_drag_item.h" #include "../../game/board/card_drag_item.h"
#include "../../game/board/card_item.h" #include "../../game/board/card_item.h"
#include "../../game/player/player.h"
#include "../../game/player/player_actions.h" #include "../../game/player/player_actions.h"
#include "../../game/player/player_logic.h"
#include "../../game/z_values.h" #include "../../game/z_values.h"
#include "../../game/zones/table_zone_logic.h" #include "../../game/zones/table_zone_logic.h"
#include "../../interface/theme_manager.h" #include "../../interface/theme_manager.h"

View file

@ -2,8 +2,8 @@
#include "../../game/board/card_drag_item.h" #include "../../game/board/card_drag_item.h"
#include "../../game/board/card_item.h" #include "../../game/board/card_item.h"
#include "../../game/player/player.h"
#include "../../game/player/player_actions.h" #include "../../game/player/player_actions.h"
#include "../../game/player/player_logic.h"
#include "../../game/zones/view_zone_logic.h" #include "../../game/zones/view_zone_logic.h"
#include <QBrush> #include <QBrush>

View file

@ -4,8 +4,8 @@
#include "../../filters/syntax_help.h" #include "../../filters/syntax_help.h"
#include "../../game/board/card_item.h" #include "../../game/board/card_item.h"
#include "../../game/game_scene.h" #include "../../game/game_scene.h"
#include "../../game/player/player.h"
#include "../../game/player/player_actions.h" #include "../../game/player/player_actions.h"
#include "../../game/player/player_logic.h"
#include "../../game/z_values.h" #include "../../game/z_values.h"
#include "../../interface/pixel_map_generator.h" #include "../../interface/pixel_map_generator.h"
#include "view_zone.h" #include "view_zone.h"
@ -37,7 +37,7 @@ constexpr qreal kMinVisibleWidth = 100.0;
* @param _revealZone if false, the cards will be face down. * @param _revealZone if false, the cards will be face down.
* @param _writeableRevealZone whether the player can interact with the revealed cards. * @param _writeableRevealZone whether the player can interact with the revealed cards.
*/ */
ZoneViewWidget::ZoneViewWidget(Player *_player, ZoneViewWidget::ZoneViewWidget(PlayerLogic *_player,
CardZoneLogic *_origZone, CardZoneLogic *_origZone,
int numberCards, int numberCards,
bool _revealZone, bool _revealZone,

View file

@ -20,7 +20,7 @@ class QLabel;
class QPushButton; class QPushButton;
class CardZone; class CardZone;
class ZoneViewZone; class ZoneViewZone;
class Player; class PlayerLogic;
class CardDatabase; class CardDatabase;
class QScrollBar; class QScrollBar;
class GameScene; class GameScene;
@ -65,7 +65,7 @@ private:
bool canBeShuffled; bool canBeShuffled;
int extraHeight; int extraHeight;
Player *player; PlayerLogic *player;
bool draggingWindow = false; bool draggingWindow = false;
QPoint dragStartScreenPos; QPoint dragStartScreenPos;
@ -108,7 +108,7 @@ private slots:
void expandWindow(); void expandWindow();
public: public:
ZoneViewWidget(Player *_player, ZoneViewWidget(PlayerLogic *_player,
CardZoneLogic *_origZone, CardZoneLogic *_origZone,
int numberCards = 0, int numberCards = 0,
bool _revealZone = false, bool _revealZone = false,
@ -119,7 +119,7 @@ public:
{ {
return zone; return zone;
} }
Player *getPlayer() const PlayerLogic *getPlayer() const
{ {
return player; return player;
} }

View file

@ -10,8 +10,8 @@
#include "../game/game_view.h" #include "../game/game_view.h"
#include "../game/log/message_log_widget.h" #include "../game/log/message_log_widget.h"
#include "../game/phases_toolbar.h" #include "../game/phases_toolbar.h"
#include "../game/player/player.h"
#include "../game/player/player_list_widget.h" #include "../game/player/player_list_widget.h"
#include "../game/player/player_logic.h"
#include "../game/replay.h" #include "../game/replay.h"
#include "../interface/card_picture_loader/card_picture_loader.h" #include "../interface/card_picture_loader/card_picture_loader.h"
#include "../interface/widgets/cards/card_info_frame_widget.h" #include "../interface/widgets/cards/card_info_frame_widget.h"
@ -363,7 +363,7 @@ void TabGame::retranslateUi()
cardInfoFrameWidget->retranslateUi(); cardInfoFrameWidget->retranslateUi();
QMapIterator<int, Player *> i(game->getPlayerManager()->getPlayers()); QMapIterator<int, PlayerLogic *> i(game->getPlayerManager()->getPlayers());
while (i.hasNext()) { while (i.hasNext()) {
i.next().value()->getGraphicsItem()->retranslateUi(); i.next().value()->getGraphicsItem()->retranslateUi();
@ -489,7 +489,7 @@ void TabGame::actGameInfo()
void TabGame::actConcede() void TabGame::actConcede()
{ {
Player *player = game->getPlayerManager()->getActiveLocalPlayer(game->getGameState()->getActivePlayer()); PlayerLogic *player = game->getPlayerManager()->getActiveLocalPlayer(game->getGameState()->getActivePlayer());
if (player == nullptr) { if (player == nullptr) {
return; return;
} }
@ -606,9 +606,9 @@ void TabGame::actNextPhaseAction()
void TabGame::actRemoveLocalArrows() void TabGame::actRemoveLocalArrows()
{ {
QMapIterator<int, Player *> playerIterator(game->getPlayerManager()->getPlayers()); QMapIterator<int, PlayerLogic *> playerIterator(game->getPlayerManager()->getPlayers());
while (playerIterator.hasNext()) { while (playerIterator.hasNext()) {
Player *player = playerIterator.next().value(); PlayerLogic *player = playerIterator.next().value();
if (!player->getPlayerInfo()->getLocal()) { if (!player->getPlayerInfo()->getLocal()) {
continue; continue;
} }
@ -655,14 +655,14 @@ void TabGame::notifyPlayerKicked()
msgBox.exec(); msgBox.exec();
} }
Player *TabGame::addPlayer(Player *newPlayer) PlayerLogic *TabGame::addPlayer(PlayerLogic *newPlayer)
{ {
QString newPlayerName = "@" + newPlayer->getPlayerInfo()->getName(); QString newPlayerName = "@" + newPlayer->getPlayerInfo()->getName();
addPlayerToAutoCompleteList(newPlayerName); addPlayerToAutoCompleteList(newPlayerName);
scene->addPlayer(newPlayer); scene->addPlayer(newPlayer);
connect(newPlayer, &Player::newCardAdded, this, &TabGame::newCardAdded); connect(newPlayer, &PlayerLogic::newCardAdded, this, &TabGame::newCardAdded);
connect(newPlayer->getPlayerMenu(), &PlayerMenu::cardMenuUpdated, this, &TabGame::setCardMenu); connect(newPlayer->getPlayerMenu(), &PlayerMenu::cardMenuUpdated, this, &TabGame::setCardMenu);
messageLog->connectToPlayerEventHandler(newPlayer->getPlayerEventHandler()); messageLog->connectToPlayerEventHandler(newPlayer->getPlayerEventHandler());
@ -683,7 +683,7 @@ Player *TabGame::addPlayer(Player *newPlayer)
return newPlayer; return newPlayer;
} }
void TabGame::addLocalPlayer(Player *newPlayer, int playerId) void TabGame::addLocalPlayer(PlayerLogic *newPlayer, int playerId)
{ {
if (game->getGameState()->getClients().size() == 1) { if (game->getGameState()->getClients().size() == 1) {
newPlayer->getPlayerMenu()->setShortcutsActive(); newPlayer->getPlayerMenu()->setShortcutsActive();
@ -704,7 +704,7 @@ void TabGame::addLocalPlayer(Player *newPlayer, int playerId)
} }
} }
void TabGame::processPlayerLeave(Player *leavingPlayer) void TabGame::processPlayerLeave(PlayerLogic *leavingPlayer)
{ {
QString playerName = "@" + leavingPlayer->getPlayerInfo()->getName(); QString playerName = "@" + leavingPlayer->getPlayerInfo()->getName();
removePlayerFromAutoCompleteList(playerName); removePlayerFromAutoCompleteList(playerName);
@ -751,13 +751,13 @@ void TabGame::processMultipleRemotePlayerDeckSelect(QVector<QPair<int, QPair<QSt
} }
} }
void TabGame::processLocalPlayerDeckSelect(Player *localPlayer, int playerId, ServerInfo_Player playerInfo) void TabGame::processLocalPlayerDeckSelect(PlayerLogic *localPlayer, int playerId, ServerInfo_Player playerInfo)
{ {
loadDeckForLocalPlayer(localPlayer, playerId, playerInfo); loadDeckForLocalPlayer(localPlayer, playerId, playerInfo);
processLocalPlayerReady(playerId, playerInfo); processLocalPlayerReady(playerId, playerInfo);
} }
void TabGame::loadDeckForLocalPlayer(Player *localPlayer, int playerId, ServerInfo_Player playerInfo) void TabGame::loadDeckForLocalPlayer(PlayerLogic *localPlayer, int playerId, ServerInfo_Player playerInfo)
{ {
TabbedDeckViewContainer *deckViewContainer = deckViewContainers.value(playerId); TabbedDeckViewContainer *deckViewContainer = deckViewContainers.value(playerId);
if (playerInfo.has_deck_list()) { if (playerInfo.has_deck_list()) {
@ -784,7 +784,7 @@ void TabGame::processLocalPlayerReadyStateChanged(int playerId, bool ready)
deckViewContainers.value(playerId)->playerDeckView->setReadyStart(ready); deckViewContainers.value(playerId)->playerDeckView->setReadyStart(ready);
} }
void TabGame::createZoneForPlayer(Player *newPlayer, int playerId) void TabGame::createZoneForPlayer(PlayerLogic *newPlayer, int playerId)
{ {
if (!game->getPlayerManager()->getSpectators().contains(playerId)) { if (!game->getPlayerManager()->getSpectators().contains(playerId)) {
@ -820,7 +820,7 @@ void TabGame::startGame(bool _resuming)
mainWidget->setCurrentWidget(gamePlayAreaWidget); mainWidget->setCurrentWidget(gamePlayAreaWidget);
if (!_resuming) { if (!_resuming) {
QMapIterator<int, Player *> playerIterator(game->getPlayerManager()->getPlayers()); QMapIterator<int, PlayerLogic *> playerIterator(game->getPlayerManager()->getPlayers());
while (playerIterator.hasNext()) { while (playerIterator.hasNext()) {
playerIterator.next().value()->setGameStarted(); playerIterator.next().value()->setGameStarted();
} }
@ -863,15 +863,15 @@ void TabGame::closeGame()
gameMenu->addAction(aLeaveGame); gameMenu->addAction(aLeaveGame);
} }
Player *TabGame::setActivePlayer(int id) PlayerLogic *TabGame::setActivePlayer(int id)
{ {
Player *player = game->getPlayerManager()->getPlayer(id); PlayerLogic *player = game->getPlayerManager()->getPlayer(id);
if (!player) { if (!player) {
return nullptr; return nullptr;
} }
playerListWidget->setActivePlayer(id); playerListWidget->setActivePlayer(id);
QMapIterator<int, Player *> i(game->getPlayerManager()->getPlayers()); QMapIterator<int, PlayerLogic *> i(game->getPlayerManager()->getPlayers());
while (i.hasNext()) { while (i.hasNext()) {
i.next(); i.next();
if (i.value() == player) { if (i.value() == player) {

View file

@ -11,7 +11,7 @@
#include "../game/abstract_game.h" #include "../game/abstract_game.h"
#include "../game/log/message_log_widget.h" #include "../game/log/message_log_widget.h"
#include "../game/player/player.h" #include "../game/player/player_logic.h"
#include "../interface/widgets/menus/tearoff_menu.h" #include "../interface/widgets/menus/tearoff_menu.h"
#include "../interface/widgets/replay/replay_manager.h" #include "../interface/widgets/replay/replay_manager.h"
#include "tab.h" #include "tab.h"
@ -99,21 +99,21 @@ private:
QMap<QDockWidget *, DockActions> dockToActions; QMap<QDockWidget *, DockActions> dockToActions;
Player *addPlayer(Player *newPlayer); PlayerLogic *addPlayer(PlayerLogic *newPlayer);
void addLocalPlayer(Player *newPlayer, int playerId); void addLocalPlayer(PlayerLogic *newPlayer, int playerId);
void processRemotePlayerDeckSelect(QString deckList, int playerId, QString playerName); void processRemotePlayerDeckSelect(QString deckList, int playerId, QString playerName);
void processMultipleRemotePlayerDeckSelect(QVector<QPair<int, QPair<QString, QString>>> playerIdDeckMap); void processMultipleRemotePlayerDeckSelect(QVector<QPair<int, QPair<QString, QString>>> playerIdDeckMap);
void processLocalPlayerDeckSelect(Player *localPlayer, int playerId, ServerInfo_Player playerInfo); void processLocalPlayerDeckSelect(PlayerLogic *localPlayer, int playerId, ServerInfo_Player playerInfo);
void loadDeckForLocalPlayer(Player *localPlayer, int playerId, ServerInfo_Player playerInfo); void loadDeckForLocalPlayer(PlayerLogic *localPlayer, int playerId, ServerInfo_Player playerInfo);
void processLocalPlayerReady(int playerId, ServerInfo_Player playerInfo); void processLocalPlayerReady(int playerId, ServerInfo_Player playerInfo);
void createZoneForPlayer(Player *newPlayer, int playerId); void createZoneForPlayer(PlayerLogic *newPlayer, int playerId);
void startGame(bool resuming); void startGame(bool resuming);
void stopGame(); void stopGame();
void closeGame(); void closeGame();
bool leaveGame(); bool leaveGame();
Player *setActivePlayer(int id); PlayerLogic *setActivePlayer(int id);
void setActivePhase(int phase); void setActivePhase(int phase);
void createMenuItems(); void createMenuItems();
void createReplayMenuItems(); void createReplayMenuItems();
@ -163,7 +163,7 @@ private slots:
void actCompleterChanged(); void actCompleterChanged();
void notifyPlayerJoin(QString playerName); void notifyPlayerJoin(QString playerName);
void notifyPlayerKicked(); void notifyPlayerKicked();
void processPlayerLeave(Player *leavingPlayer); void processPlayerLeave(PlayerLogic *leavingPlayer);
void actResetLayout(); void actResetLayout();
void hideEvent(QHideEvent *event) override; void hideEvent(QHideEvent *event) override;