core anims
This commit is contained in:
@@ -41,6 +41,7 @@ pub enum Colour {
|
||||
#[derive(Debug,Clone,PartialEq,Serialize,Deserialize)]
|
||||
pub enum Action {
|
||||
Hit { construct: Uuid, skill: Skill },
|
||||
HitCast { construct: Uuid, skill: Skill, source: Uuid },
|
||||
Damage { construct: Uuid, values: Vec<Value>, colour: Colour },
|
||||
Effect { construct: Uuid, effect: ConstructEffect },
|
||||
IncreaseCooldowns { construct: Uuid, turns: usize },
|
||||
@@ -501,6 +502,7 @@ impl Game {
|
||||
for action in actions {
|
||||
match action {
|
||||
Action::Hit { construct, skill } => self.hit(construct, skill),
|
||||
Action::HitCast { construct, skill, source } => self.hit_cast(construct, skill, source),
|
||||
Action::Damage { construct, values, colour } => self.damage(construct, values, colour),
|
||||
Action::Effect { construct, effect } => self.effect(construct, effect),
|
||||
Action::IncreaseCooldowns { construct, turns } => self.increase_cooldowns(construct, turns),
|
||||
@@ -510,6 +512,11 @@ impl Game {
|
||||
self
|
||||
}
|
||||
|
||||
fn hit_cast(&mut self, construct: Uuid, skill: Skill, source: Uuid) -> &mut Game {
|
||||
self.event_add(vec![Event::new(EventVariant::HitCast { skill: skill, source: source }, construct)]);
|
||||
self
|
||||
}
|
||||
|
||||
fn hit(&mut self, construct: Uuid, skill: Skill) -> &mut Game {
|
||||
self.event_add(vec![Event::new(EventVariant::Hit { skill: skill }, construct)]);
|
||||
self
|
||||
|
||||
+15
-92
@@ -105,7 +105,7 @@ impl Cast {
|
||||
}
|
||||
|
||||
pub fn actions(&self) -> Vec<Action> {
|
||||
let mut actions = vec![Action::Hit { construct: self.target, skill: self.skill }];
|
||||
let mut actions = vec![Action::HitCast { construct: self.target, skill: self.skill, source: self.source }];
|
||||
|
||||
let mut rest = match self.skill {
|
||||
Skill::Amplify => vec![
|
||||
@@ -186,15 +186,7 @@ impl Cast {
|
||||
},
|
||||
],
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Skill::Strike |
|
||||
Skill::Strike |
|
||||
Skill::StrikePlus |
|
||||
Skill::StrikePlusPlus => vec![
|
||||
Action::Damage {
|
||||
@@ -218,19 +210,16 @@ pub type Disable = Vec<Effect>;
|
||||
pub struct Event {
|
||||
pub target: Uuid,
|
||||
pub variant: EventVariant,
|
||||
pub stages: EventStages,
|
||||
pub delay: i64,
|
||||
}
|
||||
|
||||
impl Event {
|
||||
pub fn new(variant: EventVariant, target: Uuid) -> Event {
|
||||
let stages = variant.stages();
|
||||
|
||||
let delay = variant.delay();
|
||||
Event {
|
||||
target,
|
||||
variant,
|
||||
delay: stages.delay(),
|
||||
stages: stages,
|
||||
delay,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -238,6 +227,7 @@ impl Event {
|
||||
#[derive(Debug,Clone,PartialEq,Serialize,Deserialize)]
|
||||
pub enum EventVariant {
|
||||
Hit { skill: Skill },
|
||||
HitCast { skill: Skill, source: Uuid },
|
||||
|
||||
Damage { amount: usize, mitigation: usize, colour: Colour, display: EventConstruct },
|
||||
Effect { effect: Effect, duration: u8, display: EventConstruct },
|
||||
@@ -263,46 +253,17 @@ pub enum EventVariant {
|
||||
}
|
||||
|
||||
impl EventVariant {
|
||||
fn stages(&self) -> EventStages {
|
||||
match self {
|
||||
EventVariant::Disable { disable: _}
|
||||
=> EventStages::PostOnly,
|
||||
EventVariant::Damage { amount: _, mitigation: _, colour: _, display: _ }
|
||||
=> EventStages::PostOnly,
|
||||
EventVariant::Healing { amount: _, overhealing: _}
|
||||
=> EventStages::PostOnly,
|
||||
EventVariant::Recharge { red: _, blue: _}
|
||||
=> EventStages::PostOnly,
|
||||
EventVariant::Inversion { skill: _ }
|
||||
=> EventStages::PostOnly,
|
||||
EventVariant::Reflection { skill: _ }
|
||||
=> EventStages::PostOnly,
|
||||
EventVariant::AoeSkill { skill: _ }
|
||||
=> EventStages::PostOnly,
|
||||
EventVariant::Skill { skill: _ }
|
||||
=> EventStages::PostOnly,
|
||||
EventVariant::Effect { effect: _, duration: _, display: _ }
|
||||
=> EventStages::PostOnly,
|
||||
EventVariant::Removal { effect: _, display: _ }
|
||||
=> EventStages::PostOnly,
|
||||
EventVariant::TargetKo { skill: _ }
|
||||
=> EventStages::PostOnly,
|
||||
EventVariant::Ko ()
|
||||
=> EventStages::PostOnly,
|
||||
EventVariant::Forfeit ()
|
||||
=> EventStages::PostOnly,
|
||||
EventVariant::Incomplete ()
|
||||
=> EventStages::PostOnly,
|
||||
EventVariant::Evasion { skill: _, evasion_rating: _ }
|
||||
=> EventStages::PostOnly,
|
||||
fn delay(&self) -> i64 {
|
||||
// let source_duration = 1000; // Time for SOURCE ONLY
|
||||
let target_delay = 500; // Used for Source + Target
|
||||
let target_duration = 1500; // Time for TARGET ONLY
|
||||
let post_skill = 1000; // Time for all POST
|
||||
let source_and_target_total = target_delay + target_duration; // SOURCE + TARGET time
|
||||
|
||||
EventVariant::CooldownDecrease { skill: _, turns: _ }
|
||||
=> EventStages::PostOnly,
|
||||
EventVariant::CooldownIncrease { skill: _, turns: _ }
|
||||
=> EventStages::PostOnly,
|
||||
|
||||
EventVariant::Hit { skill: _ }
|
||||
=> EventStages::PostOnly,
|
||||
match self {
|
||||
EventVariant::Hit { skill: _ } => target_duration,
|
||||
EventVariant::HitCast { skill: _, source: _ } => source_and_target_total,
|
||||
_ => post_skill,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -328,44 +289,6 @@ impl EventConstruct {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)]
|
||||
pub enum EventStages {
|
||||
#[serde(rename = "START_SKILL END_SKILL POST_SKILL")]
|
||||
AllStages, // Anim Anim Anim
|
||||
#[serde(rename = "START_SKILL END_SKILL")]
|
||||
StartEnd, // Anim Anim Skip
|
||||
#[serde(rename = "START_SKILL POST_SKILL")]
|
||||
StartPost, // Anim Skip Anim
|
||||
#[serde(rename = "START_SKILL")]
|
||||
StartOnly, // Anim Skip Skip
|
||||
#[serde(rename = "END_SKILL POST_SKILL")]
|
||||
EndPost, // Skip Anim Anim
|
||||
#[serde(rename = "END_SKILL")]
|
||||
EndOnly, // Skip Anim Skip
|
||||
#[serde(rename = "POST_SKILL")]
|
||||
PostOnly, // Skip Skip Anim
|
||||
}
|
||||
|
||||
impl EventStages {
|
||||
fn delay(self) -> i64 {
|
||||
let source_duration = 1000; // Time for SOURCE ONLY
|
||||
let target_delay = 500; // Used for Source + Target
|
||||
let target_duration = 1500; // Time for TARGET ONLY
|
||||
let post_skill = 1000; // Time for all POST
|
||||
let source_and_target_total = target_delay + target_duration; // SOURCE + TARGET time
|
||||
|
||||
match self {
|
||||
EventStages::AllStages => source_and_target_total + post_skill, // Anim Anim Anim
|
||||
EventStages::StartEnd => source_and_target_total, // Anim Anim Skip
|
||||
EventStages::StartPost => source_duration + post_skill, // Anim Skip Anim
|
||||
EventStages::StartOnly => source_duration, // Anim Skip Skip
|
||||
EventStages::EndPost => target_duration + post_skill, // Skip Anim Anim
|
||||
EventStages::EndOnly => target_duration, // Skip Anim Skip
|
||||
EventStages::PostOnly => post_skill, // Skip Skip Anim
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)]
|
||||
pub enum Skill {
|
||||
Attack,
|
||||
|
||||
Reference in New Issue
Block a user