diff --git a/werewolves-proto/src/game/night.rs b/werewolves-proto/src/game/night.rs index 166eafa..e398a1c 100644 --- a/werewolves-proto/src/game/night.rs +++ b/werewolves-proto/src/game/night.rs @@ -19,7 +19,6 @@ use core::num::NonZeroU8; use std::collections::VecDeque; use serde::{Deserialize, Serialize}; -use werewolves_macros::Extract; use super::Result; use crate::{ @@ -30,11 +29,9 @@ use crate::{ GameTime, Village, kill::{self}, night::changes::{ChangesLookup, NightChange}, - story::NightChoice, }, message::night::{ActionPrompt, ActionResponse, ActionResult, Visits}, - player::Protection, - role::{PYREMASTER_VILLAGER_KILLS_TO_DIE, RoleBlock, RoleTitle}, + role::RoleTitle, }; enum BlockResolvedOutcome { @@ -1061,6 +1058,31 @@ impl Night { Ok(()) } + /// resolves whether the target [CharacterId] dies tonight with the current + /// state of the night + fn dies_tonight(&self, character_id: CharacterId) -> Result { + let ch = self + .changes_from_actions() + .into_iter() + .chain(self.automatic_changes()) + .collect::>(); + let mut changes = ChangesLookup::new(&ch); + if let Some(died_to) = changes.killed(character_id) + && kill::resolve_kill( + &mut changes, + character_id, + died_to, + self.night, + &self.village, + )? + .is_some() + { + Ok(true) + } else { + Ok(false) + } + } + fn changes_from_actions(&self) -> Box<[NightChange]> { self.used_actions .iter() diff --git a/werewolves-proto/src/game/night/process.rs b/werewolves-proto/src/game/night/process.rs index b9341d7..171d95d 100644 --- a/werewolves-proto/src/game/night/process.rs +++ b/werewolves-proto/src/game/night/process.rs @@ -394,7 +394,9 @@ impl Night { } => { if let Some(result) = self.used_actions.iter().find_map(|(prompt, result, _)| { prompt.matches_beholding(*marked).then_some(result) - }) { + }) && self.dies_tonight(*marked)? + && !matches!(result, ActionResult::RoleBlocked) + { Ok(ActionComplete { result: result.clone(), change: None, diff --git a/werewolves-proto/src/game_test/mod.rs b/werewolves-proto/src/game_test/mod.rs index ee99528..44d3980 100644 --- a/werewolves-proto/src/game_test/mod.rs +++ b/werewolves-proto/src/game_test/mod.rs @@ -969,7 +969,6 @@ fn big_game_test_based_on_story_test() { game.next().title().beholder(); game.mark(game.character_by_player_id(power_seer).character_id()); - game.r#continue().power_seer(); game.r#continue().sleep(); game.next_expect_day(); @@ -1050,7 +1049,6 @@ fn big_game_test_based_on_story_test() { game.next().title().beholder(); game.mark(game.character_by_player_id(power_seer).character_id()); - game.r#continue().power_seer(); game.r#continue().sleep(); game.next_expect_day(); @@ -1127,13 +1125,12 @@ fn big_game_test_based_on_story_test() { game.next().title().beholder(); game.mark(game.character_by_player_id(gravedigger).character_id()); - assert_eq!(game.r#continue().gravedigger(), Some(RoleTitle::Guardian)); game.r#continue().sleep(); game.next_expect_day(); game.mark_for_execution(game.character_by_player_id(vindicator).character_id()); game.execute().title().wolf_pack_kill(); - game.mark(game.living_villager().character_id()); + game.mark(game.character_by_player_id(mortician).character_id()); game.r#continue().sleep(); game.next().title().seer(); diff --git a/werewolves-proto/src/game_test/previous.rs b/werewolves-proto/src/game_test/previous.rs index 5bba7c5..16b6b21 100644 --- a/werewolves-proto/src/game_test/previous.rs +++ b/werewolves-proto/src/game_test/previous.rs @@ -408,7 +408,6 @@ fn previous_prompt() { game.next().title().beholder(); game.mark(game.character_by_player_id(power_seer).character_id()); - game.r#continue().power_seer(); game.r#continue().sleep(); game.next_expect_day(); diff --git a/werewolves-proto/src/game_test/role/beholder.rs b/werewolves-proto/src/game_test/role/beholder.rs index ed6adc9..2d1ce9f 100644 --- a/werewolves-proto/src/game_test/role/beholder.rs +++ b/werewolves-proto/src/game_test/role/beholder.rs @@ -12,17 +12,16 @@ // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -use core::num::NonZeroU8; #[allow(unused)] use pretty_assertions::{assert_eq, assert_ne, assert_str_eq}; use crate::{ game::{Game, GameSettings, SetupRole}, game_test::{ - ActionPromptTitleExt, ActionResultExt, AlignmentExt, GameExt, SettingsExt, gen_players, - init_log, + ActionPromptTitleExt, ActionResultExt, GameExt, SettingsExt, gen_players, init_log, }, - message::night::{ActionPrompt, ActionPromptTitle}, + message::night::ActionPromptTitle, + role::Alignment, }; #[test] @@ -59,7 +58,21 @@ fn beholding_seer() { game.next().title().beholder(); game.mark(game.character_by_player_id(seer_player_id).character_id()); - game.r#continue().seer().wolves(); + game.r#continue().sleep(); + + game.next_expect_day(); + game.execute().title().wolf_pack_kill(); + game.mark(game.character_by_player_id(seer_player_id).character_id()); + game.r#continue().sleep(); + + game.next().title().seer(); + game.mark(game.character_by_player_id(wolf_player_id).character_id()); + assert_eq!(game.r#continue().seer(), Alignment::Wolves); + game.r#continue().sleep(); + + game.next().title().beholder(); + game.mark(game.character_by_player_id(seer_player_id).character_id()); + assert_eq!(game.r#continue().seer(), Alignment::Wolves); game.r#continue().sleep(); game.next_expect_day(); diff --git a/werewolves/src/pages/role_page/beholder.rs b/werewolves/src/pages/role_page/beholder.rs index 6268ff6..3201097 100644 --- a/werewolves/src/pages/role_page/beholder.rs +++ b/werewolves/src/pages/role_page/beholder.rs @@ -21,7 +21,8 @@ pub fn BeholderPage1() -> Html {

{"BEHOLDER"}

{"PICK A PLAYER"}

-

{"IF THEY ARE AN INTEL ROLE, YOU WILL SEE WHAT THEY SAW TONIGHT"}

+

{"YOU WILL SEE WHAT INFORMATION THEY MAY HAVE GATHERED"}

+

{"SHOULD THEY DIE TONIGHT"}

}