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

157 lines
5.2 KiB
Rust
Raw Normal View History

// 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/>.
2025-10-06 21:12:12 +01:00
use core::num::NonZeroU8;
#[allow(unused)]
use pretty_assertions::{assert_eq, assert_ne, assert_str_eq};
use crate::{
game::{Game, GameSettings, OrRandom, SetupRole},
game_test::{
ActionPromptTitleExt, ActionResultExt, AlignmentExt, GameExt, SettingsExt, gen_players,
},
message::night::{ActionPrompt, ActionPromptTitle, ActionResult},
role::Role,
};
#[test]
2025-10-06 21:59:44 +01:00
fn nothing_on_wolf() {
2025-10-06 21:12:12 +01:00
let players = gen_players(1..10);
let empath_player_id = players[0].player_id;
let wolf_player_id = players[1].player_id;
let mut settings = GameSettings::empty();
settings.add_and_assign(SetupRole::Empath, empath_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.living_villager_excl(empath_player_id).character_id());
game.r#continue().sleep();
game.next().title().empath();
game.mark(game.character_by_player_id(wolf_player_id).character_id());
assert_eq!(game.r#continue(), ActionResult::Empath { scapegoat: false });
2025-10-17 21:16:10 +01:00
game.r#continue().sleep();
2025-10-06 21:12:12 +01:00
game.next_expect_day();
assert_eq!(
*game.character_by_player_id(empath_player_id).role(),
Role::Empath { cursed: false }
);
}
#[test]
2025-10-06 21:59:44 +01:00
fn takes_on_scapegoats_curse() {
2025-10-06 21:12:12 +01:00
let players = gen_players(1..10);
let empath_player_id = players[0].player_id;
let wolf_player_id = players[1].player_id;
let scapegoat_player_id = players[2].player_id;
let seer_1_player_id = players[3].player_id;
let seer_2_player_id = players[4].player_id;
let mut settings = GameSettings::empty();
settings.add_and_assign(SetupRole::Empath, empath_player_id);
settings.add_and_assign(SetupRole::Werewolf, wolf_player_id);
settings.add_and_assign(SetupRole::Seer, seer_1_player_id);
settings.add_and_assign(SetupRole::Seer, seer_2_player_id);
settings.add_and_assign(
SetupRole::Scapegoat {
redeemed: OrRandom::Random,
},
scapegoat_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().title().seer();
game.mark(
game.character_by_player_id(scapegoat_player_id)
.character_id(),
);
game.r#continue().seer().wolves();
2025-10-17 21:16:10 +01:00
game.r#continue().sleep();
2025-10-06 21:12:12 +01:00
game.next().title().seer();
game.mark(game.character_by_player_id(empath_player_id).character_id());
game.r#continue().seer().village();
2025-10-17 21:16:10 +01:00
game.r#continue().sleep();
2025-10-06 21:12:12 +01:00
game.next_expect_day();
game.execute().title().wolf_pack_kill();
game.mark(game.living_villager_excl(empath_player_id).character_id());
game.r#continue().sleep();
game.next().title().empath();
game.mark(
game.character_by_player_id(scapegoat_player_id)
.character_id(),
);
assert_eq!(game.r#continue(), ActionResult::Empath { scapegoat: true });
2025-10-17 21:16:10 +01:00
game.r#continue().sleep();
2025-10-06 21:12:12 +01:00
game.next().title().seer();
game.mark(
game.character_by_player_id(scapegoat_player_id)
.character_id(),
);
game.r#continue().seer().wolves();
2025-10-17 21:16:10 +01:00
game.r#continue().sleep();
2025-10-06 21:12:12 +01:00
game.next().title().seer();
game.mark(game.character_by_player_id(empath_player_id).character_id());
game.r#continue().seer().village();
2025-10-17 21:16:10 +01:00
game.r#continue().sleep();
2025-10-06 21:12:12 +01:00
game.next_expect_day();
assert_eq!(
*game.character_by_player_id(empath_player_id).role(),
Role::Empath { cursed: true }
);
assert_eq!(
*game.character_by_player_id(scapegoat_player_id).role(),
Role::Villager
);
game.execute().title().wolf_pack_kill();
game.mark(game.villager_character_ids().into_iter().next().unwrap());
game.r#continue().sleep();
game.next().title().seer();
game.mark(
game.character_by_player_id(scapegoat_player_id)
.character_id(),
);
game.r#continue().seer().village();
2025-10-17 21:16:10 +01:00
game.r#continue().sleep();
2025-10-06 21:12:12 +01:00
game.next().title().seer();
game.mark(game.character_by_player_id(empath_player_id).character_id());
game.r#continue().seer().wolves();
2025-10-17 21:16:10 +01:00
game.r#continue().sleep();
2025-10-06 21:12:12 +01:00
game.next_expect_day();
}