mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-29 01:53:54 -07:00
[Player] Rename player to player logic (#6913)
Took 13 minutes Took 6 seconds Took 2 minutes Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
71790d8e10
commit
5219cffa6b
79 changed files with 397 additions and 386 deletions
|
|
@ -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 <libcockatrice/card/relation/card_relation.h>
|
||||
#include <libcockatrice/utility/zone_names.h>
|
||||
|
||||
CardMenu::CardMenu(Player *_player, const CardItem *_card, bool _shortcutsActive)
|
||||
CardMenu::CardMenu(PlayerLogic *_player, const CardItem *_card, bool _shortcutsActive)
|
||||
: player(_player), card(_card), shortcutsActive(_shortcutsActive)
|
||||
{
|
||||
auto playerActions = player->getPlayerActions();
|
||||
|
||||
const QList<Player *> &players = player->getGame()->getPlayerManager()->getPlayers().values();
|
||||
const QList<PlayerLogic *> &players = player->getGame()->getPlayerManager()->getPlayers().values();
|
||||
|
||||
for (auto playerToAdd : players) {
|
||||
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()) {
|
||||
|
|
|
|||
|
|
@ -10,14 +10,14 @@
|
|||
#include <QMenu>
|
||||
|
||||
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<QAction *> aAddCounter, aSetCounter, aRemoveCounter;
|
||||
|
||||
private:
|
||||
Player *player;
|
||||
PlayerLogic *player;
|
||||
const CardItem *card;
|
||||
QList<QPair<QString, int>> playersInfo;
|
||||
bool shortcutsActive;
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -11,12 +11,12 @@
|
|||
|
||||
#include <QMenu>
|
||||
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
#include "grave_menu.h"
|
||||
|
||||
#include "../../abstract_game.h"
|
||||
#include "../player.h"
|
||||
#include "../player_actions.h"
|
||||
#include "../player_logic.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QMenu>
|
||||
#include <libcockatrice/utility/zone_names.h>
|
||||
|
||||
GraveyardMenu::GraveyardMenu(Player *_player, QWidget *parent) : TearOffMenu(parent), player(_player)
|
||||
GraveyardMenu::GraveyardMenu(PlayerLogic *_player, QWidget *parent) : TearOffMenu(parent), player(_player)
|
||||
{
|
||||
createMoveActions();
|
||||
createViewActions();
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
#include <QAction>
|
||||
#include <QMenu>
|
||||
|
||||
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
|
||||
|
|
|
|||
|
|
@ -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 <QAction>
|
||||
#include <QMenu>
|
||||
#include <libcockatrice/utility/zone_names.h>
|
||||
|
||||
HandMenu::HandMenu(Player *_player, PlayerActions *actions, QWidget *parent) : TearOffMenu(parent), player(_player)
|
||||
HandMenu::HandMenu(PlayerLogic *_player, PlayerActions *actions, QWidget *parent) : TearOffMenu(parent), player(_player)
|
||||
{
|
||||
if (player->getPlayerInfo()->local || player->getPlayerInfo()->judge) {
|
||||
aViewHand = new QAction(this);
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
#include <QAction>
|
||||
#include <QMenu>
|
||||
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -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 <QAction>
|
||||
#include <QMenu>
|
||||
|
||||
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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
#include <QAction>
|
||||
#include <QMenu>
|
||||
|
||||
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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -8,13 +8,13 @@
|
|||
#define COCKATRICE_MOVE_MENU_H
|
||||
#include <QMenu>
|
||||
|
||||
class Player;
|
||||
class PlayerLogic;
|
||||
class MoveMenu : public QMenu
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MoveMenu(Player *player);
|
||||
explicit MoveMenu(PlayerLogic *player);
|
||||
void setShortcutsActive();
|
||||
void retranslateUi();
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
#include <libcockatrice/protocol/pb/command_reveal_cards.pb.h>
|
||||
|
||||
PlayerMenu::PlayerMenu(Player *_player) : QObject(_player), player(_player)
|
||||
PlayerMenu::PlayerMenu(PlayerLogic *_player) : QObject(_player), player(_player)
|
||||
{
|
||||
playerMenu = new TearOffMenu();
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -8,14 +8,14 @@
|
|||
#define COCKATRICE_PT_MENU_H
|
||||
#include <QMenu>
|
||||
|
||||
class Player;
|
||||
class PlayerLogic;
|
||||
class PtMenu : public QMenu
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PtMenu(Player *player);
|
||||
explicit PtMenu(PlayerLogic *player);
|
||||
void retranslateUi();
|
||||
void setShortcutsActive();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
#include "rfg_menu.h"
|
||||
|
||||
#include "../player.h"
|
||||
#include "../player_actions.h"
|
||||
#include "../player_logic.h"
|
||||
|
||||
#include <libcockatrice/utility/zone_names.h>
|
||||
|
||||
RfgMenu::RfgMenu(Player *_player, QWidget *parent) : TearOffMenu(parent), player(_player)
|
||||
RfgMenu::RfgMenu(PlayerLogic *_player, QWidget *parent) : TearOffMenu(parent), player(_player)
|
||||
{
|
||||
createMoveActions();
|
||||
createViewActions();
|
||||
|
|
|
|||
|
|
@ -13,12 +13,12 @@
|
|||
#include <QAction>
|
||||
#include <QMenu>
|
||||
|
||||
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
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -11,12 +11,12 @@
|
|||
|
||||
#include <QMenu>
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -11,19 +11,19 @@
|
|||
|
||||
#include <QMenu>
|
||||
|
||||
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;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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 <libcockatrice/deck_list/tree/deck_list_card_node.h>
|
||||
#include <libcockatrice/deck_list/tree/inner_deck_list_node.h>
|
||||
|
||||
UtilityMenu::UtilityMenu(Player *_player, QMenu *playerMenu) : QMenu(playerMenu), player(_player)
|
||||
UtilityMenu::UtilityMenu(PlayerLogic *_player, QMenu *playerMenu) : QMenu(playerMenu), player(_player)
|
||||
{
|
||||
PlayerActions *playerActions = player->getPlayerActions();
|
||||
|
||||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
#include <QMenu>
|
||||
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 <QMenu>
|
||||
#include <QObject>
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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 <libcockatrice/protocol/pb/command_set_card_attr.pb.h>
|
||||
#include <libcockatrice/protocol/pb/context_move_card.pb.h>
|
||||
|
|
@ -32,7 +32,7 @@
|
|||
#include <libcockatrice/protocol/pb/event_shuffle.pb.h>
|
||||
#include <libcockatrice/utility/zone_names.h>
|
||||
|
||||
PlayerEventHandler::PlayerEventHandler(Player *_player) : QObject(_player), player(_player)
|
||||
PlayerEventHandler::PlayerEventHandler(PlayerLogic *_player) : QObject(_player), player(_player)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -261,7 +261,7 @@ void PlayerEventHandler::eventDelCounter(const Event_DelCounter &event)
|
|||
|
||||
void PlayerEventHandler::eventDumpZone(const Event_DumpZone &event)
|
||||
{
|
||||
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<int, Player *> playerIterator(player->getGame()->getPlayerManager()->getPlayers());
|
||||
QMapIterator<int, PlayerLogic *> playerIterator(player->getGame()->getPlayerManager()->getPlayers());
|
||||
while (playerIterator.hasNext()) {
|
||||
Player *p = playerIterator.next().value();
|
||||
PlayerLogic *p = playerIterator.next().value();
|
||||
|
||||
QList<ArrowItem *> arrowsToDelete;
|
||||
QMapIterator<int, ArrowItem *> arrowIterator(p->getArrows());
|
||||
|
|
@ -428,8 +428,8 @@ void PlayerEventHandler::eventDestroyCard(const Event_DestroyCard &event)
|
|||
|
||||
void PlayerEventHandler::eventAttachCard(const Event_AttachCard &event)
|
||||
{
|
||||
const QMap<int, Player *> &playerList = player->getGame()->getPlayerManager()->getPlayers();
|
||||
Player *targetPlayer = nullptr;
|
||||
const QMap<int, PlayerLogic *> &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) {
|
||||
|
|
|
|||
|
|
@ -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<uint> &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<uint> &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,
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <QGraphicsObject>
|
||||
|
||||
|
|
@ -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<GameScene *>(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;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
#ifndef PLAYERLISTWIDGET_H
|
||||
#define PLAYERLISTWIDGET_H
|
||||
|
||||
#include "player.h"
|
||||
#include "player_logic.h"
|
||||
|
||||
#include <QIcon>
|
||||
#include <QMap>
|
||||
|
|
|
|||
|
|
@ -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 <libcockatrice/protocol/pb/serverinfo_zone.pb.h>
|
||||
#include <libcockatrice/utility/color.h>
|
||||
|
||||
Player::Player(const ServerInfo_User &info, int _id, bool _local, bool _judge, AbstractGame *_parent)
|
||||
PlayerLogic::PlayerLogic(const ServerInfo_User &info, int _id, bool _local, bool _judge, AbstractGame *_parent)
|
||||
: QObject(_parent), game(_parent), playerInfo(new PlayerInfo(info, _id, _local, _judge)),
|
||||
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<QString> 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<int, AbstractCounter *> 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<int, Player *> &playerList = game->getPlayerManager()->getPlayers();
|
||||
Player *startPlayer = playerList.value(arrow.start_player_id(), 0);
|
||||
Player *targetPlayer = playerList.value(arrow.target_player_id(), 0);
|
||||
const QMap<int, PlayerLogic *> &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<int, ArrowItem *> 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();
|
||||
|
|
@ -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();
|
||||
|
|
@ -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<int, Player *>()), localPlayerId(_localPlayerId),
|
||||
: QObject(_game), game(_game), players(QMap<int, PlayerLogic *>()), 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<int, Player *> playerIterator(players);
|
||||
QMapIterator<int, PlayerLogic *> 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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
#include <libcockatrice/protocol/pb/serverinfo_playerproperties.pb.h>
|
||||
|
||||
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<int, Player *> players;
|
||||
QMap<int, PlayerLogic *> players;
|
||||
int localPlayerId;
|
||||
bool localPlayerIsJudge;
|
||||
bool localPlayerIsSpectator;
|
||||
|
|
@ -42,7 +42,7 @@ public:
|
|||
return localPlayerId;
|
||||
}
|
||||
|
||||
[[nodiscard]] const QMap<int, Player *> &getPlayers() const
|
||||
[[nodiscard]] const QMap<int, PlayerLogic *> &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);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#include "player_target.h"
|
||||
|
||||
#include "../../interface/pixel_map_generator.h"
|
||||
#include "player.h"
|
||||
#include "player_logic.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QPainter>
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
#include <QtMath>
|
||||
#include <libcockatrice/protocol/pb/serverinfo_user.pb.h>
|
||||
|
||||
PlayerCounter::PlayerCounter(Player *_player, int _id, const QString &_name, int _value, QGraphicsItem *parent)
|
||||
PlayerCounter::PlayerCounter(PlayerLogic *_player, int _id, const QString &_name, int _value, QGraphicsItem *parent)
|
||||
: AbstractCounter(_player, _id, _name, false, _value, false, parent)
|
||||
{
|
||||
}
|
||||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -13,13 +13,13 @@
|
|||
|
||||
#include <QPixmap>
|
||||
|
||||
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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue