Comparing version 0.0.2-alpha to 0.0.3-alpha
@@ -6,5 +6,5 @@ const yo = require('yo-yo') | ||
function Board ({ boardState, symbols, readOnly, onCellSelect }) { | ||
function Board ({ props, symbols, readOnly, onCellSelect }) { | ||
return yo`<div class="Board"> | ||
${boardState.map((cell, index) => | ||
${props.map((cell, index) => | ||
yo`<label for="board_${index}"> | ||
@@ -50,3 +50,3 @@ ${cell === '' ? '' : symbols[cell]} | ||
${props.board ? Board({ | ||
boardprops: props.board, | ||
props: props.board, | ||
symbols: props.playersSymbols, | ||
@@ -71,5 +71,2 @@ readOnly: !props.isMyTurn || props.winner, | ||
const el = Game() | ||
document.body.appendChild(el) | ||
const actions = plugplay({ | ||
@@ -80,1 +77,4 @@ serverUrl: 'localhost:3000', | ||
}) | ||
const el = Game() | ||
document.body.appendChild(el) |
{ | ||
"name": "plugplay", | ||
"version": "0.0.2-alpha", | ||
"version": "0.0.3-alpha", | ||
"description": "Plug-and-play solution for multiplayer games using WebSockets", | ||
"repository": {}, | ||
@@ -10,3 +11,3 @@ "author": "Maciek Pekala <m@peka.la>", | ||
"watch-client": "watchify example/index.client.js -o example/bundle.js", | ||
"start": "node example/index.server.js" | ||
"start": "nodemon example/index.server.js" | ||
}, | ||
@@ -22,2 +23,3 @@ "dependencies": { | ||
"jest": "^19.0.2", | ||
"nodemon": "^1.11.0", | ||
"standard": "^9.0.1", | ||
@@ -24,0 +26,0 @@ "watchify": "^3.9.0", |
{ | ||
"name": "plugplay-plugin-players", | ||
"version": "0.0.0", | ||
"version": "0.0.1-alpha", | ||
"main": "server.js", | ||
@@ -5,0 +5,0 @@ "repository": {}, |
{ | ||
"name": "plugplay-plugin-rooms", | ||
"version": "0.0.0", | ||
"version": "0.0.1-alpha", | ||
"main": "server.js", | ||
@@ -5,0 +5,0 @@ "repository": {}, |
# plugplay | ||
<img align="right" src="./logo.jpg"> | ||
Framework for building multiplayer games using WebSockets | ||
Plug-and-play solution for multiplayer games using WebSockets. | ||
## Server | ||
Server component is a node application responsible for managing global game state and WebSocket connections. | ||
Server component is a node application responsible for managing global game state and WebSocket connections. It's | ||
basically a Redux application running on the server. | ||
@@ -26,5 +27,6 @@ ### Example | ||
### API | ||
The server component exposes one function as a default export. Calling the function starts the server. | ||
The server component exposes one function as a default export. Calling the function starts the server and returns a | ||
dispatch function that can be used to dispatch actions to the reducers. | ||
```javascript | ||
plugplay(options: OptionsObject) => void | ||
plugplay(options: OptionsObject) => dispatch: (action: Object) => any | ||
``` | ||
@@ -138,2 +140,33 @@ The `OptionsObject` has the following shape: | ||
... TODO | ||
You can extend the functionality provided by plugplay using plugins. Plugins can do one or more of these things: | ||
- modify a subtree of the state, named after the plugin's name | ||
- dispatch actions to the state, namespaced by the plugin's name | ||
- decorate the payload of actions dispatched by other plugins or plugplay's core | ||
- decorate the `clientInfo` object provided to `mapStateToClientProps` function | ||
- extend action creators object on the client | ||
- any other side effects on both server and client (e.g. persistance of data) | ||
### Existing plugins | ||
See documentation for each to learn how to use them: | ||
- [players](plugins/players) - adds a notion of players | ||
- [rooms](plugins/rooms) - adds an ability to create rooms, which players can join | ||
### Creating plugins | ||
The following only concerns plugins developers, and is not required to know to make games with `plugplay`. | ||
#### Server API | ||
Server-side, plugins expose a factory function, which can be used to customize plugin's behaviour using options. | ||
The factory function returns an instance of the plugin, which should passed to `plugplay` using `plugins` | ||
array in options. | ||
```javascript | ||
pluginFactory(options: Object) => pluginInstance: PluginInstanceObject | ||
``` | ||
```javascript | ||
PluginInstanceObject: { | ||
name: string, | ||
middleware: (store: Object) => (next: () => void) => (action: Object) => void, | ||
reducer: (state: Object, action: Object) => nextState: Object, | ||
addClientOptions (state: Object, clientInfo: Object) => decoratedClientInfo: Object, | ||
} | ||
``` |
@@ -12,3 +12,3 @@ const redux = require('redux') | ||
const clientActionMiddleware = store => next => action => { | ||
if (action.type === '@@_ SOCKET_DATA' && action.payload.event === 'player action') { | ||
if (action.type === '@@_SOCKET_DATA' && action.payload.event === 'player action') { | ||
next({ | ||
@@ -94,4 +94,6 @@ type: 'USER_ACTION', | ||
}) | ||
return store.dispatch.bind(store) | ||
} | ||
module.exports = main |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
189550
18
517
170
0
6