From 9e16ef3161a1968a78179de2c52b4d6bbee46777 Mon Sep 17 00:00:00 2001 From: Jordan Pawlett Date: Mon, 27 Apr 2020 21:52:57 +0100 Subject: [PATCH] Reduce limitations on both game room names and usernames. Add time limit on winner selection --- services/clients-service/src/clients-service.ts | 4 ++-- services/games-service/src/game.ts | 6 ++++++ services/rooms-service/src/rooms-service.ts | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/services/clients-service/src/clients-service.ts b/services/clients-service/src/clients-service.ts index 3e43c633..5862fa72 100644 --- a/services/clients-service/src/clients-service.ts +++ b/services/clients-service/src/clients-service.ts @@ -54,7 +54,7 @@ export default class ClientsService extends Service { */ private validationSchema = { _id: { type: 'string' }, - username: { type: 'string', pattern: '^[a-zA-Z0-9]+([_ -]?[a-zA-Z0-9])*$', min: 4, max: 12 }, + username: { type: 'string', pattern: '^[a-zA-Z0-9]+([_ -]?[a-zA-Z0-9])*$', min: 3, max: 12 }, socket: { type: 'string', optional: true }, roomId: { type: 'string', optional: true }, disconnectedAt: { type: 'number', optional: true, default: null } @@ -151,7 +151,7 @@ export default class ClientsService extends Service { * @memberof ClientsService */ private isUsernameValid(username: string): boolean { - if (username.length < 4 || username.length > 12) { + if (username.length < 3 || username.length > 12) { return false; } diff --git a/services/games-service/src/game.ts b/services/games-service/src/game.ts index 2dc81385..2c477b16 100644 --- a/services/games-service/src/game.ts +++ b/services/games-service/src/game.ts @@ -190,6 +190,12 @@ export default class Game extends TurnHandler { this.lastGameState = initialData; await this.broker.emit('games.updated', initialData); + + // If the czar doesn't pick a winner within 60 seconds. Move on. + // should handle a "no winner selected state" + this.gameInterval = setTimeout(() => { + this.handleNextTurn(); + }, 60 * 1000); } private setGameTimer() { diff --git a/services/rooms-service/src/rooms-service.ts b/services/rooms-service/src/rooms-service.ts index 1099c50a..4ebd3197 100644 --- a/services/rooms-service/src/rooms-service.ts +++ b/services/rooms-service/src/rooms-service.ts @@ -60,7 +60,7 @@ export default class RoomsService extends Service { host: 'string', players: { type: 'array', items: 'string', default: [] }, spectators: { type: 'array', items: 'string', default: [] }, - name: { type: 'string', pattern: '^[a-zA-Z0-9]+([_ -]?[a-zA-Z0-9])*$', min: 4, max: 12 }, + name: { type: 'string', pattern: '^[a-zA-Z0-9]+([_ -]?[a-zA-Z0-9])*$', min: 2, max: 16 }, status: { type: 'enum', values: ['pending', 'started', 'finished'], default: 'pending' }, options: { type: 'object', strict: true, props: {