story

package
v0.0.0-...-c470439 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 28, 2019 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package story encapsulates routines for managing a Create Your Own Adventure story

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chapter

type Chapter struct {
	Title      string   `json:"title"`
	Paragraphs []string `json:"story"`
	Options    []struct {
		Text  string `json:"text"`
		Title string `json:"arc"`
	} `json:"options"`
}

Chapter encapsulates a chapter of a story

type Story

type Story struct {
	// contains filtered or unexported fields
}

Story encapsulates a set of chapters, indexed by string id

func FromJSONFile

func FromJSONFile(jsonFilename string) (*Story, error)

FromJSONFile receives a json filename as argument, attempts to parse it and return a struct of type Story. In case of an issue with the file or json contents, an error is returned.

func (*Story) ChapterByID

func (st *Story) ChapterByID(id string) (Chapter, error)

ChapterByID attempts to find a chapter in the story by the provided id. In case one is not found, an error is returned.

func (*Story) IntroChapter

func (st *Story) IntroChapter() (Chapter, error)

IntroChapter attempts to find a chapter in the story by the intro id of the story. In case one is not found, an error is returned.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL