Skip to content

Commit

Permalink
Removed direct Game reference from Players header to speed up build
Browse files Browse the repository at this point in the history
  • Loading branch information
Arcidev committed Aug 25, 2024
1 parent f9b8e22 commit de94574
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 4 deletions.
1 change: 1 addition & 0 deletions Server/Server/ConnectedUser.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <iostream>
#include "ConnectedUser.h"
#include "Game.h"
#include "Player.h"
#include "NetworkServices.h"
#include "ServerNetwork.h"
Expand Down
1 change: 1 addition & 0 deletions Server/Server/PacketHandlers/CardHandler.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "PacketHandler.h"
#include "../ConnectedUser.h"
#include "../DataHolder.h"
#include "../Game.h"
#include "../Player.h"
#include "../Cards/PlayableCard.h"
#include "../../Shared/SharedDefines.h"
Expand Down
1 change: 1 addition & 0 deletions Server/Server/PacketHandlers/ChatHandler.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "PacketHandler.h"
#include "../ConnectedUser.h"
#include "../Game.h"
#include "../Player.h"
#include "../ServerNetwork.h"
#include "../../Shared/SharedDefines.h"
Expand Down
1 change: 1 addition & 0 deletions Server/Server/PacketHandlers/MiscHandler.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "PacketHandler.h"
#include "../ConnectedUser.h"
#include "../Game.h"
#include "../Player.h"
#include "../../Shared/SharedDefines.h"
#include "../../Crypto/Aes.h"
Expand Down
13 changes: 12 additions & 1 deletion Server/Server/Player.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#include <algorithm>
#include <random>
#include "Player.h"
#include "ConnectedUser.h"
#include "DataHolder.h"
#include "Game.h"
#include "Player.h"
#include "ServerNetwork.h"
#include "Cards/PlayableCard.h"
#include "PacketHandlers/PacketHandler.h"
Expand Down Expand Up @@ -257,6 +258,16 @@ inline std::string_view Player::GetName() const
return m_user->GetName();
}

inline Player* Player::GetOpponent() const
{
return m_game->GetOpponent(this);
}

inline bool Player::IsActive() const
{
return m_game->GetActivePlayer() == this;
}

void Player::SendGameInfo() const
{
Player const* opponent = GetOpponent();
Expand Down
6 changes: 3 additions & 3 deletions Server/Server/Player.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
#include <string>
#include <vector>
#include <list>
#include "Game.h"
#include "PlayerDefines.h"
#include "Cards/CardDefines.h"
#include "Spells/SpellDefines.h"

class Card;
class ConnectedUser;
class Game;
class Packet;
class PlayableCard;
class Spell;
Expand Down Expand Up @@ -67,7 +67,7 @@ class Player
void Disconnect() const;
void HandleDeckCards(bool addCard);

Player* GetOpponent() const { return m_game->GetOpponent(this); }
Player* GetOpponent() const;
PlayableCard* GetCurrentCard();
CardsMap const& GetCards() const { return m_cards; }
std::vector<PlayableCard*> const& GetCurrentCards() const { return m_currentCards; }
Expand All @@ -78,5 +78,5 @@ class Player
std::string_view GetName() const;
ConnectedUser* GetUser() const { return m_user; }
bool IsPrepared() const { return m_isPrepared; }
bool IsActive() const { return m_game->GetActivePlayer() == this; }
bool IsActive() const;
};

0 comments on commit de94574

Please sign in to comment.