Skip to content

Commit

Permalink
fixed shuffle for new deck
Browse files Browse the repository at this point in the history
  • Loading branch information
kateyphi committed Nov 26, 2019
1 parent 7f86bfa commit f0c3434
Showing 1 changed file with 44 additions and 29 deletions.
73 changes: 44 additions & 29 deletions server/classes/deck.js
Original file line number Diff line number Diff line change
@@ -1,43 +1,58 @@
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 = []
this.greyWordIndices = []
}

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,
Expand Down

0 comments on commit f0c3434

Please sign in to comment.