use crate::{
event::{impl_common, CommonEvent},
extract::Extract,
Event, EventCategory, TryExtract,
};
use num_enum::{FromPrimitive, IntoPrimitive};
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
#[cfg(feature = "strum")]
use strum::{Display, EnumCount, EnumIter, IntoStaticStr, VariantNames};
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct BuffDamageEvent {
#[cfg_attr(feature = "serde", serde(flatten))]
pub common: CommonEvent,
pub buff: u8,
pub damage: i32,
pub cycle: BuffCycle,
pub result: BuffDamageResult,
}
impl_common!(BuffDamageEvent);
impl Extract for BuffDamageEvent {
#[inline]
unsafe fn extract(event: &Event) -> Self {
Self {
common: event.into(),
buff: event.buff,
damage: event.buff_dmg,
cycle: event.is_offcycle.into(),
result: event.result.into(),
}
}
}
impl TryExtract for BuffDamageEvent {
#[inline]
fn can_extract(event: &Event) -> bool {
event.categorize() == EventCategory::BuffDamage
}
}
#[derive(
Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, IntoPrimitive, FromPrimitive,
)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(
feature = "strum",
derive(Display, EnumCount, EnumIter, IntoStaticStr, VariantNames)
)]
#[repr(u8)]
pub enum BuffDamageResult {
Hit = 0,
InvulnByBuff = 1,
InvulnBySkill1 = 2,
InvulnBySkill2 = 3,
InvulnBySkill3 = 4,
#[num_enum(catch_all)]
Unknown(u8),
}
#[derive(
Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, IntoPrimitive, FromPrimitive,
)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(
feature = "strum",
derive(Display, EnumCount, EnumIter, IntoStaticStr, VariantNames)
)]
#[repr(u8)]
pub enum BuffCycle {
Cycle = 0,
NotCycle = 1,
NotCycleOrResist = 2,
NotCycleDmgToTargetOnHit = 3,
NotCycleDmgToSourceOnHit = 4,
NotCycleDmgToTargetOnStackRemove = 5,
#[num_enum(catch_all)]
Unknown(u8),
}