From dce1797bf315b0df25f4215ede6e397717ea9101 Mon Sep 17 00:00:00 2001 From: antoinezanardi Date: Thu, 30 Jul 2020 11:59:40 +0200 Subject: [PATCH 01/10] feat(Game): Starting Game events --- CHANGELOG.md | 12 ++ package-lock.json | 91 ++++++----- package.json | 9 +- src/classes/GameEvent.js | 19 +++ .../Game/GameContent/GameContent.vue | 89 +++++++++-- .../GamePlayField/GamePlayField.vue | 49 ++++++ .../DelegatePlayField.vue | 8 +- .../GamePlayFieldContent}/EatPlayField.vue | 8 +- .../ElectSheriffPlayField.vue | 4 +- .../GamePlayFieldContent.vue} | 4 +- .../GamePlayFieldContent}/LookPlayField.vue | 8 +- .../GamePlayFieldContent}/MarkPlayField.vue | 8 +- .../ProtectPlayField.vue | 8 +- .../SettleVotesPlayField.vue | 13 +- .../GamePlayFieldContent}/ShootPlayField.vue | 8 +- .../UsePotionPlayField.vue | 16 +- .../GamePlayFieldContent}/VotePlayField.vue | 4 +- .../GamePlayFieldFooter.vue} | 16 +- .../GamePlayFieldHeader.vue} | 46 +++--- .../GameEventMonitor/GameEvent/GameEvent.vue | 149 ++++++++++++++++++ .../GameEvent/GameEventImage.vue | 144 +++++++++++++++++ .../GameEventMonitor/GameEventMonitor.vue | 52 ++++++ src/components/Statistics/Statistics.vue | 4 +- src/components/shared/Game/PlayerCard.vue | 2 +- .../shared/Game/PlayerThumbnail.vue | 7 +- src/components/shared/Game/RolePicker.vue | 2 +- src/plugins/vue-i18n/fr.json | 24 ++- 27 files changed, 658 insertions(+), 146 deletions(-) create mode 100644 src/classes/GameEvent.js create mode 100644 src/components/Game/GameContent/GamePlayField/GamePlayField.vue rename src/components/Game/GameContent/{GameContentPlayField => GamePlayField/GamePlayFieldContent}/DelegatePlayField.vue (83%) rename src/components/Game/GameContent/{GameContentPlayField => GamePlayField/GamePlayFieldContent}/EatPlayField.vue (82%) rename src/components/Game/GameContent/{GameContentPlayField => GamePlayField/GamePlayFieldContent}/ElectSheriffPlayField.vue (79%) rename src/components/Game/GameContent/{GameContentPlayField/GameContentPlayField.vue => GamePlayField/GamePlayFieldContent/GamePlayFieldContent.vue} (97%) rename src/components/Game/GameContent/{GameContentPlayField => GamePlayField/GamePlayFieldContent}/LookPlayField.vue (80%) rename src/components/Game/GameContent/{GameContentPlayField => GamePlayField/GamePlayFieldContent}/MarkPlayField.vue (85%) rename src/components/Game/GameContent/{GameContentPlayField => GamePlayField/GamePlayFieldContent}/ProtectPlayField.vue (87%) rename src/components/Game/GameContent/{GameContentPlayField => GamePlayField/GamePlayFieldContent}/SettleVotesPlayField.vue (68%) rename src/components/Game/GameContent/{GameContentPlayField => GamePlayField/GamePlayFieldContent}/ShootPlayField.vue (83%) rename src/components/Game/GameContent/{GameContentPlayField => GamePlayField/GamePlayFieldContent}/UsePotionPlayField.vue (89%) rename src/components/Game/GameContent/{GameContentPlayField => GamePlayField/GamePlayFieldContent}/VotePlayField.vue (79%) rename src/components/Game/GameContent/{GameContentFooter/GameContentFooter.vue => GamePlayField/GamePlayFieldFooter/GamePlayFieldFooter.vue} (85%) rename src/components/Game/GameContent/{GameContentHeader/GameContentHeader.vue => GamePlayField/GamePlayFieldHeader/GamePlayFieldHeader.vue} (75%) create mode 100644 src/components/Game/GameEventMonitor/GameEvent/GameEvent.vue create mode 100644 src/components/Game/GameEventMonitor/GameEvent/GameEventImage.vue create mode 100644 src/components/Game/GameEventMonitor/GameEventMonitor.vue diff --git a/CHANGELOG.md b/CHANGELOG.md index 0635ee0..cbbdb5b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # 📈 LIST OF CHANGES FOR WEREWOLVES ASSISTANT WEB +## 0.3.0 (2020-08-??) + +### 📦 Packages + +* `uniqid` installed with version `5.2.0`. +* `@sentry/browser` updated to version `5.20.1`. +* `@sentry/integrations` updated to version `5.20.1`. +* `sweetalert2` updated to version `9.17.1`. +* `vue-i18n` updated to version `8.19.0`. + +--- + ## 0.2.0 (2020-07-24) ### 🚀 New features diff --git a/package-lock.json b/package-lock.json index b0b1718..c10c135 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "werewolves-assistant-web", - "version": "0.1.0", + "version": "0.2.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -229,69 +229,69 @@ } }, "@sentry/browser": { - "version": "5.20.0", - "resolved": "https://registry.npmjs.org/@sentry/browser/-/browser-5.20.0.tgz", - "integrity": "sha512-xVPL7/RuAPcemfSzXiyPHAt4M+0BfzkdTlN+PZb6frCEo4k6E0UiN6WLsGj/iwa2gXhyfTQXtbTuP+tDuNPEJw==", + "version": "5.20.1", + "resolved": "https://registry.npmjs.org/@sentry/browser/-/browser-5.20.1.tgz", + "integrity": "sha512-ClykuvrEsMKgAvifx5VHzRjchwYbJFX8YiIicYx+Wr3MXL2jLG6OEfHHJwJeyBL2C3vxd5O0KPK3pGMR9wPMLA==", "requires": { - "@sentry/core": "5.20.0", - "@sentry/types": "5.20.0", - "@sentry/utils": "5.20.0", + "@sentry/core": "5.20.1", + "@sentry/types": "5.20.1", + "@sentry/utils": "5.20.1", "tslib": "^1.9.3" } }, "@sentry/core": { - "version": "5.20.0", - "resolved": "https://registry.npmjs.org/@sentry/core/-/core-5.20.0.tgz", - "integrity": "sha512-fzzWKEolc0O6H/phdDenzKs7JXDSb0sooxVn0QCUkwWSzACALQh+NR/UciOXyhyuoUiqu4zthYQx02qtGqizeQ==", - "requires": { - "@sentry/hub": "5.20.0", - "@sentry/minimal": "5.20.0", - "@sentry/types": "5.20.0", - "@sentry/utils": "5.20.0", + "version": "5.20.1", + "resolved": "https://registry.npmjs.org/@sentry/core/-/core-5.20.1.tgz", + "integrity": "sha512-gG622/UY2TePruF6iUzgVrbIX5vN8w2cjlWFo1Est8MvCfQsz8agGaLMCAyl5hCGJ6K2qTUZDOlbCNIKoMclxg==", + "requires": { + "@sentry/hub": "5.20.1", + "@sentry/minimal": "5.20.1", + "@sentry/types": "5.20.1", + "@sentry/utils": "5.20.1", "tslib": "^1.9.3" } }, "@sentry/hub": { - "version": "5.20.0", - "resolved": "https://registry.npmjs.org/@sentry/hub/-/hub-5.20.0.tgz", - "integrity": "sha512-DiU8fpjAAMOgSx5tsTekMtHPCAtSNWSNS91FFkDCqPn6fYG+/aK/hB5kTlJwr+GTM1815+WWrtXP6y2ecSmZuA==", + "version": "5.20.1", + "resolved": "https://registry.npmjs.org/@sentry/hub/-/hub-5.20.1.tgz", + "integrity": "sha512-Nv5BXf14BEc08acDguW6eSqkAJLVf8wki283FczEvTsQZZuSBHM9cJ5Hnehr6n+mr8wWpYLgUUYM0oXXigUmzQ==", "requires": { - "@sentry/types": "5.20.0", - "@sentry/utils": "5.20.0", + "@sentry/types": "5.20.1", + "@sentry/utils": "5.20.1", "tslib": "^1.9.3" } }, "@sentry/integrations": { - "version": "5.20.0", - "resolved": "https://registry.npmjs.org/@sentry/integrations/-/integrations-5.20.0.tgz", - "integrity": "sha512-ADL6rBJbwYy4P30zjWiRzmAc+PDqMch2URj+Tj89oVK+tUDQQ9qOM9DD4rBTeidqO2h1ninyZAJ3Vu9UJ/5g9A==", + "version": "5.20.1", + "resolved": "https://registry.npmjs.org/@sentry/integrations/-/integrations-5.20.1.tgz", + "integrity": "sha512-VpeZHYT8Fvw1J5478MqXXORf3Ftpt34YM4e+sTPuGrmf4Gro7lXdyownqiSaa7kwwNVQEV3zMlRDczVZzXQThw==", "requires": { - "@sentry/types": "5.20.0", - "@sentry/utils": "5.20.0", + "@sentry/types": "5.20.1", + "@sentry/utils": "5.20.1", "tslib": "^1.9.3" } }, "@sentry/minimal": { - "version": "5.20.0", - "resolved": "https://registry.npmjs.org/@sentry/minimal/-/minimal-5.20.0.tgz", - "integrity": "sha512-oA+0g7p3bapzjgGKQIkSjcjA85VG1HPmjxBD9wpRvNjmYuVmm80Cl1H/P+xg/hupw/kNmASAX4IOd5Z9pEeboA==", + "version": "5.20.1", + "resolved": "https://registry.npmjs.org/@sentry/minimal/-/minimal-5.20.1.tgz", + "integrity": "sha512-2PeJKDTHNsUd1jtSLQBJ6oRI+xrIJrYDQmsyK/qs9D7HqHfs+zNAMUjYseiVeSAFGas5IcNSuZbPRV4BnuoZ0w==", "requires": { - "@sentry/hub": "5.20.0", - "@sentry/types": "5.20.0", + "@sentry/hub": "5.20.1", + "@sentry/types": "5.20.1", "tslib": "^1.9.3" } }, "@sentry/types": { - "version": "5.20.0", - "resolved": "https://registry.npmjs.org/@sentry/types/-/types-5.20.0.tgz", - "integrity": "sha512-/9tiGiXBRsOKM66HeCpt0iSF0vnAIqHzXgC97icNQIstx/ZA8tcLs9540cHDeaN0cyZUyZF1o8ECqcLXGNODWQ==" + "version": "5.20.1", + "resolved": "https://registry.npmjs.org/@sentry/types/-/types-5.20.1.tgz", + "integrity": "sha512-OU+i/lcjGpDJv0XkNpsKrI2r1VPp8qX0H6Knq8NuZrlZe3AbvO3jRJJK0pH14xFv8Xok5jbZZpKKoQLxYfxqsw==" }, "@sentry/utils": { - "version": "5.20.0", - "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-5.20.0.tgz", - "integrity": "sha512-w0AeAzWEf35h9U9QL/4lgS9MqaTPjeSmQYNU/n4ef3FKr+u8HP68Ra7NZ0adiKgi67Yxr652kWopOLPl7CxvZg==", + "version": "5.20.1", + "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-5.20.1.tgz", + "integrity": "sha512-dhK6IdO6g7Q2CoxCbB+q8gwUapDUH5VjraFg0UBzgkrtNhtHLylqmwx0sWQvXCcp14Q/3MuzEbb4euvoh8o8oA==", "requires": { - "@sentry/types": "5.20.0", + "@sentry/types": "5.20.1", "tslib": "^1.9.3" } }, @@ -12008,9 +12008,9 @@ } }, "sweetalert2": { - "version": "9.17.0", - "resolved": "https://registry.npmjs.org/sweetalert2/-/sweetalert2-9.17.0.tgz", - "integrity": "sha512-tOby96N1FlTT8Xi7Y7QlTiswNJTySgghmRSyFwb3pO3zdrhsR2PUp4ucmye7a3CTLbLdqjHdszsGlCJ0v6pGaQ==" + "version": "9.17.1", + "resolved": "https://registry.npmjs.org/sweetalert2/-/sweetalert2-9.17.1.tgz", + "integrity": "sha512-D/VE2lT/bKd64/RBglLUtQ+3nsftzjzIiP2iqN6zPzPwf+2djIY+4k8Bg430zxRUn4DkZzyIuU58q3n0J43lvw==" }, "symbol-observable": { "version": "1.0.1", @@ -12481,6 +12481,11 @@ "integrity": "sha1-sxxa6CVIRKOoKBVBzisEuGWnNP8=", "dev": true }, + "uniqid": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/uniqid/-/uniqid-5.2.0.tgz", + "integrity": "sha512-LH8zsvwJ/GL6YtNfSOmMCrI9piraAUjBfw2MCvleNE6a4pVKJwXjG2+HWhkVeFcSg+nmaPKbMrMOoxwQluZ1Mg==" + }, "uniqs": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/uniqs/-/uniqs-2.0.0.tgz", @@ -12830,9 +12835,9 @@ "dev": true }, "vue-i18n": { - "version": "8.18.2", - "resolved": "https://registry.npmjs.org/vue-i18n/-/vue-i18n-8.18.2.tgz", - "integrity": "sha512-0X5nBTCZAVjlwcrPaYJwNs3iipBBTv0AUHwQUOa8yP3XbQGWKbRHqBb3OhCYtum/IHDD21d/df5Xd2VgyxbxfA==" + "version": "8.19.0", + "resolved": "https://registry.npmjs.org/vue-i18n/-/vue-i18n-8.19.0.tgz", + "integrity": "sha512-jXPsvkmDMkwhjGQEDF6BgGsmJQLjIO1CXJQ1RjZRnU80kzRG+/+277ADFTulAPQSb0hUlrsp4VzEPdeO7lKcRA==" }, "vue-loader": { "version": "15.9.3", diff --git a/package.json b/package.json index 88d4c24..36ae1b8 100644 --- a/package.json +++ b/package.json @@ -13,8 +13,8 @@ }, "dependencies": { "@fortawesome/fontawesome-free": "^5.14.0", - "@sentry/browser": "^5.20.0", - "@sentry/integrations": "^5.20.0", + "@sentry/browser": "^5.20.1", + "@sentry/integrations": "^5.20.1", "axios": "^0.19.2", "bootstrap": "^4.5.0", "epic-spinners": "^1.1.0", @@ -24,12 +24,13 @@ "popper.js": "^1.16.1", "qs": "^6.9.4", "sass-loader": "^9.0.2", - "sweetalert2": "^9.17.0", + "sweetalert2": "^9.17.1", + "uniqid": "^5.2.0", "v-tooltip": "^2.0.3", "vee-validate": "^3.3.7", "vue": "^2.6.11", "vue-flip": "^1.0.2", - "vue-i18n": "^8.18.2", + "vue-i18n": "^8.19.0", "vue-roller": "^1.12.1", "vue-router": "^3.2.0", "vue-select": "^3.10.7", diff --git a/src/classes/GameEvent.js b/src/classes/GameEvent.js new file mode 100644 index 0000000..4e5f0e2 --- /dev/null +++ b/src/classes/GameEvent.js @@ -0,0 +1,19 @@ +import uniqId from "uniqid"; +import { getProp } from "@/helpers/functions/Class"; +import Player from "./Player"; + +class GameEvent { + constructor(gameEvent = null) { + this._id = getProp(gameEvent, "_id", uniqId()); + this.type = getProp(gameEvent, "type"); + this.targets = getProp(gameEvent, "targets", [], targets => targets.map(target => ({ + player: new Player(target.player), + potion: { + life: getProp(target, "potion.life"), + death: getProp(target, "potion.death"), + }, + }))); + } +} + +export default GameEvent; \ No newline at end of file diff --git a/src/components/Game/GameContent/GameContent.vue b/src/components/Game/GameContent/GameContent.vue index 4f0cf0d..447ec54 100644 --- a/src/components/Game/GameContent/GameContent.vue +++ b/src/components/Game/GameContent/GameContent.vue @@ -1,21 +1,24 @@ \ No newline at end of file diff --git a/src/components/Game/GameContent/GamePlayField/GamePlayField.vue b/src/components/Game/GameContent/GamePlayField/GamePlayField.vue new file mode 100644 index 0000000..06cd051 --- /dev/null +++ b/src/components/Game/GameContent/GamePlayField/GamePlayField.vue @@ -0,0 +1,49 @@ + + + + + \ No newline at end of file diff --git a/src/components/Game/GameContent/GameContentPlayField/DelegatePlayField.vue b/src/components/Game/GameContent/GamePlayField/GamePlayFieldContent/DelegatePlayField.vue similarity index 83% rename from src/components/Game/GameContent/GameContentPlayField/DelegatePlayField.vue rename to src/components/Game/GameContent/GamePlayField/GamePlayFieldContent/DelegatePlayField.vue index bea3858..35828bd 100644 --- a/src/components/Game/GameContent/GameContentPlayField/DelegatePlayField.vue +++ b/src/components/Game/GameContent/GamePlayField/GamePlayFieldContent/DelegatePlayField.vue @@ -12,10 +12,10 @@ \ No newline at end of file diff --git a/src/components/Game/GameEventMonitor/GameEvent/GameEventImage.vue b/src/components/Game/GameEventMonitor/GameEvent/GameEventImage.vue new file mode 100644 index 0000000..de04676 --- /dev/null +++ b/src/components/Game/GameEventMonitor/GameEvent/GameEventImage.vue @@ -0,0 +1,144 @@ + + + + + \ No newline at end of file diff --git a/src/components/Game/GameEventMonitor/GameEventMonitor.vue b/src/components/Game/GameEventMonitor/GameEventMonitor.vue new file mode 100644 index 0000000..afb3082 --- /dev/null +++ b/src/components/Game/GameEventMonitor/GameEventMonitor.vue @@ -0,0 +1,52 @@ + + + + + \ No newline at end of file diff --git a/src/components/Statistics/Statistics.vue b/src/components/Statistics/Statistics.vue index ba989fa..0cacd2d 100644 --- a/src/components/Statistics/Statistics.vue +++ b/src/components/Statistics/Statistics.vue @@ -39,13 +39,13 @@
  • - +
  • - +
  • diff --git a/src/components/shared/Game/PlayerCard.vue b/src/components/shared/Game/PlayerCard.vue index 1f9c172..afa19b2 100644 --- a/src/components/shared/Game/PlayerCard.vue +++ b/src/components/shared/Game/PlayerCard.vue @@ -45,7 +45,7 @@ export default { }, computed: { playerRole() { - return this.player.role.current ? this.$t(`Role.${this.player.role.current}`) : this.$t(`PlayerCard.pickRole`); + return this.player.role.current ? this.$tc(`Role.${this.player.role.current}`, 1) : this.$t(`PlayerCard.pickRole`); }, }, methods: { diff --git a/src/components/shared/Game/PlayerThumbnail.vue b/src/components/shared/Game/PlayerThumbnail.vue index 6507072..8bcaeff 100644 --- a/src/components/shared/Game/PlayerThumbnail.vue +++ b/src/components/shared/Game/PlayerThumbnail.vue @@ -2,7 +2,7 @@
    - + @@ -29,6 +37,8 @@ import GameEvent from "@/classes/GameEvent"; import Game from "@/classes/Game"; import RoleImage from "@/components/shared/Game/RoleImage"; import sheriffSVG from "@/assets/svg/attributes/sheriff.svg"; +import deadSVG from "@/assets/svg/attributes/dead.svg"; +import seenSVG from "@/assets/svg/actions/look.svg"; export default { name: "GameEventImage", @@ -60,9 +70,19 @@ export default { }; }, computed: { - attributeImageSource() { - return sheriffSVG; + isEffectGameEvent() { + const effectGameEventTypes = ["sheriff-elected", "player-dies", "seer-looks"]; + return effectGameEventTypes.includes(this.event.type); + }, + effectImageSource() { + const effectGameEventTypeImageSource = { + "sheriff-elected": sheriffSVG, + "player-dies": deadSVG, + "seer-looks": seenSVG, + }; + return effectGameEventTypeImageSource[this.event.type]; }, + }, created() { if (this.event.type === "game-starts") { @@ -113,7 +133,7 @@ export default { 50% { transform: rotate(-20deg); } - 100%{ + 100% { transform: rotate(0deg); } } @@ -134,6 +154,10 @@ export default { #role-effect-container { position: relative; + img.dead-player { + filter: grayscale(1); + } + #effect-image { position: absolute; height: 40%; diff --git a/src/components/Game/GameWinners/GameWinners.vue b/src/components/Game/GameWinners/GameWinners.vue index de1e308..aa88245 100644 --- a/src/components/Game/GameWinners/GameWinners.vue +++ b/src/components/Game/GameWinners/GameWinners.vue @@ -3,7 +3,8 @@
    - Trophy + Trophy
    diff --git a/src/components/shared/Game/RoleImage.vue b/src/components/shared/Game/RoleImage.vue index de1f925..d16ac16 100644 --- a/src/components/shared/Game/RoleImage.vue +++ b/src/components/shared/Game/RoleImage.vue @@ -21,7 +21,7 @@ export default { }, data() { return { - IMGs: { back, guard, hunter, raven, seer, villager, werewolf, witch }, + IMGs: { back, guard, hunter, raven, seer, villager, werewolf, werewolves: werewolf, witch }, }; }, computed: { diff --git a/src/helpers/functions/Array.js b/src/helpers/functions/Array.js new file mode 100644 index 0000000..fa1cac7 --- /dev/null +++ b/src/helpers/functions/Array.js @@ -0,0 +1,9 @@ +/** + * @description Insert a value into the array according to the condition. Needs to be called like ...insertIf(condition, value1, value2, value3) + * @param condition + * @param elements List of values to insert + * @returns {*[]} + */ +export function insertIf(condition, ...elements) { + return condition ? elements : []; +} \ No newline at end of file diff --git a/src/plugins/vue-i18n/fr.json b/src/plugins/vue-i18n/fr.json index 0c38566..34d93da 100644 --- a/src/plugins/vue-i18n/fr.json +++ b/src/plugins/vue-i18n/fr.json @@ -211,9 +211,20 @@ "looksLifeSomeWerewolvesIntroducedThemselves": "Il semblerait qu'un ou plusieurs loups-garous se soient faufilé dans le village...", "villagersMurderWerewolves": "Villageois, prenez les fourches et nettoyez votre village de ces canidés !", "beforeStartingLetsElectSheriff": "Mais avant de vous entretuer, il faut élire le maire de ce village.", + "playerDies": "{player} est mort ! Quelle tragédie...", + "playerRevealsRole": "Il ou elle révèle son rôle aux survivants.", "playerHasBeenPromotedSheriff": "{player} a été promu maire !", + "sheriffCanMakeASpeech": "Le maire peut, s'il le souhaite, faire un discours poignant sur son élection.", "nightFalls": "La nuit tombe sur le village de Thiercelieux...", - "inhabitantsFallAsleep": "Les habitants du village s'endorment." + "inhabitantsFallAsleep": "Les habitants du village s'endorment.", + "dayRises": "Le jour se lève sur le village de Thiercelieux.", + "seerStarts": "La voyante se réveille et va découvrir dans sa boule de cristal le rôle d'un habitant.", + "seerHasSeen": "La voyante a vu", + "werewolvesStart": "Le loup-garou se réveille et va choisir son dîner de ce soir. | Les loups-garous se réveillent et vont choisir leur dîner de ce soir.", + "witchStarts": "La sorcière se réveille et va, si elle le souhaite, utiliser ses potions.", + "guardStarts": "Le salvateur se réveille et va protéger la personne de son choix.", + "ravenStarts": "Le corbeau se réveille et va, s'il le souhaite, marquer de sa plume un des habitants.", + "hunterStarts": "Dans son dernier souffle, le chasseur s'apprête à choisir la cible de sa vengeance." } }, "Statistics": { @@ -232,6 +243,15 @@ "createGameNow": "Créer une partie maintenant" }, "Role": { + "a": { + "villager": "un villageois", + "werewolf": "un loup-garou", + "seer": "une voyante", + "witch": "une sorcière", + "hunter": "un chasseur", + "guard": "un salvateur", + "raven": "un corbeau" + }, "villager": "Villageois", "werewolf": "Loup-Garou | Loups-Garous", "seer": "Voyante", From 0e675bf25a18ea70b73bac1db8920906bbe911b1 Mon Sep 17 00:00:00 2001 From: antoinezanardi Date: Thu, 30 Jul 2020 22:37:24 +0200 Subject: [PATCH 03/10] feat(Game): Bug on werewolves side display and confirm alert for leaving game --- CHANGELOG.md | 9 ++++++ public/index.html | 2 +- src/components/Game/Game.vue | 29 +++++++++++++++---- .../GameEventMonitor/GameEvent/GameEvent.vue | 2 +- .../GameEvent/GameEventImage.vue | 11 +++++-- .../GameWerewolvesSide/GameWerewolvesSide.vue | 4 +-- src/components/NavBar/NavBar.vue | 23 --------------- .../shared/Game/PlayerVotes/PlayerVote.vue | 3 +- src/components/shared/Game/RolePicker.vue | 2 +- src/plugins/router/index.js | 16 ++++++++++ src/plugins/vue-i18n/fr.json | 11 ++++--- 11 files changed, 69 insertions(+), 43 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index af480c5..9f644f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,18 @@ ## 0.3.0 (2020-08-??) +### 🚀 New features + +* If the user leaves a playing game, a confirm alert is triggered. + ### 🌟 Enhancements * The trophy at the end of a game has a sweet `TADA !` animation. +* When player are voting, the text `vote for` has been UX improved. + +### 🐛 Bug fixes + +* Werewolf side doesn't have an overflow-y anymore. ### 📦 Packages diff --git a/public/index.html b/public/index.html index 0c8b617..d13db52 100644 --- a/public/index.html +++ b/public/index.html @@ -5,7 +5,7 @@ - + <%= htmlWebpackPlugin.options.title %> diff --git a/src/components/Game/Game.vue b/src/components/Game/Game.vue index fd29057..3ddf5e4 100644 --- a/src/components/Game/Game.vue +++ b/src/components/Game/Game.vue @@ -11,23 +11,24 @@ @updateGame="updateGame"/> - +
    diff --git a/src/components/Game/GameEventMonitor/GameEvent/GameEvent.vue b/src/components/Game/GameEventMonitor/GameEvent/GameEvent.vue index 6f048d1..dc1befb 100644 --- a/src/components/Game/GameEventMonitor/GameEvent/GameEvent.vue +++ b/src/components/Game/GameEventMonitor/GameEvent/GameEvent.vue @@ -88,7 +88,7 @@ export default { }, "seer-looks": { messages: [ - `${i18n.t("GameEvent.messages.seerHasSeen")} ${i18n.t(`Role.a.${this.hasGameEventTarget ? this.event.targets[0].player.role.current : null}`)} !`, + `${i18n.t("GameEvent.messages.seerHasSeen")} ${i18n.t(`Role.a.${this.hasGameEventTarget ? this.event.targets[0].player.role.current : "villager"}`)} !`, ], }, "werewolves-start": { diff --git a/src/components/Game/GameEventMonitor/GameEvent/GameEventImage.vue b/src/components/Game/GameEventMonitor/GameEvent/GameEventImage.vue index 341b048..6317259 100644 --- a/src/components/Game/GameEventMonitor/GameEvent/GameEventImage.vue +++ b/src/components/Game/GameEventMonitor/GameEvent/GameEventImage.vue @@ -19,7 +19,8 @@
    - Effect Image @@ -27,7 +28,8 @@

    - +
    @@ -151,6 +153,11 @@ export default { transform: translateY(35px); } + .role-image { + border: 5px solid #303030; + border-radius: 5px; + } + #role-effect-container { position: relative; diff --git a/src/components/Game/GameWerewolvesSide/GameWerewolvesSide.vue b/src/components/Game/GameWerewolvesSide/GameWerewolvesSide.vue index af0d104..78a79ee 100644 --- a/src/components/Game/GameWerewolvesSide/GameWerewolvesSide.vue +++ b/src/components/Game/GameWerewolvesSide/GameWerewolvesSide.vue @@ -1,11 +1,11 @@ + + \ No newline at end of file diff --git a/src/components/Game/GameWinners/GameSummaryModal/GameSummaryModal.vue b/src/components/Game/GameWinners/GameSummaryModal/GameSummaryModal.vue new file mode 100644 index 0000000..5608fd9 --- /dev/null +++ b/src/components/Game/GameWinners/GameSummaryModal/GameSummaryModal.vue @@ -0,0 +1,58 @@ + + + + + \ No newline at end of file diff --git a/src/components/Game/GameWinners/GameWinners.vue b/src/components/Game/GameWinners/GameWinners.vue index aa88245..c1508a7 100644 --- a/src/components/Game/GameWinners/GameWinners.vue +++ b/src/components/Game/GameWinners/GameWinners.vue @@ -17,19 +17,26 @@
    -
    +
    + +
    +
    -
    +
    +
    @@ -39,10 +46,11 @@ import { stringify } from "qs"; import trophy from "../../../assets/svg/game/trophy.svg"; import Game from "../../../classes/Game"; import PlayerCard from "../../shared/Game/PlayerCard"; +import GameSummaryModal from "@/components/Game/GameWinners/GameSummaryModal/GameSummaryModal"; export default { name: "GameWinners", - components: { PlayerCard }, + components: { GameSummaryModal, PlayerCard }, props: { game: { type: Game, diff --git a/src/components/Statistics/Statistics.vue b/src/components/Statistics/Statistics.vue index 0cacd2d..6d3e7c4 100644 --- a/src/components/Statistics/Statistics.vue +++ b/src/components/Statistics/Statistics.vue @@ -60,9 +60,13 @@
    -
    +

    - +
    +
    +
    +
    + diff --git a/src/plugins/vue-i18n/fr.json b/src/plugins/vue-i18n/fr.json index 0012727..5a4ab8f 100644 --- a/src/plugins/vue-i18n/fr.json +++ b/src/plugins/vue-i18n/fr.json @@ -168,14 +168,24 @@ "useDeathPotionOn": "Utiliser la potion de mort sur ..." }, "GameWinners": { - "wonByWerewolves": "Partie gagnée par le seul loup garou | Partie gagnée par les loups garous", + "wonByWerewolves": "Partie gagnée par le seul loup-garou | Partie gagnée par les loups-garous", "wonByVillagers": "Partie gagnée par le seul villageois | Partie gagnée par les villageois", "restartGame": "Recommencer une partie", "quit": "Quitter", "newGame": "Nouvelle partie", "doYouWantToKeepSamePlayers": "Voulez-vous rejouer avec les mêmes joueurs ?", "keepSamePlayers": "Garder les mêmes joueurs", - "fromScratch": "Recommencer du début" + "fromScratch": "Recommencer du début", + "seeGameSummary": "Voir le récapitulatif de partie" + }, + "GameSummaryModal": { + "gameSummary": "Récapitulatif de la partie", + "gameHistory": "Historique de la partie", + "close": "Fermer" + }, + "GameSummaryHistoryLine": { + "day": "Jour", + "night": "Nuit" }, "PlayFieldActionText": { "wantsToLook": "souhaite voir le rôle de", From 548d7f4edb86a7fdc54b41e430d38f9369442bcf Mon Sep 17 00:00:00 2001 From: antoinezanardi Date: Sat, 1 Aug 2020 19:11:42 +0200 Subject: [PATCH 07/10] feat(Game): Fixing some bugs --- CHANGELOG.md | 6 ++++- package-lock.json | 18 +++++-------- package.json | 4 +-- src/components/Game/Game.vue | 8 +++++- .../GameVillagersSide/GameVillagersSide.vue | 6 ++--- .../GameWerewolvesSide/GameWerewolvesSide.vue | 2 +- .../GameSummaryModal/GameSummaryModal.vue | 2 +- src/components/GameLobby/GameLobby.vue | 26 ++++++++++++++++++- .../Home/AccountModal/AccountModal.vue | 2 +- src/helpers/functions/Error.js | 2 +- src/plugins/error/index.js | 2 +- src/plugins/vue-i18n/fr.json | 16 +++++++----- 12 files changed, 63 insertions(+), 31 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cbd5506..f3d2432 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### 🚀 New features * If the user leaves a playing game, a confirm alert is triggered. +* If the user leaves the game lobby while composition has started, a confirm alert is triggered. * Timer of 5 minutes added for `elect-sheriff` and `vote` plays. * Game events like player death, role turn and some effect (like seen or promoted sheriff) are displayed during the game. @@ -12,10 +13,12 @@ * The trophy at the end of a game has a sweet `TADA !` animation. * When player are voting, the text `vote for` has been UX improved. +* Quit button added to Game Lobby. ### 🐛 Bug fixes * Werewolf side doesn't have an overflow-y anymore. +* User is redirected to home page if he tries to load a game he doesn't own. ### 📦 Packages @@ -24,9 +27,10 @@ * `uniqid` installed with version `5.2.0`. * `@sentry/browser` updated to version `5.20.1`. * `@sentry/integrations` updated to version `5.20.1`. +* `eslint` updated to version `7.6.0`. * `sweetalert2` updated to version `9.17.1`. * `vue-i18n` updated to version `8.20.0`. -* `vue-roller` updated to version `1.12.2`. +* `vue-roller` updated to version `1.12.3`. --- diff --git a/package-lock.json b/package-lock.json index 2eace45..6216280 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4373,9 +4373,9 @@ } }, "eslint": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.5.0.tgz", - "integrity": "sha512-vlUP10xse9sWt9SGRtcr1LAC67BENcQMFeV+w5EvLEoFe3xJ8cF1Skd0msziRx/VMC+72B4DxreCE+OR12OA6Q==", + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.6.0.tgz", + "integrity": "sha512-QlAManNtqr7sozWm5TF4wIH9gmUm2hE3vNRUvyoYAa4y1l5/jxD/PQStEjBMQtCqZmSep8UxrcecI60hOpe61w==", "dev": true, "requires": { "@babel/code-frame": "^7.0.0", @@ -4557,12 +4557,6 @@ "type-check": "~0.4.0" } }, - "lodash": { - "version": "4.17.19", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.19.tgz", - "integrity": "sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==", - "dev": true - }, "optionator": { "version": "0.9.1", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz", @@ -12884,9 +12878,9 @@ "integrity": "sha512-bhP7MlgJQ8TIkZJXAfDf78uJO+mEI3CaLABLjv0WNzr4CcGRGPIAItyWYnP6LsPA4Oq0WE+suidNs6dgpO4RHg==" }, "vue-roller": { - "version": "1.12.2", - "resolved": "https://registry.npmjs.org/vue-roller/-/vue-roller-1.12.2.tgz", - "integrity": "sha512-tiQWV2YnphLfsj0AX8ux7f++Or1GYayCfISTYjZ9lBn0qZpT9BOPgzK4p+0NoOzJSC49OSBJUbdpOpJhd9aC0Q==", + "version": "1.12.3", + "resolved": "https://registry.npmjs.org/vue-roller/-/vue-roller-1.12.3.tgz", + "integrity": "sha512-lN9QxU/wE0yaRvxzUEASQZy9kc8xovli3ZuFXr68HnUWRjkfuKk+gMeIDR245KBu60llSZ3C6T7FlNseFcacZQ==", "requires": { "core-js": "^3.6.5", "vue": "^2.6.11", diff --git a/package.json b/package.json index f6d6a85..31b0822 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "vue": "^2.6.11", "vue-flip": "^1.0.2", "vue-i18n": "^8.20.0", - "vue-roller": "^1.12.2", + "vue-roller": "^1.12.3", "vue-router": "^3.2.0", "vue-select": "^3.10.7", "vue-toasted": "^1.1.28", @@ -49,7 +49,7 @@ "@vue/eslint-config-airbnb": "^5.1.0", "@vue/test-utils": "^1.0.3", "chai": "^4.1.2", - "eslint": "^7.5.0", + "eslint": "^7.6.0", "eslint-plugin-import": "^2.22.0", "eslint-plugin-vue": "^6.2.2", "vue-template-compiler": "^2.6.11" diff --git a/src/components/Game/Game.vue b/src/components/Game/Game.vue index e3b421e..5ce3dcf 100644 --- a/src/components/Game/Game.vue +++ b/src/components/Game/Game.vue @@ -25,6 +25,7 @@ import GameVillagersSide from "./GameVillagersSide/GameVillagersSide"; import GameWerewolvesSide from "./GameWerewolvesSide/GameWerewolvesSide"; import GameContent from "./GameContent/GameContent"; import GameWinners from "./GameWinners/GameWinners"; +import { isAPIError } from "@/helpers/functions/Error"; export default { name: "Game", @@ -46,7 +47,12 @@ export default { const { data } = await this.$werewolvesAssistantAPI.getGame(this.$route.params.id); this.game = new Game(data); } catch (e) { - this.$error.display(e); + if (isAPIError(e) && e.response.data.type === "GAME_DOESNT_BELONG_TO_USER") { + await this.$router.push("/"); + this.$toasted.error(this.$t("Game.youDontOwnThisGame"), { icon: "lock" }); + } else { + this.$error.display(e); + } } finally { this.loading.getGame = false; } diff --git a/src/components/Game/GameVillagersSide/GameVillagersSide.vue b/src/components/Game/GameVillagersSide/GameVillagersSide.vue index d6ffd4c..8e18a40 100644 --- a/src/components/Game/GameVillagersSide/GameVillagersSide.vue +++ b/src/components/Game/GameVillagersSide/GameVillagersSide.vue @@ -1,18 +1,18 @@