Skip to content

Instantly share code, notes, and snippets.

View i-van's full-sized avatar
🇺🇦

Ivan Nosov i-van

🇺🇦
View GitHub Profile
var async = require('asyncawait/async'),
await = require('asyncawait/await'),
fs = require('fs');
function read(path) {
return function(done) {
fs.readFile(path, 'utf8', done);
}
}
/**
* get random event
*
* format: array('event1' => 'chance1', 'event2' => 'chance2', ...)
*
* @param array $events
* @return string
*/
public function randomEvent(array $events)
{
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) {
var Q = require('q');
/**
* @param {Array} [data]
* @constructor
*/
function AsyncAray(data) {
this._data = data || [];
}
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
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());
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);
{
"env": {
"node": true
},
"globals": {
"require": true,
"describe": true,
"context": true,
"it": true,
"before": true,
/**
* @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 {
/**
* @param {{ gameId: string, userId: string }} data
* @param {Function} done
* @returns {*}
*/
connectionMessage: function(data, done) {
var that = this;
async.waterfall([
function(next) {