use serde::{Deserialize, Serialize}; use thiserror::Error; use crate::{player::CharacterId, role::RoleTitle}; #[derive(Debug, Clone, PartialEq, Error, Serialize, Deserialize)] pub enum GameError { #[error("too many roles. have {players} players, but {roles} roles (incl wolves)")] TooManyRoles { players: u8, roles: u8 }, #[error("wolves range must start at 1")] NoWolves, #[error("message invalid for game state")] InvalidMessageForGameState, #[error("no executions during night time")] NoExecutionsAtNight, #[error("no-trial not allowed")] NoTrialNotAllowed, #[error("chracter is already dead")] CharacterAlreadyDead, #[error("no matching character found")] NoMatchingCharacterFound, #[error("character not in joined player pool")] CharacterNotInJoinedPlayers, #[error("{0}")] GenericError(String), #[error("invalid cause of death")] InvalidCauseOfDeath, #[error("invalid target")] InvalidTarget, #[error("timed out")] TimedOut, #[error("host channel closed")] HostChannelClosed, #[error("too few players: got {got} but the settings require at least {need}")] TooFewPlayers { got: u8, need: u8 }, #[error("it's already daytime")] AlreadyDaytime, #[error("it's not the end of the night yet")] NotEndOfNight, #[error("it's not day yet")] NotDayYet, #[error("it's not night")] NotNight, #[error("invalid role, expected {expected:?} got {got:?}")] InvalidRole { expected: RoleTitle, got: RoleTitle }, #[error("villagers cannot be added to settings")] CantAddVillagerToSettings, #[error("no mentor for an apprentice to be an apprentice to :(")] NoApprenticeMentor, #[error("BUG: cannot find character in village, but they should be there")] CannotFindTargetButShouldBeThere, #[error("inactive game object")] InactiveGameObject, #[error("socket error: {0}")] SocketError(String), #[error("this night is over")] NightOver, #[error("no night actions")] NoNightActions, #[error("still awaiting response")] AwaitingResponse, #[error("current state already has a response")] NightNeedsNext, #[error("night zero actions can only be obtained on night zero")] NotNightZero, #[error("wolves intro in progress")] WolvesIntroInProgress, #[error("a game is still ongoing")] GameOngoing, #[error("needs a role reveal")] NeedRoleReveal, }