half merged
This commit is contained in:
+49
-47
@@ -4,7 +4,7 @@ use rand::prelude::*;
|
||||
use failure::Error;
|
||||
use failure::err_msg;
|
||||
|
||||
use skill::{Skill, Cast, Disable, Event, EventVariant, EventConstruct};
|
||||
use skill::{Skill, Cast, Disable, EventVariant, EventConstruct};
|
||||
use game::{Colour};
|
||||
use effect::{Cooldown, Effect};
|
||||
use spec::{Spec};
|
||||
@@ -415,7 +415,7 @@ impl Construct {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn increase_cooldowns(&mut self, turns: usize) -> Vec<Event> {
|
||||
pub fn increase_cooldowns(&mut self, turns: usize) -> Vec<EventVariant> {
|
||||
let mut events = vec![];
|
||||
|
||||
for skill in self.skills.iter_mut() {
|
||||
@@ -423,11 +423,11 @@ impl Construct {
|
||||
match skill.cd {
|
||||
Some(cd) => {
|
||||
skill.cd = Some(cd.saturating_add(turns));
|
||||
events.push(Event::new(EventVariant::CooldownIncrease { turns, skill: skill.skill }, self.id))
|
||||
events.push(EventVariant::CooldownIncrease { target: self.id, turns })
|
||||
},
|
||||
None => {
|
||||
skill.cd = Some(turns);
|
||||
events.push(Event::new(EventVariant::CooldownIncrease { turns, skill: skill.skill }, self.id))
|
||||
events.push(EventVariant::CooldownIncrease { target: self.id, turns })
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -546,9 +546,9 @@ impl Construct {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn recharge(&mut self, red_amount: usize, blue_amount: usize) -> Vec<Event> {
|
||||
pub fn recharge(&mut self, red_amount: usize, blue_amount: usize) -> Vec<EventVariant> {
|
||||
let mut events = vec![];
|
||||
|
||||
let target = self.id;
|
||||
if self.is_ko() { return events; }
|
||||
|
||||
match self.affected(Effect::Invert) {
|
||||
@@ -565,7 +565,7 @@ impl Construct {
|
||||
let blue = new_blue_life - current_blue_life;
|
||||
|
||||
if red != 0 || blue != 0 {
|
||||
events.push(Event::new(EventVariant::Recharge { red, blue }, self.id));
|
||||
events.push(EventVariant::Recharge { target, red, blue });
|
||||
}
|
||||
},
|
||||
true => {
|
||||
@@ -591,12 +591,13 @@ impl Construct {
|
||||
self.reduce_green_life(red_remainder);
|
||||
let red_damage_amount = red_current_green_life - self.green_life();
|
||||
|
||||
events.push(Event::new(EventVariant::Damage {
|
||||
events.push(EventVariant::Damage {
|
||||
target,
|
||||
amount: red_damage_amount,
|
||||
mitigation: red_mitigation,
|
||||
colour: Colour::Red,
|
||||
display: EventConstruct::new(self),
|
||||
}, self.id));
|
||||
});
|
||||
}
|
||||
|
||||
if blue_amount != 0 {
|
||||
@@ -620,21 +621,23 @@ impl Construct {
|
||||
self.reduce_green_life(blue_remainder);
|
||||
let blue_damage_amount = blue_current_green_life - self.green_life();
|
||||
|
||||
events.push(Event::new(EventVariant::Damage {
|
||||
events.push(EventVariant::Damage {
|
||||
target,
|
||||
amount: blue_damage_amount,
|
||||
mitigation: blue_mitigation,
|
||||
colour: Colour::Blue,
|
||||
display: EventConstruct::new(self),
|
||||
}, self.id));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
return events;
|
||||
}
|
||||
|
||||
pub fn deal_green_damage(&mut self, amount: usize) -> Vec<Event> {
|
||||
pub fn deal_green_damage(&mut self, amount: usize) -> Vec<EventVariant> {
|
||||
let mut events = vec![];
|
||||
if self.is_ko() { return events; }
|
||||
let target = self.id;
|
||||
|
||||
let mods = self.effects.iter()
|
||||
.filter(|e| e.effect.modifications().contains(&Stat::GreenDamageTaken))
|
||||
@@ -653,10 +656,11 @@ impl Construct {
|
||||
let healing = new_green_life - current_green_life;
|
||||
let overhealing = modified_power - healing;
|
||||
|
||||
events.push(Event::new(EventVariant::Healing {
|
||||
events.push(EventVariant::Healing {
|
||||
target,
|
||||
amount: healing,
|
||||
overhealing,
|
||||
}, self.id));
|
||||
});
|
||||
},
|
||||
true => {
|
||||
// events.push(Event::new(EventVariant::Inversion { skill }));
|
||||
@@ -666,22 +670,24 @@ impl Construct {
|
||||
self.reduce_green_life(modified_power);
|
||||
let delta = current_green_life - self.green_life();
|
||||
|
||||
events.push(Event::new(EventVariant::Damage {
|
||||
events.push(EventVariant::Damage {
|
||||
target,
|
||||
amount: delta,
|
||||
mitigation: 0,
|
||||
colour: Colour::Green,
|
||||
display: EventConstruct::new(self),
|
||||
}, self.id));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return events;
|
||||
}
|
||||
|
||||
pub fn deal_red_damage(&mut self, amount: usize) -> Vec<Event> {
|
||||
pub fn deal_red_damage(&mut self, amount: usize) -> Vec<EventVariant> {
|
||||
let mut events = vec![];
|
||||
|
||||
if self.is_ko() { return events; }
|
||||
let target = self.id;
|
||||
|
||||
let mods = self.effects.iter()
|
||||
.filter(|e| e.effect.modifications().contains(&Stat::RedDamageTaken))
|
||||
@@ -708,17 +714,17 @@ impl Construct {
|
||||
self.reduce_green_life(remainder);
|
||||
let delta = current_green_life - self.green_life();
|
||||
|
||||
events.push(Event::new(
|
||||
events.push(
|
||||
EventVariant::Damage {
|
||||
target,
|
||||
amount: delta,
|
||||
mitigation,
|
||||
colour: Colour::Red,
|
||||
display: EventConstruct::new(self),
|
||||
},
|
||||
self.id
|
||||
));
|
||||
}
|
||||
);
|
||||
if self.is_ko() {
|
||||
events.push(Event::new(EventVariant::Ko {}, self.id));
|
||||
events.push(EventVariant::Ko { target });
|
||||
}
|
||||
},
|
||||
true => {
|
||||
@@ -735,16 +741,17 @@ impl Construct {
|
||||
let recharge = self.red_life.value - current_life;
|
||||
|
||||
if healing > 0 {
|
||||
events.push(Event::new(
|
||||
EventVariant::Healing{
|
||||
events.push(
|
||||
EventVariant::Healing {
|
||||
target,
|
||||
amount: healing,
|
||||
overhealing: overhealing - recharge,
|
||||
}, self.id
|
||||
));
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if recharge > 0 {
|
||||
events.push(Event::new(EventVariant::Recharge { red: recharge, blue: 0 }, self.id));
|
||||
events.push(EventVariant::Recharge { target, red: recharge, blue: 0 });
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -752,10 +759,11 @@ impl Construct {
|
||||
return events;
|
||||
}
|
||||
|
||||
pub fn deal_blue_damage(&mut self, amount: usize) -> Vec<Event> {
|
||||
pub fn deal_blue_damage(&mut self, amount: usize) -> Vec<EventVariant> {
|
||||
let mut events = vec![];
|
||||
|
||||
if self.is_ko() { return events; }
|
||||
let target = self.id;
|
||||
|
||||
let mods = self.effects.iter()
|
||||
.filter(|e| e.effect.modifications().contains(&Stat::BlueDamageTaken))
|
||||
@@ -778,12 +786,13 @@ impl Construct {
|
||||
self.reduce_green_life(remainder);
|
||||
let delta = current_green_life - self.green_life();
|
||||
|
||||
events.push(Event::new(EventVariant::Damage {
|
||||
events.push(EventVariant::Damage {
|
||||
target,
|
||||
amount: delta,
|
||||
mitigation,
|
||||
colour: Colour::Blue,
|
||||
display: EventConstruct::new(self),
|
||||
}, self.id));
|
||||
display: EventConstruct::new(self),
|
||||
});
|
||||
},
|
||||
true => {
|
||||
// events.push(Event::new(EventVariant::Inversion { skill }));
|
||||
@@ -799,17 +808,11 @@ impl Construct {
|
||||
let recharge = self.blue_life.value - current_life;
|
||||
|
||||
if healing > 0 {
|
||||
events.push(
|
||||
Event::new(EventVariant::Healing {
|
||||
amount: healing,
|
||||
overhealing,
|
||||
},
|
||||
self.id
|
||||
));
|
||||
events.push(EventVariant::Healing { target, amount: healing, overhealing });
|
||||
}
|
||||
|
||||
if recharge > 0 {
|
||||
events.push(Event::new(EventVariant::Recharge { red: 0, blue: recharge }, self.id));
|
||||
events.push(EventVariant::Recharge { target, red: 0, blue: recharge });
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -817,7 +820,7 @@ impl Construct {
|
||||
return events;
|
||||
}
|
||||
|
||||
pub fn add_effect(&mut self, effect: ConstructEffect) -> Vec<Event> {
|
||||
pub fn add_effect(&mut self, effect: ConstructEffect) -> Vec<EventVariant> {
|
||||
if self.is_ko() { return vec![] }
|
||||
|
||||
if self.affected(Effect::Banish) { panic!("banish immunity not fixt yet") }
|
||||
@@ -834,13 +837,12 @@ impl Construct {
|
||||
}
|
||||
|
||||
// todo modified durations cause of buffs
|
||||
let result = Event::new(
|
||||
EventVariant::Effect {
|
||||
effect: effect.effect,
|
||||
duration: effect.duration,
|
||||
display: EventConstruct::new(self),
|
||||
}, self.id
|
||||
);
|
||||
let result = EventVariant::Effect {
|
||||
target: self.id,
|
||||
effect: effect.effect,
|
||||
duration: effect.duration,
|
||||
display: EventConstruct::new(self)
|
||||
};
|
||||
|
||||
return vec![result];
|
||||
}
|
||||
|
||||
+35
-9
@@ -42,12 +42,13 @@ pub enum Colour {
|
||||
|
||||
#[derive(Debug,Clone,PartialEq,Serialize,Deserialize)]
|
||||
pub enum Action {
|
||||
Cast { construct: Uuid, skill: Skill },
|
||||
Hit { construct: Uuid, skill: Skill },
|
||||
Damage { construct: Uuid, values: Vec<Value>, colour: Colour },
|
||||
Healing { construct: Uuid, values: Vec<Value>, colour: Colour },
|
||||
Effect { construct: Uuid, effect: ConstructEffect },
|
||||
IncreaseCooldowns { construct: Uuid, turns: usize },
|
||||
Hit { skill: Skill },
|
||||
Cast { skill: Skill },
|
||||
Damage { skill: Skill, construct: Uuid, values: Vec<Value>, colour: Colour },
|
||||
Effect { skill: Skill, construct: Uuid, effect: ConstructEffect },
|
||||
IncreaseCooldowns { skill: Skill, construct: Uuid, turns: usize },
|
||||
Healing { skill: Skill, construct: Uuid, values: Vec<Value>, colour: Colour },
|
||||
// Recharge { skill: Skill, red: usize, blue: usize },
|
||||
}
|
||||
|
||||
#[derive(Debug,Clone,Serialize,Deserialize)]
|
||||
@@ -495,15 +496,15 @@ impl Game {
|
||||
self.skill_phase_start(r_animation_ms)
|
||||
}
|
||||
|
||||
pub fn actions(&mut self, actions: Vec<Action>) -> &mut Game {
|
||||
pub fn actions(&mut self, cast: Cast) -> &mut Game {
|
||||
let mut events_group = vec![];
|
||||
|
||||
// calculate values first?
|
||||
// for result damage value need to pass &events and .find()
|
||||
|
||||
for action in actions {
|
||||
for action in cast.actions() {
|
||||
let mut events = match action {
|
||||
Action::Cast { construct, skill } => self.cast(construct, skill),
|
||||
Action::Cast { construct, skill, direction } => self.cast(construct, skill),
|
||||
Action::Hit { construct, skill } => self.hit(construct, skill),
|
||||
Action::Damage { construct, values, colour } => self.damage(construct, values, colour),
|
||||
Action::Healing { construct, values, colour } => unimplemented!(),
|
||||
@@ -540,6 +541,31 @@ impl Game {
|
||||
self.construct_by_id(construct).unwrap().increase_cooldowns(turns)
|
||||
}
|
||||
|
||||
fn direction(&mut self, cast: Cast) -> (i8, i8) {
|
||||
let i = self.players.iter()
|
||||
.find(|t| t.constructs.iter().any(|c| c.id == cast.source))
|
||||
.unwrap().constructs
|
||||
.iter()
|
||||
.position(|c| c.id == cast.source)
|
||||
.unwrap() as i8;
|
||||
|
||||
let j = self.players.iter()
|
||||
.find(|t| t.constructs.iter().any(|c| c.id == cast.target))
|
||||
.unwrap().constructs
|
||||
.iter()
|
||||
.position(|c| c.id == cast.target)
|
||||
.unwrap() as i8;
|
||||
let x = j - i;
|
||||
|
||||
let target = self.construct_by_id(cast.target).unwrap();
|
||||
// is the caster player account same as target player account side of screen
|
||||
let y = match cast.player == target.account {
|
||||
true => 0,
|
||||
false => 1
|
||||
};
|
||||
(x, y)
|
||||
}
|
||||
|
||||
fn progress_durations(&mut self, events: &Vec<Cast>) -> &mut Game {
|
||||
for mut construct in self.all_constructs() {
|
||||
// info!("progressing durations for {:}", construct.name);
|
||||
|
||||
+72
-94
@@ -32,6 +32,10 @@ impl Cast {
|
||||
};
|
||||
}
|
||||
|
||||
pub fn target(self) -> Uuid {
|
||||
self.target
|
||||
}
|
||||
|
||||
pub fn new_tick(source: &mut Construct, target: &mut Construct, skill: Skill) -> Cast {
|
||||
Cast {
|
||||
id: Uuid::new_v4(),
|
||||
@@ -53,10 +57,10 @@ impl Cast {
|
||||
let mut actions = vec![];
|
||||
|
||||
if self.skill.cast_animation() {
|
||||
actions.push({ Action::Cast { construct: self.source, skill: self.skill }});
|
||||
actions.push(Action::Cast { cast: *self });
|
||||
}
|
||||
|
||||
actions.push(Action::Hit { construct: self.target, skill: self.skill });
|
||||
actions.push(Action::Hit { cast: *self });
|
||||
|
||||
let mut rest = match self.skill {
|
||||
Skill::Attack => vec![
|
||||
@@ -85,18 +89,21 @@ impl Cast {
|
||||
|
||||
Skill::Amplify => vec![
|
||||
Action::Effect {
|
||||
cast: *self,
|
||||
construct: self.target,
|
||||
effect: ConstructEffect { effect: Effect::Amplify, duration: 2, meta: Some(EffectMeta::Multiplier(150)), tick: None },
|
||||
},
|
||||
],
|
||||
Skill::AmplifyPlus => vec![
|
||||
Action::Effect {
|
||||
cast: *self,
|
||||
construct: self.target,
|
||||
effect: ConstructEffect { effect: Effect::Amplify, duration: 3, meta: Some(EffectMeta::Multiplier(175)), tick: None },
|
||||
},
|
||||
],
|
||||
Skill::AmplifyPlusPlus => vec![
|
||||
Action::Effect {
|
||||
cast: *self,
|
||||
construct: self.target,
|
||||
effect: ConstructEffect { effect: Effect::Amplify, duration: 4, meta: Some(EffectMeta::Multiplier(200)), tick: None },
|
||||
},
|
||||
@@ -115,6 +122,7 @@ impl Cast {
|
||||
],
|
||||
Skill::AbsorbPlus => vec![
|
||||
Action::Effect {
|
||||
cast: *self,
|
||||
construct: self.target,
|
||||
effect: ConstructEffect { effect: Effect::Absorb, duration: 1, meta: Some(EffectMeta::Skill(Skill::AbsorptionPlus)), tick: None },
|
||||
},
|
||||
@@ -126,6 +134,7 @@ impl Cast {
|
||||
],
|
||||
Skill::AbsorbPlusPlus => vec![
|
||||
Action::Effect {
|
||||
cast: *self,
|
||||
construct: self.target,
|
||||
effect: ConstructEffect { effect: Effect::Absorb, duration: 1, meta: Some(EffectMeta::Skill(Skill::AbsorptionPlusPlus)), tick: None },
|
||||
},
|
||||
@@ -150,6 +159,7 @@ impl Cast {
|
||||
values: vec![Value::Stat { construct: self.target, stat: Stat::BlueLife, mult: self.skill.multiplier() }],
|
||||
},
|
||||
Action::Effect {
|
||||
cast: *self,
|
||||
construct: self.target,
|
||||
effect: ConstructEffect { effect: Effect::Banish, duration: 2, meta: None, tick: None }
|
||||
}
|
||||
@@ -159,6 +169,7 @@ impl Cast {
|
||||
Skill::BashPlus |
|
||||
Skill::BashPlusPlus => vec![
|
||||
Action::Damage {
|
||||
cast: *self,
|
||||
construct: self.target,
|
||||
colour: Colour::Red,
|
||||
values: vec![
|
||||
@@ -167,10 +178,12 @@ impl Cast {
|
||||
],
|
||||
},
|
||||
Action::Effect {
|
||||
cast: *self,
|
||||
construct: self.target,
|
||||
effect: ConstructEffect {effect: Effect::Stun, duration: 2, meta: None, tick: None }
|
||||
},
|
||||
Action::IncreaseCooldowns {
|
||||
cast: *self,
|
||||
construct: self.target,
|
||||
turns: 1,
|
||||
},
|
||||
@@ -180,6 +193,7 @@ impl Cast {
|
||||
Skill::BlastPlus |
|
||||
Skill::BlastPlusPlus => vec![
|
||||
Action::Damage {
|
||||
cast: *self,
|
||||
construct: self.target,
|
||||
colour: Colour::Blue,
|
||||
values: vec![Value::Stat { construct: self.source, stat: Stat::BluePower, mult: self.skill.multiplier() }],
|
||||
@@ -260,6 +274,7 @@ impl Cast {
|
||||
Skill::CounterAttackPlus |
|
||||
Skill::CounterAttackPlusPlus => vec![
|
||||
Action::Damage {
|
||||
cast: *self,
|
||||
construct: self.target,
|
||||
colour: Colour::Red,
|
||||
values: vec![Value::Stat { construct: self.source, stat: Stat::RedPower, mult: self.skill.multiplier() }],
|
||||
@@ -295,7 +310,6 @@ impl Cast {
|
||||
],
|
||||
|
||||
|
||||
|
||||
Skill::Slay |
|
||||
Skill::SlayPlus |
|
||||
Skill::SlayPlusPlus => vec![
|
||||
@@ -387,7 +401,6 @@ impl Cast {
|
||||
colour: Colour::Red,
|
||||
},
|
||||
],
|
||||
|
||||
_ => unimplemented!()
|
||||
};
|
||||
|
||||
@@ -398,7 +411,6 @@ impl Cast {
|
||||
|
||||
fn end() {}
|
||||
|
||||
|
||||
// fn heal(source: &mut Construct, target: &mut Construct, skill: Skill) {
|
||||
// let amount = source.green_power().pct(skill.multiplier());
|
||||
// target.deal_green_damage(skill, amount)
|
||||
@@ -756,105 +768,72 @@ pub fn resolve(game: &mut Game, cast: Cast) {
|
||||
|
||||
pub type Disable = Vec<Effect>;
|
||||
|
||||
#[derive(Debug,Clone,PartialEq,Serialize,Deserialize)]
|
||||
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();
|
||||
|
||||
Event {
|
||||
target,
|
||||
variant,
|
||||
delay: stages.delay(),
|
||||
stages: stages,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug,Clone,PartialEq,Serialize,Deserialize)]
|
||||
#[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)]
|
||||
pub enum EventVariant {
|
||||
Cast { skill: Skill },
|
||||
Hit { skill: Skill },
|
||||
Cast { target: Uuid, player: Uuid, x: i8, y: i8 },
|
||||
Hit { target: Uuid, player: Uuid, x: i8, y: i8 },
|
||||
HitAoe { target: Uuid },
|
||||
|
||||
Damage { amount: usize, mitigation: usize, colour: Colour, display: EventConstruct },
|
||||
Effect { effect: Effect, duration: u8, display: EventConstruct },
|
||||
Removal { effect: Option<Effect>, display: EventConstruct },
|
||||
Damage { target: Uuid, amount: usize, mitigation: usize, colour: Colour, display: EventConstruct },
|
||||
Effect { target: Uuid, effect: Effect, duration: u8, display: EventConstruct },
|
||||
Removal { target: Uuid, effect: Option<Effect>, display: EventConstruct },
|
||||
|
||||
Disable { disable: Disable },
|
||||
Healing { amount: usize, overhealing: usize },
|
||||
Recharge { red: usize, blue: usize },
|
||||
Inversion { skill: Skill },
|
||||
Reflection { skill: Skill },
|
||||
AoeSkill { skill: Skill },
|
||||
Skill { skill: Skill },
|
||||
TargetKo { skill: Skill },
|
||||
// skill not necessary but makes it neater as all events are arrays in js
|
||||
Ko (),
|
||||
Healing { target: Uuid, amount: usize, overhealing: usize },
|
||||
Recharge { target: Uuid, red: usize, blue: usize },
|
||||
Inversion { target: Uuid },
|
||||
Reflection { target: Uuid },
|
||||
Ko { target: Uuid },
|
||||
|
||||
CooldownIncrease { target: Uuid, turns: usize },
|
||||
CooldownDecrease { target: Uuid, turns: usize },
|
||||
Forfeit (),
|
||||
Incomplete (),
|
||||
// not used
|
||||
Evasion { skill: Skill, evasion_rating: usize },
|
||||
|
||||
CooldownIncrease { turns: usize, skill: Skill },
|
||||
CooldownDecrease { turns: usize, skill: Skill },
|
||||
}
|
||||
|
||||
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_duration = 1500; // Time for target animation
|
||||
let target_delay = 500; // Add delay if theres source animation
|
||||
let combat_text_delay = 1300; // Time for all post skill
|
||||
let combat_text_overlap = 600; // overlap between animation and combat text
|
||||
|
||||
EventVariant::CooldownDecrease { skill: _, turns: _ }
|
||||
=> EventStages::PostOnly,
|
||||
EventVariant::CooldownIncrease { skill: _, turns: _ }
|
||||
=> EventStages::PostOnly,
|
||||
match self {
|
||||
EventVariant::Cast { target: _, x: _, y: _, player: _ } => target_delay,
|
||||
EventVariant::Hit { target: _, x: _, y: _, player: _ } |
|
||||
EventVariant::HitAoe { target: _ } => target_duration - combat_text_overlap,
|
||||
_ => combat_text_delay,
|
||||
}
|
||||
}
|
||||
|
||||
EventVariant::Hit { skill: _ }
|
||||
=> EventStages::PostOnly,
|
||||
EventVariant::Cast { skill: _ }
|
||||
=> EventStages::PostOnly,
|
||||
pub fn to_event(&self, cast: Cast) -> Event {
|
||||
let delay = self.delay();
|
||||
let focus = match self {
|
||||
EventVariant::HitAoe { target: _ } => vec![cast.source, cast.target], // some tricky multi target here l8r
|
||||
_ => vec![cast.source, cast.target],
|
||||
};
|
||||
|
||||
Event {
|
||||
cast,
|
||||
focus,
|
||||
variant: *self,
|
||||
delay,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug,Clone,PartialEq,Serialize,Deserialize)]
|
||||
pub struct Event {
|
||||
pub cast: Cast,
|
||||
pub focus: Vec<Uuid>,
|
||||
pub variant: EventVariant,
|
||||
pub delay: i64,
|
||||
}
|
||||
|
||||
|
||||
// used to show the progress of a construct
|
||||
// while the resolutions are animating
|
||||
#[derive(Debug,Clone,PartialEq,Serialize,Deserialize)]
|
||||
#[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)]
|
||||
pub struct EventConstruct {
|
||||
pub id: Uuid,
|
||||
pub red: usize,
|
||||
@@ -1763,8 +1742,6 @@ impl Skill {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// #[cfg(test)]
|
||||
mod tests {
|
||||
use skill::*;
|
||||
@@ -1775,18 +1752,19 @@ mod tests {
|
||||
let actions = cast.actions();
|
||||
|
||||
match actions[0] {
|
||||
Action::Hit { construct: _, skill } => {
|
||||
assert_eq!(skill, Skill::Attack);
|
||||
Action::Hit { cast } => {
|
||||
assert_eq!(cast.skill, Skill::Attack);
|
||||
},
|
||||
_ => panic!("{:?}", actions),
|
||||
};
|
||||
|
||||
match actions[1] {
|
||||
Action::Damage { construct: _, values: _, colour } => {
|
||||
Action::Damage { cast: _, construct: _, values: _, colour } => {
|
||||
assert_eq!(colour, Colour::Red);
|
||||
},
|
||||
_ => panic!("{:?}", actions),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
// #[test]
|
||||
|
||||
Reference in New Issue
Block a user