mirror of
https://github.com/jcreek/EstimationPoker.git
synced 2026-07-13 02:53:46 +00:00
feat(#5): Add the ability to select pre-defined card sets
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user