#pragma once

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

#include "blitz/protocol/Protocol.h"

namespace blitz {
namespace protocol {

/**
 * \class PlayerLoginPacket
 * \brief Packet for when a player logs in.
 * %Packet structure :
 * |      PacketType 		|
 * |------------------------|
 * | PacketType::PlayerLogin|
 *
 * |	 Field Name 	|  	 Field Type		|  			  Notes 			   |
 * |--------------------|-------------------|----------------------------------|
 * |	Player Name		|   std::string 	| Name of the player that logged in|
 */
class PlayerLoginPacket : public Packet {
  private:
	std::string m_PlayerName;

  public:
	/**
	 * \brief Default constructor.
	 */
	PlayerLoginPacket() {}
	/**
	 * \brief Constructor.
	 * \param playerName The name of the player that logged in.
	 */
	PlayerLoginPacket(std::string playerName) : m_PlayerName(playerName) {}
	virtual ~PlayerLoginPacket() {}

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

	/**
	 * \brief Get the name of the player that logged in.
	 * \return The name of the player that logged in.
	 */
	const std::string& GetPlayerName() const {
		return m_PlayerName;
	}

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

}  // namespace protocol
}  // namespace blitz
