Pre-release
Adventure.js Docs Downloads
Score: 0 Moves: 0
Tutorial explaining how to use the Adventurejs scorecard. tutorial, scorecard

Start Scripting:Scorecard

To be written...

MyGame.scorecard.set({
  
  // This is how you set score events for your game. 
  // You can add as few or as many as you like, 
  // and set points to whatever number you like.
  // The names are up to you, so set them however you like.
  score_events: {
    "open window": 1,
    "take ann": 1,
    "open library door": 1,
    "open top drawer": 1,
    "open chest": 1,
    "take andy": 1,

    // Let's say you want the game to start with 
    // some points already set. You can do that like this.
    "preset points": { points: 5, complete: true, recorded: true },

    // You can set negative points too. These unset points cancel 
    // out the preset points above.
    "unset points": { points: -5, complete: true, recorded: true },
  },




// Scoring

PlugGame.scorecard.set({
  
  // aggregate_updates determines how score updates 
  // are printed. With aggregate_updates set to true,
  // if multiple score events occur in a turn, only 
  // one score update will be printed, with the 
  // cumulative score change. If aggregate_updates are
  // false, each score update will be printed, and will 
  // use unique score_message that may be provided.
  aggregate_updates: false,

  // This is how you set score events for your game. 
  // You can add as few or as many as you like, 
  // and set points to whatever number you like.
  // The names are up to you, so set them however you like.
  score_events: {
    "plug sink": 1,
    "unplug sink": 1,
    "put plug in sink": 1,
    "remove plug from sink": 1,
    "plug in radio": 1,
    "unplug radio": 1,
    "plug in any computer part": 1,
    "unplug any computer part": 1,

    // Let's say you want the game to start with 
    // some points already set. You can do that like this.
    "preset points": { points: 5, complete: true, recorded:true },

    // You can set negative points too. These preset
    // and unset points cancel each other out.
    "unset points": { points: -5, complete: true, recorded:true },

    // You can also assign "bonus" points. These won't be 
    // counted in the total, allowing player to earn a 
    // score like 110/100.
    // Customize the score message by setting score_message
    // to a string or array or function.
    "scan dollar": { points: 1, bonus: true, message: "[ ** $(We) got a bonus point! ** ]" },
    "print dollar": { points: 1, bonus: true, message: "[ ** $(We) got a bonus point! ** ]" },

  },

  // To attach a score event to your custom function, use
  // PlugGame.scorecard.completeEvent('open window');
  // You'll see these sprinkled throughout this demo code.
  
  // Adventurejs has built-in scoring functions, 
  // but you may, if you like, write custom score handling.

  // return a string

  // score_message: `$(Our) score went up! `,

  // return a custom function

  // score_message: function(){ 
  //   return `Dude, you totally just got ${this.diff} points!`
  // },

  // Or maybe you just want to tweak the score display. 
  // By default score appears in 0/0 format, but let's 
  // say you'd like it to say "Score: 0 out of 0".

  // score_format: function()
  // {
  //   return `Score: ${this.score} out of ${this.total}`;
  // }

  // Technically you don't even need to use numbered scores.
  // You could, if you wanted, set scores as text, like so:

  // score_format: function()
  // {
  //   return `Current danger level: ${this.game.vars.danger_level}`;
  // }

  // score_message and score_format have access to:
  // - this.score (old score)
  // - this.newscore (new score)
  // - this.diff (difference between old/new )
  // - this.total (total of points available)