diff --git a/.gitignore b/.gitignore index cbbc451..fe15919 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,8 @@ server/dist/* server/resources/* *.log *.sh +test.* +*.ignore* #=============================================================================# # The files that were auto-generated into a .gitignore by Vue-cli diff --git a/server/src/events/ResetGame.ts b/server/src/events/ResetGame.ts index a39c0b0..dad75bb 100644 --- a/server/src/events/ResetGame.ts +++ b/server/src/events/ResetGame.ts @@ -15,7 +15,7 @@ export default (io: Server, socket: Socket, data: ResetGame) => { let game = games[data.game_code]; game.log.info(`Resetting game`); - game.teams.forEach(t => t.resetHand()); + game.teams.forEach(t => t.reset()); game.questions.reset(); game.resetObject(); game.ingame = false; diff --git a/server/src/events/SendCard.ts b/server/src/events/SendCard.ts index 6b040d7..380c5b6 100644 --- a/server/src/events/SendCard.ts +++ b/server/src/events/SendCard.ts @@ -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", diff --git a/server/src/events/StartGame.ts b/server/src/events/StartGame.ts index 14580e9..31505bb 100644 --- a/server/src/events/StartGame.ts +++ b/server/src/events/StartGame.ts @@ -27,8 +27,8 @@ export default (io: Server, socket: Socket, data: StartGame) => { }; // Ensure the questions deck got populated - if (game.questions.size <= 0) { - game.log.error(`Questions deck has no cards before the game started.`); + if (game.questions?.size <= 0) { + game.log.error(`The questions deck has no cards in the deck.`); socket.emit(`GameStarted`, { status: 507, message: `Questions deck failed to parse, try again in a few seconds or start a new game.`, diff --git a/server/src/objects/Team.ts b/server/src/objects/Team.ts index 668c820..da5f1f3 100644 --- a/server/src/objects/Team.ts +++ b/server/src/objects/Team.ts @@ -36,11 +36,13 @@ export class Team { }; - public resetHand(): void { + public reset(): void { /** - * Removes all the cards from the guesser's hand + * Resets all the per-game data related to this team */ this._hand = []; + this._questions = []; + this._answers = new Array(8).fill(``); } diff --git a/web/src/components/Hand.vue b/web/src/components/Hand.vue index 235153e..1350b42 100644 --- a/web/src/components/Hand.vue +++ b/web/src/components/Hand.vue @@ -28,6 +28,12 @@ :key="`card_${cardIndex}`" @click.self="handleCardClick(cardIndex)" > + + {{ cardIndex }} +

{{ questions[cardIndex - 1] }}

@@ -66,7 +72,7 @@ export default { return this.$store.state.writer_card_button; } else { return `Unknown Role`; - } + }; }, questions() { return this.$store.state.questions; @@ -85,6 +91,15 @@ export default { }; return false; }, + multipleGuessersOnTeam() { + let player_count = 0; + for (var player of this.$store.state.players) { + if (player.team === this.$store.state.team && this.userRole === player.role) { + player_count++; + }; + }; + return player_count > 1; + }, }, methods: { sendCard(cardIndex) { @@ -201,11 +216,18 @@ export default { flex-direction: column; width: calc(100% / 9); border-radius: 10px; + position: relative; padding: 10px; display: flex; height: 80%; } +.card-id { + position: absolute; + left: 5px; + top: 5px; +} + .card-text { flex-grow: 1; }