From 633267316026bda883472bee1c998014e34e15f3 Mon Sep 17 00:00:00 2001 From: Oliver-Akins Date: Thu, 7 Jan 2021 11:22:32 -0700 Subject: [PATCH] Close #32 -> Hand Discarding Size Increase --- server/src/events/NewHand.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/server/src/events/NewHand.ts b/server/src/events/NewHand.ts index 710abf4..cd41e3d 100644 --- a/server/src/events/NewHand.ts +++ b/server/src/events/NewHand.ts @@ -1,4 +1,4 @@ -import { conf, games, log } from '../main'; +import { games, log } from '../main'; import { Server, Socket } from 'socket.io'; export default (io: Server, socket: Socket, data: NewHand) => { @@ -18,6 +18,13 @@ export default (io: Server, socket: Socket, data: NewHand) => { let team = game.teams[data.team - 1]; let deck = game.questions; + /** + * The amount of cards that the team has in their hand prior to + * discarding all of their hand, this is used to make sure that they + * get back the same number of cards that they had in their hand. + */ + let handSize = team.hand.length; + // Empty the medium's hand to the discard pile so we know where the // cards are. for (var card of team.hand) { @@ -27,7 +34,7 @@ export default (io: Server, socket: Socket, data: NewHand) => { }; // Add the questions and then alert the game clients about the changes - team.addCardsToHand(deck.draw(conf.game.hand_size)); + team.addCardsToHand(deck.draw(handSize)); game.log.silly(`Drew a new hand of cards for team ${data.team}.`); io.to(game.id).emit(`UpdateHand`, { status: 200,