update effects during combat anim loop
This commit is contained in:
parent
6d9e13598c
commit
6295d8888e
@ -228,9 +228,10 @@ function eventClasses(resolution, construct) {
|
||||
}
|
||||
|
||||
if (type === 'Effect') {
|
||||
const { skill, effect, duration } = event;
|
||||
const { skill, effect, duration, construct_effects: constructEffects } = event;
|
||||
if (source && startSkill) return 'active-skill';
|
||||
if (target && endSkill) return 'active-skill';
|
||||
if (target && postSkill) construct.effects = constructEffects;
|
||||
}
|
||||
|
||||
if (type === 'Skill') {
|
||||
@ -241,7 +242,10 @@ function eventClasses(resolution, construct) {
|
||||
}
|
||||
|
||||
if (type === 'Removal') {
|
||||
const { effect } = event;
|
||||
const { effect, construct_effects: constructEffects } = event;
|
||||
if (source && startSkill) return 'active-skill';
|
||||
if (target && endSkill) return 'active-skill';
|
||||
if (target && postSkill) construct.effects = constructEffects;
|
||||
}
|
||||
|
||||
if (type === 'Recharge') {
|
||||
|
||||
@ -757,13 +757,6 @@ impl Construct {
|
||||
};
|
||||
}
|
||||
|
||||
// todo modified durations cause of buffs
|
||||
let result = Event::Effect {
|
||||
effect: effect.effect,
|
||||
duration: effect.duration,
|
||||
skill,
|
||||
};
|
||||
|
||||
if let Some(p) = self.effects.iter().position(|ce| ce.effect == effect.effect) {
|
||||
// duplicate effect
|
||||
// replace existing
|
||||
@ -775,6 +768,13 @@ impl Construct {
|
||||
self.effects.push(effect);
|
||||
}
|
||||
|
||||
// todo modified durations cause of buffs
|
||||
let result = Event::Effect {
|
||||
effect: effect.effect,
|
||||
duration: effect.duration,
|
||||
construct_effects: self.effects.clone(),
|
||||
skill,
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@ -528,7 +528,7 @@ impl Game {
|
||||
self.log.push(format!("[{:}] {:} {:?} {:} REFLECTED",
|
||||
speed, source.name, skill, target.name)),
|
||||
|
||||
Event::Effect { skill, effect, duration } =>
|
||||
Event::Effect { skill, effect, duration, construct_effects: _ } =>
|
||||
self.log.push(format!("[{:}] {:} {:?} {:} {:?} {:}T",
|
||||
speed, source.name, skill, target.name, effect, duration)),
|
||||
|
||||
@ -540,7 +540,7 @@ impl Game {
|
||||
self.log.push(format!("[{:}] {:} {:?} {:}",
|
||||
speed, source.name, skill, target.name)),
|
||||
|
||||
Event::Removal { effect } =>
|
||||
Event::Removal { effect, construct_effects: _ } =>
|
||||
self.log.push(format!("[{:}] {:?} removed {:} {:?}",
|
||||
speed, source.name, target.name, effect)),
|
||||
|
||||
@ -1265,7 +1265,7 @@ mod tests {
|
||||
|
||||
let Resolution { source: _, target: _, event } = game.resolved.pop().unwrap();
|
||||
match event {
|
||||
Event::Effect { effect, skill: _, duration: _ } => assert_eq!(effect, Effect::Scatter),
|
||||
Event::Effect { effect, skill: _, duration: _, construct_effects: _ } => assert_eq!(effect, Effect::Scatter),
|
||||
_ => panic!("not siphon"),
|
||||
};
|
||||
|
||||
@ -1357,7 +1357,7 @@ mod tests {
|
||||
let Resolution { source, target: _, event } = r;
|
||||
match source.id == x_construct.id {
|
||||
true => match event {
|
||||
Event::Effect { effect, duration, skill: _ } => {
|
||||
Event::Effect { effect, duration, skill: _, construct_effects: _ } => {
|
||||
assert!(*effect == Effect::Stun);
|
||||
assert!(*duration == 1);
|
||||
true
|
||||
|
||||
@ -437,10 +437,10 @@ pub enum Event {
|
||||
Recharge { skill: Skill, red: u64, blue: u64 },
|
||||
Inversion { skill: Skill },
|
||||
Reflection { skill: Skill },
|
||||
Effect { skill: Skill, effect: Effect, duration: u8 },
|
||||
AoeSkill { skill: Skill },
|
||||
Skill { skill: Skill },
|
||||
Removal { effect: Effect },
|
||||
Effect { skill: Skill, effect: Effect, duration: u8, construct_effects: Vec<ConstructEffect> },
|
||||
Removal { effect: Effect, construct_effects: Vec<ConstructEffect> },
|
||||
TargetKo { skill: Skill },
|
||||
// skill not necessary but makes it neater as all events are arrays in js
|
||||
Ko { skill: Skill },
|
||||
@ -1539,7 +1539,8 @@ fn strangle_tick(source: &mut Construct, target: &mut Construct, mut results: Re
|
||||
.position(|e| e.effect == Effect::Strangling)
|
||||
.expect("no strangling on construct");
|
||||
source.effects.remove(i);
|
||||
results.push(Resolution::new(source, source).event(Event::Removal { effect: Effect::Strangling }));
|
||||
results.push(Resolution::new(source, source)
|
||||
.event(Event::Removal { effect: Effect::Strangling, construct_effects: target.effects.clone() }));
|
||||
}
|
||||
|
||||
return results;
|
||||
@ -1877,7 +1878,8 @@ fn purge(source: &mut Construct, target: &mut Construct, mut results: Resolution
|
||||
.iter()
|
||||
.position(|ce| ce.effect.category() == EffectCategory::Buff) {
|
||||
let ce = target.effects.remove(i);
|
||||
results.push(Resolution::new(source, target).event(Event::Removal { effect: ce.effect }));
|
||||
results.push(Resolution::new(source, target)
|
||||
.event(Event::Removal { effect: ce.effect, construct_effects: target.effects.clone() }));
|
||||
}
|
||||
|
||||
return results;
|
||||
@ -1890,7 +1892,8 @@ fn purify(source: &mut Construct, target: &mut Construct, mut results: Resolutio
|
||||
.iter()
|
||||
.position(|ce| ce.effect.category() == EffectCategory::Debuff) {
|
||||
let ce = target.effects.remove(i);
|
||||
results.push(Resolution::new(source, target).event(Event::Removal { effect: ce.effect }));
|
||||
results.push(Resolution::new(source, target)
|
||||
.event(Event::Removal { effect: ce.effect, construct_effects: target.effects.clone() }));
|
||||
target.deal_green_damage(skill, amount)
|
||||
.into_iter()
|
||||
.for_each(|e| results.push(Resolution::new(source, target).event(e)));
|
||||
@ -2092,7 +2095,7 @@ mod tests {
|
||||
|
||||
let Resolution { source: _, target: _, event } = results.remove(0);
|
||||
match event {
|
||||
Event::Effect { effect, skill: _, duration: _ } => assert_eq!(effect, Effect::Siphon),
|
||||
Event::Effect { effect, skill: _, duration: _, construct_effects: _ } => assert_eq!(effect, Effect::Siphon),
|
||||
_ => panic!("not siphon"),
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user