empath fix and tests

This commit is contained in:
emilis 2025-10-06 21:12:12 +01:00
parent b1e80b5f4f
commit 153d39f0bb
No known key found for this signature in database
4 changed files with 152 additions and 1 deletions

View File

@ -1064,7 +1064,7 @@ impl Night {
..
} => {
let marked = self.village.character_by_id(*marked)?;
let scapegoat = marked.role_title() != RoleTitle::Scapegoat;
let scapegoat = marked.role_title() == RoleTitle::Scapegoat;
Ok(ActionComplete {
result: ActionResult::Empath { scapegoat },

View File

@ -58,6 +58,10 @@ pub trait ActionPromptTitleExt {
fn masons_wake(&self);
fn masons_leader_recruit(&self);
fn beholder(&self);
fn vindicator(&self);
fn pyremaster(&self);
fn empath(&self);
fn adjudicator(&self);
}
impl ActionPromptTitleExt for ActionPromptTitle {
@ -115,6 +119,18 @@ impl ActionPromptTitleExt for ActionPromptTitle {
fn beholder(&self) {
assert_eq!(*self, ActionPromptTitle::Beholder)
}
fn vindicator(&self) {
assert_eq!(*self, ActionPromptTitle::Vindicator)
}
fn pyremaster(&self) {
assert_eq!(*self, ActionPromptTitle::PyreMaster)
}
fn adjudicator(&self) {
assert_eq!(*self, ActionPromptTitle::Adjudicator)
}
fn empath(&self) {
assert_eq!(*self, ActionPromptTitle::Empath)
}
}
pub trait ActionResultExt {

View File

@ -0,0 +1,134 @@
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]
fn empath_nothing_on_wolf() {
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 });
game.next_expect_day();
assert_eq!(
*game.character_by_player_id(empath_player_id).role(),
Role::Empath { cursed: false }
);
}
#[test]
fn empath_takes_on_scapegoats_curse() {
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();
game.next().title().seer();
game.mark(game.character_by_player_id(empath_player_id).character_id());
game.r#continue().seer().village();
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 });
game.next().title().seer();
game.mark(
game.character_by_player_id(scapegoat_player_id)
.character_id(),
);
game.r#continue().seer().wolves();
game.next().title().seer();
game.mark(game.character_by_player_id(empath_player_id).character_id());
game.r#continue().seer().village();
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();
game.next().title().seer();
game.mark(game.character_by_player_id(empath_player_id).character_id());
game.r#continue().seer().wolves();
game.next_expect_day();
}

View File

@ -1,5 +1,6 @@
mod beholder;
mod elder;
mod empath;
mod mason;
mod scapegoat;
mod shapeshifter;