use std::str::FromStr;
use serde::{Deserialize, Serialize};


#[derive(Debug, Serialize, Deserialize)]
pub enum ConditionType {
  #[serde(rename = "blinded")]
  Blinded,
  #[serde(rename = "charmed")]
  Charmed,
  #[serde(rename = "deafened")]
  Deafened,
  #[serde(rename = "exhaustion")]
  Exhaustion,
  #[serde(rename = "frightened")]
  Frightened,
  #[serde(rename = "grappled")]
  Grappled,
  #[serde(rename = "incapacitated")]
  Incapacitated,
  #[serde(rename = "invisible")]
  Invisible,
  #[serde(rename = "paralyzed")]
  Paralyzed,
  #[serde(rename = "petrified")]
  Petrified,
  #[serde(rename = "poisoned")]
  Poisoned,
  #[serde(rename = "prone")]
  Prone,
  #[serde(rename = "restrained")]
  Restrained,
  #[serde(rename = "stunned")]
  Stunned,
  #[serde(rename = "unconscious")]
  Unconscious
}

impl ConditionType {
  pub fn to_string(&self) -> String {
    match self {
      ConditionType::Blinded => "Blinded".to_string(),
      ConditionType::Charmed => "Charmed".to_string(),
      ConditionType::Deafened => "Deafened".to_string(),
      ConditionType::Exhaustion => "Exhaustion".to_string(),
      ConditionType::Frightened => "Frightened".to_string(),
      ConditionType::Grappled => "Grappled".to_string(),
      ConditionType::Incapacitated => "Incapacitated".to_string(),
      ConditionType::Invisible => "Invisible".to_string(),
      ConditionType::Paralyzed => "Paralyzed".to_string(),
      ConditionType::Petrified => "Petrified".to_string(),
      ConditionType::Poisoned => "Poisoned".to_string(),
      ConditionType::Prone => "Prone".to_string(),
      ConditionType::Restrained => "Restrained".to_string(),
      ConditionType::Stunned => "Stunned".to_string(),
      ConditionType::Unconscious => "Unconscious".to_string()
    }
  }
}

impl FromStr for ConditionType {
  type Err = ();
  fn from_str(s: &str) -> Result<Self, Self::Err> {
    match s {
      "Blinded" => Ok(ConditionType::Blinded),
      "Charmed" => Ok(ConditionType::Charmed),
      "Deafened" => Ok(ConditionType::Deafened),
      "Exhaustion" => Ok(ConditionType::Exhaustion),
      "Frightened" => Ok(ConditionType::Frightened),
      "Grappled" => Ok(ConditionType::Grappled),
      "Incapacitated" => Ok(ConditionType::Incapacitated),
      "Invisible" => Ok(ConditionType::Invisible),
      "Paralyzed" => Ok(ConditionType::Paralyzed),
      "Petrified" => Ok(ConditionType::Petrified),
      "Poisoned" => Ok(ConditionType::Poisoned),
      "Prone" => Ok(ConditionType::Prone),
      "Restrained" => Ok(ConditionType::Restrained),
      "Stunned" => Ok(ConditionType::Stunned),
      "Unconscious" => Ok(ConditionType::Unconscious),
      _ => Err(())
    }
  }
}
