use serde::{Deserialize, Serialize}; use werewolves_macros::ChecksAs; use crate::{ player::CharacterId, role::{Alignment, PreviousGuardianAction, Role, RoleTitle}, }; use super::Target; #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] pub enum ActionPrompt { WolvesIntro { wolves: Box<[(Target, RoleTitle)]>, }, RoleChange { new_role: RoleTitle, }, Seer { living_players: Box<[Target]>, }, Protector { targets: Box<[Target]>, }, Arcanist { living_players: Box<[Target]>, }, Gravedigger { dead_players: Box<[Target]>, }, Hunter { current_target: Option, living_players: Box<[Target]>, }, Militia { living_players: Box<[Target]>, }, MapleWolf { kill_or_die: bool, living_players: Box<[Target]>, }, Guardian { previous: Option, living_players: Box<[Target]>, }, WolfPackKill { living_villagers: Box<[Target]>, }, Shapeshifter, AlphaWolf { living_villagers: Box<[Target]>, }, DireWolf { living_players: Box<[Target]>, }, } impl PartialOrd for ActionPrompt { fn partial_cmp(&self, other: &Self) -> Option { fn ordering_num(prompt: &ActionPrompt) -> u8 { match prompt { ActionPrompt::WolvesIntro { wolves: _ } => 0, ActionPrompt::Guardian { living_players: _, previous: _, } | ActionPrompt::Protector { targets: _ } => 1, ActionPrompt::WolfPackKill { living_villagers: _, } => 2, ActionPrompt::Shapeshifter => 3, ActionPrompt::AlphaWolf { living_villagers: _, } => 4, ActionPrompt::DireWolf { living_players: _ } => 5, ActionPrompt::Seer { living_players: _ } | ActionPrompt::Arcanist { living_players: _ } | ActionPrompt::Gravedigger { dead_players: _ } | ActionPrompt::Hunter { current_target: _, living_players: _, } | ActionPrompt::Militia { living_players: _ } | ActionPrompt::MapleWolf { kill_or_die: _, living_players: _, } | ActionPrompt::RoleChange { new_role: _ } => 0xFF, } } ordering_num(self).partial_cmp(&ordering_num(other)) } } #[derive(Debug, Clone, Serialize, PartialEq, Deserialize, ChecksAs)] pub enum ActionResponse { Seer(CharacterId), Arcanist(CharacterId, CharacterId), Gravedigger(CharacterId), Hunter(CharacterId), Militia(Option), MapleWolf(Option), Guardian(CharacterId), WolfPackKillVote(CharacterId), #[checks] Shapeshifter(bool), AlphaWolf(Option), Direwolf(CharacterId), Protector(CharacterId), #[checks] RoleChangeAck, WolvesIntroAck, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub enum ActionResult { RoleBlocked, Seer(Alignment), Arcanist { same: bool }, GraveDigger(Option), GoBackToSleep, WolvesIntroDone, } #[derive(Debug, Clone, Serialize, Deserialize)] pub enum RoleChange { Elder(Role), Apprentice(Role), Shapeshift(Role), }