79 lines
2.3 KiB
Rust
79 lines
2.3 KiB
Rust
|
|
use core::num::NonZeroU8;
|
||
|
|
#[allow(unused)]
|
||
|
|
use pretty_assertions::{assert_eq, assert_ne, assert_str_eq};
|
||
|
|
|
||
|
|
use crate::{
|
||
|
|
diedto::DiedTo,
|
||
|
|
game::{Game, GameSettings, OrRandom, SetupRole},
|
||
|
|
game_test::{
|
||
|
|
ActionPromptTitleExt, ActionResultExt, AlignmentExt, GameExt, ServerToHostMessageExt,
|
||
|
|
SettingsExt, gen_players,
|
||
|
|
},
|
||
|
|
message::{
|
||
|
|
host::{HostDayMessage, HostGameMessage},
|
||
|
|
night::{ActionPrompt, ActionPromptTitle, ActionResult},
|
||
|
|
},
|
||
|
|
role::Role,
|
||
|
|
};
|
||
|
|
|
||
|
|
#[test]
|
||
|
|
fn wolf_kill_prevented() {
|
||
|
|
let players = gen_players(1..10);
|
||
|
|
let diseased_player_id = players[0].player_id;
|
||
|
|
let wolf_player_id = players[1].player_id;
|
||
|
|
|
||
|
|
let mut settings = GameSettings::empty();
|
||
|
|
settings.add_and_assign(SetupRole::Diseased, diseased_player_id);
|
||
|
|
settings.add_and_assign(SetupRole::Werewolf, wolf_player_id);
|
||
|
|
|
||
|
|
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();
|
||
|
|
game.execute().title().wolf_pack_kill();
|
||
|
|
game.mark(
|
||
|
|
game.character_by_player_id(diseased_player_id)
|
||
|
|
.character_id(),
|
||
|
|
);
|
||
|
|
game.r#continue().sleep();
|
||
|
|
|
||
|
|
game.next_expect_day();
|
||
|
|
|
||
|
|
assert_eq!(
|
||
|
|
game.character_by_player_id(diseased_player_id)
|
||
|
|
.died_to()
|
||
|
|
.cloned(),
|
||
|
|
Some(DiedTo::Wolfpack {
|
||
|
|
killing_wolf: game.character_by_player_id(wolf_player_id).character_id(),
|
||
|
|
night: NonZeroU8::new(1).unwrap()
|
||
|
|
})
|
||
|
|
);
|
||
|
|
|
||
|
|
assert_eq!(
|
||
|
|
game.process(HostGameMessage::Day(HostDayMessage::Execute))
|
||
|
|
.unwrap()
|
||
|
|
.prompt(),
|
||
|
|
ActionPrompt::CoverOfDarkness
|
||
|
|
);
|
||
|
|
game.r#continue().r#continue();
|
||
|
|
game.next_expect_day();
|
||
|
|
game.execute().title().wolf_pack_kill();
|
||
|
|
let target = game.living_villager_excl(wolf_player_id);
|
||
|
|
game.mark(target.character_id());
|
||
|
|
game.r#continue().sleep();
|
||
|
|
|
||
|
|
game.next_expect_day();
|
||
|
|
assert_eq!(
|
||
|
|
game.character_by_player_id(target.player_id())
|
||
|
|
.died_to()
|
||
|
|
.cloned(),
|
||
|
|
Some(DiedTo::Wolfpack {
|
||
|
|
killing_wolf: game.character_by_player_id(wolf_player_id).character_id(),
|
||
|
|
night: NonZeroU8::new(3).unwrap()
|
||
|
|
})
|
||
|
|
);
|
||
|
|
}
|