Pre-release
AdventureJS Docs Downloads
Score: 0 Moves: 0

Defined in: adventure/Scorecard.js, line 5

Framework class

Description

Scorecard is a repository for Game score options. Scorecard is created automatically by Game. This is an internal class that authors should not need to construct. However, authors can set scoring options from their game file as shown below, and call score updates from custom scripts.

Example:

var MyGame = new adventurejs.Game( "MyGame", "GameDisplay" );
MyGame.scorecard.set({
  score_events: {
    "unlock door": { points: 1, complete: false, bonus: false, message: '', recorded: false },
    "unlock chest": { points: 1, complete: false, bonus: false, message: '', recorded: false },
    "drink potion": { points: 1, complete: false, bonus: false, message: '', recorded: false },
  }
});

Private Constructor:

var foo = new adventurejs.Scorecard(game)

Parameters:

  • game Game
    A reference to the game instance.
Inherited Overrides

Methods Collapse all  |  Expand all

aggregateUpdates
aggregateUpdates()

Defined in: adventure/Scorecard.js, line 238

Print score updates in the aggregate.
completeEvent
completeEvent(event) → {Boolean}

Defined in: adventure/Scorecard.js, line 144

Parameters:

  • event String
    A string matching an event key.
Mark the selected event as complete and update the score.

Returns:

Boolean
createEvent
createEvent() → {String}

Defined in: adventure/Scorecard.js, line 128

Create a new event.

Returns:

String
formatScore
formatScore()

Defined in: adventure/Scorecard.js, line 321

Format the score/total before printing it to display.
recordEvent
recordEvent(event) → {Boolean}

Defined in: adventure/Scorecard.js, line 168

Parameters:

  • event String
    A string matching an event key.
Mark the selected event as recorded after updating the score.

Returns:

Boolean
restoreScore
restoreScore()

Defined in: adventure/Scorecard.js, line 218

Restore the player's score from a saved file or undo.
set
set(props) → {adventurejs.Scorecard}

Defined in: adventure/Scorecard.js, line 333

Parameters:

  • props Object
    A generic object containing properties to copy to the instance.
Provides a chainable shortcut method for setting a number of properties on the instance.

Returns:

adventurejs.Scorecard Returns the instance the method is called on (useful for chaining calls.)
stackUpdates
stackUpdates()

Defined in: adventure/Scorecard.js, line 260

Print score updates in a stack.
updateScore
updateScore()

Defined in: adventure/Scorecard.js, line 187

Update the player's score.

Properties  | 

diff
diff :Boolean

Defined in: adventure/Scorecard.js, line 60

Default value: 0

Used to show the difference between old score and new score during score updates.
newscore
newscore :Boolean

Defined in: adventure/Scorecard.js, line 52

Default value: 0

Used to compare old score vs new score during score updates.
score
score :Boolean

Defined in: adventure/Scorecard.js, line 45

Default value: 0

Used to keep track of player's current score.
score_events
score_events :Boolean

Defined in: adventure/Scorecard.js, line 100

Default value: {}

Used to store the game's score events.
score_format
score_format :Boolean

Defined in: adventure/Scorecard.js, line 75

Default value: {}

Can be used to set customized score printouts in the game display. score_format is subject to getStringArrayFunction() which means that it can be set to a string or an array or a function. For example, this returns a string:
score_message: `{Our} score went up! `,
This returns 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}`;
}
score_format
score_format :Boolean

Defined in: adventure/Scorecard.js, line 107

Default value: {}

summarize_updates determines how score updates are printed. With summarize_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 summarize_updates are false, each score update will be printed, and will use unique score_message that may be provided.
score_message
score_message :Boolean

Defined in: adventure/Scorecard.js, line 68

Default value: ""

Can be set to print when player earns any score update.