#pragma once

#include "td/protocol/Protocol.h"
#include "td/game/BaseGame.h"

namespace td {
namespace protocol {

struct WorldHeader {
	game::TowerTileColorPalette m_TowerPlacePalette;
	Color m_WalkablePalette;
	std::vector<Color> m_DecorationPalette;
	Color m_Background;

	game::SpawnColorPalette m_SpawnColorPalette;

	game::TilePalette m_TilePalette;

	game::Spawn m_RedSpawn, m_BlueSpawn;
	game::TeamCastle m_RedCastle, m_BlueCastle;

	const game::World* m_World;
};

class WorldBeginDataPacket : public Packet {
private:
	WorldHeader m_Header;
public:
	WorldBeginDataPacket() {}
	WorldBeginDataPacket(const game::World* world) {
		m_Header.m_World = world;
	}
	virtual ~WorldBeginDataPacket() {}

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

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

	const game::TowerTileColorPalette& GetTowerTilePalette() const { return m_Header.m_TowerPlacePalette; }
	const Color& GetWalkableTileColor() const { return m_Header.m_WalkablePalette; }
	const std::vector<Color>& GetDecorationPalette() const { return m_Header.m_DecorationPalette; }
	const Color& GetBackgroundColor() const { return m_Header.m_Background; }

	const game::Spawn& GetRedSpawn() const { return m_Header.m_RedSpawn; }
	const game::Spawn& GetBlueSpawn() const { return m_Header.m_BlueSpawn; }

	const game::SpawnColorPalette& GetSpawnPalette() const { return m_Header.m_SpawnColorPalette; }

	const game::TeamCastle& GetRedCastle() const { return m_Header.m_RedCastle; }
	const game::TeamCastle& GetBlueCastle() const { return m_Header.m_BlueCastle; }

	const game::TilePalette GetTilePalette() const { return m_Header.m_TilePalette; }

	void setWorldHeader(const WorldHeader& header) { m_Header = header; }
};

} // namespace protocol
} // namespace td
