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> {
|
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 {
|
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
|
// 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"));
|
return Err(err_msg("cryp cannot cast that skill"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -927,160 +927,190 @@ mod tests {
|
|||||||
return game;
|
return game;
|
||||||
}
|
}
|
||||||
|
|
||||||
// #[test]
|
#[test]
|
||||||
// fn phase_test() {
|
fn phase_test() {
|
||||||
// let mut game = create_test_game();
|
let mut game = create_test_game();
|
||||||
|
|
||||||
// let x_team = game.teams[0].clone();
|
let x_team = game.teams[0].clone();
|
||||||
// let y_team = game.teams[1].clone();
|
let y_team = game.teams[1].clone();
|
||||||
|
|
||||||
// let x_cryp = x_team.cryps[0].clone();
|
let x_cryp = x_team.cryps[0].clone();
|
||||||
// let y_cryp = y_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 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 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(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(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]
|
#[test]
|
||||||
// fn stun_test() {
|
fn stun_test() {
|
||||||
// let mut game = create_test_game();
|
let mut game = create_test_game();
|
||||||
|
|
||||||
// let x_team = game.teams[0].clone();
|
let x_team = game.teams[0].clone();
|
||||||
// let y_team = game.teams[1].clone();
|
let y_team = game.teams[1].clone();
|
||||||
|
|
||||||
// let x_cryp = x_team.cryps[0].clone();
|
let x_cryp = x_team.cryps[0].clone();
|
||||||
// let y_cryp = y_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 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 y_attack_id = game.add_skill(y_team.id, y_cryp.id, Some(x_team.id), Skill::TestTouch).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(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(y_team.id, y_cryp.id, x_stun_id).unwrap();
|
||||||
|
|
||||||
// assert!(game.target_phase_finished());
|
assert!(game.target_phase_finished());
|
||||||
// game.resolve_phase_start();
|
game.resolve_phase_start();
|
||||||
|
|
||||||
// // should auto progress back to skill phase
|
// should auto progress back to skill phase
|
||||||
// assert!(game.phase == Phase::Skill);
|
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).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);
|
||||||
// }
|
}
|
||||||
|
|
||||||
// #[test]
|
#[test]
|
||||||
// fn cooldown_test() {
|
fn ko_resolution_test() {
|
||||||
// let mut game = create_test_game();
|
let mut game = create_test_game();
|
||||||
|
|
||||||
// let x_team = game.teams[0].clone();
|
let x_team = game.teams[0].clone();
|
||||||
// let y_team = game.teams[1].clone();
|
let y_team = game.teams[1].clone();
|
||||||
|
|
||||||
// let x_cryp = x_team.cryps[0].clone();
|
let x_cryp = x_team.cryps[0].clone();
|
||||||
// let y_cryp = y_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();
|
game.team_by_id(y_team.id).cryp_by_id(y_cryp.id).unwrap().phys_dmg.set(u64::max_value());
|
||||||
// let y_attack_id = game.add_skill(y_team.id, y_cryp.id, Some(x_team.id), Skill::TestTouch).unwrap();
|
|
||||||
|
|
||||||
// game.target_phase_start();
|
let x_stun_id = game.add_skill(x_team.id, x_cryp.id, Some(y_team.id), Skill::TestStun).unwrap();
|
||||||
// game.add_target(x_team.id, x_cryp.id, y_attack_id).unwrap();
|
let y_attack_id = game.add_skill(y_team.id, y_cryp.id, Some(x_team.id), Skill::Attack).unwrap();
|
||||||
// game.add_target(y_team.id, y_cryp.id, x_stun_id).unwrap();
|
|
||||||
|
|
||||||
// game.resolve_phase_start();
|
assert!(game.skill_phase_finished());
|
||||||
|
game.target_phase_start();
|
||||||
|
|
||||||
// // should auto progress back to skill phase
|
game.add_target(x_team.id, x_cryp.id, y_attack_id).unwrap();
|
||||||
// assert!(game.phase == Phase::Skill);
|
game.add_target(y_team.id, y_cryp.id, x_stun_id).unwrap();
|
||||||
|
|
||||||
// // after 1 turn block should be off cooldown
|
assert!(game.target_phase_finished());
|
||||||
// assert!(game.team_by_id(y_team.id).cryps[0].skill_on_cd(Skill::Block).is_none());
|
game.resolve_phase_start();
|
||||||
// assert!(game.team_by_id(x_team.id).cryps[0].skill_on_cd(Skill::Block).is_none());
|
|
||||||
|
|
||||||
// // second round
|
// resolution should have been prevented by KO
|
||||||
// // now we block and it should go back on cd
|
assert!(!game.team_by_id(y_team.id).cryps[0].is_stunned());
|
||||||
// let _x_block_id = game.add_skill(x_team.id, x_cryp.id, None, Skill::Block).unwrap();
|
assert!(game.phase == Phase::Finish);
|
||||||
// let _y_block_id = game.add_skill(y_team.id, y_cryp.id, None, Skill::Block).unwrap();
|
}
|
||||||
|
|
||||||
// game.target_phase_start();
|
|
||||||
|
|
||||||
// assert!(game.team_by_id(y_team.id).cryps[0].skill_on_cd(Skill::Block).is_some());
|
#[test]
|
||||||
// assert!(game.team_by_id(x_team.id).cryps[0].skill_on_cd(Skill::Block).is_some());
|
fn cooldown_test() {
|
||||||
// }
|
let mut game = create_test_game();
|
||||||
|
|
||||||
// #[test]
|
let x_team = game.teams[0].clone();
|
||||||
// fn block_test() {
|
let y_team = game.teams[1].clone();
|
||||||
// let mut game = create_test_game();
|
|
||||||
|
|
||||||
// let x_team = game.teams[0].clone();
|
let x_cryp = x_team.cryps[0].clone();
|
||||||
// let y_team = game.teams[1].clone();
|
let y_cryp = y_team.cryps[0].clone();
|
||||||
|
|
||||||
// let x_cryp = x_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_cryp = y_team.cryps[0].clone();
|
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
|
game.target_phase_start();
|
||||||
// assert!(game.add_skill(x_team.id, x_cryp.id, Some(y_cryp.id), Skill::TestBlock).is_err());
|
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();
|
game.resolve_phase_start();
|
||||||
// let y_attack_id = game.add_skill(y_team.id, y_cryp.id, Some(x_team.id), Skill::TestStun).unwrap();
|
|
||||||
|
|
||||||
// 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
|
// after 1 turn block should be off cooldown
|
||||||
// assert!(game.add_target(y_team.id, y_cryp.id, x_block_id).is_err());
|
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
|
// second round
|
||||||
// assert!(game.add_target(x_team.id, y_cryp.id, y_attack_id).is_err());
|
// 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
|
#[test]
|
||||||
// assert!(game.team_by_id(x_team.id).cryps[0].is_stunned() == false);
|
fn block_test() {
|
||||||
// }
|
let mut game = create_test_game();
|
||||||
|
|
||||||
// #[test]
|
let x_team = game.teams[0].clone();
|
||||||
// fn drain_test() {
|
let y_team = game.teams[1].clone();
|
||||||
// let mut game = create_test_game();
|
|
||||||
|
|
||||||
// let x_team = game.teams[0].clone();
|
let x_cryp = x_team.cryps[0].clone();
|
||||||
// let y_team = game.teams[1].clone();
|
let y_cryp = y_team.cryps[0].clone();
|
||||||
|
|
||||||
// let x_cryp = x_team.cryps[0].clone();
|
// ensure that you can't pass a target for a block
|
||||||
// let y_cryp = y_team.cryps[0].clone();
|
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 x_block_id = game.add_skill(x_team.id, x_cryp.id, None, Skill::TestBlock).unwrap();
|
||||||
// let y_touch_id = game.add_skill(y_team.id, y_cryp.id, Some(x_team.id), Skill::TestTouch).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();
|
// ensure you can't target a self targeting skill
|
||||||
// game.add_target(y_team.id, y_cryp.id, x_drain_id).unwrap();
|
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_target(x_team.id, x_cryp.id, y_attack_id).unwrap();
|
||||||
// game.add_skill(y_team.id, y_cryp.id, None, Skill::TestBlock).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]
|
#[test]
|
||||||
fn ko_pve_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 {
|
match self {
|
||||||
Effect::Stun => true,
|
Effect::Stun => true,
|
||||||
Effect::Silence => match skill.category() {
|
Effect::Silence => match skill.category() {
|
||||||
@ -684,8 +684,8 @@ impl Skill {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn castable(&self, cryp: &Cryp) -> bool {
|
pub fn disabled(&self, cryp: &Cryp) -> bool {
|
||||||
!cryp.effects.iter().any(|e| e.effect.prevents_casting(*self))
|
cryp.effects.iter().any(|e| e.effect.disables_skill(*self))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1241,7 +1241,7 @@ mod tests {
|
|||||||
|
|
||||||
silence(&mut x.clone(), &mut x);
|
silence(&mut x.clone(), &mut x);
|
||||||
assert!(x.effects.iter().any(|e| e.effect == Effect::Silence));
|
assert!(x.effects.iter().any(|e| e.effect == Effect::Silence));
|
||||||
assert!(!Skill::Decay.castable(&x));
|
assert!(Skill::Decay.disabled(&x));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user