diff --git a/server/README.md b/server/README.md index aa38053..b997449 100644 --- a/server/README.md +++ b/server/README.md @@ -2,17 +2,17 @@ 1. `cd` into this `server` directory. 2. Run `pnpm install` to install all of the required dependencies. 3. Create a copy of the `template.toml` file, and name it `server.toml`. -4. Edit the `server.toml` file to adjust the +4. Edit the `server.toml` file to adjust the server and game settings. 5. Run `tsc` to compile the TypeScript into Javascript. This should create a `dist` directory. -## Using systemd to manage the server: (Not currently implemented) +## Using systemd to manage the server: This app comes with a `ghost-writer.service` file which is already set up to manage the server, it just requires a little bit of additional setup. If you change any of the symlinking in the steps below, it is your responsibility to figure it out, I will not guarantee support for people who attempt to modify -the service file. +the service file beyond the steps below. 6. Create a symlink named `server` in the server root (`/`) pointing to the server folder in the Ghost Writer git repository. diff --git a/server/src/events/NewHand.ts b/server/src/events/NewHand.ts index 7acb880..51a04be 100644 --- a/server/src/events/NewHand.ts +++ b/server/src/events/NewHand.ts @@ -36,7 +36,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(handSize)); game.log.silly(`Drew a new hand of cards for team ${data.team}.`); - io.to(game.id).emit(`UpdateHand`, { + io.to(`${game.id}:${team.id}:guesser`).emit(`UpdateHand`, { status: 200, mode: `replace`, questions: team.hand, diff --git a/server/src/events/SendCard.ts b/server/src/events/SendCard.ts index 67aae24..6b040d7 100644 --- a/server/src/events/SendCard.ts +++ b/server/src/events/SendCard.ts @@ -6,7 +6,7 @@ export default (io: Server, socket: Socket, data: SendCard) => { // Assert game exists if (!games[data.game_code]) { - log.debug(`Can't send a card in a game that doesn't exist: ${data.game_code}`); + log.debug(`Can't fing a game with code: ${data.game_code}`); socket.emit(`UpdateHand`, { status: 404, message: `Game with code ${data.game_code} could not be found`, @@ -20,7 +20,7 @@ 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); @@ -42,7 +42,7 @@ export default (io: Server, socket: Socket, data: SendCard) => { // The writer is sending the card to the writer else if (data.from === "guesser") { - game.log.debug(`Guesser is sending a card to the writer.`); + game.log.debug(`Guesser is sending a card to the writer`); // Update the team's hand team.removeCard(data.text); diff --git a/server/template.toml b/server/template.toml index ca45d4b..8e4e5f1 100644 --- a/server/template.toml +++ b/server/template.toml @@ -35,6 +35,9 @@ key = '' # directory of the CLI instantiating the server. (or an absolute path) # - If "type" is "sheets", then this is a sheet identifier used by Google # Sheets to indicate which sheet to use when downloading the content. +# In the published URL, this is the sequence of number between the +# `gid=` and the `&`, so if the URL has `gid=123456789&`, the fingerprint +# would be `123456789`. fingerprint = '' # The zero-indexed column number to use when getting the question text. @@ -46,6 +49,9 @@ column = 0 # directory of the CLI instantiating the server. (or an absolute path) # - If "type" is "sheets", then this is a sheet identifier used by Google # Sheets to indicate which sheet to use when downloading the content. +# In the published URL, this is the sequence of number between the +# `gid=` and the `&`, so if the URL has `gid=123456789&`, the fingerprint +# would be `123456789`. fingerprint = '' diff --git a/web/src/components/GameBoard.vue b/web/src/components/GameBoard.vue index 3780643..7136a7f 100644 --- a/web/src/components/GameBoard.vue +++ b/web/src/components/GameBoard.vue @@ -13,7 +13,7 @@ v-for="answerIndex in 8" :class="[ `answer`, - answers[`team_${3 - $store.state.team}`][answerIndex-1].toLowerCase() === getObject + answers[`team_${3 - $store.state.team}`][answerIndex-1].toLowerCase().match(getObject) ? `correct`: `` ]" :key="`${otherTeamID}-answer-container-${answerIndex}`" @@ -58,7 +58,7 @@ v-for="answerIndex in 8" :class="[ `answer`, - answers[`team_${$store.state.team}`][answerIndex-1].toLowerCase() === getObject + answers[`team_${$store.state.team}`][answerIndex-1].toLowerCase().match(getObject) ? `correct`: `` ]" :key="`${teamID}-answer-container-${answerIndex}`" @@ -109,7 +109,7 @@ import PastQuestions from './PastQuestions'; export default { name: `GameBoard`, components: { - "past-questions": PastQuestions + "past-questions": PastQuestions, }, data() {return { visible: false, @@ -126,9 +126,9 @@ export default { }, getObject() { if (!this.$store.state.chosen_object) { - return ``; + return /\n/; }; - return this.$store.state.chosen_object.toLowerCase() + `.`; + return new RegExp(`${this.$store.state.chosen_object.toLowerCase()}\\.?`); }, }, methods: { diff --git a/web/src/components/Hand.vue b/web/src/components/Hand.vue index b68e3d5..7a31aa8 100644 --- a/web/src/components/Hand.vue +++ b/web/src/components/Hand.vue @@ -73,10 +73,11 @@ export default { }, gameOver() { if (this.$store.state.chosen_object) { - let targetAnswer = this.$store.state.chosen_object.toLowerCase()+`.`; + let answerRegex = new RegExp(`${this.$store.state.chosen_object.toLowerCase()}\\.?`); + for (var team in this.$store.state.answers) { for (var answer of this.$store.state.answers[team]) { - if (answer.toLowerCase() === targetAnswer) { + if (answer.toLowerCase().match(answerRegex)) { return true; }; }; diff --git a/web/src/components/PlayerList.vue b/web/src/components/PlayerList.vue index 6ab57bd..483270a 100644 --- a/web/src/components/PlayerList.vue +++ b/web/src/components/PlayerList.vue @@ -2,13 +2,10 @@

Players:

{{ player.name }} - - ( {{ teamName(player.team) }} {{ roleName(player.role) }} ) -
@@ -22,7 +19,9 @@ export default { return this.$store.state.is_host; }, players() { - return this.$store.state.players; + return this.$store.state.players.filter( + p => p.role == null && p.team == null + ); }, gameCode() { return this.$store.state.game_code; diff --git a/web/src/components/TeamRoleSelect.vue b/web/src/components/TeamRoleSelect.vue index eb8ea41..c6cc8d1 100644 --- a/web/src/components/TeamRoleSelect.vue +++ b/web/src/components/TeamRoleSelect.vue @@ -7,12 +7,31 @@ > {{ $store.state.writer_name }} +
+
+ {{ player.name }} +
+
+
+
+
+ {{ player.name }} +
+
@@ -29,7 +48,17 @@ export default { computed: { teamName() { return this.$store.state[`team_${this.teamID}`].name; - } + }, + writers() { + return this.$store.state.players.filter( + p => p.team === this.teamID && p.role === `writer` + ); + }, + guessers() { + return this.$store.state.players.filter( + p => p.team === this.teamID && p.role === `guesser` + ); + }, }, methods: { joinRole(role) { @@ -81,6 +110,10 @@ export default { width: 25%; } +hr { + width: 90%; +} + button { background-color: var(--background3); color: var(--background3-text); diff --git a/web/src/css/theme.css b/web/src/css/theme.css index 7c60758..e437fca 100644 --- a/web/src/css/theme.css +++ b/web/src/css/theme.css @@ -73,8 +73,8 @@ --confirm-background-darken: #006600; --confirm-background-lighten: #00aa00; --confirm-text: white; - --cancel-background: #aa0000; - --cancel-background-darken: #830101; - --cancel-background-lighten: #e71111; + --cancel-background: #c94a4a; + --cancel-background-darken: #a54141; + --cancel-background-lighten: #fa7d7d; --cancel-text: white; } \ No newline at end of file