31 lines
675 B
Rust
31 lines
675 B
Rust
|
|
#![allow(clippy::new_without_default)]
|
||
|
|
use error::GameError;
|
||
|
|
use serde::{Deserialize, Serialize};
|
||
|
|
use thiserror::Error;
|
||
|
|
|
||
|
|
// pub mod action;
|
||
|
|
pub mod diedto;
|
||
|
|
pub mod error;
|
||
|
|
pub mod game;
|
||
|
|
pub mod message;
|
||
|
|
pub mod modifier;
|
||
|
|
pub mod nonzero;
|
||
|
|
pub mod player;
|
||
|
|
pub mod role;
|
||
|
|
|
||
|
|
#[derive(Debug, Error, Clone, Serialize, Deserialize)]
|
||
|
|
pub enum MessageError {
|
||
|
|
#[error("{0}")]
|
||
|
|
GameError(#[from] GameError),
|
||
|
|
}
|
||
|
|
|
||
|
|
pub(crate) trait MustBeInVillage<T> {
|
||
|
|
fn must_be_in_village(self) -> Result<T, GameError>;
|
||
|
|
}
|
||
|
|
|
||
|
|
impl<T> MustBeInVillage<T> for Option<T> {
|
||
|
|
fn must_be_in_village(self) -> Result<T, GameError> {
|
||
|
|
self.ok_or(GameError::CannotFindTargetButShouldBeThere)
|
||
|
|
}
|
||
|
|
}
|