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({
  points: {
    "unlock door": { value: 1, awarded: false, bonus: false, award_text: '', recorded: false },
    "unlock chest": { value: 1, awarded: false, bonus: false, award_text: '', recorded: false },
    "drink potion": { value: 1, awarded: false, bonus: false, award_text: '', 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

awardPoint
awardPoint(point, recurse) → {Boolean}

Defined in: adventure/Scorecard.js, line 155

Parameters:

  • point String | Object
    An id string or object reference.
  • recurse Boolean
    Whether to award nested points.
Mark the selected point as complete and update the score.

Returns:

Boolean
clearPoint
clearPoint(point) → {Boolean}

Defined in: adventure/Scorecard.js, line 202

Parameters:

  • point String
    A string matching an point key.
Mark the selected point as incomplete and update the score.

Returns:

Boolean
completePoint
completePoint(point) → {Boolean}

Defined in: adventure/Scorecard.js, line 581

Parameters:

  • point String
    A string matching an point key.
This is a utility method that awards and also records a point. Meant for debugging so author can award a point in the console.

Returns:

Boolean
countAwardedPoints
countAwardedPoints()

Defined in: adventure/Scorecard.js, line 220

Recursively count awarded points.
createPoint
createPoint() → {Object}

Defined in: adventure/Scorecard.js, line 240

Create a new point object with default values.

Returns:

Object
findGoal
findGoal(key, root) → {Object|null}

Defined in: adventure/Goalcard.js, line 121

Parameters:

  • key String
    A name or id to search for.
  • root Object
    The root object level to begin search.
Recursively find goal by name or key.

Returns:

Object | null
findGoalByName
findGoalByName(key, root) → {Object|null}

Defined in: adventure/Goalcard.js, line 163

Parameters:

  • key String
    An object key to search for.
  • root Object
    The root object level to begin search.
Recursively find goal by its name.

Returns:

Object | null
findPointByKey
findPointByKey(key, root) → {Object|null}

Defined in: adventure/Scorecard.js, line 263

Parameters:

  • key String
    An object key to search for.
  • root Object
    The root object level to begin search.
Find point by key. Looks recursively.

Returns:

Object | null
findPointByText
findPointByText(key, root) → {Object|null}

Defined in: adventure/Scorecard.js, line 290

Parameters:

  • key String
    An object key to search for.
  • root Object
    The root object level to begin search.
Recursively find point by its text.

Returns:

Object | null
formatScore
formatScore()

Defined in: adventure/Scorecard.js, line 314

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

Defined in: adventure/Scorecard.js, line 326

Parameters:

  • point String | Object
    An id string or object reference.
Get a point by numerical key or by its text or if a point object is received pass it on.

Returns:

Boolean
itemizePoints
itemizePoints()

Defined in: adventure/Scorecard.js, line 346

Get an itemized list of completed points.
listGoals
listGoals()

Defined in: adventure/Goalcard.js, line 195

Get a printable list of goals.
listPoints
listPoints()

Defined in: adventure/Scorecard.js, line 376

Get an itemized list of completed points.
processLonghand
processLonghand()

Defined in: adventure/Scorecard.js, line 402

Process score data in longhand format.
processShorthand
processShorthand()

Defined in: adventure/Scorecard.js, line 460

Process score data in shorthand format.
recordPoint
recordPoint(point) → {Boolean}

Defined in: adventure/Scorecard.js, line 566

Parameters:

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

Returns:

Boolean
restoreScore
restoreScore()

Defined in: adventure/Scorecard.js, line 594

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

Defined in: adventure/Scorecard.js, line 650

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 615

Print score updates in a stack.
summarizeUpdates
summarizeUpdates()

Defined in: adventure/Scorecard.js, line 133

Print score updates in the aggregate.
updateScore
updateScore()

Defined in: adventure/Scorecard.js, line 680

Update the player's score.

Properties  | 

award_text
award_text :Boolean

Defined in: adventure/Scorecard.js, line 59

Default value: ""

Can be set to print when player is awarded any point.
diff
diff :Boolean

Defined in: adventure/Scorecard.js, line 51

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 43

Default value: 0

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

Defined in: adventure/Scorecard.js, line 98

Default value: {}

If user has no points and types points print this.
overview
overview :Boolean

Defined in: adventure/Scorecard.js, line 105

Default value: {}

If user types points print this as a leading overview.
points
points :Boolean

Defined in: adventure/Scorecard.js, line 91

Default value: {}

Used to store the game's points.
score
score :Boolean

Defined in: adventure/Scorecard.js, line 36

Default value: 0

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

Defined in: adventure/Scorecard.js, line 66

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:
award_text: `{Our} score went up! `,
This returns a custom function:
award_text: 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}`;
}
summarize_updates
summarize_updates :Boolean

Defined in: adventure/Scorecard.js, line 112

Default value: {}

summarize_updates determines how score updates are printed. With summarize_updates set to true, if multiple points 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 award_text that may be provided.