Skip to content

Commit

Permalink
Don't disable registration for local instances and fix null room
Browse files Browse the repository at this point in the history
  • Loading branch information
vck3000 committed Jan 26, 2024
1 parent 8435994 commit 8fc942b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,9 @@ class Settings {
}
}

export default new Settings();
const settingsSingleton = new Settings();
if (process.env.ENV != 'prod') {
settingsSingleton.toggleDisableRegistration();
}

export default settingsSingleton;
8 changes: 5 additions & 3 deletions src/sockets/filters/createRoomFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ import GameWrapper from '../../gameplay/gameWrapper';
import { WAITING } from '../../gameplay/game';

export class CreateRoomFilter {
// Returns true if user can chat. Else false.
// Returns true if user can create a room. Else false.
createRoomRequest(username: string, rooms: GameWrapper[]): boolean {
// User cannot make a room if they already have one that is in "waiting" status.
const waitingRooms = rooms.filter((room) => room.getStatus() == WAITING);
const waitingRooms = rooms.filter(
(room) => room && room.getStatus() === WAITING,
);

const sameUserWithWaitingRooms = waitingRooms.filter(
(room) => room.host.toLowerCase() == username.toLowerCase(),
(room) => room.host.toLowerCase() === username.toLowerCase(),
);

return sameUserWithWaitingRooms.length === 0;
Expand Down

0 comments on commit 8fc942b

Please sign in to comment.