add back aoe event post merge

This commit is contained in:
Mashy 2019-12-10 23:24:18 +10:00
parent b1cb2cec37
commit 279ab5795e
3 changed files with 38 additions and 23 deletions

View File

@ -90,6 +90,7 @@ function registerEvents(store) {
console.log(newRes);
return eachSeries(newRes, (r, cb) => {
const timeout = r.delay;
if (timeout === 0) return cb(); // TargetKo etc
setAnimations(r, store);
return setTimeout(cb, timeout);
}, err => {

View File

@ -933,7 +933,7 @@ impl Construct {
if self.is_ko() { return vec![] }
match event {
Event::Damage { construct, colour, amount, mitigation, display: _ } => {
Event::Damage { construct: _, colour, amount: _, mitigation: _, display: _ } => {
let mut casts = vec![];
if self.affected(Effect::Electric) && !cast.skill.is_tick() {
let ConstructEffect { effect: _, duration: _, meta, tick: _ } =

View File

@ -478,13 +478,19 @@ impl Game {
}
fn resolve(&mut self, cast: Cast) -> &mut Game {
// Send custom intial cast / hit aoe actions
// If the skill is disabled for source nothing else will happen
if let Some(effects) = self.construct(cast.source).disabled(cast.skill) {
self.add_resolution(&cast, &Event::Disable { construct: cast.source, effects });
return self;
}
// for aoe events send the source / target animations before each set of casts
if cast.skill.aoe() {
/*let actions = match cast.skill.cast_animation() {
true => vec![Action::Cast, Action::HitAoe],
false => vec![Action::HitAoe]
};
self.execute(cast, actions);*/
if cast.skill.cast_animation() {
let event = self.cast(cast);
self.add_resolution(&cast, &event);
}
let event = self.hit_aoe(cast);
self.add_resolution(&cast, &event);
}
let casts = self.modify_cast(cast);
@ -526,11 +532,6 @@ impl Game {
// such as healing based on damage done etc
let mut event_list = vec![];
if let Some(effects) = self.construct(cast.source).disabled(cast.skill) {
self.add_resolution(&cast, &Event::Disable { construct: cast.source, effects });
return self;
}
if self.construct(cast.target).is_ko() {
self.add_resolution(&cast, &Event::TargetKo { construct: cast.target });
return self;
@ -550,9 +551,8 @@ impl Game {
for action in cast.actions() {
let events = match action {
Action::Cast => self.cast(cast),
Action::Hit => self.hit(cast),
Action::HitAoe => self.hit_aoe(cast),
Action::Cast => vec![self.cast(cast)],
Action::Hit => vec![self.hit(cast)],
Action::Damage { construct, values, colour } => {
let amount = self.reduce_values(&values, &event_list);
@ -647,15 +647,15 @@ impl Game {
})
}
fn cast(&mut self, cast: Cast) -> Vec<Event> {
vec![Event::Cast { construct: cast.source, player: cast.player, direction: self.direction(cast) }]
fn cast(&mut self, cast: Cast) -> Event {
Event::Cast { construct: cast.source, player: cast.player, direction: self.direction(cast) }
}
fn hit(&mut self, cast: Cast) -> Vec<Event> {
vec![Event::Hit { construct: cast.target, player: cast.player, direction: self.direction(cast) }]
fn hit(&mut self, cast: Cast) -> Event {
Event::Hit { construct: cast.target, player: cast.player, direction: self.direction(cast) }
}
fn hit_aoe(&mut self, cast: Cast) -> Vec<Event> {
fn hit_aoe(&mut self, cast: Cast) -> Event {
let construct = self.players.iter()
.find(|t| t.constructs.iter().any(|c| c.id == cast.target))
.unwrap()
@ -664,7 +664,7 @@ impl Game {
.map(|c| c.id)
.collect();
vec![Event::HitAoe { construct, player: cast.player, direction: self.direction(cast) }]
Event::HitAoe { construct, player: cast.player, direction: self.direction(cast) }
}
fn damage(&mut self, construct: Uuid, amount: usize, colour: Colour) -> Vec<Event> {
@ -892,7 +892,6 @@ pub enum Value {
#[derive(Debug,Clone,PartialEq)]
pub enum Action {
Hit,
HitAoe,
Cast,
Heal { construct: Uuid, values: Vec<Value>, colour: Colour },
Damage { construct: Uuid, values: Vec<Value>, colour: Colour },
@ -969,6 +968,7 @@ impl Event {
let target_duration = 1500;
let combat_text_duration = 1300;
// Exhaustively match all events so they're all properly considered
match self {
Event::Cast { construct: _, direction: _, player: _ } => {
match next_event {
@ -994,7 +994,21 @@ impl Event {
None => target_duration,
}
},
_ => combat_text_duration,
// Events that show combat text
Event::Damage { construct: _, amount: _, mitigation: _, colour: _, display: _ } |
Event::Effect { construct: _, effect: _, duration: _, display: _ } |
Event::Removal { construct: _, effect: _, display: _ } |
Event::Healing { construct: _, amount: _, overhealing: _, colour: _, display: _ } |
Event::Inversion { construct: _ } |
Event::Reflection { construct: _ } |
Event::Ko { construct: _ } |
Event::CooldownIncrease { construct: _, turns: _ } |
Event::CooldownDecrease { construct: _, turns: _ } => combat_text_duration,
// Events that are skipped on client
Event::TargetKo { construct: _ } |
Event::Disable { construct: _, effects: _ } |
Event::Forfeit() => 0,
}
}
}