From 9beb8e824595674571bd167a7fc9024ef9ccb56b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20Br=C3=BCbach?= Date: Tue, 9 Sep 2025 11:37:24 +0200 Subject: [PATCH] Reorganize method/variable definitions, remove unused ones. Took 1 hour 8 minutes Took 24 seconds --- cockatrice/src/game/player/player.cpp | 4 +- cockatrice/src/game/player/player.h | 101 ++++++++++++----------- cockatrice/src/game/player/player_info.h | 10 --- 3 files changed, 53 insertions(+), 62 deletions(-) diff --git a/cockatrice/src/game/player/player.cpp b/cockatrice/src/game/player/player.cpp index 635d7384b..aaf4466d1 100644 --- a/cockatrice/src/game/player/player.cpp +++ b/cockatrice/src/game/player/player.cpp @@ -47,8 +47,8 @@ Player::Player(const ServerInfo_User &info, int _id, bool _local, bool _judge, TabGame *_parent) : QObject(_parent), game(_parent), playerInfo(new PlayerInfo(info, _id, _local, _judge)), - playerEventHandler(new PlayerEventHandler(this)), playerActions(new PlayerActions(this)), dialogSemaphore(false), - active(false) + playerEventHandler(new PlayerEventHandler(this)), playerActions(new PlayerActions(this)), active(false), + dialogSemaphore(false) { initializeZones(); diff --git a/cockatrice/src/game/player/player.h b/cockatrice/src/game/player/player.h index 22f994f31..d4742d5e6 100644 --- a/cockatrice/src/game/player/player.h +++ b/cockatrice/src/game/player/player.h @@ -57,6 +57,7 @@ const int MAX_TOKENS_PER_DIALOG = 99; class Player : public QObject { Q_OBJECT + signals: void openDeckEditor(const DeckLoader *deck); void newCardAdded(AbstractCardItem *card); @@ -74,9 +75,35 @@ public: ~Player() override; void retranslateUi(); - [[nodiscard]] PlayerInfo *getPlayerInfo() const + void initializeZones(); + void updateZones(); + void clear(); + + void processPlayerInfo(const ServerInfo_Player &info); + void processCardAttachment(const ServerInfo_Player &info); + + void addCard(CardItem *c); + void deleteCard(CardItem *c); + + bool clearCardsToDelete(); + + bool getActive() const { - return playerInfo; + return active; + } + + TabGame *getGame() const + { + return game; + } + + GameScene *getGameScene(); + + [[nodiscard]] PlayerGraphicsItem *getGraphicsItem(); + + [[nodiscard]] PlayerActions *getPlayerActions() const + { + return playerActions; }; [[nodiscard]] PlayerEventHandler *getPlayerEventHandler() const @@ -84,19 +111,14 @@ public: return playerEventHandler; } - [[nodiscard]] PlayerActions *getPlayerActions() const + [[nodiscard]] PlayerInfo *getPlayerInfo() const { - return playerActions; + return playerInfo; }; - TabGame *getGame() const + [[nodiscard]] PlayerMenu *getPlayerMenu() const { - return game; - } - - const QMap &getArrows() const - { - return arrows; + return playerMenu; } template T *addZone(T *zone) @@ -105,16 +127,16 @@ public: return zone; } - const QMap &getZones() const - { - return zones; - } - CardZoneLogic *getZone(const QString zoneName) { return zones.value(zoneName); } + const QMap &getZones() const + { + return zones; + } + PileZoneLogic *getDeckZone() { return qobject_cast(zones.value("deck")); @@ -150,43 +172,12 @@ public: return qobject_cast(zones.value("hand")); } - void updateZones(); - - void clear(); - void initializeZones(); - - bool getActive() const - { - return active; - } - - [[nodiscard]] PlayerGraphicsItem *getGraphicsItem(); - - GameScene *getGameScene(); - - PlayerMenu *getPlayerMenu() const - { - return playerMenu; - } - - void setDialogSemaphore(const bool _active) - { - dialogSemaphore = _active; - } - - void processPlayerInfo(const ServerInfo_Player &info); - void processCardAttachment(const ServerInfo_Player &info); - - void addCard(CardItem *c); - void deleteCard(CardItem *c); - - bool clearCardsToDelete(); - AbstractCounter *addCounter(const ServerInfo_Counter &counter); AbstractCounter *addCounter(int counterId, const QString &name, QColor color, int radius, int value); void delCounter(int counterId); void clearCounters(); void incrementAllCardCounters(); + QMap getCounters() { return counters; @@ -198,8 +189,18 @@ public: void removeArrow(ArrowItem *arrow); void clearArrows(); + const QMap &getArrows() const + { + return arrows; + } + void setGameStarted(); + void setDialogSemaphore(const bool _active) + { + dialogSemaphore = _active; + } + private: TabGame *game; PlayerInfo *playerInfo; @@ -208,6 +209,8 @@ private: PlayerMenu *playerMenu; PlayerGraphicsItem *graphicsItem; + bool active; + QMap zones; QMap counters; QMap arrows; @@ -215,8 +218,6 @@ private: bool dialogSemaphore; QList cardsToDelete; - bool active; - // void eventConnectionStateChanged(const Event_ConnectionStateChanged &event); }; diff --git a/cockatrice/src/game/player/player_info.h b/cockatrice/src/game/player/player_info.h index 0fdd3a33c..01a6fc690 100644 --- a/cockatrice/src/game/player/player_info.h +++ b/cockatrice/src/game/player/player_info.h @@ -28,16 +28,6 @@ public: DeckLoader *deck; QStringList predefinedTokens; - StackZone *stack; - TableZone *table; - HandZone *hand; - PlayerTarget *playerTarget; - - PlayerTarget *getPlayerTarget() const - { - return playerTarget; - } - int getZoneId() const { return zoneId;