Merge branch 'master' of ssh://cryps.gg:40022/~/cryps

This commit is contained in:
Mashy 2018-12-14 16:10:03 +10:00
commit f78cf7ffff
3 changed files with 27 additions and 17 deletions

View File

@ -24,7 +24,7 @@ impl CrypSkill {
CrypSkill {
skill,
self_targeting: skill.self_targeting(),
cd: skill.cd(),
cd: skill.base_cd(),
}
}
}
@ -255,16 +255,20 @@ impl Cryp {
pub fn reduce_cooldowns(&mut self) -> &mut Cryp {
for skill in self.skills.iter_mut() {
// if used cooldown
if let Some(cd) = skill.skill.cd() {
// if the cd is 1 it becomes none
if cd == 1 {
// println!("{:?} is now off cd", skill.skill);
skill.cd = None;
continue;
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;
continue;
}
// otherwise decrement it
skill.cd = Some(current_cd.saturating_sub(1));
}
// otherwise decrement it
skill.cd = Some(cd.saturating_sub(1));
}
}
@ -273,7 +277,6 @@ impl Cryp {
pub fn reduce_effect_durations(&mut self, log: &mut Log) -> &mut Cryp {
self.effects = self.effects.clone().into_iter().filter_map(|mut effect| {
effect.duration = effect.duration.saturating_sub(1);
if effect.duration == 0 {

View File

@ -889,6 +889,7 @@ mod tests {
.learn(Skill::TestTouch)
.learn(Skill::TestBlock)
.learn(Skill::TestDrain)
.learn(Skill::Empower)
.learn(Skill::Block)
.create();
@ -899,6 +900,7 @@ mod tests {
.learn(Skill::TestTouch)
.learn(Skill::TestBlock)
.learn(Skill::TestDrain)
.learn(Skill::Empower)
.learn(Skill::Block)
.create();
@ -1066,12 +1068,11 @@ mod tests {
game.resolve_phase_start();
// resolution should have been prevented by KO
println!("{:#?}", game);
// println!("{:#?}", game);
assert!(!game.team_by_id(y_team.id).cryps[0].is_stunned());
assert!(game.phase == Phase::Finish);
}
#[test]
fn cooldown_test() {
let mut game = create_test_game();
@ -1094,19 +1095,25 @@ mod tests {
// should auto progress back to skill phase
assert!(game.phase == Phase::Skill);
// 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::Empower).is_some());
assert!(game.team_by_id(x_team.id).cryps[0].skill_on_cd(Skill::Block).is_none());
// second round
// now we block and it should go back on cd
let _x_block_id = game.add_skill(x_team.id, x_cryp.id, None, Skill::Block).unwrap();
let _y_block_id = game.add_skill(y_team.id, y_cryp.id, None, Skill::Block).unwrap();
let y_touch_id = game.add_skill(y_team.id, y_cryp.id, Some(x_team.id), Skill::TestTouch).unwrap();
game.target_phase_start();
assert!(game.team_by_id(y_team.id).cryps[0].skill_on_cd(Skill::Block).is_some());
game.add_target(x_team.id, x_cryp.id, y_touch_id).unwrap();
game.resolve_phase_start();
assert!(game.team_by_id(x_team.id).cryps[0].skill_on_cd(Skill::Block).is_some());
assert!(game.team_by_id(y_team.id).cryps[0].skill_on_cd(Skill::Empower).is_none());
}
#[test]
@ -1119,7 +1126,7 @@ mod tests {
let x_cryp = x_team.cryps[0].clone();
let y_cryp = y_team.cryps[0].clone();
let x_block_id = game.add_skill(x_team.id, x_cryp.id, None, Skill::TestBlock).unwrap();
let _x_block_id = game.add_skill(x_team.id, x_cryp.id, None, Skill::TestBlock).unwrap();
let y_attack_id = game.add_skill(y_team.id, y_cryp.id, Some(x_team.id), Skill::TestStun).unwrap();
game.target_phase_start();

View File

@ -50,7 +50,7 @@ impl Cast {
}
pub fn used_cooldown(&self) -> bool {
return self.skill.cd().is_some();
return self.skill.base_cd().is_some();
}
}
@ -344,7 +344,7 @@ pub enum Skill {
}
impl Skill {
pub fn cd(&self) -> Cooldown {
pub fn base_cd(&self) -> Cooldown {
match self {
Skill::Attack => None,