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
|
||||
|
||||
### Version 2.15.4
|
||||
- added ability to run a non-nomination vote
|
||||
|
||||
### Version 2.15.3
|
||||
- add Huntsman/Damsel, Noble, Al-Hadikhia, Golem, Fearmonger to list of available characters
|
||||
|
||||
|
|
|
@ -155,6 +155,12 @@
|
|||
Nomination
|
||||
</li>
|
||||
</template>
|
||||
<template v-if="!session.nomination">
|
||||
<li @click="callVote(player)">
|
||||
<font-awesome-icon icon="vote-yea" />
|
||||
Call for Vote
|
||||
</li>
|
||||
</template>
|
||||
</template>
|
||||
<li
|
||||
@click="claimSeat"
|
||||
|
@ -326,6 +332,13 @@ export default {
|
|||
this.isMenuOpen = false;
|
||||
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() {
|
||||
this.$emit("trigger", ["cancel"]);
|
||||
},
|
||||
|
|
|
@ -247,6 +247,12 @@ export default {
|
|||
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() {
|
||||
this.move = -1;
|
||||
this.swap = -1;
|
||||
|
|
|
@ -6,9 +6,16 @@
|
|||
</div>
|
||||
<div class="overlay">
|
||||
<audio src="../assets/sounds/countdown.mp3" preload="auto"></audio>
|
||||
<em class="blue">{{ nominator.name }}</em> nominated
|
||||
<em>{{ nominee.name }}</em
|
||||
>!
|
||||
<div v-if="isNomination">
|
||||
<em class="blue">{{ nominator.name }}</em> nominated
|
||||
<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 />
|
||||
<em class="blue">
|
||||
{{ voters.length }} vote{{ voters.length !== 1 ? "s" : "" }}
|
||||
|
@ -55,7 +62,10 @@
|
|||
</template>
|
||||
<div class="button demon" @click="finish">Close</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
|
||||
class="button"
|
||||
:class="{
|
||||
|
@ -146,6 +156,18 @@ export default {
|
|||
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() {
|
||||
return this.players.find(p => p.id === this.session.playerId);
|
||||
},
|
||||
|
@ -155,6 +177,7 @@ export default {
|
|||
},
|
||||
canVote: function() {
|
||||
if (!this.player) return false;
|
||||
if (this.session.nomination.length === 3) return true;
|
||||
if (this.player.isVoteless && this.nominee.role.team !== "traveler")
|
||||
return false;
|
||||
const session = this.session;
|
||||
|
|
|
@ -77,12 +77,14 @@ const mutations = {
|
|||
addHistory(state, players) {
|
||||
if (!state.isVoteHistoryAllowed && state.isSpectator) 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";
|
||||
state.voteHistory.push({
|
||||
timestamp: new Date(),
|
||||
nominator: players[state.nomination[0]].name,
|
||||
nominee: players[state.nomination[1]].name,
|
||||
type: isExile ? "Exile" : "Execution",
|
||||
nominee: nonNomination ? "" : players[state.nomination[1]].name,
|
||||
type: nonNomination ? voteType : isExile ? "Exile" : "Execution",
|
||||
majority: Math.ceil(
|
||||
players.filter(player => !player.isDead || isExile).length / 2
|
||||
),
|
||||
|
|
Loading…
Add table
Reference in a new issue