Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function expired(player) {
var max, vel = options.speed;
max = Math.max.apply(Math, Object.keys(player));
// distance travelled is greater than the board, plus latency
return (Gun.time.is() - (max + options.latency)) * vel > 700;
}
module.exports = function find(player) {
var coord, position;
coord = sort(player);
coord = coord[coord.length - 1];
// if the player has no history
if (!coord) {
return null;
}
// don't mutate the last position, make a copy
position = Gun.obj.copy(coord);
position[coord.axis] = distance(coord);
position.time = Gun.time.is();
return position;
};
module.exports = function (number) {
var start, color, time = Gun.time.is();
player.db = players.db.path(number).put({});
player.index = number;
player.object = players.list[number];
// get the player starting point
start = position(number);
player.db.path(time).stringify(start);
// give the player a chance to escape
invincible.player(player.index, true);
};
/*jslint nomen: true, node: true */
'use strict';
var handshake = require('../lib/handshake');
var peers = require('../lib/peers');
var SimplePeer = require('simple-peer');
var Gun = require('gun/gun');
var local = require('./local');
Gun.time.now = function () {
return new Date().getTime();
};
Gun.on('opt').event(function (gun, opt) {
opt = opt || {};
var support, browser, wire, rtc = opt.rtc;
support = SimplePeer.WEBRTC_SUPPORT;
browser = typeof window !== 'undefined';
if (rtc === false || (!support && browser)) {
return;
}
if (!peers.db) {
peers.db = new Gun({
Gun.time.is = function () {
return Gun.time.is() + Math.round(diff);
};
module.exports = function (direction) {
var time, turn, position;
position = find(local.player.object);
if (!position) {
return;
}
turn = extract(direction);
time = Gun.time.is();
if (position.axis === turn.axis) {
return;
}
local.player.db.path(time).stringify(turn);
};
function distance(coord) {
var delta, elapsed = Gun.time.is() - coord.time;
delta = (elapsed * options.speed) * coord.direction;
return delta + coord[coord.axis];
}
}).on(function (msg) {
if (msg.recieved && !processed) {
processed = true;
var now, latency, diff;
now = Gun.time.is();
latency = (now - msg.sent) / 2;
diff = now - (msg.recieved + latency);
Gun.time.is = function () {
return Gun.time.is() + Math.round(diff);
};
(callback || function () {})();
}
});
module.exports = function (callback) {
var adjustment = gun.put({
sent: Gun.time.is()
}).on(function (msg) {
if (msg.recieved && !processed) {
processed = true;
var now, latency, diff;
now = Gun.time.is();
latency = (now - msg.sent) / 2;
diff = now - (msg.recieved + latency);
Gun.time.is = function () {
return Gun.time.is() + Math.round(diff);
};
(callback || function () {})();