cooldown stuff
This commit is contained in:
parent
4475887410
commit
5446ee19ae
@ -1,17 +1,13 @@
|
||||
[package]
|
||||
name = "mnml-core"
|
||||
name = "mnml_core"
|
||||
version = "1.10.0"
|
||||
authors = ["ntr <ntr@smokestack.io>", "mashy <mashy@mnml.gg>"]
|
||||
|
||||
[dependencies]
|
||||
chrono = { version = "0.4", features = ["serde"] }
|
||||
failure = "0.1"
|
||||
log = "0.4"
|
||||
rand = "0.6"
|
||||
serde = "1"
|
||||
serde_derive = "1"
|
||||
|
||||
rand = "0.6"
|
||||
uuid = { version = "0.5", features = ["serde", "v4"] }
|
||||
chrono = { version = "0.4", features = ["serde"] }
|
||||
bcrypt = "0.2"
|
||||
|
||||
failure = "0.1"
|
||||
|
||||
log = "0.4"
|
||||
|
||||
@ -438,7 +438,6 @@ impl Construct {
|
||||
if skill.skill.base_cd().is_some() {
|
||||
// what is the current cd
|
||||
if let Some(current_cd) = skill.cd {
|
||||
|
||||
// if it's 1 set it to none
|
||||
if current_cd == 1 {
|
||||
skill.cd = None;
|
||||
@ -1006,4 +1005,20 @@ mod tests {
|
||||
return;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn construct_reduce_cooldown_test() {
|
||||
let mut construct = Construct::new()
|
||||
.named(&"sleepygirl".to_string());
|
||||
|
||||
construct.learn_mut(Skill::Sleep);
|
||||
|
||||
let mut i = 0;
|
||||
while construct.skill_on_cd(Skill::Sleep).is_some() {
|
||||
construct.reduce_cooldowns();
|
||||
i += 1;
|
||||
}
|
||||
|
||||
assert_eq!(i, Skill::Sleep.base_cd().unwrap());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -398,7 +398,7 @@ impl Game {
|
||||
self.phase = Phase::Resolve;
|
||||
// self.log.push("<Resolve Phase>".to_string());
|
||||
|
||||
self.resolve_skills()
|
||||
self.resolve_stack()
|
||||
}
|
||||
|
||||
fn stack_sort_speed(&mut self) -> &mut Game {
|
||||
@ -444,7 +444,7 @@ impl Game {
|
||||
}
|
||||
}
|
||||
|
||||
fn resolve_skills(mut self) -> Game {
|
||||
fn resolve_stack(mut self) -> Game {
|
||||
if self.phase != Phase::Resolve {
|
||||
panic!("game not in Resolve phase");
|
||||
}
|
||||
@ -466,28 +466,23 @@ 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 casters = vec![];
|
||||
let mut r_animation_ms = 0;
|
||||
while let Some(cast) = self.stack.pop() {
|
||||
// info!("{:} casts ", cast);
|
||||
|
||||
let mut resolutions = resolve(&cast, &mut self);
|
||||
let mut resolutions = vec![];
|
||||
resolutions = resolve(&cast, &mut self, resolutions);
|
||||
r_animation_ms = resolutions.iter().fold(r_animation_ms, |acc, r| acc + r.clone().get_delay());
|
||||
|
||||
|
||||
// the cast itself goes into this temp vec to handle cooldowns
|
||||
// if theres no resolution events, the skill didn't trigger (disable etc)
|
||||
if resolutions.len() > 0 {
|
||||
casts.push(cast);
|
||||
if resolutions.len() > 0 && cast.used_cooldown() {
|
||||
casters.push(cast);
|
||||
}
|
||||
|
||||
self.resolved.append(&mut resolutions);
|
||||
|
||||
// while let Some(resolution) = resolutions.pop() {
|
||||
// self.log_resolution(cast.speed, &resolution);
|
||||
// // the results go into the resolutions
|
||||
// self.resolved.push(resolution);
|
||||
// }
|
||||
// println!("{:?}", self.resolved);
|
||||
|
||||
// sort the stack again in case speeds have changed
|
||||
self.stack_sort_speed();
|
||||
@ -496,7 +491,7 @@ impl Game {
|
||||
// info!("{:#?}", self.casts);
|
||||
|
||||
// handle cooldowns and statuses
|
||||
self.progress_durations(&casts);
|
||||
self.progress_durations(&casters);
|
||||
|
||||
if self.finished() {
|
||||
return self.finish()
|
||||
@ -513,16 +508,10 @@ impl Game {
|
||||
continue;
|
||||
}
|
||||
|
||||
// only reduce cooldowns if no cd was used
|
||||
{
|
||||
if let Some(skill) = resolved.iter()
|
||||
.filter(|s| s.source_construct_id == construct.id)
|
||||
.find(|s| s.used_cooldown()) {
|
||||
construct.skill_set_cd(skill.skill);
|
||||
} else {
|
||||
construct.reduce_cooldowns();
|
||||
}
|
||||
}
|
||||
match resolved.iter().find(|s| s.source_construct_id == construct.id) {
|
||||
Some(skill) => { construct.skill_set_cd(skill.skill); },
|
||||
None => { construct.reduce_cooldowns(); },
|
||||
};
|
||||
|
||||
// always reduce durations
|
||||
construct.reduce_effect_durations();
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
extern crate rand;
|
||||
extern crate uuid;
|
||||
extern crate bcrypt;
|
||||
extern crate chrono;
|
||||
|
||||
extern crate serde;
|
||||
|
||||
@ -21,9 +21,7 @@ pub fn dev_resolve(a_id: Uuid, b_id: Uuid, skill: Skill) -> Resolutions {
|
||||
return resolve_skill(skill, &mut a, &mut b, resolutions);
|
||||
}
|
||||
|
||||
pub fn resolve(cast: &Cast, game: &mut Game) -> Resolutions {
|
||||
let mut resolutions = vec![];
|
||||
|
||||
pub fn resolve(cast: &Cast, game: &mut Game, mut resolutions: Resolutions) -> Resolutions {
|
||||
let skill = cast.skill;
|
||||
let source = game.construct_by_id(cast.source_construct_id).unwrap().clone();
|
||||
let targets = game.get_targets(cast.skill, &source, cast.target_construct_id);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user