fix tests and remove test skills

This commit is contained in:
ntr 2019-05-29 13:47:34 +10:00
parent 22652b6994
commit f4992e4e87
3 changed files with 75 additions and 106 deletions

View File

@ -948,11 +948,11 @@ mod tests {
let mut x = Construct::new() let mut x = Construct::new()
.named(&"pronounced \"creeep\"".to_string()) .named(&"pronounced \"creeep\"".to_string())
.learn(Skill::Attack) .learn(Skill::Attack)
.learn(Skill::TestStun) .learn(Skill::Stun)
.learn(Skill::TestTouch) .learn(Skill::Attack)
.learn(Skill::TestBlock) .learn(Skill::Block)
.learn(Skill::TestParry) .learn(Skill::ParryI)
.learn(Skill::TestSiphon) .learn(Skill::SiphonI)
.learn(Skill::AmplifyI) .learn(Skill::AmplifyI)
.learn(Skill::Stun) .learn(Skill::Stun)
.learn(Skill::Block); .learn(Skill::Block);
@ -960,11 +960,11 @@ mod tests {
let mut y = Construct::new() let mut y = Construct::new()
.named(&"lemongrass tea".to_string()) .named(&"lemongrass tea".to_string())
.learn(Skill::Attack) .learn(Skill::Attack)
.learn(Skill::TestStun) .learn(Skill::Stun)
.learn(Skill::TestTouch) .learn(Skill::Attack)
.learn(Skill::TestBlock) .learn(Skill::Block)
.learn(Skill::TestParry) .learn(Skill::ParryI)
.learn(Skill::TestSiphon) .learn(Skill::SiphonI)
.learn(Skill::AmplifyI) .learn(Skill::AmplifyI)
.learn(Skill::Stun) .learn(Skill::Stun)
.learn(Skill::Block); .learn(Skill::Block);
@ -996,22 +996,22 @@ mod tests {
let mut i = Construct::new() let mut i = Construct::new()
.named(&"pretaliate".to_string()) .named(&"pretaliate".to_string())
.learn(Skill::Attack) .learn(Skill::Attack)
.learn(Skill::TestTouch); .learn(Skill::Attack);
let mut j = Construct::new() let mut j = Construct::new()
.named(&"poy sian".to_string()) .named(&"poy sian".to_string())
.learn(Skill::Attack) .learn(Skill::Attack)
.learn(Skill::TestTouch); .learn(Skill::Attack);
let mut x = Construct::new() let mut x = Construct::new()
.named(&"pronounced \"creeep\"".to_string()) .named(&"pronounced \"creeep\"".to_string())
.learn(Skill::Attack) .learn(Skill::Attack)
.learn(Skill::TestTouch); .learn(Skill::Attack);
let mut y = Construct::new() let mut y = Construct::new()
.named(&"lemongrass tea".to_string()) .named(&"lemongrass tea".to_string())
.learn(Skill::Attack) .learn(Skill::Attack)
.learn(Skill::TestTouch); .learn(Skill::Attack);
let mut game = Game::new(); let mut game = Game::new();
@ -1073,8 +1073,12 @@ mod tests {
let x_construct = x_player.constructs[0].clone(); let x_construct = x_player.constructs[0].clone();
let y_construct = y_player.constructs[0].clone(); let y_construct = y_player.constructs[0].clone();
game.add_skill(x_player.id, x_construct.id, Some(y_construct.id), Skill::TestStun).unwrap(); while game.construct_by_id(x_construct.id).unwrap().skill_on_cd(Skill::Stun).is_some() {
game.add_skill(y_player.id, y_construct.id, Some(x_construct.id), Skill::TestTouch).unwrap(); game.construct_by_id(x_construct.id).unwrap().reduce_cooldowns();
}
game.add_skill(x_player.id, x_construct.id, Some(y_construct.id), Skill::Stun).unwrap();
game.add_skill(y_player.id, y_construct.id, Some(x_construct.id), Skill::Attack).unwrap();
game.player_ready(x_player.id).unwrap(); game.player_ready(x_player.id).unwrap();
game.player_ready(y_player.id).unwrap(); game.player_ready(y_player.id).unwrap();
@ -1102,11 +1106,15 @@ mod tests {
game.player_by_id(y_player.id).unwrap().construct_by_id(y_construct.id).unwrap().red_power.force(1000000000); game.player_by_id(y_player.id).unwrap().construct_by_id(y_construct.id).unwrap().red_power.force(1000000000);
game.player_by_id(y_player.id).unwrap().construct_by_id(y_construct.id).unwrap().speed.force(1000000000); game.player_by_id(y_player.id).unwrap().construct_by_id(y_construct.id).unwrap().speed.force(1000000000);
while game.construct_by_id(x_construct.id).unwrap().skill_on_cd(Skill::Stun).is_some() {
game.construct_by_id(x_construct.id).unwrap().reduce_cooldowns();
}
// just in case // just in case
// remove all mitigation // remove all mitigation
game.player_by_id(x_player.id).unwrap().construct_by_id(x_construct.id).unwrap().red_life.force(0); game.player_by_id(x_player.id).unwrap().construct_by_id(x_construct.id).unwrap().red_life.force(0);
game.add_skill(x_player.id, x_construct.id, Some(y_construct.id), Skill::TestStun).unwrap(); game.add_skill(x_player.id, x_construct.id, Some(y_construct.id), Skill::Stun).unwrap();
game.add_skill(y_player.id, y_construct.id, Some(x_construct.id), Skill::Attack).unwrap(); game.add_skill(y_player.id, y_construct.id, Some(x_construct.id), Skill::Attack).unwrap();
game.player_ready(x_player.id).unwrap(); game.player_ready(x_player.id).unwrap();
@ -1136,8 +1144,8 @@ mod tests {
assert!(game.player_by_id(y_player.id).unwrap().constructs[0].skill_on_cd(Skill::Stun).is_some()); assert!(game.player_by_id(y_player.id).unwrap().constructs[0].skill_on_cd(Skill::Stun).is_some());
assert!(game.player_by_id(x_player.id).unwrap().constructs[0].skill_on_cd(Skill::Block).is_none()); assert!(game.player_by_id(x_player.id).unwrap().constructs[0].skill_on_cd(Skill::Block).is_none());
game.add_skill(x_player.id, x_construct.id, Some(y_construct.id), Skill::TestTouch).unwrap(); game.add_skill(x_player.id, x_construct.id, Some(y_construct.id), Skill::Attack).unwrap();
game.add_skill(y_player.id, y_construct.id, Some(x_construct.id), Skill::TestTouch).unwrap(); game.add_skill(y_player.id, y_construct.id, Some(x_construct.id), Skill::Attack).unwrap();
game.player_ready(x_player.id).unwrap(); game.player_ready(x_player.id).unwrap();
game.player_ready(y_player.id).unwrap(); game.player_ready(y_player.id).unwrap();
@ -1151,7 +1159,7 @@ mod tests {
// second round // second round
// now we block and it should go back on cd // now we block and it should go back on cd
// game.add_skill(x_player.id, x_construct.id, Some(y_construct.id), Skill::Stun).unwrap(); // game.add_skill(x_player.id, x_construct.id, Some(y_construct.id), Skill::Stun).unwrap();
game.add_skill(y_player.id, y_construct.id, Some(x_construct.id), Skill::TestTouch).unwrap(); game.add_skill(y_player.id, y_construct.id, Some(x_construct.id), Skill::Attack).unwrap();
game.player_ready(x_player.id).unwrap(); game.player_ready(x_player.id).unwrap();
game.player_ready(y_player.id).unwrap(); game.player_ready(y_player.id).unwrap();
@ -1172,8 +1180,16 @@ mod tests {
let x_construct = x_player.constructs[0].clone(); let x_construct = x_player.constructs[0].clone();
let y_construct = y_player.constructs[0].clone(); let y_construct = y_player.constructs[0].clone();
game.add_skill(x_player.id, x_construct.id, None, Skill::TestParry).unwrap(); while game.construct_by_id(y_construct.id).unwrap().skill_on_cd(Skill::Stun).is_some() {
game.add_skill(y_player.id, y_construct.id, Some(x_construct.id), Skill::TestStun).unwrap(); game.construct_by_id(y_construct.id).unwrap().reduce_cooldowns();
}
while game.construct_by_id(x_construct.id).unwrap().skill_on_cd(Skill::ParryI).is_some() {
game.construct_by_id(x_construct.id).unwrap().reduce_cooldowns();
}
game.add_skill(x_player.id, x_construct.id, None, Skill::ParryI).unwrap();
game.add_skill(y_player.id, y_construct.id, Some(x_construct.id), Skill::Stun).unwrap();
game.player_ready(x_player.id).unwrap(); game.player_ready(x_player.id).unwrap();
game.player_ready(y_player.id).unwrap(); game.player_ready(y_player.id).unwrap();
@ -1210,7 +1226,7 @@ mod tests {
assert!(game.construct_by_id(x_construct.id).unwrap().affected(Effect::Corrupt)); assert!(game.construct_by_id(x_construct.id).unwrap().affected(Effect::Corrupt));
// attack and receive debuff // attack and receive debuff
game.add_skill(y_player.id, y_construct.id, Some(x_construct.id), Skill::TestTouch).unwrap(); game.add_skill(y_player.id, y_construct.id, Some(x_construct.id), Skill::Attack).unwrap();
game.player_ready(x_player.id).unwrap(); game.player_ready(x_player.id).unwrap();
game.player_ready(y_player.id).unwrap(); game.player_ready(y_player.id).unwrap();
game = game.resolve_phase_start(); game = game.resolve_phase_start();
@ -1319,10 +1335,10 @@ mod tests {
game.construct_by_id(x_construct.id).unwrap().reduce_cooldowns(); game.construct_by_id(x_construct.id).unwrap().reduce_cooldowns();
} }
game.add_skill(i_player.id, i_construct.id, Some(x_construct.id), Skill::TestTouch).unwrap(); game.add_skill(i_player.id, i_construct.id, Some(x_construct.id), Skill::Attack).unwrap();
game.add_skill(i_player.id, j_construct.id, Some(x_construct.id), Skill::TestTouch).unwrap(); game.add_skill(i_player.id, j_construct.id, Some(x_construct.id), Skill::Attack).unwrap();
game.add_skill(x_player.id, x_construct.id, Some(i_construct.id), Skill::RuinI).unwrap(); game.add_skill(x_player.id, x_construct.id, Some(i_construct.id), Skill::RuinI).unwrap();
game.add_skill(x_player.id, y_construct.id, Some(i_construct.id), Skill::TestTouch).unwrap(); game.add_skill(x_player.id, y_construct.id, Some(i_construct.id), Skill::Attack).unwrap();
game.player_ready(i_player.id).unwrap(); game.player_ready(i_player.id).unwrap();
game.player_ready(x_player.id).unwrap(); game.player_ready(x_player.id).unwrap();
@ -1369,10 +1385,10 @@ mod tests {
game.construct_by_id(x_construct.id).unwrap().reduce_cooldowns(); game.construct_by_id(x_construct.id).unwrap().reduce_cooldowns();
} }
game.add_skill(i_player.id, i_construct.id, Some(x_construct.id), Skill::TestTouch).unwrap(); game.add_skill(i_player.id, i_construct.id, Some(x_construct.id), Skill::Attack).unwrap();
game.add_skill(i_player.id, j_construct.id, Some(x_construct.id), Skill::TestTouch).unwrap(); game.add_skill(i_player.id, j_construct.id, Some(x_construct.id), Skill::Attack).unwrap();
game.add_skill(x_player.id, x_construct.id, Some(i_construct.id), Skill::TauntI).unwrap(); game.add_skill(x_player.id, x_construct.id, Some(i_construct.id), Skill::TauntI).unwrap();
game.add_skill(x_player.id, y_construct.id, Some(i_construct.id), Skill::TestTouch).unwrap(); game.add_skill(x_player.id, y_construct.id, Some(i_construct.id), Skill::Attack).unwrap();
game.player_ready(i_player.id).unwrap(); game.player_ready(i_player.id).unwrap();
game.player_ready(x_player.id).unwrap(); game.player_ready(x_player.id).unwrap();
@ -1400,10 +1416,10 @@ mod tests {
let x_construct = x_player.constructs[0].clone(); let x_construct = x_player.constructs[0].clone();
let y_construct = x_player.constructs[1].clone(); let y_construct = x_player.constructs[1].clone();
game.add_skill(i_player.id, i_construct.id, Some(x_construct.id), Skill::TestTouch).unwrap(); game.add_skill(i_player.id, i_construct.id, Some(x_construct.id), Skill::Attack).unwrap();
game.add_skill(i_player.id, j_construct.id, Some(x_construct.id), Skill::TestTouch).unwrap(); game.add_skill(i_player.id, j_construct.id, Some(x_construct.id), Skill::Attack).unwrap();
game.add_skill(x_player.id, x_construct.id, Some(i_construct.id), Skill::TestTouch).unwrap(); game.add_skill(x_player.id, x_construct.id, Some(i_construct.id), Skill::Attack).unwrap();
game.add_skill(x_player.id, y_construct.id, Some(i_construct.id), Skill::TestTouch).unwrap(); game.add_skill(x_player.id, y_construct.id, Some(i_construct.id), Skill::Attack).unwrap();
game.player_ready(i_player.id).unwrap(); game.player_ready(i_player.id).unwrap();
game.player_ready(x_player.id).unwrap(); game.player_ready(x_player.id).unwrap();
@ -1420,10 +1436,10 @@ mod tests {
assert!(game.player_by_id(x_player.id).unwrap().skills_required() == 2); assert!(game.player_by_id(x_player.id).unwrap().skills_required() == 2);
// add some more skills // add some more skills
game.add_skill(i_player.id, j_construct.id, Some(x_construct.id), Skill::TestTouch).unwrap(); game.add_skill(i_player.id, j_construct.id, Some(x_construct.id), Skill::Attack).unwrap();
game.add_skill(x_player.id, x_construct.id, Some(j_construct.id), Skill::TestTouch).unwrap(); game.add_skill(x_player.id, x_construct.id, Some(j_construct.id), Skill::Attack).unwrap();
game.add_skill(x_player.id, y_construct.id, Some(j_construct.id), Skill::TestTouch).unwrap(); game.add_skill(x_player.id, y_construct.id, Some(j_construct.id), Skill::Attack).unwrap();
assert!(game.add_skill(x_player.id, x_construct.id, Some(i_construct.id), Skill::TestTouch).is_err()); assert!(game.add_skill(x_player.id, x_construct.id, Some(i_construct.id), Skill::Attack).is_err());
game.player_ready(i_player.id).unwrap(); game.player_ready(i_player.id).unwrap();
game.player_ready(x_player.id).unwrap(); game.player_ready(x_player.id).unwrap();

View File

@ -139,13 +139,6 @@ pub enum Item {
TriageI, TriageI,
TriageII, TriageII,
TriageIII, TriageIII,
TestTouch,
TestStun,
TestBlock,
TestParry,
TestSiphon,
} }
pub enum ItemEffect { pub enum ItemEffect {
@ -877,11 +870,11 @@ impl From<Skill> for Item {
Skill::CorruptII => Item::CorruptII, Skill::CorruptII => Item::CorruptII,
Skill::CorruptIII => Item::CorruptIII, Skill::CorruptIII => Item::CorruptIII,
Skill::TestTouch => Item::TestTouch, Skill::Attack => Item::Attack,
Skill::TestStun => Item::TestStun, Skill::Stun => Item::Stun,
Skill::TestBlock => Item::TestBlock, Skill::Block => Item::Block,
Skill::TestParry => Item::TestParry, Skill::ParryI => Item::ParryI,
Skill::TestSiphon => Item::TestSiphon, Skill::SiphonI => Item::SiphonI,
_ => panic!("{:?} not implemented with item conversion", skill), _ => panic!("{:?} not implemented with item conversion", skill),
} }
} }
@ -1147,7 +1140,6 @@ mod tests {
#[test] #[test]
fn item_info_test() { fn item_info_test() {
let info = item_info(); item_info();
println!("{:#?}", info);
} }
} }

View File

@ -276,16 +276,6 @@ pub fn resolve(skill: Skill, source: &mut Construct, target: &mut Construct, mut
// Not used // Not used
Skill::Injure => injure(source, target, resolutions, skill), Skill::Injure => injure(source, target, resolutions, skill),
// -----------------
// Test
// -----------------
Skill::TestAttack => attack(source, target, resolutions, skill),
Skill::TestHeal => heal(source, target, resolutions, skill),
Skill::TestTouch => touch(source, target, resolutions, skill),
Skill::TestStun => stun(source, target, resolutions, Skill::Stun),
Skill::TestBlock => block(source, target, resolutions, Skill::Block),
Skill::TestParry => parry(source, target, resolutions, Skill::ParryI),
Skill::TestSiphon => siphon(source, target, resolutions, Skill::SiphonI),
}; };
return resolutions; return resolutions;
@ -845,15 +835,6 @@ pub enum Skill {
TriageTickI, TriageTickI,
TriageTickII, TriageTickII,
TriageTickIII, TriageTickIII,
// used by tests, no cd, 100% multiplier
TestAttack,
TestHeal,
TestTouch, // No damage
TestStun,
TestBlock,
TestParry,
TestSiphon,
} }
impl Skill { impl Skill {
@ -1265,17 +1246,6 @@ impl Skill {
Skill::TriageTickI | Skill::TriageTickI |
Skill::TriageTickII | Skill::TriageTickII |
Skill::TriageTickIII => None, Skill::TriageTickIII => None,
// Triggers
// -----------------
// Test
// -----------------
Skill::TestAttack => None,
Skill::TestHeal => None,
Skill::TestTouch => None,
Skill::TestStun => None,
Skill::TestBlock => None,
Skill::TestSiphon => None,
Skill::TestParry => None,
} }
} }
@ -1323,15 +1293,6 @@ impl Skill {
pub fn speed(&self) -> u8 { pub fn speed(&self) -> u8 {
match self { match self {
// -----------------
// Test
// -----------------
Skill::TestTouch => 10,
Skill::TestStun => 5,
Skill::TestBlock => 10,
Skill::TestParry => 10,
Skill::TestSiphon => 10,
Skill::StrikeI => u8::max_value(), Skill::StrikeI => u8::max_value(),
Skill::StrikeII => Skill::StrikeI.speed(), Skill::StrikeII => Skill::StrikeI.speed(),
Skill::StrikeIII => Skill::StrikeI.speed(), Skill::StrikeIII => Skill::StrikeI.speed(),
@ -1379,8 +1340,8 @@ impl Skill {
Skill::ParryI | Skill::ParryI |
Skill::ParryII | Skill::ParryII |
Skill::ParryIII | Skill::ParryIII |
Skill::TestBlock | Skill::Block |
Skill::TestParry => true, Skill::ParryI => true,
_ => false, _ => false,
} }
@ -2003,11 +1964,12 @@ mod tests {
block(&mut y.clone(), &mut y, vec![], Skill::Block); block(&mut y.clone(), &mut y, vec![], Skill::Block);
assert!(y.effects.iter().any(|e| e.effect == Effect::Block)); assert!(y.effects.iter().any(|e| e.effect == Effect::Block));
let mut results = attack(&mut x, &mut y, vec![], Skill::TestAttack); let mut results = attack(&mut x, &mut y, vec![], Skill::Attack);
let Resolution { source: _, target: _, event } = results.remove(0); let Resolution { source: _, target: _, event } = results.remove(0);
match event { match event {
Event::Damage { amount, mitigation: _, colour: _, skill: _ } => assert_eq!(amount, 50), Event::Damage { amount, mitigation: _, colour: _, skill: _ } =>
assert!(amount < x.red_power().pct(Skill::Attack.multiplier())),
_ => panic!("not damage"), _ => panic!("not damage"),
}; };
} }
@ -2066,30 +2028,29 @@ mod tests {
// give red shield but reduce to 0 // give red shield but reduce to 0
y.red_life.force(64); y.red_life.force(64);
y.red_life.reduce(64); y.red_life.reduce(64);
x.red_power.force(256 + 64); x.red_power.force(512);
invert(&mut y.clone(), &mut y, vec![], Skill::InvertI); invert(&mut y.clone(), &mut y, vec![], Skill::InvertI);
assert!(y.affected(Effect::Invert)); assert!(y.affected(Effect::Invert));
// heal should deal green damage // heal should deal green damage
heal(&mut x, &mut y, vec![], Skill::TestHeal); heal(&mut x, &mut y, vec![], Skill::HealI);
assert!(y.green_life() == 768); assert!(y.green_life() < 1024);
// attack should heal and recharge red shield // attack should heal and recharge red shield
let mut results = attack(&mut x, &mut y, vec![], Skill::TestAttack); let mut results = attack(&mut x, &mut y, vec![], Skill::Attack);
assert!(y.green_life() == 1024);
match results.remove(0).event { match results.remove(0).event {
Event::Inversion { skill } => assert_eq!(skill, Skill::TestAttack), Event::Inversion { skill } => assert_eq!(skill, Skill::Attack),
_ => panic!("not inversion"), _ => panic!("not inversion"),
}; };
match results.remove(0).event { match results.remove(0).event {
Event::Healing { skill: _, overhealing: _, amount } => assert_eq!(amount, 256), Event::Healing { skill: _, overhealing: _, amount } => assert!(amount > 0),
_ => panic!("not healing from inversion"), _ => panic!("not healing from inversion"),
}; };
match results.remove(0).event { match results.remove(0).event {
Event::Recharge { skill: _, red, blue: _ } => assert_eq!(red, 64), Event::Recharge { skill: _, red, blue: _ } => assert!(red > 0),
_ => panic!("not recharge from inversion"), _ => panic!("not recharge from inversion"),
}; };
} }
@ -2106,19 +2067,19 @@ mod tests {
assert!(y.affected(Effect::Reflect)); assert!(y.affected(Effect::Reflect));
let mut results = vec![]; let mut results = vec![];
results = resolve(Skill::TestAttack, &mut x, &mut y, results); results = resolve(Skill::Attack, &mut x, &mut y, results);
assert!(x.green_life() == 768); assert!(x.green_life() < 1024);
let Resolution { source: _, target: _, event } = results.remove(0); let Resolution { source: _, target: _, event } = results.remove(0);
match event { match event {
Event::Reflection { skill } => assert_eq!(skill, Skill::TestAttack), Event::Reflection { skill } => assert_eq!(skill, Skill::Attack),
_ => panic!("not reflection"), _ => panic!("not reflection"),
}; };
let Resolution { source: _, target: _, event } = results.remove(0); let Resolution { source: _, target: _, event } = results.remove(0);
match event { match event {
Event::Damage { amount, mitigation: _, colour: _, skill: _ } => assert_eq!(amount, 256), Event::Damage { amount, mitigation: _, colour: _, skill: _ } => assert!(amount > 0),
_ => panic!("not damage"), _ => panic!("not damage"),
}; };
} }