werewolves/werewolves-proto/src/game_test/role/hunter.rs

78 lines
2.3 KiB
Rust
Raw Normal View History

use core::num::NonZeroU8;
use crate::{
diedto::DiedTo,
error::GameError,
game::{Game, GameSettings, SetupRole},
game_test::{
ActionPromptTitleExt, ActionResultExt, GameExt, SettingsExt, gen_players, init_log,
},
message::{
host::{HostGameMessage, HostNightMessage},
night::{ActionPromptTitle, ActionResponse},
},
role::{PreviousGuardianAction, Role},
};
#[test]
fn can_change_targets() {
init_log();
let players = gen_players(1..10);
let hunter = players[0].player_id;
let wolf = players[1].player_id;
let mut settings = GameSettings::empty();
settings.add_and_assign(SetupRole::Werewolf, wolf);
settings.add_and_assign(SetupRole::Hunter, hunter);
settings.fill_remaining_slots_with_villagers(9);
let mut game = Game::new(&players, settings).unwrap();
game.r#continue().r#continue();
assert_eq!(game.next().title(), ActionPromptTitle::WolvesIntro);
game.r#continue().sleep();
game.next_expect_day();
let hunt_target = game.living_villager();
game.execute().title().wolf_pack_kill();
game.mark(
game.living_villager_excl(hunt_target.player_id())
.character_id(),
);
game.r#continue().sleep();
game.next().title().hunter();
game.mark(hunt_target.character_id());
game.r#continue().sleep();
game.next_expect_day();
match game.character_by_player_id(hunter).role() {
Role::Hunter {
target: Some(target),
} => assert_eq!(*target, hunt_target.character_id()),
Role::Hunter { target: None } => panic!("did not record target"),
_ => panic!("not a guardian?"),
}
let hunt_target = game.living_villager_excl(hunt_target.player_id());
game.execute().title().wolf_pack_kill();
game.mark(
game.living_villager_excl(hunt_target.player_id())
.character_id(),
);
game.r#continue().sleep();
game.next().title().hunter();
game.mark(hunt_target.character_id());
game.r#continue().sleep();
game.next_expect_day();
match game.character_by_player_id(hunter).role() {
Role::Hunter {
target: Some(target),
} => assert_eq!(*target, hunt_target.character_id()),
Role::Hunter { target: None } => panic!("did not record target"),
_ => panic!("not a guardian?"),
}
}