fix drain logs

This commit is contained in:
ntr 2018-11-13 22:36:02 +11:00
parent c175e80817
commit eb8aa98e42
3 changed files with 9 additions and 12 deletions

View File

@ -203,7 +203,7 @@ impl Cryp {
if let Some(cd) = skill.skill.cd() { if let Some(cd) = skill.skill.cd() {
// if the cd is 1 it becomes none // if the cd is 1 it becomes none
if cd == 1 { if cd == 1 {
println!("{:?} is now off cd", skill.skill); // println!("{:?} is now off cd", skill.skill);
skill.cd = None; skill.cd = None;
continue; continue;
} }

View File

@ -30,7 +30,7 @@ impl Team {
fn skills_required(&self) -> usize { fn skills_required(&self) -> usize {
let required = self.cryps.iter().filter(|c| c.available_skills().len() > 0).collect::<Vec<&Cryp>>().len(); let required = self.cryps.iter().filter(|c| c.available_skills().len() > 0).collect::<Vec<&Cryp>>().len();
println!("{:?} requires {:?} skills this turn", self.id, required); // println!("{:?} requires {:?} skills this turn", self.id, required);
return required; return required;
} }
@ -351,10 +351,10 @@ impl Game {
// find their statuses with ticks // find their statuses with ticks
let mut ticks = self.all_cryps() let mut ticks = self.all_cryps()
.iter_mut() .iter()
.flat_map( .flat_map(
|c| c.effects |c| c.effects
.iter_mut() .iter()
.filter_map(|e| e.tick)) .filter_map(|e| e.tick))
.collect::<Vec<Cast>>(); .collect::<Vec<Cast>>();
@ -393,7 +393,7 @@ impl Game {
fn progress_durations(&mut self) -> &mut Game { fn progress_durations(&mut self) -> &mut Game {
for mut cryp in self.all_cryps() { for mut cryp in self.all_cryps() {
println!("progressing durations for {:?}", cryp.name); // println!("progressing durations for {:?}", cryp.name);
// only reduce cooldowns if no cd was used // only reduce cooldowns if no cd was used
// have to borrow self for the skill check // have to borrow self for the skill check
@ -815,7 +815,6 @@ mod tests {
// should auto progress back to skill phase // should auto progress back to skill phase
assert!(game.phase == Phase::Skill); assert!(game.phase == Phase::Skill);
println!("{:#?}", game);
assert!(game.team_by_id(y_team.id).cryps[0].is_stunned()); assert!(game.team_by_id(y_team.id).cryps[0].is_stunned());
assert!(game.team_by_id(y_team.id).skills_required() == 0); assert!(game.team_by_id(y_team.id).skills_required() == 0);
} }
@ -844,6 +843,7 @@ mod tests {
// after 1 turn block should be off cooldown // after 1 turn block should be off cooldown
assert!(game.team_by_id(y_team.id).cryps[0].skill_on_cd(Skill::Block).is_none()); assert!(game.team_by_id(y_team.id).cryps[0].skill_on_cd(Skill::Block).is_none());
assert!(game.team_by_id(x_team.id).cryps[0].skill_on_cd(Skill::Block).is_none());
// second round // second round
// now we block and it should go back on cd // now we block and it should go back on cd
@ -886,7 +886,6 @@ mod tests {
// should not be stunned because of block // should not be stunned because of block
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);
println!("{:#?}", game.log);
} }
#[test] #[test]

View File

@ -627,10 +627,10 @@ fn drain_tick(cryp: &mut Cryp, target: &mut Cryp, log: &mut Log) {
cryp.stamina.value cryp.stamina.value
].iter().min().unwrap(); ].iter().min().unwrap();
let healing = new_hp.saturating_sub(target.hp.value);
let overhealing = cryp.hp.value + damage - target.stamina.value;
cryp.hp.value = new_hp; cryp.hp.value = new_hp;
log.push(format!("{:?} | Drain healing {:?} ({:?} OH)", target.name, healing, overhealing)); let healing = new_hp.saturating_sub(cryp.hp.value);
let overhealing = cryp.hp.value + damage - cryp.stamina.value;
log.push(format!("{:?} | Drain healing {:?} ({:?} OH)", cryp.name, healing, overhealing));
} }
fn banish(_cryp: &mut Cryp, target: &mut Cryp, log: &mut Log) { fn banish(_cryp: &mut Cryp, target: &mut Cryp, log: &mut Log) {
@ -662,8 +662,6 @@ mod tests {
let mut log = vec![]; let mut log = vec![];
heal(&mut y, &mut x, &mut log); heal(&mut y, &mut x, &mut log);
println!("{:?}", log);
} }
#[test] #[test]