Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var Room = require('colyseus').Room;
var State = require('../modules/state').state;
var DataLink = require('../modules/datalink');
var share = require('../../shared/constants');
class GameRoom extends Room
{
onInit(options)
{
this.setState(new State());
}
onAuth(options)
{
if(options.isNewUser){
// the last 3 values are for the default role_id = 1, status = 1 and state = 1:
var Room = require('colyseus').Room
class ChatRoom extends Room {
constructor (options) {
super(options)
// this.useTimeline()
this.setPatchRate(1000 / 192);
this.setState({ messages: [] })
// Call game simulation at 60fps (16.6ms)
this.setSimulationInterval( this.tick.bind(this), 1000 / 60 )
console.log("ChatRoom created!", options)
var Room = require('colyseus').Room
class ChatRoom extends Room {
constructor (options) {
options.updateInterval = 1000
super(options, { messages: [] })
console.log("ChatRoom created!", options)
}
onJoin (client) {
this.sendState(client)
console.log("ChatRoom:", client.id, "connected")
}
onLeave (client) {
// console.log("ChatRoom:", client.id, "disconnected")
this.column = column;
this.row = row;
this.xPos = column * cellSize;
this.yPos = row * cellSize;
this.walls = [true, true, true, true]; // 0 = top, 1 = right, 2 = bottom, 3 = left
this.visited = false; // Whether the cell has been traversed or not
}
const Room = require("colyseus").Room;
export class MazeRoom extends Room {
// this room supports only 4 clients connected
onInit (options) {
this.maxClients = 2;
this.maze = new Maze(23, 35);
this.maze.createMaze();
console.log("BasicRoom created!", options);
this.broadcast(this.maze);
}
onJoin (client) {
this.broadcast(`${ client.sessionId } joined.`);
/**
*
* Reldens - RoomLogin
*
* This room is the base to authenticate every single client join.
* Since we are hitting the storage to validate the client we doing it on each join.
*
*/
// @TODO: - Seiyria - can also do `const { Room } = require('colyseus');
const Room = require('colyseus').Room;
class RoomLogin extends Room
{
onCreate(options)
{
this.config = options.config;
this.loginManager = options.loginManager;
this.validateRoomData = false;
}
async onAuth(client, options, request)
{
if(!options){
return false;
}
var Room = require('colyseus').Room
class BattleRoom extends Room {
constructor (options) {
super(options)
this.setState({})
console.log("BattleRoom created!", options)
}
requestJoin(options) {
return (options.invalid_param != 10)
}
onJoin (client) {
if (this.clients.length == 4) {
this.lock()
var Room = require('colyseus').Room
class BattleRoom extends Room {
constructor (options) {
options.updateInterval = 1100
super(options)
console.log("BattleRoom created!", options)
}
requestJoin(options) {
return (options.invalid_param != 10)
}
onJoin (client) {
if (this.clients.length == 4) {
this.lock()