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", "GameContainer" );
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:
-
gameGame
A reference to the game instance.
- Index
- Methods
- Properties
Methods Collapse all |
awardPoint
awardPoint(point, recurse) → {Boolean}
Defined in: Adventure/Scorecard.js, line 156
Parameters:
-
pointString | Object
An id string or object reference. -
recurseBoolean
Whether to award nested points.
Returns:
Boolean
clearPoint
clearPoint(point) → {Boolean}
Defined in: Adventure/Scorecard.js, line 203
Parameters:
-
pointString
A string matching an point key.
Returns:
Boolean
completePoint
completePoint(point) → {Boolean}
Defined in: Adventure/Scorecard.js, line 582
Parameters:
-
pointString
A string matching an point key.
Returns:
Boolean
countAwardedPoints
countAwardedPoints()
Defined in: Adventure/Scorecard.js, line 221
createPoint
createPoint() → {Object}
Defined in: Adventure/Scorecard.js, line 241
Returns:
Object
findGoal
findGoal(key, root) → {Object|null}
Defined in: Adventure/Goalcard.js, line 122
Parameters:
-
keyString
A name or id to search for. -
rootObject
The root object level to begin search.
Returns:
Object
|
null
findGoalByName
findGoalByName(key, root) → {Object|null}
Defined in: Adventure/Goalcard.js, line 164
Parameters:
-
keyString
An object key to search for. -
rootObject
The root object level to begin search.
Returns:
Object
|
null
findPointByKey
findPointByKey(key, root) → {Object|null}
Defined in: Adventure/Scorecard.js, line 264
Parameters:
-
keyString
An object key to search for. -
rootObject
The root object level to begin search.
Returns:
Object
|
null
findPointByText
findPointByText(key, root) → {Object|null}
Defined in: Adventure/Scorecard.js, line 291
Parameters:
-
keyString
An object key to search for. -
rootObject
The root object level to begin search.
Returns:
Object
|
null
formatScore
formatScore()
Defined in: Adventure/Scorecard.js, line 315
getPoint
getPoint(point) → {Boolean}
Defined in: Adventure/Scorecard.js, line 327
Parameters:
-
pointString | Object
An id string or object reference.
Returns:
Boolean
itemizePoints
itemizePoints()
Defined in: Adventure/Scorecard.js, line 347
listGoals
listGoals()
Defined in: Adventure/Goalcard.js, line 196
listPoints
listPoints()
Defined in: Adventure/Scorecard.js, line 377
processLonghand
processLonghand()
Defined in: Adventure/Scorecard.js, line 403
processShorthand
processShorthand()
Defined in: Adventure/Scorecard.js, line 461
recordPoint
recordPoint(point) → {Boolean}
Defined in: Adventure/Scorecard.js, line 567
Parameters:
-
pointString
A string matching an point key.
Returns:
Boolean
restoreScore
restoreScore()
Defined in: Adventure/Scorecard.js, line 595
set
set(props) → {AdventureJS.Scorecard}
Defined in: Adventure/Scorecard.js, line 651
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.)
stackUpdates
stackUpdates()
Defined in: Adventure/Scorecard.js, line 616
summarizeUpdates
summarizeUpdates()
Defined in: Adventure/Scorecard.js, line 134
updateScore
updateScore()
Defined in: Adventure/Scorecard.js, line 681
Properties |
award_text
award_text :Boolean
Defined in: Adventure/Scorecard.js, line 60
Default value: ""
diff
diff :Boolean
Defined in: Adventure/Scorecard.js, line 52
Default value: 0
newscore
newscore :Boolean
Defined in: Adventure/Scorecard.js, line 44
Default value: 0
noscore
noscore :Boolean
Defined in: Adventure/Scorecard.js, line 99
Default value: {}
overview
overview :Boolean
Defined in: Adventure/Scorecard.js, line 106
Default value: {}
points
points :Boolean
score
score :Boolean
Defined in: Adventure/Scorecard.js, line 37
Default value: 0
score_format
score_format :Boolean
Defined in: Adventure/Scorecard.js, line 67
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:
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 113
Default value: {}