use crate::{
Attribute,
AttributeDef,
DescriptionFormat,
EffectType,
ItemAttribute,
TryFromIntAttributeValue,
};
use num_enum::{IntoPrimitive, TryFromPrimitive};
use serde_repr::{Deserialize_repr, Serialize_repr};
use strum::{Display, EnumCount, EnumIter, EnumString};
#[derive(
Debug,
Clone,
Copy,
Eq,
PartialEq,
Ord,
PartialOrd,
Hash,
Display,
Serialize_repr,
Deserialize_repr,
EnumString,
EnumIter,
EnumCount,
TryFromPrimitive,
IntoPrimitive,
)]
#[repr(u32)]
#[strum(serialize_all = "title_case")]
#[allow(missing_docs)]
pub enum Killstreaker {
FireHorns = 2002,
CerebralDischarge = 2003,
Tornado = 2004,
Flames = 2005,
Singularity = 2006,
Incinerator = 2007,
#[strum(serialize = "Hypno-Beam")]
HypnoBeam = 2008,
}
impl Attribute for Killstreaker {
const DEFINDEX: u32 = 2013;
const USES_FLOAT_VALUE: bool = true;
const ATTRIBUTE: AttributeDef = AttributeDef {
defindex: 2013,
name: "killstreak effect",
attribute_class: Some("killstreak_effect"),
description_string: Some("Killstreaker: %s1"),
description_format: Some(DescriptionFormat::ValueIsKillstreakEffectIndex),
effect_type: EffectType::Positive,
hidden: false,
stored_as_integer: false,
};
fn attribute_float_value(&self) -> Option<f32> {
Some((*self as u32) as f32)
}
}
impl TryFromIntAttributeValue for Killstreaker {}
impl From<Killstreaker> for ItemAttribute {
fn from(val: Killstreaker) -> Self {
ItemAttribute {
defindex: Killstreaker::DEFINDEX,
value: val.attribute_value(),
float_value: val.attribute_float_value(),
}
}
}