simplify resolutions further
This commit is contained in:
parent
171367ab06
commit
cff22550f9
@ -373,7 +373,7 @@ impl Cryp {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn reduce_effect_durations(&mut self, _log: &mut Log) -> &mut Cryp {
|
pub fn reduce_effect_durations(&mut self) -> &mut Cryp {
|
||||||
self.effects = self.effects.clone().into_iter().filter_map(|mut effect| {
|
self.effects = self.effects.clone().into_iter().filter_map(|mut effect| {
|
||||||
effect.duration = effect.duration.saturating_sub(1);
|
effect.duration = effect.duration.saturating_sub(1);
|
||||||
|
|
||||||
|
|||||||
@ -86,7 +86,7 @@ pub struct Game {
|
|||||||
pub teams: Vec<Team>,
|
pub teams: Vec<Team>,
|
||||||
pub phase: Phase,
|
pub phase: Phase,
|
||||||
pub stack: Vec<Cast>,
|
pub stack: Vec<Cast>,
|
||||||
pub resolved: Vec<Cast>,
|
pub resolved: Vec<Resolution>,
|
||||||
pub log: Vec<String>,
|
pub log: Vec<String>,
|
||||||
pub instance: Option<Uuid>,
|
pub instance: Option<Uuid>,
|
||||||
pub mode: GameMode,
|
pub mode: GameMode,
|
||||||
@ -476,6 +476,11 @@ impl Game {
|
|||||||
|
|
||||||
self.log_resolution(&cast);
|
self.log_resolution(&cast);
|
||||||
|
|
||||||
|
// the results go into the resolutions
|
||||||
|
self.resolved.append(&mut cast.resolutions);
|
||||||
|
|
||||||
|
// the cast itself goes into this temp vec
|
||||||
|
// to handle cooldowns
|
||||||
resolving.push(cast);
|
resolving.push(cast);
|
||||||
|
|
||||||
// if target.is_ko() && !target.ko_logged {
|
// if target.is_ko() && !target.ko_logged {
|
||||||
@ -498,10 +503,8 @@ impl Game {
|
|||||||
|
|
||||||
// println!("{:#?}", self.resolving);
|
// println!("{:#?}", self.resolving);
|
||||||
|
|
||||||
// now Resolve has all been assigned
|
|
||||||
// handle cooldowns and statuses
|
// handle cooldowns and statuses
|
||||||
self.progress_durations(&resolving);
|
self.progress_durations(&resolving);
|
||||||
self.resolved.append(&mut resolving);
|
|
||||||
|
|
||||||
if self.finished() {
|
if self.finished() {
|
||||||
return self.finish()
|
return self.finish()
|
||||||
@ -533,7 +536,7 @@ impl Game {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// always reduce durations
|
// always reduce durations
|
||||||
cryp.reduce_effect_durations(&mut self.log);
|
cryp.reduce_effect_durations();
|
||||||
self.update_cryp(&mut cryp);
|
self.update_cryp(&mut cryp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1105,29 +1108,6 @@ mod tests {
|
|||||||
assert!(game.team_by_id(x_team.id).cryps[0].is_stunned() == false);
|
assert!(game.team_by_id(x_team.id).cryps[0].is_stunned() == false);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn siphon_test() {
|
|
||||||
let mut game = create_test_game();
|
|
||||||
|
|
||||||
let x_team = game.teams[0].clone();
|
|
||||||
let y_team = game.teams[1].clone();
|
|
||||||
|
|
||||||
let x_cryp = x_team.cryps[0].clone();
|
|
||||||
let y_cryp = y_team.cryps[0].clone();
|
|
||||||
|
|
||||||
let _x_siphon_id = game.add_skill(x_team.id, x_cryp.id, Some(y_cryp.id), Skill::TestSiphon).unwrap();
|
|
||||||
let _y_touch_id = game.add_skill(y_team.id, y_cryp.id, Some(x_cryp.id), Skill::TestTouch).unwrap();
|
|
||||||
|
|
||||||
game = game.resolve_phase_start();
|
|
||||||
|
|
||||||
game.add_skill(x_team.id, x_cryp.id, None, Skill::TestBlock).unwrap();
|
|
||||||
game.add_skill(y_team.id, y_cryp.id, None, Skill::TestBlock).unwrap();
|
|
||||||
|
|
||||||
game = game.resolve_phase_start();
|
|
||||||
|
|
||||||
assert!(game.resolved.iter().any(|r| r.skill == Skill::SiphonTick));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn ko_pve_test() {
|
fn ko_pve_test() {
|
||||||
let mut game = create_2v2_test_game();
|
let mut game = create_2v2_test_game();
|
||||||
|
|||||||
@ -981,12 +981,11 @@ mod tests {
|
|||||||
let mut y = Cryp::new()
|
let mut y = Cryp::new()
|
||||||
.named(&"camel".to_string());
|
.named(&"camel".to_string());
|
||||||
|
|
||||||
let mut log = vec![];
|
|
||||||
decay(&mut x, &mut y, vec![]);
|
decay(&mut x, &mut y, vec![]);
|
||||||
|
|
||||||
assert!(y.effects.iter().any(|e| e.effect == Effect::Decay));
|
assert!(y.effects.iter().any(|e| e.effect == Effect::Decay));
|
||||||
|
|
||||||
y.reduce_effect_durations(&mut log);
|
y.reduce_effect_durations();
|
||||||
let _decay = y.effects.iter().find(|e| e.effect == Effect::Decay);
|
let _decay = y.effects.iter().find(|e| e.effect == Effect::Decay);
|
||||||
// assert!(y.hp() == y.hp().saturating_sub(decay.unwrap().tick.unwrap().amount));
|
// assert!(y.hp() == y.hp().saturating_sub(decay.unwrap().tick.unwrap().amount));
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user