Pre-release
AdventureJS Docs Downloads
Score: 0 Moves: 0
Tutorial explaining how to use the AdventureJS scorecard shorthand. tutorial, scorecard shorthand

Goals, Hints, and Scores: Scorecard Shorthand

Scorecards are a system for creating points, updating a player's score, printing score update messages, and setting the score in the status bar. The shorthand method accepts text in a markdown format, and uses it to build point data objects. Each point consists minimally of a name and a point value. (Additional properties can be defined using the longhand method.)

Example Code

MyGame.scorecard.set({
  points: `
    # brass keys | 1
    # - take melted brass key | 1
    # - take giant brass key | 1
    # - take tiny brass key | 1
    open library door | 1
    open top drawer | 1
    open chest | 1
  `,
});

Shorthand Cheatsheet

  • Use my point | 1 to set a name and value for a point.
  • Use # to define a group of points. A group can have no value of its own, or have its own value that adds to the score when all of its children are completed.
  • Use # - to nest a point within a group.
  • Use multiple ## to define nested groups.

Shorthand Explained

  • Use plain text with no leading character to define a singular point. Use a | as a separator to define name and value.
    Expand for example
    MyGame.scorecard.set({
      points: `
        open window | 1
      `,
    });
  • Use a leading # to define a group of points. A group may have points of its own, which will automatically be awarded on completion of all its children.
    Expand for example
    MyGame.scorecard.set({
      points: `
        open window | 1
        # brass keys | 1
      `,
    });
  • Nest points under a group by using # -.
    Expand for example
    MyGame.scorecard.set({
      points: `
        open window | 1
        # brass keys | 1
        # - take melted brass key | 1
        # - take giant brass key | 1
        # - take tiny brass key | 1
      `,
    });
  • Use multiple hash marks ## to define nested groups of points.
    Expand for example
    MyGame.scorecard.set({
      points: `
        open window | 1
        # brass keys | 1
        # - take melted brass key | 1
        # - take giant brass key | 1
        # - take tiny brass key | 1
        ## Use all the keys
      `,
    });
  • Use multiple hash marks followed by a dash ## - to define points within nested groups of points.
    Expand for example
    MyGame.scorecard.set({
      points: `
        open window | 1
        # brass keys | 1
        # - take melted brass key | 1
        # - take giant brass key | 1
        # - take tiny brass key | 1
        ## Use all the keys
        ## - unlock the diary
        ## - unlock the music box
        ## - unlock the desk drawer
      `,
    });

Example game

var MyGame = new adventurejs.Game("MyGame", "MyGameDisplay");

MyGame.scorecard.set({
  points: `
    take lamp | 1
    take knapsack | 1
    # fruit | 1
    # - take banana | 1
    # - take apple | 1
    # - take orange | 1
    # gems | 1
    # - take diamond | 1
    # - take ruby | 1
    # - take emerald | 1
  `,
})