[−][src]Function kingslayer::get_world
pub fn get_world(path: &str) -> Cli
Creates a Cli from the given file
A full game requires a loop, printing the result of cli.ask(&cli.prompt()), and handling a death case. All other properties are managed in the world JSON.
A game can be setup and started like so:
use kingslayer::get_world; fn main() { let cli = kingslayer::get_world("data/world.json"); println!("{}", cli.ask("l")); loop { match cli.ask(&cli.prompt()) { s => { println!("{}", s); if s.contains("You died.") { break; } } } } }
The string parameter should link to an existing file with the proper JSON setup for creating a working game.