#pragma once

#include "blitz/game/Game.h"
#include "blitz/game/LeaderBoard.h"
#include "blitz/protocol/PacketHandler.h"
#include <vector>

namespace blitz {

class Client;

namespace client {

class ClientGame : public game::Game, public protocol::PacketHandler {
  private:
	Client* m_Client;
	game::LeaderBoard m_LeaderBoard;

  public:
	ClientGame(Client* client, protocol::PacketDispatcher* dispatcher);
	virtual ~ClientGame();

	void Tick(std::uint64_t delta) override;

	virtual void HandlePacket(const protocol::PlayerJoinPacket* packet) override;
	virtual void HandlePacket(const protocol::PlayerLeavePacket* packet) override;
	virtual void HandlePacket(const protocol::PlayerListPacket* packet) override;
	virtual void HandlePacket(const protocol::PlayerPositionAndRotationPacket* packet) override;
	virtual void HandlePacket(const protocol::PlayerShootPacket* packet) override;
	virtual void HandlePacket(const protocol::UpdateHealthPacket* packet) override;
	virtual void HandlePacket(const protocol::PlayerStatsPacket* packet) override;
	virtual void HandlePacket(const protocol::UpdateGameStatePacket* packet) override;
	virtual void HandlePacket(const protocol::ServerConfigPacket* packet) override;

	virtual void AddPlayer(game::PlayerID player, const std::string& name) override;
	virtual void RemovePlayer(game::PlayerID player) override;

	const game::LeaderBoard& GetLeaderBoard() const {
		return m_LeaderBoard;
	}

  private:
	void RegisterHandlers();
};

}  // namespace client
}  // namespace blitz
