Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
listen(httpServer, port = 8080, callback = () => {})
{
Assert.integer(port);
Assert.isFunction(callback);
this._gameLoop.start(1000 / 45, this.update.bind(this));
this._httpServer = httpServer;
this._wsServer = new WebsocketServer({ server: this._httpServer });
this._wsServer.on('connection', this.onConnection.bind(this));
this._httpServer.listen(port, () => {
this._logger.info(`Server is listening on port: ${port}`);
callback();
});
}
constructor(name, src, startFrom, rows = 20, columns = 20)
{
Assert.string(name);
Assert.string(src);
Assert.integer(startFrom);
Assert.integer(rows);
Assert.integer(columns);
this._name = name;
this._src = src;
this._startFrom = startFrom;
this._size = rows * columns;
this._rows = rows;
this._columns = columns;
this._img = null;
this._isLoaded = false;
}
constructor(name, src, startFrom, rows = 20, columns = 20)
{
Assert.string(name);
Assert.string(src);
Assert.integer(startFrom);
Assert.integer(rows);
Assert.integer(columns);
this._name = name;
this._src = src;
this._startFrom = startFrom;
this._size = rows * columns;
this._rows = rows;
this._columns = columns;
this._img = null;
this._isLoaded = false;
}
constructor(startX, endX, startY, endY)
{
Assert.integer(startX);
Assert.integer(endX);
Assert.integer(startY);
Assert.integer(endY);
this._startX = startX;
this._endX = endX;
this._startY = startY;
this._endY = endY;
}
constructor(startX, endX, startY, endY)
{
Assert.integer(startX);
Assert.integer(endX);
Assert.integer(startY);
Assert.integer(endY);
this._startX = startX;
this._endX = endX;
this._startY = startY;
this._endY = endY;
}
requiredExp(level)
{
Assert.integer(level);
if (level < 1) {
return 0;
}
return (50 * Math.pow(level - 1, 3) - 150 * Math.pow(level - 1, 2) + 400 * (level - 1)) / 3;
}
_format(number, leadingZeroes) {
Assert.integer(number);
Assert.integer(leadingZeroes);
let s = number + "";
while (s.length < leadingZeroes) {
s = "0" + s
}
return s;
}
}