1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
pub mod cleanup;
pub mod migrate;
pub mod npc_ai;
pub mod replenish_resources;
pub mod report;
pub mod simulate_npcs;
pub mod sync_npcs;

use super::RtState;
use std::fmt;

#[derive(Debug)]
pub enum RuleError {
    NoSuchRule(&'static str),
}

impl fmt::Display for RuleError {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        match self {
            Self::NoSuchRule(r) => {
                write!(f, "tried to fetch rule state '{}' but it does not exist", r)
            },
        }
    }
}

pub trait Rule: Sized + Send + Sync + 'static {
    fn start(rtstate: &mut RtState) -> Result<Self, RuleError>;
}