#pragma once

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

#include "blitz/game/Game.h"
#include "blitz/protocol/Protocol.h"

namespace blitz {
namespace protocol {

/**
 * \class UpdateGameStatePacket
 * \brief Packet for updating the game state.
 * %Packet structure :
 * |      PacketType 		     |
 * |-----------------------------|
 * | PacketType::UpdateGameState |
 *
 * |	 Field Name 	|  	 Field Type		|  			          Notes 	               |
 * |--------------------|-------------------|----------------------------------------------|
 * |	Game State		|    GameState		|             The new game state               |
 * |	Time Remaining	|    std::uint64_t	| The time remaining in the current game state |
 */
class UpdateGameStatePacket : public Packet {
  private:
	game::GameState m_GameState;
	std::uint64_t m_TimeRemaining;

  public:
	/**
	 * \brief Default constructor.
	 */
	UpdateGameStatePacket() {}
	/**
	 * \brief Constructor.
	 * \param a_GameState The new game state.
	 * \param a_TimeRemaining The time remaining in the current game state.
	 */
	UpdateGameStatePacket(game::GameState a_GameState, std::uint64_t a_TimeRemaining = 0) :
		m_GameState(a_GameState), m_TimeRemaining(a_TimeRemaining) {}
	virtual ~UpdateGameStatePacket() {}

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

	/**
	 * \brief Get the new game state.
	 * \return The new game state.
	 */
	game::GameState GetGameState() const {
		return m_GameState;
	}

	/**
	 * \brief Get the time remaining in the current game state.
	 * \return The time remaining in the current game state.
	 */
	std::uint64_t GetTimeRemaining() const {
		return m_TimeRemaining;
	}

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

}  // namespace protocol
}  // namespace blitz