Home Reference Source
public class | source

game

The object you pass to the jumbogrove function.

Example:

const game = {
    id: 'jg-example',
    version: 1,
    globalState: {
        aliensHaveInvaded: false,
    },
    willEnter: (model, ui, previousId, nextId) => {
        console.log("Transitioning from", previousId, "to", nextId);
    },
};
jumbogrove('#app', game);

Member Summary

Public Members
public

The Markdown string you want to show at the top of the right sidebar.

public

If you set this to false, the browser will not scroll as new text is added.

public

List of character definitions.

public

If you set this to false, fewer styles will be applied to the HTML.

public

The Markdown string you want to show whenever the game is saved.

public

The initial value of model.globalState.

public

An ID unique to your game.

public

The ID of the first situation you want to show the player.

public

The Markdown string you want to show at the top of the left sidebar.

public

If you set this to false, the right sidebar will not be shown.

public

If you set this to false, the left sidebar will not be shown.

public

List of situation definitions.

public

The current version of your game.

Method Summary

Public Methods
public

didAct(model: model, ui: ui, situation: Situation, action: string)

Called when the game is just executed the given action on the given sitaution.

public

didEnter(model: model, ui: ui, previousId: string, nextId: string)

Called when the game has just entered a new situation.

public

didExit(model: model, ui: ui, thisId: string, nextId: string)

Called when the game just exited a situation.

public

init(model: model, ui: ui)

Called immediately after all initial objects have been created, but before the first situation has been entered.

public

willAct(model: model, ui: ui, situation: Situation, action: string)

Called when the game is about to execute the given action on the given sitaution.

public

willEnter(model: model, ui: ui, previousId: string, nextId: string): Boolean

Called when the game has requested to enter a new situation.

public

willExit(model: model, ui: ui, thisId: string, nextId: string)

Called when the game is about to exit a situation.

Public Members

public asideHeader: string source

The Markdown string you want to show at the top of the right sidebar. This string is processed by the template engine before being displayed.

public autoScroll: Boolean source

If you set this to false, the browser will not scroll as new text is added. Default true.

public characters: character source

List of character definitions. Note: this is not the same as the Character class! There's a difference between what you write in your game definition, and what gets passed to the various callbacks.

public defaultStylesheet: Boolean source

If you set this to false, fewer styles will be applied to the HTML. Default true.

public gameSaveMessage: string source

The Markdown string you want to show whenever the game is saved.

public globalState: * source

The initial value of model.globalState. Must be JSON-safe.

public id: string source

An ID unique to your game. Used to determine save location.

public initialSituation: string source

The ID of the first situation you want to show the player.

public navHeader: string source

The Markdown string you want to show at the top of the left sidebar.

public showAside: Boolean source

If you set this to false, the right sidebar will not be shown. Default true.

public showNav: Boolean source

If you set this to false, the left sidebar will not be shown. Default true.

public situations: situation source

List of situation definitions. Note: this is not the same as the Situation class! There's a difference between what you write in your game definition, and what gets passed to the various callbacks.

public version: number source

The current version of your game. Used to determine save location.

Public Methods

public didAct(model: model, ui: ui, situation: Situation, action: string) source

Called when the game is just executed the given action on the given sitaution.

Params:

NameTypeAttributeDescription
model model
ui ui
situation Situation
action string

public didEnter(model: model, ui: ui, previousId: string, nextId: string) source

Called when the game has just entered a new situation.

Params:

NameTypeAttributeDescription
model model
ui ui
previousId string
nextId string

public didExit(model: model, ui: ui, thisId: string, nextId: string) source

Called when the game just exited a situation.

Params:

NameTypeAttributeDescription
model model
ui ui
thisId string
nextId string

public init(model: model, ui: ui) source

Called immediately after all initial objects have been created, but before the first situation has been entered. This is where you would add Markdown plugins and Nunjucks filters.

Params:

NameTypeAttributeDescription
model model
ui ui

public willAct(model: model, ui: ui, situation: Situation, action: string) source

Called when the game is about to execute the given action on the given sitaution.

Params:

NameTypeAttributeDescription
model model
ui ui
situation Situation
action string

public willEnter(model: model, ui: ui, previousId: string, nextId: string): Boolean source

Called when the game has requested to enter a new situation. This function returns a truthy value (true) if this should be allowed, false if not.

It is safe to call model.do() or model.goTo() from willEnter(), as long as you return false afterward.

Params:

NameTypeAttributeDescription
model model
ui ui
previousId string
nextId string

Return:

Boolean

public willExit(model: model, ui: ui, thisId: string, nextId: string) source

Called when the game is about to exit a situation.

Params:

NameTypeAttributeDescription
model model
ui ui
thisId string
nextId string