diff --git a/cockatrice/CMakeLists.txt b/cockatrice/CMakeLists.txt index bac565f53..389577d4f 100644 --- a/cockatrice/CMakeLists.txt +++ b/cockatrice/CMakeLists.txt @@ -95,13 +95,13 @@ set(cockatrice_SOURCES src/game/player/menu/say_menu.cpp src/game/player/menu/sideboard_menu.cpp src/game/player/menu/utility_menu.cpp - src/game/player/player.cpp src/game/player/player_actions.cpp src/game/player/player_area.cpp src/game/player/player_event_handler.cpp src/game/player/player_graphics_item.cpp src/game/player/player_info.cpp src/game/player/player_list_widget.cpp + src/game/player/player_logic.cpp src/game/player/player_manager.cpp src/game/player/player_target.cpp src/game/replay.cpp diff --git a/cockatrice/src/game/abstract_game.cpp b/cockatrice/src/game/abstract_game.cpp index 8c777d587..5b1b4bff2 100644 --- a/cockatrice/src/game/abstract_game.cpp +++ b/cockatrice/src/game/abstract_game.cpp @@ -1,7 +1,7 @@ #include "abstract_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) { @@ -44,7 +44,7 @@ void AbstractGame::setActiveCard(CardItem *card) CardItem *AbstractGame::getCard(int playerId, const QString &zoneName, int cardId) const { - Player *player = playerManager->getPlayer(playerId); + PlayerLogic *player = playerManager->getPlayer(playerId); if (!player) { return nullptr; } diff --git a/cockatrice/src/game/board/abstract_card_item.cpp b/cockatrice/src/game/board/abstract_card_item.cpp index d9458990b..86b3e27c8 100644 --- a/cockatrice/src/game/board/abstract_card_item.cpp +++ b/cockatrice/src/game/board/abstract_card_item.cpp @@ -13,7 +13,7 @@ #include #include -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), bgColor(Qt::transparent), isHovered(false), realZValue(0) { diff --git a/cockatrice/src/game/board/abstract_card_item.h b/cockatrice/src/game/board/abstract_card_item.h index 517b5cf28..ed545e1ab 100644 --- a/cockatrice/src/game/board/abstract_card_item.h +++ b/cockatrice/src/game/board/abstract_card_item.h @@ -14,7 +14,7 @@ #include #include -class Player; +class PlayerLogic; class AbstractCardItem : public ArrowTarget { @@ -56,7 +56,7 @@ public: } explicit AbstractCardItem(QGraphicsItem *parent = nullptr, const CardRef &cardRef = {}, - Player *_owner = nullptr, + PlayerLogic *_owner = nullptr, int _id = -1); ~AbstractCardItem() override; QRectF boundingRect() const override; diff --git a/cockatrice/src/game/board/abstract_counter.cpp b/cockatrice/src/game/board/abstract_counter.cpp index ef3efb539..e0e801ab2 100644 --- a/cockatrice/src/game/board/abstract_counter.cpp +++ b/cockatrice/src/game/board/abstract_counter.cpp @@ -2,8 +2,8 @@ #include "../../client/settings/cache_settings.h" #include "../../interface/widgets/tabs/tab_game.h" -#include "../player/player.h" #include "../player/player_actions.h" +#include "../player/player_logic.h" #include "translate_counter_name.h" #include @@ -16,7 +16,7 @@ #include #include -AbstractCounter::AbstractCounter(Player *_player, +AbstractCounter::AbstractCounter(PlayerLogic *_player, int _id, const QString &_name, bool _shownInCounterArea, diff --git a/cockatrice/src/game/board/abstract_counter.h b/cockatrice/src/game/board/abstract_counter.h index 074650d54..7bc07d41f 100644 --- a/cockatrice/src/game/board/abstract_counter.h +++ b/cockatrice/src/game/board/abstract_counter.h @@ -13,7 +13,7 @@ #include #include -class Player; +class PlayerLogic; class QAction; class QKeyEvent; class QMenu; @@ -25,7 +25,7 @@ class AbstractCounter : public QObject, public QGraphicsItem, public AbstractPla Q_INTERFACES(QGraphicsItem) protected: - Player *player; + PlayerLogic *player; int id; QString name; int value; @@ -48,7 +48,7 @@ private slots: void setCounter(); public: - AbstractCounter(Player *_player, + AbstractCounter(PlayerLogic *_player, int _id, const QString &_name, bool _shownInCounterArea, diff --git a/cockatrice/src/game/board/arrow_item.cpp b/cockatrice/src/game/board/arrow_item.cpp index 498a3dfab..b9d01c40e 100644 --- a/cockatrice/src/game/board/arrow_item.cpp +++ b/cockatrice/src/game/board/arrow_item.cpp @@ -3,8 +3,8 @@ #include "../../client/settings/cache_settings.h" #include "../../game_graphics/zones/card_zone.h" -#include "../player/player.h" #include "../player/player_actions.h" +#include "../player/player_logic.h" #include "../player/player_target.h" #include "../z_values.h" #include "card_item.h" @@ -21,7 +21,11 @@ #include #include -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), 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) { } diff --git a/cockatrice/src/game/board/arrow_item.h b/cockatrice/src/game/board/arrow_item.h index cb78ee066..f2de94d2f 100644 --- a/cockatrice/src/game/board/arrow_item.h +++ b/cockatrice/src/game/board/arrow_item.h @@ -12,7 +12,7 @@ class CardItem; class QGraphicsSceneMouseEvent; class QMenu; -class Player; +class PlayerLogic; class ArrowTarget; class ArrowItem : public QObject, public QGraphicsItem @@ -24,7 +24,7 @@ private: QMenu *menu; protected: - Player *player; + PlayerLogic *player; int id; ArrowTarget *startItem, *targetItem; bool targetLocked; @@ -33,7 +33,7 @@ protected: void mousePressEvent(QGraphicsSceneMouseEvent *event) override; 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; void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override; [[nodiscard]] QRectF boundingRect() const override @@ -51,7 +51,7 @@ public: { return id; } - [[nodiscard]] Player *getPlayer() const + [[nodiscard]] PlayerLogic *getPlayer() const { return player; } @@ -86,7 +86,7 @@ private: QList childArrows; 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); protected: diff --git a/cockatrice/src/game/board/arrow_target.cpp b/cockatrice/src/game/board/arrow_target.cpp index 2c7cdfec8..bcd067bdb 100644 --- a/cockatrice/src/game/board/arrow_target.cpp +++ b/cockatrice/src/game/board/arrow_target.cpp @@ -1,9 +1,9 @@ #include "arrow_target.h" -#include "../player/player.h" +#include "../player/player_logic.h" #include "arrow_item.h" -ArrowTarget::ArrowTarget(Player *_owner, QGraphicsItem *parent) +ArrowTarget::ArrowTarget(PlayerLogic *_owner, QGraphicsItem *parent) : AbstractGraphicsItem(parent), owner(_owner), beingPointedAt(false) { setFlag(ItemSendsScenePositionChanges); diff --git a/cockatrice/src/game/board/arrow_target.h b/cockatrice/src/game/board/arrow_target.h index 55f4ef678..59ef48277 100644 --- a/cockatrice/src/game/board/arrow_target.h +++ b/cockatrice/src/game/board/arrow_target.h @@ -11,24 +11,24 @@ #include -class Player; +class PlayerLogic; class ArrowItem; class ArrowTarget : public AbstractGraphicsItem { Q_OBJECT protected: - Player *owner; + PlayerLogic *owner; private: bool beingPointedAt; QList arrowsFrom, arrowsTo; public: - explicit ArrowTarget(Player *_owner, QGraphicsItem *parent = nullptr); + explicit ArrowTarget(PlayerLogic *_owner, QGraphicsItem *parent = nullptr); ~ArrowTarget() override; - [[nodiscard]] Player *getOwner() const + [[nodiscard]] PlayerLogic *getOwner() const { return owner; } diff --git a/cockatrice/src/game/board/card_item.cpp b/cockatrice/src/game/board/card_item.cpp index bd47d5bd5..a08194540 100644 --- a/cockatrice/src/game/board/card_item.cpp +++ b/cockatrice/src/game/board/card_item.cpp @@ -6,8 +6,8 @@ #include "../../interface/widgets/tabs/tab_game.h" #include "../game_scene.h" #include "../phase.h" -#include "../player/player.h" #include "../player/player_actions.h" +#include "../player/player_logic.h" #include "../zones/view_zone_logic.h" #include "arrow_item.h" #include "card_drag_item.h" @@ -20,7 +20,11 @@ #include #include -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) { owner->addCard(this); @@ -273,7 +277,7 @@ void CardItem::drawArrow(const QColor &arrowColor) } 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 if (SettingsCache::instance().getDoNotDeleteArrowsInSubPhases()) { int currentPhase = game->getGameState()->getCurrentPhase(); diff --git a/cockatrice/src/game/board/card_item.h b/cockatrice/src/game/board/card_item.h index aa29ec014..1e99dbe2a 100644 --- a/cockatrice/src/game/board/card_item.h +++ b/cockatrice/src/game/board/card_item.h @@ -17,7 +17,7 @@ class CardDatabase; class CardDragItem; class CardZone; class ServerInfo_Card; -class Player; +class PlayerLogic; class QAction; class QColor; @@ -48,7 +48,7 @@ public: { return Type; } - explicit CardItem(Player *_owner, + explicit CardItem(PlayerLogic *_owner, QGraphicsItem *parent = nullptr, const CardRef &cardRef = {}, int _cardid = -1, @@ -73,11 +73,11 @@ public: { return gridPoint; } - [[nodiscard]] Player *getOwner() const + [[nodiscard]] PlayerLogic *getOwner() const { return owner; } - void setOwner(Player *_owner) + void setOwner(PlayerLogic *_owner) { owner = _owner; } diff --git a/cockatrice/src/game/board/counter_general.cpp b/cockatrice/src/game/board/counter_general.cpp index d68486a1b..7dd0b1f15 100644 --- a/cockatrice/src/game/board/counter_general.cpp +++ b/cockatrice/src/game/board/counter_general.cpp @@ -5,7 +5,7 @@ #include -GeneralCounter::GeneralCounter(Player *_player, +GeneralCounter::GeneralCounter(PlayerLogic *_player, int _id, const QString &_name, const QColor &_color, diff --git a/cockatrice/src/game/board/counter_general.h b/cockatrice/src/game/board/counter_general.h index 3db1d7bb4..ac008fa49 100644 --- a/cockatrice/src/game/board/counter_general.h +++ b/cockatrice/src/game/board/counter_general.h @@ -17,7 +17,7 @@ private: int radius; public: - GeneralCounter(Player *_player, + GeneralCounter(PlayerLogic *_player, int _id, const QString &_name, const QColor &_color, diff --git a/cockatrice/src/game/game_event_handler.cpp b/cockatrice/src/game/game_event_handler.cpp index 82fa2b911..b338deaea 100644 --- a/cockatrice/src/game/game_event_handler.cpp +++ b/cockatrice/src/game/game_event_handler.cpp @@ -99,7 +99,7 @@ void GameEventHandler::processGameEventContainer(const GameEventContainer &cont, if (cont.has_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) { emit setContextJudgeName(judgep->getPlayerInfo()->getName()); } else if (game->getPlayerManager()->getSpectators().contains(id)) { @@ -160,7 +160,7 @@ void GameEventHandler::processGameEventContainer(const GameEventContainer &cont, break; default: { - Player *player = game->getPlayerManager()->getPlayers().value(playerId, 0); + PlayerLogic *player = game->getPlayerManager()->getPlayers().value(playerId, 0); if (!player) { qCWarning(GameEventHandlerLog) << "unhandled game event: invalid player id"; break; @@ -261,7 +261,7 @@ void GameEventHandler::eventGameStateChanged(const Event_GameStateChanged &event emit spectatorJoined(prop); } } else { - Player *player = game->getPlayerManager()->getPlayers().value(playerId, 0); + PlayerLogic *player = game->getPlayerManager()->getPlayers().value(playerId, 0); if (!player) { player = game->getPlayerManager()->addPlayer(playerId, prop.user_info()); emit playerJoined(prop); @@ -310,7 +310,7 @@ void GameEventHandler::processCardAttachmentsForPlayers(const Event_GameStateCha const ServerInfo_Player &playerInfo = event.player_list(i); const ServerInfo_PlayerProperties &prop = playerInfo.properties(); 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) { continue; } @@ -323,7 +323,7 @@ void GameEventHandler::eventPlayerPropertiesChanged(const Event_PlayerProperties int eventPlayerId, const GameEventContext &context) { - Player *player = game->getPlayerManager()->getPlayers().value(eventPlayerId, 0); + PlayerLogic *player = game->getPlayerManager()->getPlayers().value(eventPlayerId, 0); if (!player) { return; } @@ -347,7 +347,7 @@ void GameEventHandler::eventPlayerPropertiesChanged(const Event_PlayerProperties case GameEventContext::CONCEDE: { player->setConceded(true); - QMapIterator playerIterator(game->getPlayerManager()->getPlayers()); + QMapIterator playerIterator(game->getPlayerManager()->getPlayers()); while (playerIterator.hasNext()) { playerIterator.next().value()->updateZones(); } @@ -359,7 +359,7 @@ void GameEventHandler::eventPlayerPropertiesChanged(const Event_PlayerProperties case GameEventContext::UNCONCEDE: { player->setConceded(false); - QMapIterator playerIterator(game->getPlayerManager()->getPlayers()); + QMapIterator playerIterator(game->getPlayerManager()->getPlayers()); while (playerIterator.hasNext()) { playerIterator.next().value()->updateZones(); } @@ -409,7 +409,7 @@ void GameEventHandler::eventJoin(const Event_Join &event, int /*eventPlayerId*/, emit logJoinSpectator(playerName); emit spectatorJoined(playerInfo); } else { - Player *newPlayer = game->getPlayerManager()->addPlayer(playerId, playerInfo.user_info()); + PlayerLogic *newPlayer = game->getPlayerManager()->addPlayer(playerId, playerInfo.user_info()); emit logJoinPlayer(newPlayer); 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*/) { - Player *player = game->getPlayerManager()->getPlayers().value(eventPlayerId, 0); + PlayerLogic *player = game->getPlayerManager()->getPlayers().value(eventPlayerId, 0); if (!player) { return; } @@ -452,7 +452,7 @@ void GameEventHandler::eventLeave(const Event_Leave &event, int eventPlayerId, c player->deleteLater(); // Rearrange all remaining zones so that attachment relationship updates take place - QMapIterator playerIterator(game->getPlayerManager()->getPlayers()); + QMapIterator playerIterator(game->getPlayerManager()->getPlayers()); while (playerIterator.hasNext()) { playerIterator.next().value()->updateZones(); } @@ -474,7 +474,7 @@ void GameEventHandler::eventReverseTurn(const Event_ReverseTurn &event, int eventPlayerId, const GameEventContext & /*context*/) { - Player *player = game->getPlayerManager()->getPlayers().value(eventPlayerId, 0); + PlayerLogic *player = game->getPlayerManager()->getPlayers().value(eventPlayerId, 0); if (!player) { return; } @@ -505,7 +505,7 @@ void GameEventHandler::eventSetActivePlayer(const Event_SetActivePlayer &event, const GameEventContext & /*context*/) { 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) { return; } diff --git a/cockatrice/src/game/game_event_handler.h b/cockatrice/src/game/game_event_handler.h index 302e7a6ff..250f2c185 100644 --- a/cockatrice/src/game/game_event_handler.h +++ b/cockatrice/src/game/game_event_handler.h @@ -38,7 +38,7 @@ class Event_Kicked; class Event_ReverseTurn; class AbstractGame; class PendingCommand; -class Player; +class PlayerLogic; inline Q_LOGGING_CATEGORY(GameEventHandlerLog, "game_event_handler"); @@ -95,7 +95,7 @@ public slots: signals: void emitUserEvent(); 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 remotePlayersDecksSelected(QVector>> opponentDecks); void localPlayerSideboardLocked(int playerId, bool sideboardLocked); @@ -115,18 +115,18 @@ signals: void logSpectatorSay(ServerInfo_User userInfo, QString message); void logSpectatorLeave(QString name, QString reason); void logGameStart(); - void logReadyStart(Player *player); - void logNotReadyStart(Player *player); - void logDeckSelect(Player *player, QString deckHash, int sideboardSize); - void logSideboardLockSet(Player *player, bool sideboardLocked); - void logConnectionStateChanged(Player *player, bool connected); + void logReadyStart(PlayerLogic *player); + void logNotReadyStart(PlayerLogic *player); + void logDeckSelect(PlayerLogic *player, QString deckHash, int sideboardSize); + void logSideboardLockSet(PlayerLogic *player, bool sideboardLocked); + void logConnectionStateChanged(PlayerLogic *player, bool connected); void logJoinSpectator(QString spectatorName); - void logJoinPlayer(Player *player); - void logLeave(Player *player, QString reason); + void logJoinPlayer(PlayerLogic *player); + void logLeave(PlayerLogic *player, QString reason); void logKicked(); - void logTurnReversed(Player *player, bool reversed); + void logTurnReversed(PlayerLogic *player, bool reversed); void logGameClosed(); - void logActivePlayer(Player *activePlayer); + void logActivePlayer(PlayerLogic *activePlayer); void logActivePhaseChanged(int activePhase); void logConcede(int playerId); void logUnconcede(int playerId); diff --git a/cockatrice/src/game/game_scene.cpp b/cockatrice/src/game/game_scene.cpp index b5026ad33..91ac0adc6 100644 --- a/cockatrice/src/game/game_scene.cpp +++ b/cockatrice/src/game/game_scene.cpp @@ -6,8 +6,8 @@ #include "../game_graphics/zones/view_zone_widget.h" #include "board/card_item.h" #include "phases_toolbar.h" -#include "player/player.h" #include "player/player_graphics_item.h" +#include "player/player_logic.h" #include #include @@ -78,7 +78,7 @@ QList GameScene::selectedCards() const * * 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(); @@ -93,7 +93,7 @@ void GameScene::addPlayer(Player *player) * * 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(); @@ -178,14 +178,14 @@ void GameScene::processViewSizeChange(const QSize &newSize) * * Used to determine rotation and layout order. */ -QList GameScene::collectActivePlayers(int &firstPlayerIndex) const +QList GameScene::collectActivePlayers(int &firstPlayerIndex) const { - QList activePlayers; + QList activePlayers; firstPlayerIndex = 0; bool firstPlayerFound = false; for (auto *pgItem : players) { - Player *p = pgItem->getPlayer(); + PlayerLogic *p = pgItem->getPlayer(); if (p && !p->getConceded()) { activePlayers.append(p); if (!firstPlayerFound && p->getPlayerInfo()->getLocal()) { @@ -205,9 +205,9 @@ QList GameScene::collectActivePlayers(int &firstPlayerIndex) const * * Applies rotation offset and ensures the list wraps correctly. */ -QList GameScene::rotatePlayers(const QList &activePlayers, int firstPlayerIndex) const +QList GameScene::rotatePlayers(const QList &activePlayers, int firstPlayerIndex) const { - QList rotated = activePlayers; + QList rotated = activePlayers; if (!rotated.isEmpty()) { int totalRotation = firstPlayerIndex + playerRotation; while (totalRotation < 0) { @@ -238,7 +238,7 @@ int GameScene::determineColumnCount(int playerCount) * - Position players in columns with spacing. * - Mirror graphics for visual balance. */ -QSizeF GameScene::computeSceneSizeAndPlayerLayout(const QList &playersPlaying, int columns) +QSizeF GameScene::computeSceneSizeAndPlayerLayout(const QList &playersPlaying, int columns) { playersByColumn.clear(); @@ -246,7 +246,7 @@ QSizeF GameScene::computeSceneSizeAndPlayerLayout(const QList &players qreal sceneHeight = 0, sceneWidth = -playerAreaSpacing; QList columnWidth; - QListIterator playersIter(playersPlaying); + QListIterator playersIter(playersPlaying); for (int col = 0; col < columns; ++col) { playersByColumn.append(QList()); columnWidth.append(0); @@ -254,7 +254,7 @@ QSizeF GameScene::computeSceneSizeAndPlayerLayout(const QList &players int rowsInColumn = rows - (playersPlaying.size() % columns) * col; // Adjust rows for uneven columns for (int j = 0; j < rowsInColumn; ++j) { - Player *player = playersIter.next(); + PlayerLogic *player = playersIter.next(); if (col == 0) { playersByColumn[col].prepend(player->getGraphicsItem()); } else { @@ -435,7 +435,7 @@ CardItem *GameScene::findTopmostCardInZone(const QList &items, * If an identical view exists, it is closed. Otherwise, a new ZoneViewWidget is created * 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) { 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 withWritePermission Whether edits are allowed. */ -void GameScene::addRevealedZoneView(Player *player, +void GameScene::addRevealedZoneView(PlayerLogic *player, CardZoneLogic *zone, const QList &cardList, bool withWritePermission) diff --git a/cockatrice/src/game/game_scene.h b/cockatrice/src/game/game_scene.h index 0cb332ad0..a2d712609 100644 --- a/cockatrice/src/game/game_scene.h +++ b/cockatrice/src/game/game_scene.h @@ -12,7 +12,7 @@ inline Q_LOGGING_CATEGORY(GameSceneLog, "game_scene"); inline Q_LOGGING_CATEGORY(GameScenePlayerAdditionRemovalLog, "game_scene.player_addition_removal"); -class Player; +class PlayerLogic; class PlayerGraphicsItem; class ZoneViewWidget; class CardZone; @@ -83,13 +83,13 @@ public: * @brief Adds a player to the scene and stores their graphics item. * @param player Player to add. */ - void addPlayer(Player *player); + void addPlayer(PlayerLogic *player); /** * @brief Removes a player from the scene. * @param player Player to remove. */ - void removePlayer(Player *player); + void removePlayer(PlayerLogic *player); /** * @brief Adjusts the global rotation offset for player layout. @@ -111,7 +111,7 @@ public: * @param firstPlayerIndex Output index of first local player. * @return List of active players. */ - QList collectActivePlayers(int &firstPlayerIndex) const; + QList collectActivePlayers(int &firstPlayerIndex) const; /** * @brief Rotates the list of players for layout. @@ -119,7 +119,7 @@ public: * @param firstPlayerIndex Index of first local player. * @return Rotated list. */ - QList rotatePlayers(const QList &players, int firstPlayerIndex) const; + QList rotatePlayers(const QList &players, int firstPlayerIndex) const; /** * @brief Determines the number of columns to display players in. @@ -134,7 +134,7 @@ public: * @param columns Number of columns to split into. * @return Calculated scene size. */ - QSizeF computeSceneSizeAndPlayerLayout(const QList &playersPlaying, int columns); + QSizeF computeSceneSizeAndPlayerLayout(const QList &playersPlaying, int columns); /** * @brief Computes the minimum width for each column based on player minimum widths. @@ -177,10 +177,10 @@ public: public slots: /** 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). */ - void addRevealedZoneView(Player *player, + void addRevealedZoneView(PlayerLogic *player, CardZoneLogic *zone, const QList &cardList, bool withWritePermission); diff --git a/cockatrice/src/game/log/message_log_widget.cpp b/cockatrice/src/game/log/message_log_widget.cpp index 09f6e656b..53f671256 100644 --- a/cockatrice/src/game/log/message_log_widget.cpp +++ b/cockatrice/src/game/log/message_log_widget.cpp @@ -5,7 +5,7 @@ #include "../board/card_item.h" #include "../board/translate_counter_name.h" #include "../phase.h" -#include "../player/player.h" +#include "../player/player_logic.h" #include <../../client/settings/card_counter_settings.h> #include @@ -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.") : 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))); } -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.") : 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))); } -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.") .arg(sanitizeHtml(player->getPlayerInfo()->getName())) @@ -148,7 +151,7 @@ void MessageLogWidget::logUnconcede(int playerId) true); } -void MessageLogWidget::logConnectionStateChanged(Player *player, bool connectionState) +void MessageLogWidget::logConnectionStateChanged(PlayerLogic *player, bool connectionState) { if (connectionState) { soundEngine->playSound("player_reconnect"); @@ -161,10 +164,10 @@ void MessageLogWidget::logConnectionStateChanged(Player *player, bool connection } } -void MessageLogWidget::logCreateArrow(Player *player, - Player *startPlayer, +void MessageLogWidget::logCreateArrow(PlayerLogic *player, + PlayerLogic *startPlayer, QString startCard, - Player *targetPlayer, + PlayerLogic *targetPlayer, QString targetCard, 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) { 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) { 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( 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, CardZoneLogic *startZone, int oldX, @@ -359,7 +362,7 @@ void MessageLogWidget::logMoveCard(Player *player, appendHtmlServerMessage(message); } -void MessageLogWidget::logDrawCards(Player *player, int number, bool deckIsEmpty) +void MessageLogWidget::logDrawCards(PlayerLogic *player, int number, bool deckIsEmpty) { soundEngine->playSound("draw_card"); 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) { 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) { appendHtmlServerMessage( @@ -418,7 +421,7 @@ void MessageLogWidget::logGameFlooded() 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"); 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); } -void MessageLogWidget::logLeave(Player *player, QString reason) +void MessageLogWidget::logLeave(PlayerLogic *player, QString reason) { soundEngine->playSound("player_leave"); 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)))); } -void MessageLogWidget::logNotReadyStart(Player *player) +void MessageLogWidget::logNotReadyStart(PlayerLogic *player) { appendHtmlServerMessage( 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) { return; @@ -476,16 +479,16 @@ void MessageLogWidget::logReplayStarted(int 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()))); } -void MessageLogWidget::logRevealCards(Player *player, +void MessageLogWidget::logRevealCards(PlayerLogic *player, CardZoneLogic *zone, int cardId, QString cardName, - Player *otherPlayer, + PlayerLogic *otherPlayer, bool faceDown, int amount, 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.") .arg(sanitizeHtml(player->getPlayerInfo()->getName())) .arg(reversed ? tr("reversed") : tr("normal"))); } -void MessageLogWidget::logRollDie(Player *player, int sides, const QList &rolls) +void MessageLogWidget::logRollDie(PlayerLogic *player, int sides, const QList &rolls) { if (rolls.length() == 1) { const auto roll = rolls.at(0); @@ -612,7 +615,7 @@ void MessageLogWidget::logRollDie(Player *player, int sides, const QList & 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); } @@ -627,13 +630,13 @@ void MessageLogWidget::logSetActivePhase(int phaseNumber) phase.getName() + ""); } -void MessageLogWidget::logSetActivePlayer(Player *player) +void MessageLogWidget::logSetActivePlayer(PlayerLogic *player) { appendHtml("
" + QDateTime::currentDateTime().toString("[hh:mm:ss] ") + QString(tr("%1's turn.")).arg(player->getPlayerInfo()->getName()) + "
"); } -void MessageLogWidget::logSetAnnotation(Player *player, CardItem *card, QString newAnnotation) +void MessageLogWidget::logSetAnnotation(PlayerLogic *player, CardItem *card, QString newAnnotation) { appendHtmlServerMessage( QString(tr("%1 sets annotation of %2 to %3.")) @@ -642,7 +645,7 @@ void MessageLogWidget::logSetAnnotation(Player *player, CardItem *card, QString .arg(QString(""%1"").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; int delta = abs(oldValue - value); @@ -660,7 +663,7 @@ void MessageLogWidget::logSetCardCounter(Player *player, QString cardName, int c .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") { soundEngine->playSound("life_change"); @@ -675,7 +678,7 @@ void MessageLogWidget::logSetCounter(Player *player, QString counterName, int va .arg(value - oldValue)); } -void MessageLogWidget::logSetDoesntUntap(Player *player, CardItem *card, bool doesntUntap) +void MessageLogWidget::logSetDoesntUntap(PlayerLogic *player, CardItem *card, bool doesntUntap) { QString str; 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()))); } -void MessageLogWidget::logSetPT(Player *player, CardItem *card, QString newPT) +void MessageLogWidget::logSetPT(PlayerLogic *player, CardItem *card, QString newPT) { if (currentContext == MessageContext_MoveCard) { 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) { 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) { 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) { return; @@ -784,14 +787,14 @@ void MessageLogWidget::logSpectatorSay(const ServerInfo_User &spectator, QString 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.") .arg(sanitizeHtml(player->getPlayerInfo()->getName())) .arg(cardLink(std::move(cardName)))); } -void MessageLogWidget::logUndoDraw(Player *player, QString cardName) +void MessageLogWidget::logUndoDraw(PlayerLogic *player, QString cardName) { if (cardName.isEmpty()) { appendHtmlServerMessage(tr("%1 undoes their last draw.").arg(sanitizeHtml(player->getPlayerInfo()->getName()))); diff --git a/cockatrice/src/game/log/message_log_widget.h b/cockatrice/src/game/log/message_log_widget.h index 78f830e53..25db21864 100644 --- a/cockatrice/src/game/log/message_log_widget.h +++ b/cockatrice/src/game/log/message_log_widget.h @@ -13,7 +13,7 @@ class AbstractGame; class CardItem; class GameEventContext; -class Player; +class PlayerLogic; class PlayerEventHandler; class MessageLogWidget : public ChatView @@ -39,66 +39,66 @@ public: public slots: void containerProcessingDone(); void containerProcessingStarted(const GameEventContext &context); - void logAlwaysRevealTopCard(Player *player, CardZoneLogic *zone, bool reveal); - void logAlwaysLookAtTopCard(Player *player, CardZoneLogic *zone, bool reveal); - void logAttachCard(Player *player, QString cardName, Player *targetPlayer, QString targetCardName); + void logAlwaysRevealTopCard(PlayerLogic *player, CardZoneLogic *zone, bool reveal); + void logAlwaysLookAtTopCard(PlayerLogic *player, CardZoneLogic *zone, bool reveal); + void logAttachCard(PlayerLogic *player, QString cardName, PlayerLogic *targetPlayer, QString targetCardName); void logConcede(int playerId); void logUnconcede(int playerId); - void logConnectionStateChanged(Player *player, bool connectionState); - void logCreateArrow(Player *player, - Player *startPlayer, + void logConnectionStateChanged(PlayerLogic *player, bool connectionState); + void logCreateArrow(PlayerLogic *player, + PlayerLogic *startPlayer, QString startCard, - Player *targetPlayer, + PlayerLogic *targetPlayer, QString targetCard, bool playerTarget); - void logCreateToken(Player *player, QString cardName, QString pt, bool faceDown); - void logDeckSelect(Player *player, QString deckHash, int sideboardSize); - void logDestroyCard(Player *player, QString cardName); - void logDrawCards(Player *player, int number, bool deckIsEmpty); - void logDumpZone(Player *player, CardZoneLogic *zone, int numberCards, bool isReversed = false); - void logFlipCard(Player *player, QString cardName, bool faceDown); + void logCreateToken(PlayerLogic *player, QString cardName, QString pt, bool faceDown); + void logDeckSelect(PlayerLogic *player, QString deckHash, int sideboardSize); + void logDestroyCard(PlayerLogic *player, QString cardName); + void logDrawCards(PlayerLogic *player, int number, bool deckIsEmpty); + void logDumpZone(PlayerLogic *player, CardZoneLogic *zone, int numberCards, bool isReversed = false); + void logFlipCard(PlayerLogic *player, QString cardName, bool faceDown); void logGameClosed(); void logGameStart(); void logGameFlooded(); - void logJoin(Player *player); + void logJoin(PlayerLogic *player); void logJoinSpectator(QString name); void logKicked(); - void logLeave(Player *player, QString reason); + void logLeave(PlayerLogic *player, QString reason); void logLeaveSpectator(QString name, QString reason); - void logNotReadyStart(Player *player); - void logMoveCard(Player *player, + void logNotReadyStart(PlayerLogic *player); + void logMoveCard(PlayerLogic *player, CardItem *card, CardZoneLogic *startZone, int oldX, CardZoneLogic *targetZone, int newX); - void logMulligan(Player *player, int number); + void logMulligan(PlayerLogic *player, int number); void logReplayStarted(int gameId); - void logReadyStart(Player *player); - void logRevealCards(Player *player, + void logReadyStart(PlayerLogic *player); + void logRevealCards(PlayerLogic *player, CardZoneLogic *zone, int cardId, QString cardName, - Player *otherPlayer, + PlayerLogic *otherPlayer, bool faceDown, int amount, bool isLentToAnotherPlayer); - void logReverseTurn(Player *player, bool reversed); - void logRollDie(Player *player, int sides, const QList &rolls); - void logSay(Player *player, QString message); + void logReverseTurn(PlayerLogic *player, bool reversed); + void logRollDie(PlayerLogic *player, int sides, const QList &rolls); + void logSay(PlayerLogic *player, QString message); void logSetActivePhase(int phase); - void logSetActivePlayer(Player *player); - void logSetAnnotation(Player *player, CardItem *card, QString newAnnotation); - void logSetCardCounter(Player *player, QString cardName, int counterId, int value, int oldValue); - void logSetCounter(Player *player, QString counterName, int value, int oldValue); - void logSetDoesntUntap(Player *player, CardItem *card, bool doesntUntap); - void logSetPT(Player *player, CardItem *card, QString newPT); - void logSetSideboardLock(Player *player, bool locked); - void logSetTapped(Player *player, CardItem *card, bool tapped); - void logShuffle(Player *player, CardZoneLogic *zone, int start, int end); + void logSetActivePlayer(PlayerLogic *player); + void logSetAnnotation(PlayerLogic *player, CardItem *card, QString newAnnotation); + void logSetCardCounter(PlayerLogic *player, QString cardName, int counterId, int value, int oldValue); + void logSetCounter(PlayerLogic *player, QString counterName, int value, int oldValue); + void logSetDoesntUntap(PlayerLogic *player, CardItem *card, bool doesntUntap); + void logSetPT(PlayerLogic *player, CardItem *card, QString newPT); + void logSetSideboardLock(PlayerLogic *player, bool locked); + void logSetTapped(PlayerLogic *player, CardItem *card, bool tapped); + void logShuffle(PlayerLogic *player, CardZoneLogic *zone, int start, int end); void logSpectatorSay(const ServerInfo_User &spectator, QString message); - void logUnattachCard(Player *player, QString cardName); - void logUndoDraw(Player *player, QString cardName); + void logUnattachCard(PlayerLogic *player, QString cardName); + void logUndoDraw(PlayerLogic *player, QString cardName); void setContextJudgeName(QString player); void appendHtmlServerMessage(const QString &html, bool optionalIsBold = false, diff --git a/cockatrice/src/game/phases_toolbar.h b/cockatrice/src/game/phases_toolbar.h index 215a97dd1..dd2477424 100644 --- a/cockatrice/src/game/phases_toolbar.h +++ b/cockatrice/src/game/phases_toolbar.h @@ -21,7 +21,7 @@ namespace protobuf class Message; } } // namespace google -class Player; +class PlayerLogic; class GameCommand; class PhaseButton : public QObject, public QGraphicsItem diff --git a/cockatrice/src/game/player/menu/card_menu.cpp b/cockatrice/src/game/player/menu/card_menu.cpp index 9ece326cc..933f4094c 100644 --- a/cockatrice/src/game/player/menu/card_menu.cpp +++ b/cockatrice/src/game/player/menu/card_menu.cpp @@ -5,8 +5,8 @@ #include "../../board/card_item.h" #include "../../zones/view_zone_logic.h" #include "../card_menu_action_type.h" -#include "../player.h" #include "../player_actions.h" +#include "../player_logic.h" #include "move_menu.h" #include "pt_menu.h" @@ -14,12 +14,12 @@ #include #include -CardMenu::CardMenu(Player *_player, const CardItem *_card, bool _shortcutsActive) +CardMenu::CardMenu(PlayerLogic *_player, const CardItem *_card, bool _shortcutsActive) : player(_player), card(_card), shortcutsActive(_shortcutsActive) { auto playerActions = player->getPlayerActions(); - const QList &players = player->getGame()->getPlayerManager()->getPlayers().values(); + const QList &players = player->getGame()->getPlayerManager()->getPlayers().values(); for (auto playerToAdd : players) { 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();) { if (it->second == playerToRemove->getPlayerInfo()->getId()) { diff --git a/cockatrice/src/game/player/menu/card_menu.h b/cockatrice/src/game/player/menu/card_menu.h index 3cff238de..d214d3557 100644 --- a/cockatrice/src/game/player/menu/card_menu.h +++ b/cockatrice/src/game/player/menu/card_menu.h @@ -10,14 +10,14 @@ #include class CardItem; -class Player; +class PlayerLogic; class CardMenu : public QMenu { Q_OBJECT public: - explicit CardMenu(Player *player, const CardItem *card, bool shortcutsActive); - void removePlayer(Player *playerToRemove); + explicit CardMenu(PlayerLogic *player, const CardItem *card, bool shortcutsActive); + void removePlayer(PlayerLogic *playerToRemove); void createTableMenu(bool canModifyCard); void createStackMenu(bool canModifyCard); void createGraveyardOrExileMenu(bool canModifyCard); @@ -41,7 +41,7 @@ public: QList aAddCounter, aSetCounter, aRemoveCounter; private: - Player *player; + PlayerLogic *player; const CardItem *card; QList> playersInfo; bool shortcutsActive; diff --git a/cockatrice/src/game/player/menu/custom_zone_menu.cpp b/cockatrice/src/game/player/menu/custom_zone_menu.cpp index b0f3284c9..88b7f3710 100644 --- a/cockatrice/src/game/player/menu/custom_zone_menu.cpp +++ b/cockatrice/src/game/player/menu/custom_zone_menu.cpp @@ -1,13 +1,13 @@ #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); - connect(player, &Player::clearCustomZonesMenu, this, &CustomZoneMenu::clearCustomZonesMenu); - connect(player, &Player::addViewCustomZoneActionToCustomZoneMenu, this, + connect(player, &PlayerLogic::clearCustomZonesMenu, this, &CustomZoneMenu::clearCustomZonesMenu); + connect(player, &PlayerLogic::addViewCustomZoneActionToCustomZoneMenu, this, &CustomZoneMenu::addViewCustomZoneActionToCustomZoneMenu); retranslateUi(); diff --git a/cockatrice/src/game/player/menu/custom_zone_menu.h b/cockatrice/src/game/player/menu/custom_zone_menu.h index c4e66754e..a6ea15892 100644 --- a/cockatrice/src/game/player/menu/custom_zone_menu.h +++ b/cockatrice/src/game/player/menu/custom_zone_menu.h @@ -11,12 +11,12 @@ #include -class Player; +class PlayerLogic; class CustomZoneMenu : public QMenu, public AbstractPlayerComponent { Q_OBJECT public: - explicit CustomZoneMenu(Player *player); + explicit CustomZoneMenu(PlayerLogic *player); void retranslateUi() override; void setShortcutsActive() override { @@ -26,7 +26,7 @@ public: } private: - Player *player; + PlayerLogic *player; private slots: void clearCustomZonesMenu(); void addViewCustomZoneActionToCustomZoneMenu(QString zoneName); diff --git a/cockatrice/src/game/player/menu/grave_menu.cpp b/cockatrice/src/game/player/menu/grave_menu.cpp index c3a5eb433..16a5858ca 100644 --- a/cockatrice/src/game/player/menu/grave_menu.cpp +++ b/cockatrice/src/game/player/menu/grave_menu.cpp @@ -1,14 +1,14 @@ #include "grave_menu.h" #include "../../abstract_game.h" -#include "../player.h" #include "../player_actions.h" +#include "../player_logic.h" #include #include #include -GraveyardMenu::GraveyardMenu(Player *_player, QWidget *parent) : TearOffMenu(parent), player(_player) +GraveyardMenu::GraveyardMenu(PlayerLogic *_player, QWidget *parent) : TearOffMenu(parent), player(_player) { createMoveActions(); createViewActions(); diff --git a/cockatrice/src/game/player/menu/grave_menu.h b/cockatrice/src/game/player/menu/grave_menu.h index 429173afa..167714013 100644 --- a/cockatrice/src/game/player/menu/grave_menu.h +++ b/cockatrice/src/game/player/menu/grave_menu.h @@ -13,7 +13,7 @@ #include #include -class Player; +class PlayerLogic; class GraveyardMenu : public TearOffMenu, public AbstractPlayerComponent { Q_OBJECT @@ -21,7 +21,7 @@ signals: void newPlayerActionCreated(QAction *action); public: - explicit GraveyardMenu(Player *player, QWidget *parent = nullptr); + explicit GraveyardMenu(PlayerLogic *player, QWidget *parent = nullptr); void createMoveActions(); void createViewActions(); void populateRevealRandomMenuWithActivePlayers(); @@ -40,7 +40,7 @@ public: QAction *aMoveGraveToRfg = nullptr; private: - Player *player; + PlayerLogic *player; }; #endif // COCKATRICE_GRAVE_MENU_H diff --git a/cockatrice/src/game/player/menu/hand_menu.cpp b/cockatrice/src/game/player/menu/hand_menu.cpp index 156bf2aa9..6ff177655 100644 --- a/cockatrice/src/game/player/menu/hand_menu.cpp +++ b/cockatrice/src/game/player/menu/hand_menu.cpp @@ -4,14 +4,14 @@ #include "../../../client/settings/shortcuts_settings.h" #include "../../../game_graphics/zones/hand_zone.h" #include "../../abstract_game.h" -#include "../player.h" #include "../player_actions.h" +#include "../player_logic.h" #include #include #include -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) { aViewHand = new QAction(this); diff --git a/cockatrice/src/game/player/menu/hand_menu.h b/cockatrice/src/game/player/menu/hand_menu.h index 76434cc98..4fdd0d6fc 100644 --- a/cockatrice/src/game/player/menu/hand_menu.h +++ b/cockatrice/src/game/player/menu/hand_menu.h @@ -13,7 +13,7 @@ #include #include -class Player; +class PlayerLogic; class PlayerActions; class HandMenu : public TearOffMenu, public AbstractPlayerComponent @@ -21,7 +21,7 @@ class HandMenu : public TearOffMenu, public AbstractPlayerComponent Q_OBJECT public: - HandMenu(Player *player, PlayerActions *actions, QWidget *parent = nullptr); + HandMenu(PlayerLogic *player, PlayerActions *actions, QWidget *parent = nullptr); QMenu *revealHandMenu() const { @@ -43,7 +43,7 @@ private slots: void onRevealRandomHandCardTriggered(); private: - Player *player; + PlayerLogic *player; QAction *aViewHand = nullptr; QAction *aMulligan = nullptr; diff --git a/cockatrice/src/game/player/menu/library_menu.cpp b/cockatrice/src/game/player/menu/library_menu.cpp index 72591575f..8449af05a 100644 --- a/cockatrice/src/game/player/menu/library_menu.cpp +++ b/cockatrice/src/game/player/menu/library_menu.cpp @@ -4,13 +4,13 @@ #include "../../../client/settings/shortcuts_settings.h" #include "../../../interface/widgets/tabs/tab_game.h" #include "../../abstract_game.h" -#include "../player.h" #include "../player_actions.h" +#include "../player_logic.h" #include #include -LibraryMenu::LibraryMenu(Player *_player, QWidget *parent) : TearOffMenu(parent), player(_player) +LibraryMenu::LibraryMenu(PlayerLogic *_player, QWidget *parent) : TearOffMenu(parent), player(_player) { createDrawActions(); createShuffleActions(); @@ -75,8 +75,8 @@ LibraryMenu::LibraryMenu(Player *_player, QWidget *parent) : TearOffMenu(parent) bottomLibraryMenu->addSeparator(); bottomLibraryMenu->addAction(aShuffleBottomCards); - connect(player, &Player::resetTopCardMenuActions, this, &LibraryMenu::resetTopCardMenuActions); - connect(player, &Player::deckChanged, this, &LibraryMenu::enableOpenInDeckEditorAction); + connect(player, &PlayerLogic::resetTopCardMenuActions, this, &LibraryMenu::resetTopCardMenuActions); + connect(player, &PlayerLogic::deckChanged, this, &LibraryMenu::enableOpenInDeckEditorAction); retranslateUi(); } diff --git a/cockatrice/src/game/player/menu/library_menu.h b/cockatrice/src/game/player/menu/library_menu.h index 444e8f516..e69a395e2 100644 --- a/cockatrice/src/game/player/menu/library_menu.h +++ b/cockatrice/src/game/player/menu/library_menu.h @@ -13,7 +13,7 @@ #include #include -class Player; +class PlayerLogic; class PlayerActions; class LibraryMenu : public TearOffMenu, public AbstractPlayerComponent @@ -24,7 +24,7 @@ public slots: void resetTopCardMenuActions(); public: - LibraryMenu(Player *player, QWidget *parent = nullptr); + LibraryMenu(PlayerLogic *player, QWidget *parent = nullptr); void createDrawActions(); void createShuffleActions(); void createMoveActions(); @@ -111,7 +111,7 @@ public: int defaultNumberTopCards = 1; private: - Player *player; + PlayerLogic *player; }; #endif // COCKATRICE_LIBRARY_MENU_H diff --git a/cockatrice/src/game/player/menu/move_menu.cpp b/cockatrice/src/game/player/menu/move_menu.cpp index 91e2d8d10..3a5ad4da3 100644 --- a/cockatrice/src/game/player/menu/move_menu.cpp +++ b/cockatrice/src/game/player/menu/move_menu.cpp @@ -1,10 +1,10 @@ #include "move_menu.h" #include "../card_menu_action_type.h" -#include "../player.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->setData(cmMoveToTopLibrary); diff --git a/cockatrice/src/game/player/menu/move_menu.h b/cockatrice/src/game/player/menu/move_menu.h index dc39cb6a5..59078a5c8 100644 --- a/cockatrice/src/game/player/menu/move_menu.h +++ b/cockatrice/src/game/player/menu/move_menu.h @@ -8,13 +8,13 @@ #define COCKATRICE_MOVE_MENU_H #include -class Player; +class PlayerLogic; class MoveMenu : public QMenu { Q_OBJECT public: - explicit MoveMenu(Player *player); + explicit MoveMenu(PlayerLogic *player); void setShortcutsActive(); void retranslateUi(); diff --git a/cockatrice/src/game/player/menu/player_menu.cpp b/cockatrice/src/game/player/menu/player_menu.cpp index 8a0e4af8b..d04950c96 100644 --- a/cockatrice/src/game/player/menu/player_menu.cpp +++ b/cockatrice/src/game/player/menu/player_menu.cpp @@ -10,7 +10,7 @@ #include -PlayerMenu::PlayerMenu(Player *_player) : QObject(_player), player(_player) +PlayerMenu::PlayerMenu(PlayerLogic *_player) : QObject(_player), player(_player) { playerMenu = new TearOffMenu(); diff --git a/cockatrice/src/game/player/menu/player_menu.h b/cockatrice/src/game/player/menu/player_menu.h index 104c5a930..7532ac225 100644 --- a/cockatrice/src/game/player/menu/player_menu.h +++ b/cockatrice/src/game/player/menu/player_menu.h @@ -8,7 +8,7 @@ #define COCKATRICE_PLAYER_MENU_H #include "../../../interface/widgets/menus/tearoff_menu.h" -#include "../player.h" +#include "../player_logic.h" #include "custom_zone_menu.h" #include "grave_menu.h" #include "hand_menu.h" @@ -37,7 +37,7 @@ private slots: void refreshShortcuts(); public: - explicit PlayerMenu(Player *player); + explicit PlayerMenu(PlayerLogic *player); /// Lifecycle methods: delegate to all managedComponents, plus counters separately via player->getCounters(). void retranslateUi(); @@ -74,7 +74,7 @@ public: void setShortcutsInactive(); private: - Player *player; + PlayerLogic *player; TearOffMenu *playerMenu; QMenu *countersMenu; HandMenu *handMenu; diff --git a/cockatrice/src/game/player/menu/pt_menu.cpp b/cockatrice/src/game/player/menu/pt_menu.cpp index dae03e07f..7dc3035c1 100644 --- a/cockatrice/src/game/player/menu/pt_menu.cpp +++ b/cockatrice/src/game/player/menu/pt_menu.cpp @@ -1,9 +1,9 @@ #include "pt_menu.h" -#include "../player.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(); diff --git a/cockatrice/src/game/player/menu/pt_menu.h b/cockatrice/src/game/player/menu/pt_menu.h index 44112e54f..a1cbd021c 100644 --- a/cockatrice/src/game/player/menu/pt_menu.h +++ b/cockatrice/src/game/player/menu/pt_menu.h @@ -8,14 +8,14 @@ #define COCKATRICE_PT_MENU_H #include -class Player; +class PlayerLogic; class PtMenu : public QMenu { Q_OBJECT public: - explicit PtMenu(Player *player); + explicit PtMenu(PlayerLogic *player); void retranslateUi(); void setShortcutsActive(); diff --git a/cockatrice/src/game/player/menu/rfg_menu.cpp b/cockatrice/src/game/player/menu/rfg_menu.cpp index 8a101c04c..e8aca00cb 100644 --- a/cockatrice/src/game/player/menu/rfg_menu.cpp +++ b/cockatrice/src/game/player/menu/rfg_menu.cpp @@ -1,11 +1,11 @@ #include "rfg_menu.h" -#include "../player.h" #include "../player_actions.h" +#include "../player_logic.h" #include -RfgMenu::RfgMenu(Player *_player, QWidget *parent) : TearOffMenu(parent), player(_player) +RfgMenu::RfgMenu(PlayerLogic *_player, QWidget *parent) : TearOffMenu(parent), player(_player) { createMoveActions(); createViewActions(); diff --git a/cockatrice/src/game/player/menu/rfg_menu.h b/cockatrice/src/game/player/menu/rfg_menu.h index 8f79b2f4a..7025169c8 100644 --- a/cockatrice/src/game/player/menu/rfg_menu.h +++ b/cockatrice/src/game/player/menu/rfg_menu.h @@ -13,12 +13,12 @@ #include #include -class Player; +class PlayerLogic; class RfgMenu : public TearOffMenu, public AbstractPlayerComponent { Q_OBJECT public: - explicit RfgMenu(Player *player, QWidget *parent = nullptr); + explicit RfgMenu(PlayerLogic *player, QWidget *parent = nullptr); void createMoveActions(); void createViewActions(); void retranslateUi() override; @@ -38,7 +38,7 @@ public: QAction *aMoveRfgToGrave = nullptr; private: - Player *player; + PlayerLogic *player; }; #endif // COCKATRICE_RFG_MENU_H diff --git a/cockatrice/src/game/player/menu/say_menu.cpp b/cockatrice/src/game/player/menu/say_menu.cpp index 116fba49a..a2d5ab982 100644 --- a/cockatrice/src/game/player/menu/say_menu.cpp +++ b/cockatrice/src/game/player/menu/say_menu.cpp @@ -1,10 +1,10 @@ #include "say_menu.h" #include "../../../client/settings/cache_settings.h" -#include "../player.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); initSayMenu(); diff --git a/cockatrice/src/game/player/menu/say_menu.h b/cockatrice/src/game/player/menu/say_menu.h index fadf5f368..938990193 100644 --- a/cockatrice/src/game/player/menu/say_menu.h +++ b/cockatrice/src/game/player/menu/say_menu.h @@ -11,12 +11,12 @@ #include -class Player; +class PlayerLogic; class SayMenu : public QMenu, public AbstractPlayerComponent { Q_OBJECT public: - explicit SayMenu(Player *player); + explicit SayMenu(PlayerLogic *player); void retranslateUi() override; void setShortcutsActive() override; @@ -26,7 +26,7 @@ private slots: void initSayMenu(); private: - Player *player; + PlayerLogic *player; bool shortcutsActive = false; }; diff --git a/cockatrice/src/game/player/menu/sideboard_menu.cpp b/cockatrice/src/game/player/menu/sideboard_menu.cpp index beaabfcc6..f88625a1f 100644 --- a/cockatrice/src/game/player/menu/sideboard_menu.cpp +++ b/cockatrice/src/game/player/menu/sideboard_menu.cpp @@ -1,9 +1,9 @@ #include "sideboard_menu.h" -#include "../player.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); connect(aViewSideboard, &QAction::triggered, player->getPlayerActions(), &PlayerActions::actViewSideboard); diff --git a/cockatrice/src/game/player/menu/sideboard_menu.h b/cockatrice/src/game/player/menu/sideboard_menu.h index 4a77d1b52..b5385997f 100644 --- a/cockatrice/src/game/player/menu/sideboard_menu.h +++ b/cockatrice/src/game/player/menu/sideboard_menu.h @@ -11,19 +11,19 @@ #include -class Player; +class PlayerLogic; class SideboardMenu : public QMenu, public AbstractPlayerComponent { Q_OBJECT public: - explicit SideboardMenu(Player *player, QMenu *playerMenu); + explicit SideboardMenu(PlayerLogic *player, QMenu *playerMenu); void retranslateUi() override; void setShortcutsActive() override; void setShortcutsInactive() override; private: - Player *player; + PlayerLogic *player; QAction *aViewSideboard; }; diff --git a/cockatrice/src/game/player/menu/utility_menu.cpp b/cockatrice/src/game/player/menu/utility_menu.cpp index bcb4683fd..f6d9802ae 100644 --- a/cockatrice/src/game/player/menu/utility_menu.cpp +++ b/cockatrice/src/game/player/menu/utility_menu.cpp @@ -1,14 +1,14 @@ #include "utility_menu.h" #include "../../../interface/deck_loader/deck_loader.h" -#include "../player.h" #include "../player_actions.h" +#include "../player_logic.h" #include "player_menu.h" #include #include -UtilityMenu::UtilityMenu(Player *_player, QMenu *playerMenu) : QMenu(playerMenu), player(_player) +UtilityMenu::UtilityMenu(PlayerLogic *_player, QMenu *playerMenu) : QMenu(playerMenu), player(_player) { PlayerActions *playerActions = player->getPlayerActions(); @@ -30,11 +30,11 @@ UtilityMenu::UtilityMenu(Player *_player, QMenu *playerMenu) : QMenu(playerMenu) aCreateAnotherToken->setEnabled(false); aIncrementAllCardCounters = new QAction(this); - connect(aIncrementAllCardCounters, &QAction::triggered, player, &Player::incrementAllCardCounters); + connect(aIncrementAllCardCounters, &QAction::triggered, player, &PlayerLogic::incrementAllCardCounters); createPredefinedTokenMenu = new QMenu(QString()); createPredefinedTokenMenu->setEnabled(false); - connect(player, &Player::deckChanged, this, &UtilityMenu::populatePredefinedTokensMenu); + connect(player, &PlayerLogic::deckChanged, this, &UtilityMenu::populatePredefinedTokensMenu); playerMenu->addAction(aIncrementAllCardCounters); playerMenu->addSeparator(); diff --git a/cockatrice/src/game/player/menu/utility_menu.h b/cockatrice/src/game/player/menu/utility_menu.h index 117a7e13a..6d922d726 100644 --- a/cockatrice/src/game/player/menu/utility_menu.h +++ b/cockatrice/src/game/player/menu/utility_menu.h @@ -11,7 +11,7 @@ #include -class Player; +class PlayerLogic; class UtilityMenu : public QMenu, public AbstractPlayerComponent { Q_OBJECT @@ -22,7 +22,7 @@ public slots: void setShortcutsInactive() override; public: - explicit UtilityMenu(Player *player, QMenu *playerMenu); + explicit UtilityMenu(PlayerLogic *player, QMenu *playerMenu); [[nodiscard]] bool createAnotherTokenActionExists() const { @@ -41,7 +41,7 @@ public: } private: - Player *player; + PlayerLogic *player; QStringList predefinedTokens; QMenu *createPredefinedTokenMenu; diff --git a/cockatrice/src/game/player/player_actions.cpp b/cockatrice/src/game/player/player_actions.cpp index d5ba3b22b..341769899 100644 --- a/cockatrice/src/game/player/player_actions.cpp +++ b/cockatrice/src/game/player/player_actions.cpp @@ -36,7 +36,7 @@ // milliseconds in between triggers of the move top cards until action 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) { moveTopCardTimer = new QTimer(this); @@ -1770,7 +1770,7 @@ void PlayerActions::cardMenuAction() return; } - Player *startPlayer = zone->getPlayer(); + PlayerLogic *startPlayer = zone->getPlayer(); if (!startPlayer) { return; } diff --git a/cockatrice/src/game/player/player_actions.h b/cockatrice/src/game/player/player_actions.h index ba62f1c59..535e37707 100644 --- a/cockatrice/src/game/player/player_actions.h +++ b/cockatrice/src/game/player/player_actions.h @@ -10,7 +10,7 @@ #include "../dialogs/dlg_create_token.h" #include "../dialogs/dlg_move_top_cards_until.h" #include "event_processing_options.h" -#include "player.h" +#include "player_logic.h" #include #include @@ -29,7 +29,7 @@ class CardItem; class Command_MoveCard; class GameEventContext; class PendingCommand; -class Player; +class PlayerLogic; class PlayerActions : public QObject { Q_OBJECT @@ -40,7 +40,7 @@ public: RANDOM_CARD_FROM_ZONE = -2 }; - explicit PlayerActions(Player *player); + explicit PlayerActions(PlayerLogic *player); void sendGameCommand(PendingCommand *pend); void sendGameCommand(const google::protobuf::Message &command); @@ -159,7 +159,7 @@ public slots: void cardMenuAction(); private: - Player *player; + PlayerLogic *player; int defaultNumberTopCards = 1; int defaultNumberTopCardsToPlaceBelow = 1; diff --git a/cockatrice/src/game/player/player_event_handler.cpp b/cockatrice/src/game/player/player_event_handler.cpp index afc32208d..244929338 100644 --- a/cockatrice/src/game/player/player_event_handler.cpp +++ b/cockatrice/src/game/player/player_event_handler.cpp @@ -5,8 +5,8 @@ #include "../board/arrow_item.h" #include "../board/card_item.h" #include "../board/card_list.h" -#include "player.h" #include "player_actions.h" +#include "player_logic.h" #include #include @@ -32,7 +32,7 @@ #include #include -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) { - 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) { return; } @@ -274,13 +274,13 @@ void PlayerEventHandler::eventDumpZone(const Event_DumpZone &event) 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) { return; } QString startZoneString = QString::fromStdString(event.start_zone()); 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) { return; } @@ -353,9 +353,9 @@ void PlayerEventHandler::eventMoveCard(const Event_MoveCard &event, const GameEv // Look at all arrows from and to the card. // If the card was moved to another zone, delete the arrows, otherwise update them. - QMapIterator playerIterator(player->getGame()->getPlayerManager()->getPlayers()); + QMapIterator playerIterator(player->getGame()->getPlayerManager()->getPlayers()); while (playerIterator.hasNext()) { - Player *p = playerIterator.next().value(); + PlayerLogic *p = playerIterator.next().value(); QList arrowsToDelete; QMapIterator arrowIterator(p->getArrows()); @@ -428,8 +428,8 @@ void PlayerEventHandler::eventDestroyCard(const Event_DestroyCard &event) void PlayerEventHandler::eventAttachCard(const Event_AttachCard &event) { - const QMap &playerList = player->getGame()->getPlayerManager()->getPlayers(); - Player *targetPlayer = nullptr; + const QMap &playerList = player->getGame()->getPlayerManager()->getPlayers(); + PlayerLogic *targetPlayer = nullptr; CardZoneLogic *targetZone = nullptr; CardItem *targetCard = nullptr; if (event.has_target_player_id()) { @@ -506,7 +506,7 @@ void PlayerEventHandler::eventRevealCards(const Event_RevealCards &event, EventP if (!zone) { return; } - Player *otherPlayer = nullptr; + PlayerLogic *otherPlayer = nullptr; if (event.has_other_player_id()) { otherPlayer = player->getGame()->getPlayerManager()->getPlayers().value(event.other_player_id()); if (!otherPlayer) { diff --git a/cockatrice/src/game/player/player_event_handler.h b/cockatrice/src/game/player/player_event_handler.h index 9f67d24ab..ae3d9aaae 100644 --- a/cockatrice/src/game/player/player_event_handler.h +++ b/cockatrice/src/game/player/player_event_handler.h @@ -15,7 +15,7 @@ class CardItem; class CardZoneLogic; -class Player; +class PlayerLogic; class Event_AttachCard; class Event_ChangeZoneProperties; class Event_CreateArrow; @@ -40,48 +40,48 @@ class PlayerEventHandler : public QObject Q_OBJECT signals: - void logSay(Player *player, QString message); - void logShuffle(Player *player, CardZoneLogic *zone, int start, int end); - void logRollDie(Player *player, int sides, const QList &rolls); - void logCreateArrow(Player *player, - Player *startPlayer, + void logSay(PlayerLogic *player, QString message); + void logShuffle(PlayerLogic *player, CardZoneLogic *zone, int start, int end); + void logRollDie(PlayerLogic *player, int sides, const QList &rolls); + void logCreateArrow(PlayerLogic *player, + PlayerLogic *startPlayer, QString startCard, - Player *targetPlayer, + PlayerLogic *targetPlayer, QString targetCard, bool _playerTarget); - void logCreateToken(Player *player, QString cardName, QString pt, bool faceDown); - void logDrawCards(Player *player, int number, bool deckIsEmpty); - void logUndoDraw(Player *player, QString cardName); - void logMoveCard(Player *player, + void logCreateToken(PlayerLogic *player, QString cardName, QString pt, bool faceDown); + void logDrawCards(PlayerLogic *player, int number, bool deckIsEmpty); + void logUndoDraw(PlayerLogic *player, QString cardName); + void logMoveCard(PlayerLogic *player, CardItem *card, CardZoneLogic *startZone, int oldX, CardZoneLogic *targetZone, int newX); - void logFlipCard(Player *player, QString cardName, bool faceDown); - void logDestroyCard(Player *player, QString cardName); - void logAttachCard(Player *player, QString cardName, Player *targetPlayer, QString targetCardName); - void logUnattachCard(Player *player, QString cardName); - void logSetCardCounter(Player *player, QString cardName, int counterId, int value, int oldValue); - void logSetTapped(Player *player, CardItem *card, bool tapped); - void logSetCounter(Player *player, QString counterName, int value, int oldValue); - void logSetDoesntUntap(Player *player, CardItem *card, bool doesntUntap); - void logSetPT(Player *player, CardItem *card, QString newPT); - void logSetAnnotation(Player *player, CardItem *card, QString newAnnotation); - void logDumpZone(Player *player, CardZoneLogic *zone, int numberCards, bool isReversed = false); - void logRevealCards(Player *player, + void logFlipCard(PlayerLogic *player, QString cardName, bool faceDown); + void logDestroyCard(PlayerLogic *player, QString cardName); + void logAttachCard(PlayerLogic *player, QString cardName, PlayerLogic *targetPlayer, QString targetCardName); + void logUnattachCard(PlayerLogic *player, QString cardName); + void logSetCardCounter(PlayerLogic *player, QString cardName, int counterId, int value, int oldValue); + void logSetTapped(PlayerLogic *player, CardItem *card, bool tapped); + void logSetCounter(PlayerLogic *player, QString counterName, int value, int oldValue); + void logSetDoesntUntap(PlayerLogic *player, CardItem *card, bool doesntUntap); + void logSetPT(PlayerLogic *player, CardItem *card, QString newPT); + void logSetAnnotation(PlayerLogic *player, CardItem *card, QString newAnnotation); + void logDumpZone(PlayerLogic *player, CardZoneLogic *zone, int numberCards, bool isReversed = false); + void logRevealCards(PlayerLogic *player, CardZoneLogic *zone, int cardId, QString cardName, - Player *otherPlayer, + PlayerLogic *otherPlayer, bool faceDown, int amount, bool isLentToAnotherPlayer = false); - void logAlwaysRevealTopCard(Player *player, CardZoneLogic *zone, bool reveal); - void logAlwaysLookAtTopCard(Player *player, CardZoneLogic *zone, bool reveal); + void logAlwaysRevealTopCard(PlayerLogic *player, CardZoneLogic *zone, bool reveal); + void logAlwaysLookAtTopCard(PlayerLogic *player, CardZoneLogic *zone, bool reveal); public: - PlayerEventHandler(Player *player); + PlayerEventHandler(PlayerLogic *player); void processGameEvent(GameEvent::GameEventType type, const GameEvent &event, @@ -110,7 +110,7 @@ public: void eventChangeZoneProperties(const Event_ChangeZoneProperties &event); private: - Player *player; + PlayerLogic *player; void setCardAttrHelper(const GameEventContext &context, CardItem *card, diff --git a/cockatrice/src/game/player/player_graphics_item.cpp b/cockatrice/src/game/player/player_graphics_item.cpp index c60dbcdd0..eea2434d2 100644 --- a/cockatrice/src/game/player/player_graphics_item.cpp +++ b/cockatrice/src/game/player/player_graphics_item.cpp @@ -8,15 +8,15 @@ #include "../board/abstract_card_item.h" #include "../hand_counter.h" -PlayerGraphicsItem::PlayerGraphicsItem(Player *_player) : player(_player) +PlayerGraphicsItem::PlayerGraphicsItem(PlayerLogic *_player) : player(_player) { connect(&SettingsCache::instance(), &SettingsCache::horizontalHandChanged, this, &PlayerGraphicsItem::rearrangeZones); connect(&SettingsCache::instance(), &SettingsCache::handJustificationChanged, this, &PlayerGraphicsItem::rearrangeZones); - connect(player, &Player::rearrangeCounters, this, &PlayerGraphicsItem::rearrangeCounters); - connect(player, &Player::concededChanged, this, [this](int, bool c) { setVisible(!c); }); - connect(player, &Player::zoneIdChanged, this, [this](int id) { playerArea->setPlayerZoneId(id); }); + connect(player, &PlayerLogic::rearrangeCounters, this, &PlayerGraphicsItem::rearrangeCounters); + connect(player, &PlayerLogic::concededChanged, this, [this](int, bool c) { setVisible(!c); }); + connect(player, &PlayerLogic::zoneIdChanged, this, [this](int id) { playerArea->setPlayerZoneId(id); }); playerArea = new PlayerArea(this); diff --git a/cockatrice/src/game/player/player_graphics_item.h b/cockatrice/src/game/player/player_graphics_item.h index fd4c469e7..33c00be4f 100644 --- a/cockatrice/src/game/player/player_graphics_item.h +++ b/cockatrice/src/game/player/player_graphics_item.h @@ -7,7 +7,7 @@ #ifndef COCKATRICE_PLAYER_GRAPHICS_ITEM_H #define COCKATRICE_PLAYER_GRAPHICS_ITEM_H #include "../game_scene.h" -#include "player.h" +#include "player_logic.h" #include @@ -34,7 +34,7 @@ public: static constexpr int counterAreaWidth = 55; - explicit PlayerGraphicsItem(Player *player); + explicit PlayerGraphicsItem(PlayerLogic *player); void initializeZones(); [[nodiscard]] QRectF boundingRect() const override; @@ -54,7 +54,7 @@ public: return static_cast(scene()); } - Player *getPlayer() const + PlayerLogic *getPlayer() const { return player; } @@ -109,7 +109,7 @@ signals: void playerCountChanged(); private: - Player *player; + PlayerLogic *player; PlayerArea *playerArea; PlayerTarget *playerTarget; PileZone *deckZoneGraphicsItem; diff --git a/cockatrice/src/game/player/player_list_widget.h b/cockatrice/src/game/player/player_list_widget.h index 8f1487563..1815fdccd 100644 --- a/cockatrice/src/game/player/player_list_widget.h +++ b/cockatrice/src/game/player/player_list_widget.h @@ -7,7 +7,7 @@ #ifndef PLAYERLISTWIDGET_H #define PLAYERLISTWIDGET_H -#include "player.h" +#include "player_logic.h" #include #include diff --git a/cockatrice/src/game/player/player.cpp b/cockatrice/src/game/player/player_logic.cpp similarity index 86% rename from cockatrice/src/game/player/player.cpp rename to cockatrice/src/game/player/player_logic.cpp index ce36af9d4..2c09e3634 100644 --- a/cockatrice/src/game/player/player.cpp +++ b/cockatrice/src/game/player/player_logic.cpp @@ -1,4 +1,4 @@ -#include "player.h" +#include "player_logic.h" #include "../../game_graphics/zones/hand_zone.h" #include "../../game_graphics/zones/pile_zone.h" @@ -29,7 +29,7 @@ #include #include -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)), playerEventHandler(new PlayerEventHandler(this)), playerActions(new PlayerActions(this)), active(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); 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::GRAVE, false, false, true, this)); @@ -58,7 +58,7 @@ void Player::initializeZones() addZone(new HandZoneLogic(this, ZoneNames::HAND, false, false, visibleHand, this)); } -Player::~Player() +PlayerLogic::~PlayerLogic() { qCInfo(PlayerLog) << "Player destructor:" << getPlayerInfo()->getName(); @@ -72,7 +72,7 @@ Player::~Player() delete getPlayerInfo()->userInfo; } -void Player::clear() +void PlayerLogic::clear() { clearArrows(); @@ -84,7 +84,7 @@ void Player::clear() clearCounters(); } -void Player::setConceded(bool _conceded) +void PlayerLogic::setConceded(bool _conceded) { if (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) { 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 builtinZones{/* PileZones */ ZoneNames::DECK, ZoneNames::GRAVE, ZoneNames::EXILE, ZoneNames::SIDEBOARD, @@ -202,7 +202,7 @@ void Player::processPlayerInfo(const ServerInfo_Player &info) 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(); 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); } -void Player::deleteCard(CardItem *card) +void PlayerLogic::deleteCard(CardItem *card) { if (card == nullptr) { return; @@ -251,20 +251,20 @@ void Player::deleteCard(CardItem *card) } } -void Player::setDeck(const DeckList &_deck) +void PlayerLogic::setDeck(const DeckList &_deck) { deck = _deck; emit deckChanged(); } -AbstractCounter *Player::addCounter(const ServerInfo_Counter &counter) +AbstractCounter *PlayerLogic::addCounter(const ServerInfo_Counter &counter) { return addCounter(counter.id(), QString::fromStdString(counter.name()), 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)) { return nullptr; @@ -288,7 +288,7 @@ AbstractCounter *Player::addCounter(int counterId, const QString &name, QColor c return ctr; } -void Player::delCounter(int counterId) +void PlayerLogic::delCounter(int counterId) { AbstractCounter *ctr = counters.value(counterId, 0); if (!ctr) { @@ -300,7 +300,7 @@ void Player::delCounter(int counterId) emit rearrangeCounters(); } -void Player::clearCounters() +void PlayerLogic::clearCounters() { QMapIterator counterIterator(counters); while (counterIterator.hasNext()) { @@ -309,7 +309,7 @@ void Player::clearCounters() counters.clear(); } -void Player::incrementAllCardCounters() +void PlayerLogic::incrementAllCardCounters() { auto cardsToUpdate = getGameScene()->selectedCards(); if (cardsToUpdate.isEmpty()) { @@ -345,7 +345,7 @@ void Player::incrementAllCardCounters() } } -AbstractCounter *Player::getLifeCounter() const +AbstractCounter *PlayerLogic::getLifeCounter() const { for (auto counter : counters.values()) { if (counter->getName() == "life") { @@ -355,11 +355,11 @@ AbstractCounter *Player::getLifeCounter() const return nullptr; } -ArrowItem *Player::addArrow(const ServerInfo_Arrow &arrow) +ArrowItem *PlayerLogic::addArrow(const ServerInfo_Arrow &arrow) { - const QMap &playerList = game->getPlayerManager()->getPlayers(); - Player *startPlayer = playerList.value(arrow.start_player_id(), 0); - Player *targetPlayer = playerList.value(arrow.target_player_id(), 0); + const QMap &playerList = game->getPlayerManager()->getPlayers(); + PlayerLogic *startPlayer = playerList.value(arrow.start_player_id(), 0); + PlayerLogic *targetPlayer = playerList.value(arrow.target_player_id(), 0); if (!startPlayer || !targetPlayer) { 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); arrows.insert(arrowId, arrow); @@ -399,7 +399,7 @@ ArrowItem *Player::addArrow(int arrowId, CardItem *startCard, ArrowTarget *targe return arrow; } -void Player::delArrow(int arrowId) +void PlayerLogic::delArrow(int arrowId) { ArrowItem *arr = arrows.value(arrowId, 0); if (!arr) { @@ -408,14 +408,14 @@ void Player::delArrow(int arrowId) arr->delArrow(); } -void Player::removeArrow(ArrowItem *arrow) +void PlayerLogic::removeArrow(ArrowItem *arrow) { if (arrow->getId() != -1) { arrows.remove(arrow->getId()); } } -void Player::clearArrows() +void PlayerLogic::clearArrows() { QMapIterator arrowIterator(arrows); while (arrowIterator.hasNext()) { @@ -424,7 +424,7 @@ void Player::clearArrows() arrows.clear(); } -bool Player::clearCardsToDelete() +bool PlayerLogic::clearCardsToDelete() { if (cardsToDelete.isEmpty()) { return false; @@ -440,28 +440,28 @@ bool Player::clearCardsToDelete() return true; } -void Player::setActive(bool _active) +void PlayerLogic::setActive(bool _active) { active = _active; emit activeChanged(active); } -void Player::updateZones() +void PlayerLogic::updateZones() { getTableZone()->reorganizeCards(); } -PlayerGraphicsItem *Player::getGraphicsItem() +PlayerGraphicsItem *PlayerLogic::getGraphicsItem() { return graphicsItem; } -GameScene *Player::getGameScene() +GameScene *PlayerLogic::getGameScene() { return getGraphicsItem()->getGameScene(); } -void Player::setGameStarted() +void PlayerLogic::setGameStarted() { if (playerInfo->local) { emit resetTopCardMenuActions(); diff --git a/cockatrice/src/game/player/player.h b/cockatrice/src/game/player/player_logic.h similarity index 97% rename from cockatrice/src/game/player/player.h rename to cockatrice/src/game/player/player_logic.h index 43520b7ad..55599f5e2 100644 --- a/cockatrice/src/game/player/player.h +++ b/cockatrice/src/game/player/player_logic.h @@ -62,7 +62,7 @@ class TabGame; const int MAX_TOKENS_PER_DIALOG = 99; -class Player : public QObject +class PlayerLogic : public QObject { Q_OBJECT @@ -82,8 +82,8 @@ public slots: void setActive(bool _active); public: - Player(const ServerInfo_User &info, int _id, bool _local, bool _judge, AbstractGame *_parent); - ~Player() override; + PlayerLogic(const ServerInfo_User &info, int _id, bool _local, bool _judge, AbstractGame *_parent); + ~PlayerLogic() override; void initializeZones(); void updateZones(); diff --git a/cockatrice/src/game/player/player_manager.cpp b/cockatrice/src/game/player/player_manager.cpp index bd50703de..6772d3ff1 100644 --- a/cockatrice/src/game/player/player_manager.cpp +++ b/cockatrice/src/game/player/player_manager.cpp @@ -1,35 +1,35 @@ #include "player_manager.h" #include "../abstract_game.h" -#include "player.h" +#include "player_logic.h" PlayerManager::PlayerManager(AbstractGame *_game, int _localPlayerId, bool _localPlayerIsJudge, bool localPlayerIsSpectator) - : QObject(_game), game(_game), players(QMap()), localPlayerId(_localPlayerId), + : QObject(_game), game(_game), players(QMap()), localPlayerId(_localPlayerId), localPlayerIsJudge(_localPlayerIsJudge), localPlayerIsSpectator(localPlayerIsSpectator) { } bool PlayerManager::isMainPlayerConceded() const { - Player *player = players.value(localPlayerId, nullptr); + PlayerLogic *player = players.value(localPlayerId, nullptr); 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->getPlayerInfo()->getLocal()) { return active; } } - QMapIterator playerIterator(players); + QMapIterator playerIterator(players); while (playerIterator.hasNext()) { - Player *temp = playerIterator.next().value(); + PlayerLogic *temp = playerIterator.next().value(); if (temp->getPlayerInfo()->getLocal()) { return temp; } @@ -43,11 +43,11 @@ bool PlayerManager::isLocalPlayer(int playerId) 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(), - isJudge(), getGame()); - connect(newPlayer, &Player::concededChanged, this, &PlayerManager::onPlayerConceded); + auto *newPlayer = new PlayerLogic(info, playerId, isLocalPlayer(playerId) || game->getGameState()->getIsLocalGame(), + isJudge(), getGame()); + connect(newPlayer, &PlayerLogic::concededChanged, this, &PlayerManager::onPlayerConceded); players.insert(playerId, newPlayer); emit playerAdded(newPlayer); emit playerCountChanged(); @@ -56,7 +56,7 @@ Player *PlayerManager::addPlayer(int playerId, const ServerInfo_User &info) void PlayerManager::removePlayer(int playerId) { - Player *player = getPlayer(playerId); + PlayerLogic *player = getPlayer(playerId); if (!player) { return; } @@ -66,9 +66,9 @@ void PlayerManager::removePlayer(int playerId) 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) { return nullptr; } diff --git a/cockatrice/src/game/player/player_manager.h b/cockatrice/src/game/player/player_manager.h index 0f813b3e4..4f6d62a87 100644 --- a/cockatrice/src/game/player/player_manager.h +++ b/cockatrice/src/game/player/player_manager.h @@ -12,7 +12,7 @@ #include class AbstractGame; -class Player; +class PlayerLogic; class PlayerManager : public QObject { Q_OBJECT @@ -21,7 +21,7 @@ public: PlayerManager(AbstractGame *_game, int _localPlayerId, bool _localPlayerIsJudge, bool localPlayerIsSpectator); AbstractGame *game; - QMap players; + QMap players; int localPlayerId; bool localPlayerIsJudge; bool localPlayerIsSpectator; @@ -42,7 +42,7 @@ public: return localPlayerId; } - [[nodiscard]] const QMap &getPlayers() const + [[nodiscard]] const QMap &getPlayers() const { return players; } @@ -52,14 +52,14 @@ public: return players.size(); } - [[nodiscard]] Player *getActiveLocalPlayer(int activePlayer) const; + [[nodiscard]] PlayerLogic *getActiveLocalPlayer(int activePlayer) const; bool isLocalPlayer(int playerId); - Player *addPlayer(int playerId, const ServerInfo_User &info); + PlayerLogic *addPlayer(int playerId, const ServerInfo_User &info); void removePlayer(int playerId); - [[nodiscard]] Player *getPlayer(int playerId) const; + [[nodiscard]] PlayerLogic *getPlayer(int playerId) const; void onPlayerConceded(int playerId, bool conceded); @@ -106,8 +106,8 @@ public: } signals: - void playerAdded(Player *player); - void playerRemoved(Player *player); + void playerAdded(PlayerLogic *player); + void playerRemoved(PlayerLogic *player); void activeLocalPlayerConceded(); void activeLocalPlayerUnconceded(); void playerConceded(int playerId); diff --git a/cockatrice/src/game/player/player_target.cpp b/cockatrice/src/game/player/player_target.cpp index 36c9ae953..93f2c05d4 100644 --- a/cockatrice/src/game/player/player_target.cpp +++ b/cockatrice/src/game/player/player_target.cpp @@ -1,7 +1,7 @@ #include "player_target.h" #include "../../interface/pixel_map_generator.h" -#include "player.h" +#include "player_logic.h" #include #include @@ -9,7 +9,7 @@ #include #include -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) { } @@ -47,7 +47,7 @@ void PlayerCounter::paint(QPainter *painter, const QStyleOptionGraphicsItem * /* 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) { setCacheMode(DeviceCoordinateCache); diff --git a/cockatrice/src/game/player/player_target.h b/cockatrice/src/game/player/player_target.h index b60464e12..3dbc82336 100644 --- a/cockatrice/src/game/player/player_target.h +++ b/cockatrice/src/game/player/player_target.h @@ -13,13 +13,13 @@ #include -class Player; +class PlayerLogic; class PlayerCounter : public AbstractCounter { Q_OBJECT 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; void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override; }; @@ -43,7 +43,7 @@ public: return Type; } - explicit PlayerTarget(Player *_player = nullptr, QGraphicsItem *parentItem = nullptr); + explicit PlayerTarget(PlayerLogic *_player = nullptr, QGraphicsItem *parentItem = nullptr); ~PlayerTarget() override; QRectF boundingRect() const override; void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override; diff --git a/cockatrice/src/game/zones/card_zone_logic.cpp b/cockatrice/src/game/zones/card_zone_logic.cpp index 411aa19a9..aace7097e 100644 --- a/cockatrice/src/game/zones/card_zone_logic.cpp +++ b/cockatrice/src/game/zones/card_zone_logic.cpp @@ -2,8 +2,8 @@ #include "../../game_graphics/zones/view_zone.h" #include "../board/card_item.h" -#include "../player/player.h" #include "../player/player_actions.h" +#include "../player/player_logic.h" #include "view_zone_logic.h" #include @@ -20,7 +20,7 @@ * @param _contentsKnown whether the cards in the zone are known to the client * @param parent the parent QObject. */ -CardZoneLogic::CardZoneLogic(Player *_player, +CardZoneLogic::CardZoneLogic(PlayerLogic *_player, const QString &_name, bool _hasCardAttr, bool _isShufflable, diff --git a/cockatrice/src/game/zones/card_zone_logic.h b/cockatrice/src/game/zones/card_zone_logic.h index af770b104..63341343b 100644 --- a/cockatrice/src/game/zones/card_zone_logic.h +++ b/cockatrice/src/game/zones/card_zone_logic.h @@ -15,7 +15,7 @@ inline Q_LOGGING_CATEGORY(CardZoneLogicLog, "card_zone_logic"); -class Player; +class PlayerLogic; class ZoneViewZone; class QMenu; class QAction; @@ -35,7 +35,7 @@ signals: void retranslateUi(); public: - explicit CardZoneLogic(Player *_player, + explicit CardZoneLogic(PlayerLogic *_player, const QString &_name, bool _hasCardAttr, bool _isShufflable, @@ -68,7 +68,7 @@ public: return name; } [[nodiscard]] QString getTranslatedName(bool theirOwn, GrammaticalCase gc) const; - [[nodiscard]] Player *getPlayer() const + [[nodiscard]] PlayerLogic *getPlayer() const { return player; } @@ -105,7 +105,7 @@ private slots: void refreshCardInfos(); protected: - Player *player; + PlayerLogic *player; QString name; CardList cards; QList views; diff --git a/cockatrice/src/game/zones/hand_zone_logic.cpp b/cockatrice/src/game/zones/hand_zone_logic.cpp index 2dca1c6f7..36af11131 100644 --- a/cockatrice/src/game/zones/hand_zone_logic.cpp +++ b/cockatrice/src/game/zones/hand_zone_logic.cpp @@ -3,7 +3,7 @@ #include "../board/card_item.h" #include "card_zone_algorithms.h" -HandZoneLogic::HandZoneLogic(Player *_player, +HandZoneLogic::HandZoneLogic(PlayerLogic *_player, const QString &_name, bool _hasCardAttr, bool _isShufflable, diff --git a/cockatrice/src/game/zones/hand_zone_logic.h b/cockatrice/src/game/zones/hand_zone_logic.h index 8f34cc851..e5032b327 100644 --- a/cockatrice/src/game/zones/hand_zone_logic.h +++ b/cockatrice/src/game/zones/hand_zone_logic.h @@ -12,7 +12,7 @@ class HandZoneLogic : public CardZoneLogic { Q_OBJECT public: - HandZoneLogic(Player *_player, + HandZoneLogic(PlayerLogic *_player, const QString &_name, bool _hasCardAttr, bool _isShufflable, diff --git a/cockatrice/src/game/zones/pile_zone_logic.cpp b/cockatrice/src/game/zones/pile_zone_logic.cpp index 440b8df81..66edde4b7 100644 --- a/cockatrice/src/game/zones/pile_zone_logic.cpp +++ b/cockatrice/src/game/zones/pile_zone_logic.cpp @@ -2,7 +2,7 @@ #include "../board/card_item.h" -PileZoneLogic::PileZoneLogic(Player *_player, +PileZoneLogic::PileZoneLogic(PlayerLogic *_player, const QString &_name, bool _hasCardAttr, bool _isShufflable, diff --git a/cockatrice/src/game/zones/pile_zone_logic.h b/cockatrice/src/game/zones/pile_zone_logic.h index 498d0d4a2..68b39ec3a 100644 --- a/cockatrice/src/game/zones/pile_zone_logic.h +++ b/cockatrice/src/game/zones/pile_zone_logic.h @@ -17,7 +17,7 @@ signals: void callUpdate(); public: - PileZoneLogic(Player *_player, + PileZoneLogic(PlayerLogic *_player, const QString &_name, bool _hasCardAttr, bool _isShufflable, diff --git a/cockatrice/src/game/zones/stack_zone_logic.cpp b/cockatrice/src/game/zones/stack_zone_logic.cpp index 7208a259d..2120b9a1d 100644 --- a/cockatrice/src/game/zones/stack_zone_logic.cpp +++ b/cockatrice/src/game/zones/stack_zone_logic.cpp @@ -3,7 +3,7 @@ #include "../board/card_item.h" #include "card_zone_algorithms.h" -StackZoneLogic::StackZoneLogic(Player *_player, +StackZoneLogic::StackZoneLogic(PlayerLogic *_player, const QString &_name, bool _hasCardAttr, bool _isShufflable, diff --git a/cockatrice/src/game/zones/stack_zone_logic.h b/cockatrice/src/game/zones/stack_zone_logic.h index 81b9d6969..a0ac65ebf 100644 --- a/cockatrice/src/game/zones/stack_zone_logic.h +++ b/cockatrice/src/game/zones/stack_zone_logic.h @@ -12,7 +12,7 @@ class StackZoneLogic : public CardZoneLogic { Q_OBJECT public: - StackZoneLogic(Player *_player, + StackZoneLogic(PlayerLogic *_player, const QString &_name, bool _hasCardAttr, bool _isShufflable, diff --git a/cockatrice/src/game/zones/table_zone_logic.cpp b/cockatrice/src/game/zones/table_zone_logic.cpp index e6c9b8101..3d7ac4297 100644 --- a/cockatrice/src/game/zones/table_zone_logic.cpp +++ b/cockatrice/src/game/zones/table_zone_logic.cpp @@ -2,7 +2,7 @@ #include "../board/card_item.h" -TableZoneLogic::TableZoneLogic(Player *_player, +TableZoneLogic::TableZoneLogic(PlayerLogic *_player, const QString &_name, bool _hasCardAttr, bool _isShufflable, diff --git a/cockatrice/src/game/zones/table_zone_logic.h b/cockatrice/src/game/zones/table_zone_logic.h index e173bc637..1e473d4ef 100644 --- a/cockatrice/src/game/zones/table_zone_logic.h +++ b/cockatrice/src/game/zones/table_zone_logic.h @@ -16,7 +16,7 @@ signals: void toggleTapped(); public: - TableZoneLogic(Player *_player, + TableZoneLogic(PlayerLogic *_player, const QString &_name, bool _hasCardAttr, bool _isShufflable, diff --git a/cockatrice/src/game/zones/view_zone_logic.cpp b/cockatrice/src/game/zones/view_zone_logic.cpp index d025fc841..fa4a73d38 100644 --- a/cockatrice/src/game/zones/view_zone_logic.cpp +++ b/cockatrice/src/game/zones/view_zone_logic.cpp @@ -9,7 +9,7 @@ * @param _revealZone if false, the cards will be face down. * @param _writeableRevealZone whether the player can interact with the revealed cards. */ -ZoneViewZoneLogic::ZoneViewZoneLogic(Player *_player, +ZoneViewZoneLogic::ZoneViewZoneLogic(PlayerLogic *_player, CardZoneLogic *_origZone, int _numberCards, bool _revealZone, diff --git a/cockatrice/src/game/zones/view_zone_logic.h b/cockatrice/src/game/zones/view_zone_logic.h index 6bd5ecc8d..ef0fb37f3 100644 --- a/cockatrice/src/game/zones/view_zone_logic.h +++ b/cockatrice/src/game/zones/view_zone_logic.h @@ -30,7 +30,7 @@ public: REMOVE_CARD }; - ZoneViewZoneLogic(Player *_player, + ZoneViewZoneLogic(PlayerLogic *_player, CardZoneLogic *_origZone, int _numberCards, bool _revealZone, diff --git a/cockatrice/src/game_graphics/zones/hand_zone.cpp b/cockatrice/src/game_graphics/zones/hand_zone.cpp index 8bae6ed0a..09e9a5091 100644 --- a/cockatrice/src/game_graphics/zones/hand_zone.cpp +++ b/cockatrice/src/game_graphics/zones/hand_zone.cpp @@ -3,8 +3,8 @@ #include "../../client/settings/cache_settings.h" #include "../../game/board/card_drag_item.h" #include "../../game/board/card_item.h" -#include "../../game/player/player.h" #include "../../game/player/player_actions.h" +#include "../../game/player/player_logic.h" #include "../../interface/theme_manager.h" #include diff --git a/cockatrice/src/game_graphics/zones/pile_zone.cpp b/cockatrice/src/game_graphics/zones/pile_zone.cpp index cbc312d0c..302b983d8 100644 --- a/cockatrice/src/game_graphics/zones/pile_zone.cpp +++ b/cockatrice/src/game_graphics/zones/pile_zone.cpp @@ -2,8 +2,8 @@ #include "../../game/board/card_drag_item.h" #include "../../game/board/card_item.h" -#include "../../game/player/player.h" #include "../../game/player/player_actions.h" +#include "../../game/player/player_logic.h" #include "../../game/zones/pile_zone_logic.h" #include "view_zone.h" diff --git a/cockatrice/src/game_graphics/zones/stack_zone.cpp b/cockatrice/src/game_graphics/zones/stack_zone.cpp index b4c00e04e..9b0545b1d 100644 --- a/cockatrice/src/game_graphics/zones/stack_zone.cpp +++ b/cockatrice/src/game_graphics/zones/stack_zone.cpp @@ -3,8 +3,8 @@ #include "../../game/board/card_drag_item.h" #include "../../game/board/card_item.h" #include "../../game/card_dimensions.h" -#include "../../game/player/player.h" #include "../../game/player/player_actions.h" +#include "../../game/player/player_logic.h" #include "../../game/zones/stack_zone_logic.h" #include "../../interface/theme_manager.h" diff --git a/cockatrice/src/game_graphics/zones/table_zone.cpp b/cockatrice/src/game_graphics/zones/table_zone.cpp index d428a8a33..ffb4adf5c 100644 --- a/cockatrice/src/game_graphics/zones/table_zone.cpp +++ b/cockatrice/src/game_graphics/zones/table_zone.cpp @@ -4,8 +4,8 @@ #include "../../game/board/arrow_item.h" #include "../../game/board/card_drag_item.h" #include "../../game/board/card_item.h" -#include "../../game/player/player.h" #include "../../game/player/player_actions.h" +#include "../../game/player/player_logic.h" #include "../../game/z_values.h" #include "../../game/zones/table_zone_logic.h" #include "../../interface/theme_manager.h" diff --git a/cockatrice/src/game_graphics/zones/view_zone.cpp b/cockatrice/src/game_graphics/zones/view_zone.cpp index 185c1cc6e..805c60638 100644 --- a/cockatrice/src/game_graphics/zones/view_zone.cpp +++ b/cockatrice/src/game_graphics/zones/view_zone.cpp @@ -2,8 +2,8 @@ #include "../../game/board/card_drag_item.h" #include "../../game/board/card_item.h" -#include "../../game/player/player.h" #include "../../game/player/player_actions.h" +#include "../../game/player/player_logic.h" #include "../../game/zones/view_zone_logic.h" #include diff --git a/cockatrice/src/game_graphics/zones/view_zone_widget.cpp b/cockatrice/src/game_graphics/zones/view_zone_widget.cpp index a0e63bea0..03c6d8925 100644 --- a/cockatrice/src/game_graphics/zones/view_zone_widget.cpp +++ b/cockatrice/src/game_graphics/zones/view_zone_widget.cpp @@ -4,8 +4,8 @@ #include "../../filters/syntax_help.h" #include "../../game/board/card_item.h" #include "../../game/game_scene.h" -#include "../../game/player/player.h" #include "../../game/player/player_actions.h" +#include "../../game/player/player_logic.h" #include "../../game/z_values.h" #include "../../interface/pixel_map_generator.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 _writeableRevealZone whether the player can interact with the revealed cards. */ -ZoneViewWidget::ZoneViewWidget(Player *_player, +ZoneViewWidget::ZoneViewWidget(PlayerLogic *_player, CardZoneLogic *_origZone, int numberCards, bool _revealZone, diff --git a/cockatrice/src/game_graphics/zones/view_zone_widget.h b/cockatrice/src/game_graphics/zones/view_zone_widget.h index f5c29cf7d..6d59a5429 100644 --- a/cockatrice/src/game_graphics/zones/view_zone_widget.h +++ b/cockatrice/src/game_graphics/zones/view_zone_widget.h @@ -20,7 +20,7 @@ class QLabel; class QPushButton; class CardZone; class ZoneViewZone; -class Player; +class PlayerLogic; class CardDatabase; class QScrollBar; class GameScene; @@ -65,7 +65,7 @@ private: bool canBeShuffled; int extraHeight; - Player *player; + PlayerLogic *player; bool draggingWindow = false; QPoint dragStartScreenPos; @@ -108,7 +108,7 @@ private slots: void expandWindow(); public: - ZoneViewWidget(Player *_player, + ZoneViewWidget(PlayerLogic *_player, CardZoneLogic *_origZone, int numberCards = 0, bool _revealZone = false, @@ -119,7 +119,7 @@ public: { return zone; } - Player *getPlayer() const + PlayerLogic *getPlayer() const { return player; } diff --git a/cockatrice/src/interface/widgets/tabs/tab_game.cpp b/cockatrice/src/interface/widgets/tabs/tab_game.cpp index 90756dad2..4dc1d1cb1 100644 --- a/cockatrice/src/interface/widgets/tabs/tab_game.cpp +++ b/cockatrice/src/interface/widgets/tabs/tab_game.cpp @@ -10,8 +10,8 @@ #include "../game/game_view.h" #include "../game/log/message_log_widget.h" #include "../game/phases_toolbar.h" -#include "../game/player/player.h" #include "../game/player/player_list_widget.h" +#include "../game/player/player_logic.h" #include "../game/replay.h" #include "../interface/card_picture_loader/card_picture_loader.h" #include "../interface/widgets/cards/card_info_frame_widget.h" @@ -363,7 +363,7 @@ void TabGame::retranslateUi() cardInfoFrameWidget->retranslateUi(); - QMapIterator i(game->getPlayerManager()->getPlayers()); + QMapIterator i(game->getPlayerManager()->getPlayers()); while (i.hasNext()) { i.next().value()->getGraphicsItem()->retranslateUi(); @@ -489,7 +489,7 @@ void TabGame::actGameInfo() void TabGame::actConcede() { - Player *player = game->getPlayerManager()->getActiveLocalPlayer(game->getGameState()->getActivePlayer()); + PlayerLogic *player = game->getPlayerManager()->getActiveLocalPlayer(game->getGameState()->getActivePlayer()); if (player == nullptr) { return; } @@ -606,9 +606,9 @@ void TabGame::actNextPhaseAction() void TabGame::actRemoveLocalArrows() { - QMapIterator playerIterator(game->getPlayerManager()->getPlayers()); + QMapIterator playerIterator(game->getPlayerManager()->getPlayers()); while (playerIterator.hasNext()) { - Player *player = playerIterator.next().value(); + PlayerLogic *player = playerIterator.next().value(); if (!player->getPlayerInfo()->getLocal()) { continue; } @@ -655,14 +655,14 @@ void TabGame::notifyPlayerKicked() msgBox.exec(); } -Player *TabGame::addPlayer(Player *newPlayer) +PlayerLogic *TabGame::addPlayer(PlayerLogic *newPlayer) { QString newPlayerName = "@" + newPlayer->getPlayerInfo()->getName(); addPlayerToAutoCompleteList(newPlayerName); 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); messageLog->connectToPlayerEventHandler(newPlayer->getPlayerEventHandler()); @@ -683,7 +683,7 @@ Player *TabGame::addPlayer(Player *newPlayer) return newPlayer; } -void TabGame::addLocalPlayer(Player *newPlayer, int playerId) +void TabGame::addLocalPlayer(PlayerLogic *newPlayer, int playerId) { if (game->getGameState()->getClients().size() == 1) { 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(); removePlayerFromAutoCompleteList(playerName); @@ -751,13 +751,13 @@ void TabGame::processMultipleRemotePlayerDeckSelect(QVectorplayerDeckView->setReadyStart(ready); } -void TabGame::createZoneForPlayer(Player *newPlayer, int playerId) +void TabGame::createZoneForPlayer(PlayerLogic *newPlayer, int playerId) { if (!game->getPlayerManager()->getSpectators().contains(playerId)) { @@ -820,7 +820,7 @@ void TabGame::startGame(bool _resuming) mainWidget->setCurrentWidget(gamePlayAreaWidget); if (!_resuming) { - QMapIterator playerIterator(game->getPlayerManager()->getPlayers()); + QMapIterator playerIterator(game->getPlayerManager()->getPlayers()); while (playerIterator.hasNext()) { playerIterator.next().value()->setGameStarted(); } @@ -863,15 +863,15 @@ void TabGame::closeGame() 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) { return nullptr; } playerListWidget->setActivePlayer(id); - QMapIterator i(game->getPlayerManager()->getPlayers()); + QMapIterator i(game->getPlayerManager()->getPlayers()); while (i.hasNext()) { i.next(); if (i.value() == player) { diff --git a/cockatrice/src/interface/widgets/tabs/tab_game.h b/cockatrice/src/interface/widgets/tabs/tab_game.h index d8746ccc9..66f23ba09 100644 --- a/cockatrice/src/interface/widgets/tabs/tab_game.h +++ b/cockatrice/src/interface/widgets/tabs/tab_game.h @@ -11,7 +11,7 @@ #include "../game/abstract_game.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/replay/replay_manager.h" #include "tab.h" @@ -99,21 +99,21 @@ private: QMap dockToActions; - Player *addPlayer(Player *newPlayer); - void addLocalPlayer(Player *newPlayer, int playerId); + PlayerLogic *addPlayer(PlayerLogic *newPlayer); + void addLocalPlayer(PlayerLogic *newPlayer, int playerId); void processRemotePlayerDeckSelect(QString deckList, int playerId, QString playerName); void processMultipleRemotePlayerDeckSelect(QVector>> playerIdDeckMap); - void processLocalPlayerDeckSelect(Player *localPlayer, int playerId, ServerInfo_Player playerInfo); - void loadDeckForLocalPlayer(Player *localPlayer, int playerId, ServerInfo_Player playerInfo); + void processLocalPlayerDeckSelect(PlayerLogic *localPlayer, int playerId, ServerInfo_Player playerInfo); + void loadDeckForLocalPlayer(PlayerLogic *localPlayer, 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 stopGame(); void closeGame(); bool leaveGame(); - Player *setActivePlayer(int id); + PlayerLogic *setActivePlayer(int id); void setActivePhase(int phase); void createMenuItems(); void createReplayMenuItems(); @@ -163,7 +163,7 @@ private slots: void actCompleterChanged(); void notifyPlayerJoin(QString playerName); void notifyPlayerKicked(); - void processPlayerLeave(Player *leavingPlayer); + void processPlayerLeave(PlayerLogic *leavingPlayer); void actResetLayout(); void hideEvent(QHideEvent *event) override;