model
Maintains game state and allows you to make changes to it.
The model object is the primary way for you to interact with Jumbo Grove.
Member Summary
Public Members | ||
public |
List of all characters in the game. |
|
public |
The situation currently being run, or last seen by the user. |
|
public |
globalState: * Store all non-character game state here; Must be JSON-safe! You may mutate this object freely as long as it is safe to convert it to JSON and back. |
|
public |
The character with ID |
Method Summary
Public Methods | ||
public |
Look up a character by ID. |
|
public |
do(string: command): * Follow a Jumbo Grove link ( |
|
public |
Add arbitrary methods to the model object. |
|
public |
Go to the given sitaution (no |
|
public |
interpretChoices(arrayOfSituationIdsOrTags: string[], atLeast: number, atMost: number): * Given a set of situations, do some smart stuff and return the situations that match the filter. |
|
public |
isManagedLink(string: string): Boolean Returns true iff the given string can be handled by Jumbo Grove (rather than being a normal HTML link) |
|
public |
presentChoices(arrayOfSituationIdsOrTags: string[]) Given an array of tags or situation IDs (can be both in the same array), present the relevant choices in the transcript using the logic in model.interpretChoices, then go to the situation chosen by the player. |
|
public |
random(): * Return a random number 0-1. |
|
public |
Looks up a situation by ID. |
|
public |
situations(idOrTag: string): Situation[] Returns a list of all situations matching the given ID ( |
Public Members
public currentSituation: Situation | null source
The situation currently being run, or last seen by the user.
public globalState: * source
Store all non-character game state here; Must be JSON-safe! You may mutate this object freely as long as it is safe to convert it to JSON and back.
Public Methods
public character(id: string): * source
Look up a character by ID. Returns undefined
if there isn't one.
Params:
Name | Type | Attribute | Description |
id | string |
Return:
* |
public do(string: command): * source
Follow a Jumbo Grove link (@situation-id
or >action
).
Params:
Name | Type | Attribute | Description |
string | command |
Return:
* |
public extend(fns: Map<string, function>) source
Add arbitrary methods to the model object. Since the model is passed to all callbacks, this is a good way to make convenient functions accessible.
Also, anything you pass here will also be provided to the template context.
public goTo(id: string): * source
Go to the given sitaution (no @
).
Params:
Name | Type | Attribute | Description |
id | string |
Return:
* |
public interpretChoices(arrayOfSituationIdsOrTags: string[], atLeast: number, atMost: number): * source
Given a set of situations, do some smart stuff and return the situations that match the filter.
- Filter out all situations for which
situation.getCanSee(model, model.currentSituation, situation)
returnsfalse
. - Find the highest priority that matches a list of situations at least as big as
atLeast
. - If there are more situations left than there are
atMost
, randomly remove some. - Sort by
situation.displayOrder
.
Note that it is possible to end up with a list of situations for which getCanChoose()
returned false
for all of them!
This logic has been shamelessly stolen from Undum.
Return:
* |
public isManagedLink(string: string): Boolean source
Returns true iff the given string can be handled by Jumbo Grove (rather than being a normal HTML link)
Params:
Name | Type | Attribute | Description |
string | string | A string to check |
public presentChoices(arrayOfSituationIdsOrTags: string[]) source
Given an array of tags or situation IDs (can be both in the same array), present the relevant choices in the transcript using the logic in model.interpretChoices, then go to the situation chosen by the player.
Params:
Name | Type | Attribute | Description |
arrayOfSituationIdsOrTags | string[] | Array of strings containing either |
public random(): * source
Return a random number 0-1. Currently this just calls Math.random()
, but
in the future it might do something fancy with seeds that let you avoid
save scumming.
Return:
* |