Skip to content

Commit

Permalink
Reduce limitations on both game room names and usernames. Add time li…
Browse files Browse the repository at this point in the history
…mit on winner selection
  • Loading branch information
JordanPawlett committed Apr 27, 2020
1 parent 3b132fa commit 9e16ef3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions services/clients-service/src/clients-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down Expand Up @@ -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;
}

Expand Down
6 changes: 6 additions & 0 deletions services/games-service/src/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion services/rooms-service/src/rooms-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down

0 comments on commit 9e16ef3

Please sign in to comment.