Class:Scorecard
Defined in: adventure/Scorecard.js, line 5
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, recorded: message: '', false },
"drink potion": { points: 1, complete: false, bonus: false, recorded: message: '', false },
}
});
Private Constructor:
var foo = new adventurejs.Scorecard(game)
Parameters:
-
gameGame
A reference to the game instance.
- Index
- Methods
- Properties
Methods Collapse all |
aggregateUpdates
aggregateUpdates()
Defined in: adventure/Scorecard.js, line 180
completeEvent
completeEvent(event) → {Boolean}
Defined in: adventure/Scorecard.js, line 136
Parameters:
-
eventString
A string matching an event key.
Returns:
Boolean
createEvent
createEvent() → {String}
set
set(props) → {adventurejs.Scorecard}
Defined in: adventure/Scorecard.js, line 248
Parameters:
-
propsObject
A generic object containing properties to copy to the instance.
Returns:
adventurejs.Scorecard
Returns the instance the method is called on (useful for chaining calls.)
setScore
setScore()
Defined in: adventure/Scorecard.js, line 236
stackUpdates
stackUpdates()
Defined in: adventure/Scorecard.js, line 202
updateScore
updateScore()
Defined in: adventure/Scorecard.js, line 149
Properties |
diff
diff :Boolean
Defined in: adventure/Scorecard.js, line 59
Default value: 0
newscore
newscore :Boolean
Defined in: adventure/Scorecard.js, line 51
Default value: 0
score
score :Boolean
Defined in: adventure/Scorecard.js, line 44
Default value: 0
score_format
score_format :Boolean
Defined in: adventure/Scorecard.js, line 74
Default value: {}
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 99
Default value: {}
score_message
score_message :Boolean
Defined in: adventure/Scorecard.js, line 67
Default value: ""