diff --git a/server/classes/deck.js b/server/classes/deck.js index 173a38a..5fe7b52 100644 --- a/server/classes/deck.js +++ b/server/classes/deck.js @@ -1,32 +1,6 @@ class deck { constructor() { - this.words = [ - 0, - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24 - ] + this.words = [] this.redWordIndices = [] this.blueWordIndices = [] this.beigeWordIndices = [] @@ -34,10 +8,51 @@ class deck { } newDeck() { - this.shuffle() + console.log('in newDeck') + this.shuffleWords() + this.shuffleColors() } - shuffle() { + shuffleWords() { + const shuffled = [ + 'a', + 'b', + 'c', + 'd', + 'e', + 'f', + 'g', + 'h', + 'i', + 'j', + 'k', + 'l', + 'm', + 'n', + 'o', + 'p', + 'q', + 'r', + 's', + 't', + 'u', + 'v', + 'w', + 'x', + 'y' + ] + let i = 25 + let index + let temp + while (i--) { + index = Math.floor((i + 1) * Math.random()) + temp = shuffled[index] + shuffled[index] = shuffled[i] + shuffled[i] = temp + } + this.words = shuffled + } + shuffleColors() { const shuffled = [ 0, 1,