diff --git a/constants.js b/constants.js index 7e79b754..3f58fe10 100644 --- a/constants.js +++ b/constants.js @@ -65,50 +65,7 @@ const ALTERNATE_SUBCATEGORY_TO_CATEGORY = { }; const ALTERNATE_SUBCATEGORIES_FLATTENED = Object.keys(ALTERNATE_SUBCATEGORY_TO_CATEGORY); -/** - * List of multiplayer permanent room names. - */ -const PERMANENT_ROOMS = [ - { - name: 'hsquizbowl', - categories: CATEGORIES, - subcategories: SUBCATEGORIES_FLATTENED, - }, - { - name: 'collegequizbowl', - categories: CATEGORIES, - subcategories: SUBCATEGORIES_FLATTENED, - }, - { - name: 'literature', - categories: ['Literature'], - subcategories: ['American Literature', 'British Literature', 'Classical Literature', 'European Literature', 'World Literature', 'Other Literature'], - }, - { - name: 'history', - categories: ['History'], - subcategories: ['American History', 'Ancient History', 'European History', 'World History', 'Other History'], - }, - { - name: 'science', - categories: ['Science'], - subcategories: ['Biology', 'Chemistry', 'Physics', 'Other Science'], - }, - { - name: 'fine-arts', - categories: ['Fine Arts'], - subcategories: ['Visual Fine Arts', 'Auditory Fine Arts', 'Other Fine Arts'], - }, - { - name: 'trash', - categories: ['Trash'], - subcategories: ['Trash'], - }, -]; - const COOKIE_MAX_AGE = 1000 * 60 * 60 * 24 * 7; // 7 days -const ROOM_NAME_MAX_LENGTH = 32; -const USERNAME_MAX_LENGTH = 32; const WEBSOCKET_MAX_PAYLOAD = 1024 * 10 * 1; // 10 KB const ADJECTIVES = ['adaptable', 'adept', 'affectionate', 'agreeable', 'alluring', 'amazing', 'ambitious', 'amiable', 'ample', 'approachable', 'awesome', 'blithesome', 'bountiful', 'brave', 'breathtaking', 'bright', 'brilliant', 'capable', 'captivating', 'charming', 'competitive', 'confident', 'considerate', 'courageous', 'creative', 'dazzling', 'determined', 'devoted', 'diligent', 'diplomatic', 'dynamic', 'educated', 'efficient', 'elegant', 'enchanting', 'energetic', 'engaging', 'excellent', 'fabulous', 'faithful', 'fantastic', 'favorable', 'fearless', 'flexible', 'focused', 'fortuitous', 'frank', 'friendly', 'funny', 'generous', 'giving', 'gleaming', 'glimmering', 'glistening', 'glittering', 'glowing', 'gorgeous', 'gregarious', 'gripping', 'hardworking', 'helpful', 'hilarious', 'honest', 'humorous', 'imaginative', 'incredible', 'independent', 'inquisitive', 'insightful', 'kind', 'knowledgeable', 'likable', 'lovely', 'loving', 'loyal', 'lustrous', 'magnificent', 'marvelous', 'mirthful', 'moving', 'nice', 'optimistic', 'organized', 'outstanding', 'passionate', 'patient', 'perfect', 'persistent', 'personable', 'philosophical', 'plucky', 'polite', 'powerful', 'productive', 'proficient', 'propitious', 'qualified', 'ravishing', 'relaxed', 'remarkable', 'resourceful', 'responsible', 'romantic', 'rousing', 'sensible', 'shimmering', 'shining', 'sincere', 'sleek', 'sparkling', 'spectacular', 'spellbinding', 'splendid', 'stellar', 'stunning', 'stupendous', 'super', 'technological', 'thoughtful', 'twinkling', 'unique', 'upbeat', 'vibrant', 'vivacious', 'vivid', 'warmhearted', 'willing', 'wondrous', 'zestful']; @@ -127,10 +84,7 @@ export { ALTERNATE_SUBCATEGORY_TO_CATEGORY, ALTERNATE_SUBCATEGORIES_FLATTENED, SUBCATEGORIES_FLATTENED, - PERMANENT_ROOMS, COOKIE_MAX_AGE, - ROOM_NAME_MAX_LENGTH, - USERNAME_MAX_LENGTH, WEBSOCKET_MAX_PAYLOAD, ADJECTIVES, ANIMALS, diff --git a/server/multiplayer/Player.js b/server/multiplayer/Player.js index cf2947b1..53879a05 100644 --- a/server/multiplayer/Player.js +++ b/server/multiplayer/Player.js @@ -1,4 +1,4 @@ -import { USERNAME_MAX_LENGTH } from '../../constants.js'; +import { USERNAME_MAX_LENGTH } from './constants.js'; class Player { constructor(userId) { diff --git a/server/multiplayer/TossupRoom.js b/server/multiplayer/TossupRoom.js index a9837573..ca8ec6c7 100644 --- a/server/multiplayer/TossupRoom.js +++ b/server/multiplayer/TossupRoom.js @@ -1,8 +1,10 @@ import Player from './Player.js'; +import { PERMANENT_ROOMS, ROOM_NAME_MAX_LENGTH } from './constants.js'; + import RateLimit from '../RateLimit.js'; import { HEADER, ENDC, OKBLUE, OKGREEN } from '../../bcolors.js'; -import { DEFAULT_MIN_YEAR, DEFAULT_MAX_YEAR, PERMANENT_ROOMS, ROOM_NAME_MAX_LENGTH, CATEGORIES, SUBCATEGORIES_FLATTENED, ALTERNATE_SUBCATEGORIES_FLATTENED, SUBCATEGORY_TO_CATEGORY, ALTERNATE_SUBCATEGORY_TO_CATEGORY } from '../../constants.js'; +import { DEFAULT_MIN_YEAR, DEFAULT_MAX_YEAR, CATEGORIES, SUBCATEGORIES_FLATTENED, ALTERNATE_SUBCATEGORIES_FLATTENED, SUBCATEGORY_TO_CATEGORY, ALTERNATE_SUBCATEGORY_TO_CATEGORY } from '../../constants.js'; import getRandomTossups from '../../database/qbreader/get-random-tossups.js'; import getSet from '../../database/qbreader/get-set.js'; import getSetList from '../../database/qbreader/get-set-list.js'; diff --git a/server/multiplayer/constants.js b/server/multiplayer/constants.js new file mode 100644 index 00000000..61484264 --- /dev/null +++ b/server/multiplayer/constants.js @@ -0,0 +1,45 @@ +import { CATEGORIES, SUBCATEGORIES_FLATTENED } from '../../constants.js'; + +export const ROOM_NAME_MAX_LENGTH = 32; +export const USERNAME_MAX_LENGTH = 32; + +/** + * List of multiplayer permanent room names. + */ +export const PERMANENT_ROOMS = [ + { + name: 'hsquizbowl', + categories: CATEGORIES, + subcategories: SUBCATEGORIES_FLATTENED, + }, + { + name: 'collegequizbowl', + categories: CATEGORIES, + subcategories: SUBCATEGORIES_FLATTENED, + }, + { + name: 'literature', + categories: ['Literature'], + subcategories: ['American Literature', 'British Literature', 'Classical Literature', 'European Literature', 'World Literature', 'Other Literature'], + }, + { + name: 'history', + categories: ['History'], + subcategories: ['American History', 'Ancient History', 'European History', 'World History', 'Other History'], + }, + { + name: 'science', + categories: ['Science'], + subcategories: ['Biology', 'Chemistry', 'Physics', 'Other Science'], + }, + { + name: 'fine-arts', + categories: ['Fine Arts'], + subcategories: ['Visual Fine Arts', 'Auditory Fine Arts', 'Other Fine Arts'], + }, + { + name: 'trash', + categories: ['Trash'], + subcategories: ['Trash'], + }, +];