// 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 . use crate::{ game::{Game, GameSettings, OrRandom, SetupRole}, game_test::{ ActionPromptTitleExt, ActionResultExt, GameExt, SettingsExt, gen_players, init_log, }, }; #[allow(unused)] use pretty_assertions::{assert_eq, assert_ne, assert_str_eq}; #[test] fn block_on_wolf_kill_target_prevents_kill() { init_log(); let players = gen_players(1..21); let mut player_ids = players.iter().map(|p| p.player_id); let scapegoat = player_ids.next().unwrap(); let direwolf = player_ids.next().unwrap(); let wolf = player_ids.next().unwrap(); let mut settings = GameSettings::empty(); settings.add_and_assign( SetupRole::Scapegoat { redeemed: OrRandom::Determined(false), }, scapegoat, ); settings.add_and_assign(SetupRole::DireWolf, direwolf); settings.add_and_assign(SetupRole::Werewolf, wolf); settings.fill_remaining_slots_with_villagers(20); let mut game = Game::new(&players, settings).unwrap(); game.r#continue().r#continue(); game.next().title().wolves_intro(); game.r#continue().r#continue(); game.next().title().direwolf(); game.mark_villager(); game.r#continue().sleep(); game.next_expect_day(); game.execute().title().wolf_pack_kill(); let scapegoat_char_id = game.character_by_player_id(scapegoat).character_id(); game.mark(scapegoat_char_id); game.r#continue().r#continue(); game.next().title().direwolf(); game.mark(scapegoat_char_id); game.r#continue().sleep(); game.next_expect_day(); assert_eq!( game.character_by_player_id(scapegoat).died_to().cloned(), None ); } #[test] fn block_on_guardian_target_prevents_the_visit() { init_log(); let players = gen_players(1..21); let mut player_ids = players.iter().map(|p| p.player_id); let scapegoat = player_ids.next().unwrap(); let guardian = player_ids.next().unwrap(); let direwolf = player_ids.next().unwrap(); let wolf = player_ids.next().unwrap(); let mut settings = GameSettings::empty(); settings.add_and_assign( SetupRole::Scapegoat { redeemed: OrRandom::Determined(false), }, scapegoat, ); settings.add_and_assign(SetupRole::Guardian, guardian); settings.add_and_assign(SetupRole::DireWolf, direwolf); settings.add_and_assign(SetupRole::Werewolf, wolf); settings.fill_remaining_slots_with_villagers(20); let mut game = Game::new(&players, settings).unwrap(); game.r#continue().r#continue(); game.next().title().wolves_intro(); game.r#continue().r#continue(); game.next().title().direwolf(); game.mark_villager(); game.r#continue().sleep(); game.next_expect_day(); game.execute().title().guardian(); let scapegoat_char_id = game.character_by_player_id(scapegoat).character_id(); game.mark(scapegoat_char_id); game.r#continue().sleep(); game.next().title().wolf_pack_kill(); game.mark_villager(); game.r#continue().r#continue(); game.next().title().direwolf(); game.mark(scapegoat_char_id); game.r#continue().sleep(); game.next_expect_day(); assert_eq!( game.character_by_player_id(guardian) .guardian() .unwrap() .clone(), None ); }