Crate act [] [src]

Act is a simple engine for making simple, text-based adventure games.

It's on crates.io and on GitHub!

Examples

extern crate act;

use act::load_game;

fn main() {
    // Create a string containing our Act game
    let game_string = r#"
    {
       "rooms": [
           {
               "name": "start",
               "scene": "Im a starting room! Welcome to this example game.",
               "actions": [
                   {
                       "variant": "Move",
                       "fields": [
                           "Move to another room","example",""
                       ]
                   }
               ]
           },
           {
               "name": "example",
               "scene": "You enter an example room, with a big, triangular key in it. Theres also a door with a keyhole in triangular shape.",
               "actions": [
                   {
                       "variant": "PickUp",
                       "fields": [
                           "Pick the key up","TriangleKey",""
                       ]
                   },
                   {
                       "variant": "Move",
                       "fields": [
                           "Try to open the door","locked","TriangleKey"
                       ]
                   }
               ]
           },
           {
               "name": "locked",
               "scene": "You picked an item up and used it to open the door! This is the final room. Congratz!",
               "actions": [
                   {
                       "variant": "Move",
                       "fields": [
                           "Move to another room","example",""
                       ]
                   }
               ]
           }
       ]
    }
    "#;
    // Load the game into a proper Game struct
    let mut game = load_game(game_string).unwrap();
    // Start the game
    game.play();
    // Profit!
}

Structs

Character
Game
Room

Enums

Action

An Action is composed of three strings. The first one is the text that will be shown to the user. The second is what the action will do. For example, in a PickUp action, it would be the item that would be given to the user. The third one is the requirement. This will check if the user has the item specified, and only if true will proceed.

Functions

load_game