feat(#5): Add the ability to select pre-defined card sets

This commit is contained in:
Josh Creek
2023-07-30 17:01:00 +01:00
parent 7dd7605aee
commit 236588307b
5 changed files with 108 additions and 28 deletions
+32 -1
View File
@@ -1,12 +1,43 @@
import { WebSocket } from 'ws';
import { User } from './User';
class CardSet {
name: string;
values: Array<string | number>;
example: string;
constructor(name: string, values: Array<string | number>, example: string) {
this.name = name;
this.values = values;
this.example = example;
}
}
export const cardSets: Array<CardSet> = [
{ name: 'Fibonacci', values: [1, 2, 3, 5, 8, 13, 21, '?'], example: '(1, 2, 3, 5)' },
{
name: 'T-Shirt Sizing',
values: ['XS', 'S', 'M', 'L', 'XL', 'XXL', '?'],
example: '(XS, S, M, L)'
},
{ name: 'Powers of 2', values: [1, 2, 4, 8, 16, 32, '?'], example: '(1, 2, 4, 8)' },
{ name: 'Sequential', values: [1, 2, 3, 4, 5, 6, 7, 8, 9, '?'], example: '(1, 2, 3, 4)' }
];
export class Room {
id: string;
cardSet: CardSet;
users: Map<WebSocket, User>;
constructor(id: string) {
constructor(id: string, cardSetName: string) {
this.id = id;
const cardSet = cardSets.find((cardSet) => cardSet.name === cardSetName);
if (cardSet) {
this.cardSet = cardSet;
} else {
this.cardSet = cardSets[0];
}
this.users = new Map();
}