fix peeker

This commit is contained in:
ntr 2019-12-10 15:27:49 +10:00
parent 0cac570695
commit b365a6c1f1

View File

@ -451,12 +451,12 @@ impl Game {
self.stack_sort_speed();
};
// update to go through the whole most recent round and modify durations
// let mut iter = event_list.into_iter().peekable();
// while let Some(event) = iter.next() {
// resolutions.push(Resolution::new(cast, event, iter.peek()));
// }
// go through the whole most recent round and modify delays of the resolutions
let last = self.resolutions.len() - 1;
let mut iter = self.resolutions[last].iter_mut().peekable();
while let Some(res) = iter.next() {
res.set_delay(iter.peek());
}
// info!("{:#?}", self.casts);
@ -877,15 +877,18 @@ impl Resolution {
_ => vec![cast.source, cast.target],
};
let delay = event.delay(None);
Resolution {
skill: cast.skill,
delay,
delay: 0, // set at the end of the resolve phase because of changes depending on what's before/after
focus,
event,
}
}
pub fn set_delay(&mut self, next: Option<&&mut Resolution>) -> &mut Resolution {
self.delay = self.event.delay(next);
self
}
}
pub type Disable = Vec<Effect>;
@ -913,42 +916,41 @@ pub enum Event {
}
impl Event {
fn delay(&self, next_event: Option<&Event>) -> i64 {
900
// let source_overlapping = 500;
// let target_overlapping = 900;
fn delay(&self, next_event: Option<&&mut Resolution>) -> i64 {
let source_overlapping = 500;
let target_overlapping = 900;
// let source_duration = 1000;
// let target_duration = 1500;
// let combat_text_duration = 1300;
let source_duration = 1000;
let target_duration = 1500;
let combat_text_duration = 1300;
// match self {
// Event::Cast { construct: _, direction: _, player: _ } => {
// match next_event {
// Some(e) => {
// match e {
// Event::Cast { construct: _, direction: _, player: _ } => source_duration,
// _ => source_overlapping,
// }
// },
// None => source_duration
// }
// },
// Event::Hit { construct: _, direction: _, player: _ } |
// Event::HitAoe { construct: _ } => {
// match next_event {
// Some(e) => {
// match e {
// Event::Cast { construct: _, direction: _, player: _ } |
// Event::Hit { construct: _, direction: _, player: _ } => target_duration,
// _ => target_overlapping,
// }
// }
// None => target_duration,
// }
// },
// _ => combat_text_duration,
// }
match self {
Event::Cast { construct: _, direction: _, player: _ } => {
match next_event {
Some(e) => {
match e.event {
Event::Cast { construct: _, direction: _, player: _ } => source_duration,
_ => source_overlapping,
}
},
None => source_duration
}
},
Event::Hit { construct: _, direction: _, player: _ } |
Event::HitAoe { construct: _ } => {
match next_event {
Some(e) => {
match e.event {
Event::Cast { construct: _, direction: _, player: _ } |
Event::Hit { construct: _, direction: _, player: _ } => target_duration,
_ => target_overlapping,
}
}
None => target_duration,
}
},
_ => combat_text_duration,
}
}
}