From 3b36c47f8e79a3a20c3b9e719f50484dea4901c2 Mon Sep 17 00:00:00 2001 From: Steffen Date: Thu, 4 Jun 2020 18:23:33 +0200 Subject: [PATCH] added vote locking and styling --- src/App.vue | 5 +++- src/components/Gradients.vue | 43 +++++++++++++++++++++++++++++ src/components/Player.vue | 52 +++++++++++++++++++++++++++--------- src/components/Vote.vue | 46 ++++++++++++++++--------------- src/main.js | 7 ++--- 5 files changed, 114 insertions(+), 39 deletions(-) create mode 100644 src/components/Gradients.vue diff --git a/src/App.vue b/src/App.vue index 85fe37d..a27f522 100644 --- a/src/App.vue +++ b/src/App.vue @@ -18,6 +18,7 @@ + @@ -31,6 +32,7 @@ import EditionModal from "./components/modals/EditionModal"; import Intro from "./components/Intro"; import ReferenceModal from "./components/modals/ReferenceModal"; import Vote from "./components/Vote"; +import Gradients from "./components/Gradients"; export default { components: { @@ -41,7 +43,8 @@ export default { TownSquare, Menu, EditionModal, - RolesModal + RolesModal, + Gradients }, computed: { ...mapState(["grimoire", "session"]), diff --git a/src/components/Gradients.vue b/src/components/Gradients.vue new file mode 100644 index 0000000..a9b792b --- /dev/null +++ b/src/components/Gradients.vue @@ -0,0 +1,43 @@ + + + + + diff --git a/src/components/Player.vue b/src/components/Player.vue index e5c8020..ec0c030 100644 --- a/src/components/Player.vue +++ b/src/components/Player.vue @@ -8,7 +8,8 @@ dead: player.isDead, 'no-vote': player.isVoteless, you: player.id === session.playerId, - 'voted-yes': session.votes[index] + 'vote-yes': session.votes[index], + 'vote-lock': voteLocked }, player.role.team ]" @@ -44,7 +45,13 @@ + svg.vote { - color: $demon; +#townsquare.vote .player.vote-yes > svg.vote.fa-skull { opacity: 0.5; transform: scale(1); } -#townsquare.vote .player.you.voted-yes > svg.vote { +#townsquare.vote .player.you.vote-yes > svg.vote.fa-skull, +#townsquare.vote .player.vote-lock.vote-yes > svg.vote.fa-skull, +#townsquare.vote .player.vote-lock:not(.vote-yes) > svg.vote.fa-times { opacity: 1; transform: scale(1); } diff --git a/src/components/Vote.vue b/src/components/Vote.vue index f067fe9..1af0343 100644 --- a/src/components/Vote.vue +++ b/src/components/Vote.vue @@ -26,12 +26,7 @@
Finish
-
+
Vote NO
Vote YES
@@ -47,39 +42,45 @@ import { mapGetters, mapState } from "vuex"; export default { computed: { + ...mapState("players", ["players"]), + ...mapState(["session"]), + ...mapGetters({ alive: "players/alive" }), nominator: function() { - return this.$store.state.players.players[ - this.$store.state.session.nomination[0] - ]; + return this.players[this.session.nomination[0]]; }, nominatorStyle: function() { - const players = this.$store.state.players.players.length; - const nomination = this.$store.state.session.nomination[0]; + const players = this.players.length; + const nomination = this.session.nomination[0]; return { transform: `rotate(${Math.round((nomination / players) * 360)}deg)` }; }, nominee: function() { - return this.$store.state.players.players[ - this.$store.state.session.nomination[1] - ]; + return this.players[this.session.nomination[1]]; }, nomineeStyle: function() { - const players = this.$store.state.players.players.length; - const nomination = this.$store.state.session.nomination[1]; - const lock = this.$store.state.session.lockedVote; + const players = this.players.length; + const nomination = this.session.nomination[1]; + const lock = this.session.lockedVote; const rotation = (360 * (nomination + Math.min(lock, players))) / players; return { transform: `rotate(${Math.round(rotation)}deg)` }; }, player: function() { - const id = this.$store.state.session.playerId; - return this.$store.state.players.players.find(p => p.id === id); + return this.players.find(p => p.id === this.session.playerId); }, - ...mapState("players", ["players"]), - ...mapState(["session"]), - ...mapGetters({ alive: "players/alive" }) + canVote: function() { + if (!this.player) return false; + if (this.player.isVoteless && this.nominee.role.team !== "traveler") + return false; + const session = this.session; + const players = this.players.length; + const index = this.players.indexOf(this.player); + const indexAdjusted = + (index - 1 + players - session.nomination[1]) % players; + return indexAdjusted >= session.lockedVote - 1; + } }, methods: { start() { @@ -99,6 +100,7 @@ export default { this.$store.commit("session/nomination", false); }, vote(vote) { + if (!this.canVote) return false; const index = this.players.findIndex(p => p.id === this.session.playerId); if (index >= 0 && !!this.session.votes[index] !== vote) { this.$store.commit("session/vote", [index, vote]); diff --git a/src/main.js b/src/main.js index 85f3ef9..c8c2925 100644 --- a/src/main.js +++ b/src/main.js @@ -9,8 +9,8 @@ const faIcons = [ "BookOpen", "BroadcastTower", "Camera", + "Chair", "CheckSquare", - "Skull", "Cog", "Copy", "ExchangeAlt", @@ -23,16 +23,17 @@ const faIcons = [ "RedoAlt", "SearchMinus", "SearchPlus", + "Skull", "Square", "TheaterMasks", + "Times", "TimesCircle", "Undo", "User", "UserEdit", "UserFriends", "Users", - "VoteYea", - "Chair" + "VoteYea" ]; library.add(...faIcons.map(i => fas["fa" + i])); Vue.component("font-awesome-icon", FontAwesomeIcon);