Skip to content

Commit

Permalink
Updated game.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jcowman2 committed Aug 22, 2018
1 parent df48e7f commit 7e28db2
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions docs/overview/game.md
Expand Up @@ -211,8 +211,22 @@ There are three hooks for the Game Command API:

Each of these methods return `void`, and will error if called more than once.

### `onPlayerCommand((command: string) => TrackedEvent)`
### `onPlayerCommand(handler: (command: string) => TrackedEvent)`

### `onStartCommand((options: GameOption) => TrackedEvent)`
Executes whenever `postPlayerCommand` is called. The `handler` function in this case should use the player's `command`, which is a string, to generate a `TrackedEvent`.

### `onBeforeUndoCommand((game: GameInstance) => boolean)`
#### Example

```ts
const handleInput = (command: string) =>
on("INPUT", game => {
game.output.write(`You entered ${command}!`);
return noop;
});

onPlayerCommand(handleInput);
```

### `onStartCommand(handler: TrackedEvent)`

### `onBeforeUndoCommand(handler: (game: GameInstance) => boolean)`

0 comments on commit 7e28db2

Please sign in to comment.