[][src]Module simple_games::hangman

Hangman game module

One player thinks of a word, phrase or sentence and the other(s) tries to guess it by suggesting letters or numbers, within a certain number of guesses.

Usage

use simple_games::{hangman, Hangman};

let mut game = Hangman::new("loli".into(), 5);
let result = game.guess_letter('l');
assert!(!result.is_over());

match result {
    hangman::GuessResult::Mada(word, rem_att, true) => {
        println!("Guessed letter 'l', remaining attempts: {}", rem_att);
        println!("Current word: {}", word);
    },
    _ => panic!("Unexpected result of guess, should partly guess.")
}

Structs

Hangman

Hangman game state

Enums

GuessResult

Result of guessing