use core::num::NonZeroU8; use serde::{Deserialize, Serialize}; use crate::{ character::CharacterId, error::GameError, game::{GameOver, GameSettings, story::GameStory}, message::{ CharacterIdentity, night::{ActionPrompt, ActionResponse, ActionResult}, }, player::PlayerId, }; use super::{CharacterState, PlayerState, PublicIdentity}; #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub enum HostMessage { GetState, Lobby(HostLobbyMessage), InGame(HostGameMessage), ForceRoleAckFor(CharacterId), PostGame(PostGameMessage), Echo(ServerToHostMessage), } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub enum PostGameMessage { NewLobby, NextPage, PreviousPage, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub enum HostGameMessage { Day(HostDayMessage), Night(HostNightMessage), PreviousState, GetState, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub enum HostNightMessage { ActionResponse(ActionResponse), Next, NextPage, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub enum HostDayMessage { Execute, MarkForExecution(CharacterId), } impl From for HostGameMessage { fn from(value: HostDayMessage) -> Self { HostGameMessage::Day(value) } } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub enum HostLobbyMessage { GetState, ManufacturePlayer(PublicIdentity), Kick(PlayerId), SetPlayerNumber(PlayerId, NonZeroU8), GetGameSettings, SetGameSettings(GameSettings), SetQrMode(bool), Start, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, werewolves_macros::Titles)] pub enum ServerToHostMessage { Disconnect, Daytime { characters: Box<[CharacterState]>, marked: Box<[CharacterId]>, day: NonZeroU8, settings: GameSettings, }, ActionPrompt(ActionPrompt, usize), ActionResult(Option, ActionResult), Lobby(Box<[PlayerState]>), QrMode(bool), GameSettings(GameSettings), Error(GameError), GameOver(GameOver), WaitingForRoleRevealAcks { ackd: Box<[CharacterIdentity]>, waiting: Box<[CharacterIdentity]>, }, Story { story: GameStory, page: usize, }, }