Merge branch 'develop' into release/1.5.3

This commit is contained in:
ntr
2019-10-08 14:42:51 +11:00
6 changed files with 49 additions and 26 deletions
+6 -9
View File
@@ -161,14 +161,12 @@ impl Game {
self.skill_phase_start(0)
}
fn skill_phase_start(mut self, num_resolutions: usize) -> Game {
let resolution_animation_ms = num_resolutions as i64 * 2500;
fn skill_phase_start(mut self, resolution_time: i64) -> Game {
self.phase_start = Utc::now()
.checked_add_signed(Duration::milliseconds(resolution_animation_ms))
.checked_add_signed(Duration::milliseconds(resolution_time))
.expect("could not set phase start");
self.phase_end = self.time_control.game_phase_end(resolution_animation_ms);
self.phase_end = self.time_control.game_phase_end(resolution_time);
for player in self.players.iter_mut() {
if player.skills_required() == 0 {
@@ -428,13 +426,12 @@ impl Game {
// temp vec of this round's resolving skills
// because need to check cooldown use before pushing them into the complete list
let mut casts = vec![];
let mut turn_events = 0;
let mut resolution_delay = 0;
while let Some(cast) = self.stack.pop() {
// info!("{:} casts ", cast);
let mut resolutions = resolution_steps(&cast, &mut self);
turn_events += resolutions.len();
resolution_delay = resolutions.iter().fold(resolution_delay, |acc, r| acc + r.clone().get_delay());
self.resolved.append(&mut resolutions);
// while let Some(resolution) = resolutions.pop() {
@@ -460,7 +457,7 @@ impl Game {
return self.finish()
}
self.skill_phase_start(turn_events)
self.skill_phase_start(resolution_delay)
}
fn progress_durations(&mut self, resolved: &Vec<Cast>) -> &mut Game {
+24 -5
View File
@@ -415,7 +415,7 @@ pub enum EventStages {
EndPost, // Skip Anim Anim
EndOnly, // Skip Anim Skip
PostOnly, // Skip Skip Anim
None, // Skip Skip Skip
NoStages, // Skip Skip Skip
}
#[derive(Debug,Clone,PartialEq,Serialize,Deserialize)]
@@ -455,6 +455,25 @@ impl Resolution {
self.stages = s;
self
}
pub fn get_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.stages {
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
EventStages::NoStages => 0, // Skip Skip Skip
}
}
}
@@ -1363,7 +1382,7 @@ fn sustain(source: &mut Construct, target: &mut Construct, mut results: Resoluti
let stages = match e {
Event::Recharge { red, blue, skill: _ } => {
if red > 0 || blue > 0 { EventStages::PostOnly }
else { EventStages::None }
else { EventStages::NoStages }
}
_ => panic!("not recharge")
};
@@ -1382,7 +1401,7 @@ fn intercept(source: &mut Construct, target: &mut Construct, mut results: Resolu
let stages = match e {
Event::Recharge { red, blue, skill: _ } => {
if red > 0 || blue > 0 { EventStages::PostOnly }
else { EventStages::None }
else { EventStages::NoStages }
}
_ => panic!("not recharge")
};
@@ -1606,7 +1625,7 @@ fn electrocute(source: &mut Construct, target: &mut Construct, mut results: Reso
let electrocute = ConstructEffect::new(effect, duration).set_tick(Cast::new_tick(source, target, tick_skill));
results.push(Resolution::new(source, target)
.event(target.add_effect(skill, electrocute))
.stages(EventStages::EndPost));
.stages(EventStages::PostOnly));
match skip_tick {
@@ -1674,7 +1693,7 @@ fn reflect(source: &mut Construct, target: &mut Construct, mut results: Resoluti
let stages = match e {
Event::Recharge { red, blue, skill: _ } => {
if red > 0 || blue > 0 { EventStages::PostOnly }
else { EventStages::None }
else { EventStages::NoStages }
}
_ => panic!("not recharge")
};