gladstoriesengine 0.2.4

  • Readme
  • Changelog
  • Example
  • Installing
  • 65

A Dart Implementation of runtime and editor of Interactive Fiction Story format GladStoriesEngine #

Interactive Fiction Engine Home Page: https://github.com/gladimdim/GladStoriesEngine #

Examples #

Go to ./examples/ and check the dart source code there. It has a lot of comments.

How to run Tests with coverage #

pub global activate coverage

Install genhtml/lcov to generate html report from lcov:

brew install lcov
  • Run script:
./scripts/generate_coverage.sh
  • View the LCOV report at ./coverage/index.html

0.2.4 #

  • Made imageResolver a required field in the constructor.

0.2.3 #

  • Added DartDocs.
  • Fixed various linter issues.
  • No functional changes.

0.2.2 #

  • Removed accidentally added file.

0.2.1 #

  • Fixed issue when story could not be initialized without parameters.

0.2.0 #

  • Added type annotations for several methods.
  • Improved test coverage to 75%.
  • Page.hasNext logic is moved to Page.hasNextNode.
  • Page.hasNext now returns true/false depending on emptiness of next list.

0.1.3 #

  • Added example.
  • Formatted the dart files.

0.1.2 #

Fixed issues in Story constructor.

History list is initialized with an empty list.

_logCurrentPassageToHistory ignores imageResolver calls if it is null.

Page.fromMap returns empty Page is map is null or has no keys.

Added unit tests.

0.1.1 #

  • Added ImageResolver as an argument for fromJson method

0.1.0 #

  • Initial version

example/gladstoriesengine.dart

import 'package:gladstoriesengine/gladstoriesengine.dart';

// read current page

void main() {
  // create first page of the story

  var rootPage = Page(
    nodes: [
      // the page has two passages "Test" and "Second"
      PageNode(text: "Test"),
      PageNode(text: "Second"),
    ],
    // After the last passage is reached the reader should select option from the next array
    next: [
      PageNext(
        text: "Go to next page",
        // this page will be the next one to read, once the user selects "Go to next page"
        nextPage: Page(
          nodes: [
            PageNode(text: "inner node"),
          ],
          endType: EndType.ALIVE,
        ),
      ),
    ],
  );

// initialize Story with the root page and other meta data
  var story = Story(
    authors: "Authors",
    title: "Title",
    description: "Test Description",
    year: 1648,
    root: rootPage,
  );

  // check that story can continue
  story.canContinue(); // returns true

  // get current text of the story on this page.
  story.currentPage.getCurrentText(); // returns "Test"

  // continue to next Node
  story.doContinue();

  // get a new current text
  story.currentPage.getCurrentText(); // returns "Second"

  // the story cannot auto continue as the page reached its last passage
  // You need to show the user list of available next options
  if (!story.canContinue()) {
    // returns false
    story.currentPage.next
        .forEach((nextNode) => print(nextNode.text)); // prints Go to next page

    // use goToNextPage and pass the reference to PageNext
    // this action will add "Go to next page" (the next option name) and
    // the "inner node" (the first node of the next page) to the history array
    story.goToNextPage(
      story.currentPage.next[0],
    ); // switches currentpage to the next page
  }

  // the story cannot continue as the next page has only one node,
  // which is auto played when reader switches to it
  story.canContinue(); // returns false
  print(
    story.history.map((f) => f.text),
  ); // prints (Test, Second, Go to next page, inner node)

  // the current page has 'endType' defined. It means the story will end on this page with either
  // EndType.ALIVE or EndType.DEAD options. It is up to you to decide what to show to user.
  story.currentPage.isTheEnd(); // true
  story.currentPage.endType; // EndType.ALIVE
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  gladstoriesengine: ^0.2.4

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:gladstoriesengine/gladstoriesengine.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
29
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
65
Learn more about scoring.

We analyzed this package on Jul 9, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.14

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.3.0 <3.0.0
rxdart ^0.24.1 0.24.1
Dev dependencies
test ^1.15.0