rename prevents to disabled
This commit is contained in:
parent
ad381d58f6
commit
aa2ecc4ce6
@ -201,7 +201,7 @@ impl Cryp {
|
||||
}
|
||||
|
||||
pub fn available_skills(&self) -> Vec<&CrypSkill> {
|
||||
self.skills.iter().filter(|s| s.skill.castable(self)).collect()
|
||||
self.skills.iter().filter(|s| !s.skill.disabled(self)).collect()
|
||||
}
|
||||
|
||||
pub fn knows(&self, skill: Skill) -> bool {
|
||||
|
||||
@ -244,7 +244,7 @@ impl Game {
|
||||
}
|
||||
|
||||
// check here as well so uncastable spells don't go on the stack
|
||||
if !skill.castable(&cryp) {
|
||||
if skill.disabled(&cryp) {
|
||||
return Err(err_msg("cryp cannot cast that skill"));
|
||||
}
|
||||
}
|
||||
@ -927,160 +927,190 @@ mod tests {
|
||||
return game;
|
||||
}
|
||||
|
||||
// #[test]
|
||||
// fn phase_test() {
|
||||
// let mut game = create_test_game();
|
||||
#[test]
|
||||
fn phase_test() {
|
||||
let mut game = create_test_game();
|
||||
|
||||
// let x_team = game.teams[0].clone();
|
||||
// let y_team = game.teams[1].clone();
|
||||
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_cryp = x_team.cryps[0].clone();
|
||||
let y_cryp = y_team.cryps[0].clone();
|
||||
|
||||
// let x_attack_id = game.add_skill(x_team.id, x_cryp.id, Some(y_team.id), Skill::Attack).unwrap();
|
||||
// let y_attack_id = game.add_skill(y_team.id, y_cryp.id, Some(x_team.id), Skill::Attack).unwrap();
|
||||
let x_attack_id = game.add_skill(x_team.id, x_cryp.id, Some(y_team.id), Skill::Attack).unwrap();
|
||||
let y_attack_id = game.add_skill(y_team.id, y_cryp.id, Some(x_team.id), Skill::Attack).unwrap();
|
||||
|
||||
// assert!(game.skill_phase_finished());
|
||||
assert!(game.skill_phase_finished());
|
||||
|
||||
// game.target_phase_start();
|
||||
game.target_phase_start();
|
||||
|
||||
// game.add_target(x_team.id, x_cryp.id, y_attack_id).unwrap();
|
||||
// game.add_target(y_team.id, y_cryp.id, x_attack_id).unwrap();
|
||||
game.add_target(x_team.id, x_cryp.id, y_attack_id).unwrap();
|
||||
game.add_target(y_team.id, y_cryp.id, x_attack_id).unwrap();
|
||||
|
||||
// assert!(game.target_phase_finished());
|
||||
assert!(game.target_phase_finished());
|
||||
|
||||
// game.resolve_phase_start();
|
||||
game.resolve_phase_start();
|
||||
|
||||
// assert!([Phase::Skill, Phase::Finish].contains(&game.phase));
|
||||
assert!([Phase::Skill, Phase::Finish].contains(&game.phase));
|
||||
|
||||
// return;
|
||||
// }
|
||||
return;
|
||||
}
|
||||
|
||||
// #[test]
|
||||
// fn stun_test() {
|
||||
// let mut game = create_test_game();
|
||||
#[test]
|
||||
fn stun_test() {
|
||||
let mut game = create_test_game();
|
||||
|
||||
// let x_team = game.teams[0].clone();
|
||||
// let y_team = game.teams[1].clone();
|
||||
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_cryp = x_team.cryps[0].clone();
|
||||
let y_cryp = y_team.cryps[0].clone();
|
||||
|
||||
// let x_stun_id = game.add_skill(x_team.id, x_cryp.id, Some(y_team.id), Skill::TestStun).unwrap();
|
||||
// let y_attack_id = game.add_skill(y_team.id, y_cryp.id, Some(x_team.id), Skill::TestTouch).unwrap();
|
||||
let x_stun_id = game.add_skill(x_team.id, x_cryp.id, Some(y_team.id), Skill::TestStun).unwrap();
|
||||
let y_attack_id = game.add_skill(y_team.id, y_cryp.id, Some(x_team.id), Skill::TestTouch).unwrap();
|
||||
|
||||
// assert!(game.skill_phase_finished());
|
||||
// game.target_phase_start();
|
||||
assert!(game.skill_phase_finished());
|
||||
game.target_phase_start();
|
||||
|
||||
// game.add_target(x_team.id, x_cryp.id, y_attack_id).unwrap();
|
||||
// game.add_target(y_team.id, y_cryp.id, x_stun_id).unwrap();
|
||||
game.add_target(x_team.id, x_cryp.id, y_attack_id).unwrap();
|
||||
game.add_target(y_team.id, y_cryp.id, x_stun_id).unwrap();
|
||||
|
||||
// assert!(game.target_phase_finished());
|
||||
// game.resolve_phase_start();
|
||||
assert!(game.target_phase_finished());
|
||||
game.resolve_phase_start();
|
||||
|
||||
// // should auto progress back to skill phase
|
||||
// assert!(game.phase == Phase::Skill);
|
||||
// should auto progress back to skill phase
|
||||
assert!(game.phase == Phase::Skill);
|
||||
|
||||
// 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).cryps[0].is_stunned());
|
||||
assert!(game.team_by_id(y_team.id).skills_required() == 0);
|
||||
}
|
||||
|
||||
// #[test]
|
||||
// fn cooldown_test() {
|
||||
// let mut game = create_test_game();
|
||||
#[test]
|
||||
fn ko_resolution_test() {
|
||||
let mut game = create_test_game();
|
||||
|
||||
// let x_team = game.teams[0].clone();
|
||||
// let y_team = game.teams[1].clone();
|
||||
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_cryp = x_team.cryps[0].clone();
|
||||
let y_cryp = y_team.cryps[0].clone();
|
||||
|
||||
// let x_stun_id = game.add_skill(x_team.id, x_cryp.id, Some(y_team.id), Skill::TestTouch).unwrap();
|
||||
// let y_attack_id = game.add_skill(y_team.id, y_cryp.id, Some(x_team.id), Skill::TestTouch).unwrap();
|
||||
game.team_by_id(y_team.id).cryp_by_id(y_cryp.id).unwrap().phys_dmg.set(u64::max_value());
|
||||
|
||||
// game.target_phase_start();
|
||||
// game.add_target(x_team.id, x_cryp.id, y_attack_id).unwrap();
|
||||
// game.add_target(y_team.id, y_cryp.id, x_stun_id).unwrap();
|
||||
let x_stun_id = game.add_skill(x_team.id, x_cryp.id, Some(y_team.id), Skill::TestStun).unwrap();
|
||||
let y_attack_id = game.add_skill(y_team.id, y_cryp.id, Some(x_team.id), Skill::Attack).unwrap();
|
||||
|
||||
// game.resolve_phase_start();
|
||||
assert!(game.skill_phase_finished());
|
||||
game.target_phase_start();
|
||||
|
||||
// // should auto progress back to skill phase
|
||||
// assert!(game.phase == Phase::Skill);
|
||||
game.add_target(x_team.id, x_cryp.id, y_attack_id).unwrap();
|
||||
game.add_target(y_team.id, y_cryp.id, x_stun_id).unwrap();
|
||||
|
||||
// // 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(x_team.id).cryps[0].skill_on_cd(Skill::Block).is_none());
|
||||
assert!(game.target_phase_finished());
|
||||
game.resolve_phase_start();
|
||||
|
||||
// // 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();
|
||||
// resolution should have been prevented by KO
|
||||
assert!(!game.team_by_id(y_team.id).cryps[0].is_stunned());
|
||||
assert!(game.phase == Phase::Finish);
|
||||
}
|
||||
|
||||
// game.target_phase_start();
|
||||
|
||||
// assert!(game.team_by_id(y_team.id).cryps[0].skill_on_cd(Skill::Block).is_some());
|
||||
// assert!(game.team_by_id(x_team.id).cryps[0].skill_on_cd(Skill::Block).is_some());
|
||||
// }
|
||||
#[test]
|
||||
fn cooldown_test() {
|
||||
let mut game = create_test_game();
|
||||
|
||||
// #[test]
|
||||
// fn block_test() {
|
||||
// let mut game = create_test_game();
|
||||
let x_team = game.teams[0].clone();
|
||||
let y_team = game.teams[1].clone();
|
||||
|
||||
// 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_cryp = x_team.cryps[0].clone();
|
||||
// let y_cryp = y_team.cryps[0].clone();
|
||||
let x_stun_id = game.add_skill(x_team.id, x_cryp.id, Some(y_team.id), Skill::TestTouch).unwrap();
|
||||
let y_attack_id = game.add_skill(y_team.id, y_cryp.id, Some(x_team.id), Skill::TestTouch).unwrap();
|
||||
|
||||
// // ensure that you can't pass a target for a block
|
||||
// assert!(game.add_skill(x_team.id, x_cryp.id, Some(y_cryp.id), Skill::TestBlock).is_err());
|
||||
game.target_phase_start();
|
||||
game.add_target(x_team.id, x_cryp.id, y_attack_id).unwrap();
|
||||
game.add_target(y_team.id, y_cryp.id, x_stun_id).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.resolve_phase_start();
|
||||
|
||||
// game.target_phase_start();
|
||||
// should auto progress back to skill phase
|
||||
assert!(game.phase == Phase::Skill);
|
||||
|
||||
// // ensure you can't target a self targeting skill
|
||||
// assert!(game.add_target(y_team.id, y_cryp.id, x_block_id).is_err());
|
||||
// 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(x_team.id).cryps[0].skill_on_cd(Skill::Block).is_none());
|
||||
|
||||
// // ensure you can't target another team's skills
|
||||
// assert!(game.add_target(x_team.id, y_cryp.id, y_attack_id).is_err());
|
||||
// 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();
|
||||
|
||||
// game.add_target(x_team.id, x_cryp.id, y_attack_id).unwrap();
|
||||
game.target_phase_start();
|
||||
|
||||
// game.resolve_phase_start();
|
||||
assert!(game.team_by_id(y_team.id).cryps[0].skill_on_cd(Skill::Block).is_some());
|
||||
assert!(game.team_by_id(x_team.id).cryps[0].skill_on_cd(Skill::Block).is_some());
|
||||
}
|
||||
|
||||
// // should not be stunned because of block
|
||||
// assert!(game.team_by_id(x_team.id).cryps[0].is_stunned() == false);
|
||||
// }
|
||||
#[test]
|
||||
fn block_test() {
|
||||
let mut game = create_test_game();
|
||||
|
||||
// #[test]
|
||||
// fn drain_test() {
|
||||
// let mut game = create_test_game();
|
||||
let x_team = game.teams[0].clone();
|
||||
let y_team = game.teams[1].clone();
|
||||
|
||||
// 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_cryp = x_team.cryps[0].clone();
|
||||
// let y_cryp = y_team.cryps[0].clone();
|
||||
// ensure that you can't pass a target for a block
|
||||
assert!(game.add_skill(x_team.id, x_cryp.id, Some(y_cryp.id), Skill::TestBlock).is_err());
|
||||
|
||||
// let x_drain_id = game.add_skill(x_team.id, x_cryp.id, Some(y_team.id), Skill::TestDrain).unwrap();
|
||||
// let y_touch_id = game.add_skill(y_team.id, y_cryp.id, Some(x_team.id), Skill::TestTouch).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();
|
||||
game.target_phase_start();
|
||||
|
||||
// game.add_target(x_team.id, x_cryp.id, y_touch_id).unwrap();
|
||||
// game.add_target(y_team.id, y_cryp.id, x_drain_id).unwrap();
|
||||
// ensure you can't target a self targeting skill
|
||||
assert!(game.add_target(y_team.id, y_cryp.id, x_block_id).is_err());
|
||||
|
||||
// game.resolve_phase_start();
|
||||
// ensure you can't target another team's skills
|
||||
assert!(game.add_target(x_team.id, y_cryp.id, y_attack_id).is_err());
|
||||
|
||||
// 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.add_target(x_team.id, x_cryp.id, y_attack_id).unwrap();
|
||||
|
||||
// game.target_phase_start();
|
||||
game.resolve_phase_start();
|
||||
|
||||
// assert!(game.resolved.iter().any(|r| r.skill == Skill::DrainTick));
|
||||
// }
|
||||
// should not be stunned because of block
|
||||
assert!(game.team_by_id(x_team.id).cryps[0].is_stunned() == false);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn drain_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_drain_id = game.add_skill(x_team.id, x_cryp.id, Some(y_team.id), Skill::TestDrain).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();
|
||||
|
||||
game.add_target(x_team.id, x_cryp.id, y_touch_id).unwrap();
|
||||
game.add_target(y_team.id, y_cryp.id, x_drain_id).unwrap();
|
||||
|
||||
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.target_phase_start();
|
||||
|
||||
assert!(game.resolved.iter().any(|r| r.skill == Skill::DrainTick));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ko_pve_test() {
|
||||
|
||||
@ -140,7 +140,7 @@ impl Effect {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn prevents_casting(&self, skill: Skill) -> bool {
|
||||
pub fn disables_skill(&self, skill: Skill) -> bool {
|
||||
match self {
|
||||
Effect::Stun => true,
|
||||
Effect::Silence => match skill.category() {
|
||||
@ -684,8 +684,8 @@ impl Skill {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn castable(&self, cryp: &Cryp) -> bool {
|
||||
!cryp.effects.iter().any(|e| e.effect.prevents_casting(*self))
|
||||
pub fn disabled(&self, cryp: &Cryp) -> bool {
|
||||
cryp.effects.iter().any(|e| e.effect.disables_skill(*self))
|
||||
}
|
||||
}
|
||||
|
||||
@ -1241,7 +1241,7 @@ mod tests {
|
||||
|
||||
silence(&mut x.clone(), &mut x);
|
||||
assert!(x.effects.iter().any(|e| e.effect == Effect::Silence));
|
||||
assert!(!Skill::Decay.castable(&x));
|
||||
assert!(Skill::Decay.disabled(&x));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user