#pragma once

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

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

namespace blitz {
namespace protocol {

/**
 * \class PlayerLeavePacket
 * \brief Packet for when a player leaves the game.
 * %Packet structure :
 * |      PacketType 		|
 * |------------------------|
 * | PacketType::PlayerLeave|
 *
 * |	 Field Name 	|  	 Field Type		|  			  Notes 			|
 * |--------------------|-------------------|-------------------------------|
 * |	m_PlayerID		|     PlayerID		|The ID of the player that left |
 */
class PlayerLeavePacket : public Packet {
  private:
	game::PlayerID m_PlayerID;

  public:
	/**
	 * \brief Default constructor.
	 */
	PlayerLeavePacket() {}
	/**
	 * \brief Constructor.
	 * \param playerID The ID of the player that left.
	 */
	PlayerLeavePacket(game::PlayerID playerID) : m_PlayerID(playerID) {}
	virtual ~PlayerLeavePacket() {}

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

	/**
	 * \brief Get the ID of the player that left.
	 * \return The ID of the player that left.
	 */
	game::PlayerID GetPlayerID() const {
		return m_PlayerID;
	}

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

}  // namespace protocol
}  // namespace blitz
