项目作者: textventure

项目描述 :
:page_with_curl: textventure/spec
高级语言:
项目地址: git://github.com/textventure/spec.git
创建时间: 2018-08-12T03:57:56Z
项目社区:https://github.com/textventure/spec

开源协议:

下载


Introduction

This document is the specification for writing a textventure story.

Format

A textventure story is written in YAML.

Schema

On a high-level, a textventure story consists of:

  • id
  • text
  • choice

Story without choice:

  1. <id>: !!str <text>

Story with choice:

  1. <id>: !!map
  2. <text>: !!seq
  3. - <choice>: !!str <id>
Property Description
\ String (unique). Maps to \.
\ String. If a collection, maps to a sequence of \‘s.
\ String. Maps to \.

Config

There’s also an optional _config property:

  1. _config:
  2. start: start
  3. renderer: text
Key Value(s) Description
start start (default)
*
String. The start \.
renderer text (default)
html
markdown
String. Renderer for \ and \.

Example

Given the flowchart:

!-- https://gist.github.com/remarkablemark/30d3974972e6fc3348fe3c58136e5aaa --

Flowchart of a textventure

The textventure would be written as:

  1. start:
  2. You come to a fork in the road.:
  3. - Turn left.: left
  4. - Turn right.: right
  5. left: You turn left.
  6. right: You turn right.

To add choices to the right node:

  1. right:
  2. You turn right.:
  3. - Choice A: choice_a
  4. - Choice B: choice_b
  5. choice_a: Text for A.
  6. choice_b: Text for B.

To rewrite the textventure in Markdown:

  1. _config:
  2. renderer: markdown
  3. start:
  4. ? |- # keeps newlines except for the last one
  5. You come to a fork in the road.
  6. ![Image of a fork in the road](fork-in-the-road.jpg)
  7. : # html entities need to be wrapped in quotes
  8. - '← Turn _left_.': left
  9. - '→ Turn _right_.': right
  10. left: You turn left.
  11. right: You turn right.