diff --git a/client/components/Hand.js b/client/components/Hand.js
index a0078da..bce8582 100644
--- a/client/components/Hand.js
+++ b/client/components/Hand.js
@@ -5,7 +5,8 @@ export default class Hand extends React.Component {
constructor(props) {
super(props)
this.state = {
- clue: ''
+ clue: '',
+ clueNum: ''
}
this.handleChange = this.handleChange.bind(this)
this.giveClue = this.giveClue.bind(this)
@@ -14,7 +15,12 @@ export default class Hand extends React.Component {
giveClue = evt => {
evt.preventDefault()
- socket.emit('give clue', this.props.room, this.state.clue)
+ socket.emit(
+ 'give clue',
+ this.props.room,
+ this.state.clue,
+ this.state.clueNum
+ )
}
handleChange(evt) {
@@ -41,14 +47,22 @@ export default class Hand extends React.Component {
onChange={this.handleChange}
value={this.state.clue}
/>
+ Number:
+
Submit
)
} else {
return (
- Your codemaster gave the clue {this.props.currentClue.clue} Please
- select your guesses.{' '}
+ Your codemaster gave the clue {this.props.currentClue.clue} for{' '}
+ {this.props.currentClue.clueNum}. Please select your guesses.{' '}
Change turn
@@ -68,7 +82,8 @@ export default class Hand extends React.Component {
return (
Player {this.props.currentClue.player} gave the clue{' '}
- {this.props.currentClue.clue} Waiting for{' '}
+ {this.props.currentClue.clue} for {this.props.currentClue.clueNum}.
+ Waiting for the
{this.props.currentPlayer.team} {this.props.currentPlayer.role} to
submit their guesses.
diff --git a/server/classes/deck.js b/server/classes/deck.js
index 173a38a..5467614 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,52 @@ class deck {
}
newDeck() {
- this.shuffle()
+ console.log('in newDeck')
+ this.shuffleWords()
+ this.shuffleColors()
}
- shuffle() {
+ // will need to populate the array below with a randomized selection of 25 words.
+ 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,
diff --git a/server/socket/index.js b/server/socket/index.js
index 9fba209..40306df 100644
--- a/server/socket/index.js
+++ b/server/socket/index.js
@@ -64,11 +64,12 @@ module.exports = io => {
socket.emit('guesser view', rooms[roomName].deck.words)
})
- socket.on('give clue', (roomName, clue) => {
+ socket.on('give clue', (roomName, clue, clueNum) => {
const {player} = rooms[roomName].players.filter(
client => client.id === socket.id
)[0]
rooms[roomName].boardstate.currentClue.clue = clue
+ rooms[roomName].boardstate.currentClue.clueNum = clueNum
rooms[roomName].boardstate.currentClue.player = player
rooms[roomName].boardstate.activePlayer =
rooms[roomName].boardstate.activePlayer % 4 + 1