|
| 1 | +import { Client, Room } from 'colyseus' |
| 2 | +import { Dispatcher } from '@colyseus/command' |
| 3 | +import { CountryRoomState } from './schema/game_modes/CountryRoomState' |
| 4 | +import { OnJoinCommand } from '../commands/OnJoinCommand' |
| 5 | +import { OnVoteCommand } from '../commands/OnVoteCommand' |
| 6 | +import { OnLeaveCommand } from '../commands/OnLeaveCommand' |
| 7 | +import { LOBBY_PHASE, ROUND_PREPARE_STATE } from '../constants/game' |
| 8 | +import { OnRoomStartCommand } from '../commands/OnRoomStartCommand' |
| 9 | +import { OnRoomSettingsCommand } from '../commands/OnRoomSettingsCommand' |
| 10 | +import { OnLobbyCommand } from '../commands/OnLobbyCommand' |
| 11 | +import { OnRoomRestartCommand } from '../commands/OnRoomRestartCommand' |
| 12 | +import { OnUserUpdateCommand } from '../commands/OnUserUpdateCommand' |
| 13 | +import { ConnectOptions } from '../constants/clients' |
| 14 | +import { OnUpdateMetadataCommand } from '../commands/OnUpdateMetadataCommand' |
| 15 | +import { |
| 16 | + ROOM_LOBBY, |
| 17 | + ROOM_RESTART, |
| 18 | + ROOM_SETTINGS, |
| 19 | + ROOM_START, |
| 20 | + ROOM_VOTE, |
| 21 | + USER_UPDATE, |
| 22 | +} from '../constants/messages' |
| 23 | +import { LobbyRoomState } from './schema/game_modes/LobbyRoomState' |
| 24 | + |
| 25 | +export class LobbyRoom extends Room<LobbyRoomState> { |
| 26 | + dispatcher = new Dispatcher(this) |
| 27 | + autoDispose = false |
| 28 | + roundTimer = false |
| 29 | + async onCreate(options: any) { |
| 30 | + this.clock.start() |
| 31 | + this.roomId = "lobby"; |
| 32 | + this.autoDispose = false; |
| 33 | + this.maxClients = 9999999999999; |
| 34 | + |
| 35 | + this.setState( |
| 36 | + new LobbyRoomState({ |
| 37 | + |
| 38 | + }) |
| 39 | + ) |
| 40 | + |
| 41 | + this.setPatchRate(1000); |
| 42 | + } |
| 43 | + |
| 44 | + onJoin(client: Client, options: ConnectOptions) { |
| 45 | + this.state.players.set(client.sessionId, true); |
| 46 | + } |
| 47 | + |
| 48 | + onLeave(client: Client, consented: boolean) { |
| 49 | + this.state.players.delete(client.sessionId); |
| 50 | + } |
| 51 | + |
| 52 | + onDispose() {} |
| 53 | +} |
0 commit comments