#pragma once

#include "blitz/misc/Maths.h"
#include "blitz/protocol/Protocol.h"
#include <vector>

namespace blitz {
namespace protocol {

struct ColoredPart {
	Vec4f color;
	std::string text;
};

typedef std::vector<ColoredPart> ColoredText;

class ChatPacket : public Packet {
  private:
	ColoredText m_Message;

  public:
	ChatPacket() {}
	ChatPacket(const std::string& msg) : m_Message(ColorizeText(msg)) {}
	ChatPacket(const ColoredText& msg) : m_Message(msg) {}
	virtual ~ChatPacket() {}

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

	const ColoredText& GetMessage() const {
		return m_Message;
	}

	static std::string GetTextColor(Vec3uc color);
	static ColoredText ColorizeText(const std::string& text);
	static std::string GetColoredTextString(const ColoredText& text);

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

const static Vec3uc AQUA = {0, 255, 255};
const static Vec3uc BLUE = {0, 0, 255};
const static Vec3uc GREEN = {0, 255, 0};
const static Vec3uc PURPLE = {255, 0, 255};
const static Vec3uc RED = {255, 0, 0};
const static Vec3uc WHITE = {255, 255, 255};
const static Vec3uc YELLOW = {255, 255, 0};

}  // namespace protocol
}  // namespace blitz
