use std::fmt::Display;

use serde::Deserialize;

#[derive(Debug, Deserialize, PartialEq, Eq, Clone)]
pub struct Route {
	pub id: u32,
	pub name: String,
	pub color: RouteColor,
	pub tips: Vec<Tip>,
	#[serde(skip_deserializing)]
	pub interaction: Interaction,
}

#[derive(Debug, Default, Deserialize, PartialEq, Eq, Clone)]
pub enum Interaction {
	#[default]
	None,
	Poke,
	Rub,
}

impl Display for Interaction {
	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
		match self {
			Interaction::Poke => f.write_str("Poke"),
			Interaction::Rub => f.write_str("Rub"),
			_ => f.write_str(""),
		}
	}
}

#[derive(Debug, Default, Deserialize, PartialEq, Eq, Clone)]
pub enum RouteColor {
	#[default]
	#[serde(alias = "blue")]
	Blue,
	#[serde(alias = "purple")]
	Purple,
	#[serde(alias = "yellow")]
	Yellow,
	#[serde(alias = "green")]
	Green,

	#[serde(alias = "secret1")]
	SecretGreen,
	#[serde(alias = "secret2")]
	SecretRed,
}

impl Display for RouteColor {
	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
		match self {
			RouteColor::Blue => f.write_str("blue"),
			RouteColor::Purple => f.write_str("purple"),
			RouteColor::Yellow => f.write_str("yellow"),
			RouteColor::Green => f.write_str("green"),

			RouteColor::SecretGreen => f.write_str("secret1"),
			RouteColor::SecretRed => f.write_str("secret2"),
		}
	}
}

#[derive(Debug, Deserialize, PartialEq, Eq, Clone)]
pub struct Tip {
	pub to: String,
	#[serde(skip_deserializing)]
	pub to_color: RouteColor,
	pub tip: String,
}
