Protect against attempting to draw 0 cards
This commit is contained in:
parent
4d885ea36b
commit
7e12fa253a
1 changed files with 6 additions and 1 deletions
|
|
@ -24,9 +24,14 @@ export default (io: Server, socket: Socket, data: SendCard) => {
|
|||
|
||||
// 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);
|
||||
|
||||
// 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`, {
|
||||
status: 200,
|
||||
mode: "replace",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue