mirror of
https://github.com/bra1n/townsquare.git
synced 2025-04-04 22:24:36 +00:00
Added non nomination voting feature
This commit is contained in:
parent
c00b89824c
commit
7cceaf5117
5 changed files with 53 additions and 6 deletions
|
@ -1,5 +1,8 @@
|
||||||
# Release Notes
|
# Release Notes
|
||||||
|
|
||||||
|
### Version 2.15.4
|
||||||
|
- added ability to run a non-nomination vote
|
||||||
|
|
||||||
### Version 2.15.3
|
### Version 2.15.3
|
||||||
- add Huntsman/Damsel, Noble, Al-Hadikhia, Golem, Fearmonger to list of available characters
|
- add Huntsman/Damsel, Noble, Al-Hadikhia, Golem, Fearmonger to list of available characters
|
||||||
|
|
||||||
|
|
|
@ -155,6 +155,12 @@
|
||||||
Nomination
|
Nomination
|
||||||
</li>
|
</li>
|
||||||
</template>
|
</template>
|
||||||
|
<template v-if="!session.nomination">
|
||||||
|
<li @click="callVote(player)">
|
||||||
|
<font-awesome-icon icon="vote-yea" />
|
||||||
|
Call for Vote
|
||||||
|
</li>
|
||||||
|
</template>
|
||||||
</template>
|
</template>
|
||||||
<li
|
<li
|
||||||
@click="claimSeat"
|
@click="claimSeat"
|
||||||
|
@ -326,6 +332,13 @@ export default {
|
||||||
this.isMenuOpen = false;
|
this.isMenuOpen = false;
|
||||||
this.$emit("trigger", ["nominatePlayer", player]);
|
this.$emit("trigger", ["nominatePlayer", player]);
|
||||||
},
|
},
|
||||||
|
callVote() {
|
||||||
|
this.isMenuOpen = false;
|
||||||
|
const votePrompt = "Vote Type (leave blank for no label)";
|
||||||
|
const voteType = prompt(votePrompt) || "Vote";
|
||||||
|
// console.log('voteType', voteType);
|
||||||
|
this.$emit("trigger", ["callVote", voteType, this.player]);
|
||||||
|
},
|
||||||
cancel() {
|
cancel() {
|
||||||
this.$emit("trigger", ["cancel"]);
|
this.$emit("trigger", ["cancel"]);
|
||||||
},
|
},
|
||||||
|
|
|
@ -247,6 +247,12 @@ export default {
|
||||||
this.cancel();
|
this.cancel();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
callVote(player, voteType) {
|
||||||
|
if (this.session.isSpectator || this.session.lockedVote) return;
|
||||||
|
const nomination = [player, player, voteType || "Vote"];
|
||||||
|
this.$store.commit("session/nomination", { nomination });
|
||||||
|
this.cancel();
|
||||||
|
},
|
||||||
cancel() {
|
cancel() {
|
||||||
this.move = -1;
|
this.move = -1;
|
||||||
this.swap = -1;
|
this.swap = -1;
|
||||||
|
|
|
@ -6,9 +6,16 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="overlay">
|
<div class="overlay">
|
||||||
<audio src="../assets/sounds/countdown.mp3" preload="auto"></audio>
|
<audio src="../assets/sounds/countdown.mp3" preload="auto"></audio>
|
||||||
|
<div v-if="isNomination">
|
||||||
<em class="blue">{{ nominator.name }}</em> nominated
|
<em class="blue">{{ nominator.name }}</em> nominated
|
||||||
<em>{{ nominee.name }}</em
|
<em>{{ nominee.name }}</em
|
||||||
>!
|
>!
|
||||||
|
</div>
|
||||||
|
<div v-else>
|
||||||
|
<em class="blue">{{ nominator.name }}</em> called a vote!
|
||||||
|
<br />
|
||||||
|
{{ voteType ? "Vote Type: " + voteType : null }}
|
||||||
|
</div>
|
||||||
<br />
|
<br />
|
||||||
<em class="blue">
|
<em class="blue">
|
||||||
{{ voters.length }} vote{{ voters.length !== 1 ? "s" : "" }}
|
{{ voters.length }} vote{{ voters.length !== 1 ? "s" : "" }}
|
||||||
|
@ -55,7 +62,10 @@
|
||||||
</template>
|
</template>
|
||||||
<div class="button demon" @click="finish">Close</div>
|
<div class="button demon" @click="finish">Close</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="button-group mark" v-if="nominee.role.team !== 'traveler'">
|
<div
|
||||||
|
class="button-group mark"
|
||||||
|
v-if="nominee.role.team !== 'traveler' && isNomination"
|
||||||
|
>
|
||||||
<div
|
<div
|
||||||
class="button"
|
class="button"
|
||||||
:class="{
|
:class="{
|
||||||
|
@ -146,6 +156,18 @@ export default {
|
||||||
transitionDuration: this.session.votingSpeed - 100 + "ms"
|
transitionDuration: this.session.votingSpeed - 100 + "ms"
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
isNomination: function() {
|
||||||
|
return (
|
||||||
|
this.session.nomination.length === 2 || !this.session.nomination[2]
|
||||||
|
);
|
||||||
|
},
|
||||||
|
voteType: function() {
|
||||||
|
if (this.isNomination || this.session.nomination[2] === "Vote") {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.session.nomination[2];
|
||||||
|
},
|
||||||
player: function() {
|
player: function() {
|
||||||
return this.players.find(p => p.id === this.session.playerId);
|
return this.players.find(p => p.id === this.session.playerId);
|
||||||
},
|
},
|
||||||
|
@ -155,6 +177,7 @@ export default {
|
||||||
},
|
},
|
||||||
canVote: function() {
|
canVote: function() {
|
||||||
if (!this.player) return false;
|
if (!this.player) return false;
|
||||||
|
if (this.session.nomination.length === 3) return true;
|
||||||
if (this.player.isVoteless && this.nominee.role.team !== "traveler")
|
if (this.player.isVoteless && this.nominee.role.team !== "traveler")
|
||||||
return false;
|
return false;
|
||||||
const session = this.session;
|
const session = this.session;
|
||||||
|
|
|
@ -77,12 +77,14 @@ const mutations = {
|
||||||
addHistory(state, players) {
|
addHistory(state, players) {
|
||||||
if (!state.isVoteHistoryAllowed && state.isSpectator) return;
|
if (!state.isVoteHistoryAllowed && state.isSpectator) return;
|
||||||
if (!state.nomination || state.lockedVote <= players.length) return;
|
if (!state.nomination || state.lockedVote <= players.length) return;
|
||||||
|
const nonNomination = state.nomination.length === 3;
|
||||||
|
const voteType = state.nomination[2] || "Vote";
|
||||||
const isExile = players[state.nomination[1]].role.team === "traveler";
|
const isExile = players[state.nomination[1]].role.team === "traveler";
|
||||||
state.voteHistory.push({
|
state.voteHistory.push({
|
||||||
timestamp: new Date(),
|
timestamp: new Date(),
|
||||||
nominator: players[state.nomination[0]].name,
|
nominator: players[state.nomination[0]].name,
|
||||||
nominee: players[state.nomination[1]].name,
|
nominee: nonNomination ? "" : players[state.nomination[1]].name,
|
||||||
type: isExile ? "Exile" : "Execution",
|
type: nonNomination ? voteType : isExile ? "Exile" : "Execution",
|
||||||
majority: Math.ceil(
|
majority: Math.ceil(
|
||||||
players.filter(player => !player.isDead || isExile).length / 2
|
players.filter(player => !player.isDead || isExile).length / 2
|
||||||
),
|
),
|
||||||
|
|
Loading…
Add table
Reference in a new issue