0
0
Fork 0

Protect against attempting to draw 0 cards

This commit is contained in:
Oliver-Akins 2021-01-26 16:12:55 -07:00
parent 4d885ea36b
commit 7e12fa253a

View file

@ -24,9 +24,14 @@ export default (io: Server, socket: Socket, data: SendCard) => {
// Draw new cards for team // Draw new cards for team
deck.discard(data.text); deck.discard(data.text);
team.addCardsToHand(game.questions.draw(conf.game.hand_size - team.hand.length));
team.selectQuestion(data.text); team.selectQuestion(data.text);
// Get any additional cards needed
let needed_cards = conf.game.hand_size - team.hand.length;
if (needed_cards > 0) {
team.addCardsToHand(game.questions.draw(needed_cards));
};
socket.emit(`UpdateHand`, { socket.emit(`UpdateHand`, {
status: 200, status: 200,
mode: "replace", mode: "replace",