217 lines
7.9 KiB
Rust
217 lines
7.9 KiB
Rust
// Copyright (C) 2025 Emilis Bliūdžius
|
|
//
|
|
// This program is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU Affero General Public License as
|
|
// published by the Free Software Foundation, either version 3 of the
|
|
// License, or (at your option) any later version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU Affero General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
#[allow(unused)]
|
|
use pretty_assertions::{assert_eq, assert_ne, assert_str_eq};
|
|
|
|
use crate::{
|
|
game::{Game, GameSettings, SetupRole},
|
|
game_test::{ActionPromptTitleExt, ActionResultExt, GameExt, SettingsExt, gen_players},
|
|
message::night::{ActionPromptTitle, Visits},
|
|
role::{AlignmentEq, Role, RoleTitle},
|
|
};
|
|
|
|
#[test]
|
|
fn is_told_theyre_villager() {
|
|
assert_eq!(Role::Insomniac.initial_shown_role(), RoleTitle::Villager);
|
|
}
|
|
|
|
#[test]
|
|
fn sees_visits() {
|
|
let players = gen_players(1..21);
|
|
let insomniac_player_id = players[0].player_id;
|
|
let wolf_player_id = players[1].player_id;
|
|
let seer_player_id = players[2].player_id;
|
|
let arcanist_player_id = players[3].player_id;
|
|
let mut settings = GameSettings::empty();
|
|
settings.add_and_assign(SetupRole::Insomniac, insomniac_player_id);
|
|
settings.add_and_assign(SetupRole::Werewolf, wolf_player_id);
|
|
settings.add_and_assign(SetupRole::Seer, seer_player_id);
|
|
settings.add_and_assign(SetupRole::Arcanist, arcanist_player_id);
|
|
settings.fill_remaining_slots_with_villagers(20);
|
|
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().title().seer();
|
|
game.mark(game.living_villager().character_id());
|
|
game.r#continue().seer().village();
|
|
game.r#continue().sleep();
|
|
|
|
game.next().title().arcanist();
|
|
let mut villagers = game.villager_character_ids().into_iter();
|
|
game.mark(villagers.next().unwrap());
|
|
game.mark(villagers.next().unwrap());
|
|
assert_eq!(game.r#continue().arcanist(), AlignmentEq::Same);
|
|
game.r#continue().sleep();
|
|
|
|
game.next_expect_day();
|
|
|
|
game.execute().title().wolf_pack_kill();
|
|
game.mark(game.living_villager().character_id());
|
|
game.r#continue().sleep();
|
|
|
|
game.next().title().seer();
|
|
game.mark(
|
|
game.character_by_player_id(insomniac_player_id)
|
|
.character_id(),
|
|
);
|
|
game.r#continue().seer().village();
|
|
game.r#continue().sleep();
|
|
|
|
game.next().title().arcanist();
|
|
game.mark(game.character_by_player_id(seer_player_id).character_id());
|
|
game.mark(
|
|
game.character_by_player_id(insomniac_player_id)
|
|
.character_id(),
|
|
);
|
|
assert_eq!(game.r#continue().arcanist(), AlignmentEq::Same);
|
|
game.r#continue().sleep();
|
|
|
|
game.next().title().insomniac();
|
|
assert_eq!(
|
|
game.r#continue().insomniac(),
|
|
Visits::new(Box::new([
|
|
game.character_by_player_id(seer_player_id).identity(),
|
|
game.character_by_player_id(arcanist_player_id).identity()
|
|
]))
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn direwolf_block_prevents_visits_so_they_are_not_seen() {
|
|
let players = gen_players(1..21);
|
|
let mut player_ids = players.iter().map(|p| p.player_id);
|
|
let insomniac = player_ids.next().unwrap();
|
|
let wolf = player_ids.next().unwrap();
|
|
let seer = player_ids.next().unwrap();
|
|
let arcanist = player_ids.next().unwrap();
|
|
let direwolf = player_ids.next().unwrap();
|
|
let mut settings = GameSettings::empty();
|
|
settings.add_and_assign(SetupRole::Insomniac, insomniac);
|
|
settings.add_and_assign(SetupRole::Werewolf, wolf);
|
|
settings.add_and_assign(SetupRole::Seer, seer);
|
|
settings.add_and_assign(SetupRole::Arcanist, arcanist);
|
|
settings.add_and_assign(SetupRole::DireWolf, direwolf);
|
|
settings.fill_remaining_slots_with_villagers(players.len());
|
|
let mut game = Game::new(&players, settings).unwrap();
|
|
game.r#continue().r#continue();
|
|
assert_eq!(game.next().title(), ActionPromptTitle::WolvesIntro);
|
|
game.r#continue().r#continue();
|
|
|
|
game.next().title().direwolf();
|
|
game.mark(game.character_by_player_id(seer).character_id());
|
|
game.r#continue().sleep();
|
|
|
|
game.next().title().seer();
|
|
game.mark(game.living_villager().character_id());
|
|
game.r#continue().seer().village();
|
|
game.r#continue().sleep();
|
|
|
|
game.next().title().arcanist();
|
|
let mut villagers = game.villager_character_ids().into_iter();
|
|
game.mark(villagers.next().unwrap());
|
|
game.mark(villagers.next().unwrap());
|
|
assert_eq!(game.r#continue().arcanist(), AlignmentEq::Same);
|
|
game.r#continue().sleep();
|
|
|
|
game.next_expect_day();
|
|
|
|
game.execute().title().wolf_pack_kill();
|
|
game.mark(game.living_villager().character_id());
|
|
game.r#continue().r#continue();
|
|
|
|
game.next().title().direwolf();
|
|
game.mark(game.character_by_player_id(insomniac).character_id());
|
|
game.r#continue().sleep();
|
|
|
|
game.next().title().seer();
|
|
game.mark(game.character_by_player_id(insomniac).character_id());
|
|
game.r#continue().role_blocked();
|
|
game.r#continue().sleep();
|
|
|
|
game.next().title().arcanist();
|
|
game.mark(game.character_by_player_id(seer).character_id());
|
|
game.mark(game.character_by_player_id(insomniac).character_id());
|
|
game.r#continue().role_blocked();
|
|
game.r#continue().sleep();
|
|
|
|
game.next().title().insomniac();
|
|
assert_eq!(
|
|
game.r#continue().insomniac(),
|
|
Visits::new(Box::new(
|
|
[game.character_by_player_id(direwolf).identity(),]
|
|
))
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn dead_people_still_get_prompts_to_trigger_visits() {
|
|
let players = gen_players(1..21);
|
|
let mut player_ids = players.iter().map(|p| p.player_id);
|
|
let insomniac = player_ids.next().unwrap();
|
|
let wolf = player_ids.next().unwrap();
|
|
let seer = player_ids.next().unwrap();
|
|
let arcanist = player_ids.next().unwrap();
|
|
let mut settings = GameSettings::empty();
|
|
settings.add_and_assign(SetupRole::Insomniac, insomniac);
|
|
settings.add_and_assign(SetupRole::Werewolf, wolf);
|
|
settings.add_and_assign(SetupRole::Seer, seer);
|
|
settings.add_and_assign(SetupRole::Arcanist, arcanist);
|
|
settings.fill_remaining_slots_with_villagers(players.len());
|
|
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().title().seer();
|
|
game.mark(game.living_villager().character_id());
|
|
game.r#continue().seer().village();
|
|
game.r#continue().sleep();
|
|
|
|
game.next().title().arcanist();
|
|
let mut villagers = game.villager_character_ids().into_iter();
|
|
game.mark(villagers.next().unwrap());
|
|
game.mark(villagers.next().unwrap());
|
|
assert_eq!(game.r#continue().arcanist(), AlignmentEq::Same);
|
|
game.r#continue().sleep();
|
|
|
|
game.next_expect_day();
|
|
|
|
game.execute().title().wolf_pack_kill();
|
|
game.mark(game.character_by_player_id(seer).character_id());
|
|
game.r#continue().sleep();
|
|
|
|
game.next().title().seer();
|
|
game.mark(game.character_by_player_id(insomniac).character_id());
|
|
game.r#continue().seer().village();
|
|
game.r#continue().sleep();
|
|
|
|
game.next().title().arcanist();
|
|
game.mark(game.character_by_player_id(seer).character_id());
|
|
game.mark(game.character_by_player_id(insomniac).character_id());
|
|
assert_eq!(game.r#continue().arcanist(), AlignmentEq::Same);
|
|
game.r#continue().sleep();
|
|
|
|
game.next().title().insomniac();
|
|
assert_eq!(
|
|
game.r#continue().insomniac(),
|
|
Visits::new(Box::new([
|
|
game.character_by_player_id(seer).identity(),
|
|
game.character_by_player_id(arcanist).identity()
|
|
]))
|
|
);
|
|
}
|