use mastodon_async::Visibility;
/// This module contains the basic data structure of a game.
/// It's a trait that you can implement and create new games from.
/// Games are represented as state machines.

/// The game trait.
pub trait Game: Send {
    /// A static method to create a new game.
    fn new() -> Self
    where
        Self: Sized;
    /// next is the state machine. It receives a Command  and gives back a Reply.
    fn next(&mut self, m: &Command) -> Reply;
}

/// A game response. For now just a vector of strings that must be tooted.
/// In order to allow private replies, it also contains a visibility.
#[derive(Debug)]
pub struct Reply(pub Vec<String>, pub Visibility);
impl Reply {
    pub fn new() -> Self {
        // By default, replies are sent as unlisted.
        Reply(Vec::new(), Visibility::Unlisted)
    }
    pub fn push(&mut self, s: String) {
        self.0.push(s);
    }
    /// Set visibility to direct messages.
    pub fn quiet(&mut self) {
        self.1 = Visibility::Direct;
    }
}

/// A command. This is what we receive at next().
pub struct Command {
    pub sender: String,
    pub content: String,
}
