mirror of https://github.com/bra1n/townsquare.git
add list of players that voted YES
This commit is contained in:
parent
ff61770150
commit
539f3c0b76
|
@ -17,6 +17,12 @@
|
|||
<em>{{ Math.ceil(players.length / 2) }} votes</em> required to
|
||||
<em>exile</em>.
|
||||
</template>
|
||||
|
||||
<div v-if="session.lockedVote > 1">
|
||||
<em class="blue">{{ voters.join(", ") || "nobody" }} </em>
|
||||
voted <em>YES</em>
|
||||
</div>
|
||||
|
||||
<div class="button-group" v-if="!session.isSpectator">
|
||||
<div class="button" v-if="!session.lockedVote" @click="start">
|
||||
Start Vote
|
||||
|
@ -80,6 +86,17 @@ export default {
|
|||
const indexAdjusted =
|
||||
(index - 1 + players - session.nomination[1]) % players;
|
||||
return indexAdjusted >= session.lockedVote - 1;
|
||||
},
|
||||
voters: function() {
|
||||
const nomination = this.session.nomination[1];
|
||||
const voters = this.session.votes.map((vote, index) =>
|
||||
vote ? this.players[index].name : ""
|
||||
);
|
||||
const reorder = [
|
||||
...voters.slice(nomination + 1, this.players.length),
|
||||
...voters.slice(0, nomination + 1)
|
||||
];
|
||||
return reorder.slice(0, this.session.lockedVote - 1).filter(n => !!n);
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
|
|
@ -106,7 +106,7 @@ class LiveSession {
|
|||
this._handleVote(params);
|
||||
break;
|
||||
case "lock":
|
||||
this._store.commit("session/lockVote", params);
|
||||
this._handleLock(params);
|
||||
break;
|
||||
case "bye":
|
||||
this._handleBye(params);
|
||||
|
@ -414,7 +414,28 @@ class LiveSession {
|
|||
*/
|
||||
lockVote() {
|
||||
if (this._isSpectator) return;
|
||||
this._send("lock", this._store.state.session.lockedVote);
|
||||
const { lockedVote, votes, nomination } = this._store.state.session;
|
||||
const { players } = this._store.state.players;
|
||||
const index = (nomination[1] + lockedVote - 1) % players.length;
|
||||
this._send("lock", [this._store.state.session.lockedVote, votes[index]]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update vote lock and the locked vote, if it differs.
|
||||
* @param lock
|
||||
* @param vote
|
||||
* @private
|
||||
*/
|
||||
_handleLock([lock, vote]) {
|
||||
this._store.commit("session/lockVote", lock);
|
||||
if (lock > 1) {
|
||||
const { lockedVote, nomination } = this._store.state.session;
|
||||
const { players } = this._store.state.players;
|
||||
const index = (nomination[1] + lockedVote - 1) % players.length;
|
||||
if (this._store.state.session.votes[index] !== vote) {
|
||||
this._store.commit("session/vote", [index, vote]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue