From ee16218c18ba4b76ec4c04d75f8eb4e64cf4456b Mon Sep 17 00:00:00 2001 From: Oliver-Akins Date: Tue, 5 Jan 2021 14:20:54 -0700 Subject: [PATCH] Draw new cards for a team when the spirit selects a card to answer rather than right when the medium sends the card to the spirit. --- server/src/events/SendCard.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/server/src/events/SendCard.ts b/server/src/events/SendCard.ts index 6947d5d..ddda9ad 100644 --- a/server/src/events/SendCard.ts +++ b/server/src/events/SendCard.ts @@ -20,8 +20,11 @@ export default (io: Server, socket: Socket, data: SendCard) => { // The writer is answering if (data.from === "writer") { - game.log.debug(` Writer selected question to answer.`); + game.log.debug(`Writer selected question to answer.`); + + // Draw new cards for team deck.discard(data.text); + team.addCardsToHand(game.questions.draw(conf.game.hand_size - team.hand.length)); team.selectQuestion(data.text); socket.emit(`UpdateHand`, { @@ -29,6 +32,11 @@ export default (io: Server, socket: Socket, data: SendCard) => { mode: "replace", questions: [] }); + io.to(`${game.id}:${team.id}:guesser`).emit(`UpdateHand`, { + status: 200, + mode: "replace", + questions: team.hand + }); return; } @@ -38,7 +46,6 @@ export default (io: Server, socket: Socket, data: SendCard) => { // Update the team's hand team.removeCard(data.text); - team.addCardsToHand(game.questions.draw(conf.game.hand_size - team.hand.length)); // send the question text to the writer player io.to(`${game.id}:${team.id}:writer`).emit(`UpdateHand`, {