#pragma once

/**
 * \file PlayerJoinPacket.h
 * \brief File containing the blitz::protocol::PlayerJoinPacket class
 */

#include "blitz/common/Defines.h"
#include "blitz/protocol/Protocol.h"

namespace blitz {
namespace protocol {

/**
 * \class PlayerJoinPacket
 * \brief %Packet sent when a new player joins the game \n
 * %Packet structure :
 * |      PacketType 		|
 * |------------------------|
 * | PacketType::PlayerJoin	|
 *
 * |	 Field Name 	|  	 Field Type		|  			  Notes 			|
 * |--------------------|-------------------|-------------------------------|
 * |	Player ID		|  game::PlayerID	|  Id of the player who joined	|
 * |	Player Name		|   std::string 	| Name of the player who joined	|
 *
 */
class PlayerJoinPacket : public Packet {
  private:
	game::PlayerID m_PlayerID;
	std::string m_PlayerName;

  public:
	PlayerJoinPacket() {}
	PlayerJoinPacket(game::PlayerID playerID, const std::string& playerName) : m_PlayerID(playerID), m_PlayerName(playerName) {}
	virtual ~PlayerJoinPacket() {}

	virtual DataBuffer Serialize(bool packetID = true) const;
	virtual void Deserialize(DataBuffer& data);
	virtual void Dispatch(PacketHandler* handler) const;

	/**
	 * \brief Getter of the player id
	 * \return The ID of the player
	 */
	game::PlayerID GetPlayerID() const {
		return m_PlayerID;
	}

	/**
	 * \brief Getter of the player name
	 * \return The name of the player
	 */
	const std::string& GetPlayerName() const {
		return m_PlayerName;
	}

	virtual PacketType GetType() const {
		return PacketType::PlayerJoin;
	}
};

}  // namespace protocol
}  // namespace blitz
