Skip to content

Commit

Permalink
update documentations for imports
Browse files Browse the repository at this point in the history
  • Loading branch information
philihp committed Jan 8, 2018
1 parent d3121c2 commit 4aaee37
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 68 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Expand Up @@ -14,3 +14,4 @@ Robert Sandu
Rifat Nabi
Satana Charuwichitratana
Pete Nykänen
Philihp Busby
38 changes: 16 additions & 22 deletions docs/api/Client.md
@@ -1,25 +1,5 @@
# Client

```js
Client({
// The return value of Game().
game: game,

// The number of players.
numPlayers: 2,

// The React component representing your game board.
board: Board,

// Set to true to enable sending move updates to the
// server via WebSockets.
multiplayer: false,

// Set to false to disable the Debug UI.
debug: true
})
```

Creates a `boardgame.io` client. This is the entry point for
the client application, and is the only call necessary on the
client-side if you choose to roll your own move reducer.
Expand All @@ -45,7 +25,7 @@ a move or interact with the game.


### Arguments
1. obj(*object*): A config object with the options shown above.
1. obj(*object*): A config object with the options shown below.

### Returns
(`client`): A React component that runs the app.
Expand All @@ -64,7 +44,21 @@ The component supports the following `props`:
import Client from 'boardgame.io/client';

const App = Client({
...
// The return value of Game().
game: game,

// The number of players.
numPlayers: 2,

// The React component representing your game board.
board: Board,

// Set to true to enable sending move updates to the
// server via WebSockets.
multiplayer: false,

// Set to false to disable the Debug UI.
debug: true
});

ReactDOM.render(<App/>, document.getElementById('app'));
Expand Down
42 changes: 9 additions & 33 deletions docs/api/Game.md
@@ -1,36 +1,5 @@
# Game

```js
Game({
// Initial value of G.
setup: (numPlayers) => ({}),

// Game moves.
moves: {
'moveName': moveFn,
...
},

flow: {
// Determines when the game ends.
endGameIf: (G, ctx) => {
if (IsVictory(G)) {
return ctx.currentPlayer;
}
},

phases: [
// TODO
]
}

// Customized view.
playerView: (G, ctx, player) => {
return G;
},
}
```
Creates a new game implementation described by the initial
game state and the moves.

Expand Down Expand Up @@ -61,6 +30,9 @@ have `action.type` contain the name of the move, and
is customized for a given player. See [Secret State](/secret-state) for more information.
- `flow` (*object*): Arguments to customize the flow of the game. See
[Phases](/phases) for more information.
- `phases` (*array*): Optional list of phases, within which many turns will be played. For example,
you might have a setup phase where players choose starting position followed by a main phase.
See [Phases](/phases) for more information.

### Returns

Expand All @@ -74,14 +46,16 @@ have `action.type` contain the name of the move, and
### Usage

```js
import Game from 'boardgame.io/game';
import { Game } from 'boardgame.io/core';

const game = Game({
// Initial value of G.
setup: (numPlayers) => {
const G = {...};
return G;
},

// Game moves.
moves: {
moveWithoutArgs(G, ctx) {
return {...G, ...};
Expand All @@ -100,8 +74,10 @@ const game = Game({
},
},

playerView: (G, ctx) => {
// View of game state which hides private information (e.g. face-down cards).
playerView: (G, ctx, player) => {
return SecretsRemoved(G, ctx.currentPlayer);
},

});
```
20 changes: 7 additions & 13 deletions docs/api/Server.md
@@ -1,15 +1,5 @@
# Server

```js
Server({
// The return value of Game().
game: game,

// The number of players.
numPlayers: 2,
})
```

Creates a `boardgame.io` server. This is only required when
`multiplayer` is set to `true` on the client. It creates a
[Koa](http://koajs.com/) app that keeps track of the game
Expand All @@ -22,18 +12,22 @@ Notice that `game` is the same object that you also pass
to the `Client` call.

### Arguments
1. obj(*object*): A config object with the options shown above.
1. obj(*object*): A config object with the options shown below.

### Returns
(`app`): A Koa app.

### Usage

```js
const Server = require('boardgame.io/server');
import Server from 'boardgame.io/server';

const app = Server({
...
// The return value of Game().
game: game,

// The number of players.
numPlayers: 2
});

app.listen(8000);
Expand Down

0 comments on commit 4aaee37

Please sign in to comment.