import {Room} from "../room" import {Client} from "../client" export class ServerGame { room: Room; settings: Settings.Global; game: any; constructor(room: Room, settings: Settings.Global) { this.settings = settings; this.room = room; this.room.clients.forEach(c => this.addClient(c)) } addClient(client: Client): void { this.setEvents(client) } removeClient(client: Client): void { this.removeEvents(client) } gameAction(action: string, ...args: any[]): void { } setEvents(client: Client): void { let socket = client.socket; socket.on('game-action', (action, ...args) => this.gameAction(action, ...args)) } removeEvents(client: Client): void { let socket = client.socket; socket.removeAllListeners('game-action') } }