This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var async = require('asyncawait/async'), | |
await = require('asyncawait/await'), | |
fs = require('fs'); | |
function read(path) { | |
return function(done) { | |
fs.readFile(path, 'utf8', done); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* get random event | |
* | |
* format: array('event1' => 'chance1', 'event2' => 'chance2', ...) | |
* | |
* @param array $events | |
* @return string | |
*/ | |
public function randomEvent(array $events) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'), | |
app = express(); | |
app.get('/', function(req, res) { | |
res.header('Content-Type', 'application/json; charset=utf-8'); | |
res.send('{\"Status\":1}'); | |
}); | |
app.post('/Services/UserService.svc/login', function(req, res) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Q = require('q'); | |
/** | |
* @param {Array} [data] | |
* @constructor | |
*/ | |
function AsyncAray(data) { | |
this._data = data || []; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
player:1 connection +0ms | |
player:2 connection +2s | |
game:1 start +1ms | |
player:1 send: {"type":"state","data":[1,1,1,1,1,1,2,2,1,0,1,1,2,1,2,1,0,1,2,2,2,1,1,2,2,2,1,1,1,2]} +0ms | |
player:2 send: {"type":"state","data":[1,1,1,1,1,1,2,2,1,0,1,1,2,1,2,1,0,1,2,2,2,1,1,2,2,2,1,1,1,2]} +2ms | |
player:3 connection +23s | |
player:1 disconnection +19s | |
game:1 finish +1ms | |
player:2 send: {"type":"result","data":1} +0ms | |
player:4 connection +541ms |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var protoify = require('../lib/protoify'), | |
started; | |
started = Date.now(); | |
var m = protoify.encode({ getConnectionMessage: { token: 'qqweqweqweqwe' } }); | |
console.log(m); | |
console.log('time taken %s', started - Date.now()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Game.prototype.hasCombo = function() { | |
for (var index = 0, l = this.state.length; index < l; index++) { | |
var combo = [], | |
skip = [], | |
current, | |
next; | |
current = index; | |
while (true) { | |
combo.push(current); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"env": { | |
"node": true | |
}, | |
"globals": { | |
"require": true, | |
"describe": true, | |
"context": true, | |
"it": true, | |
"before": true, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @param {{ gameId: string, userId: string }} data | |
* @param {Function} done | |
* @returns {*} | |
*/ | |
connectionMessage: async.cps(function(data) { | |
var user = await(ApiUser.findOne.bind(ApiUser, { _id: data.userId })), | |
apiGame = await(ApiGame.findOne.bind(ApiGame, { _id: data.gameId })); | |
try { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @param {{ gameId: string, userId: string }} data | |
* @param {Function} done | |
* @returns {*} | |
*/ | |
connectionMessage: function(data, done) { | |
var that = this; | |
async.waterfall([ | |
function(next) { |
OlderNewer