[][src]Trait ascii_hangman_backend::HangmanBackend

pub trait HangmanBackend {
    fn new(config: &str) -> Result<Self, ConfigParseError>
    where
        Self: Sized
;
fn process_user_input(&mut self, inp: &str);
fn render_image(&self) -> String;
fn get_image_dimension(&self) -> (u8, u8);
fn render_secret(&self) -> String;
fn render_game_lifes(&self) -> String;
fn render_game_last_guess(&self) -> String;
fn render_instructions(&self) -> String;
fn get_state(&self) -> State; }

API to interact with all game logic. This is used by the desktop frontend in main.rs or by the web-app frontend in lib.rs.

Required methods

fn new(config: &str) -> Result<Self, ConfigParseError> where
    Self: Sized

Initialize the application with config data and start the first game.

fn process_user_input(&mut self, inp: &str)

The user_input is a key stroke. The meaning depends on the game's state:

fn render_image(&self) -> String

Renders the image. Make sure it is up to date with self.image.update().

fn get_image_dimension(&self) -> (u8, u8)

Forward the private image dimension

fn render_secret(&self) -> String

Renders the partly hidden secret.

fn render_game_lifes(&self) -> String

Informs about some game statistics: lifes

fn render_game_last_guess(&self) -> String

Informs about some game statistics: last guess

fn render_instructions(&self) -> String

Tells the user what to do next.

fn get_state(&self) -> State

Forwards the game's state

Loading content...

Implementors

impl HangmanBackend for Backend[src]

Loading content...