mirror of https://github.com/bra1n/townsquare.git
socket part of toggle recordVoteHistory
analogous to isNight
This commit is contained in:
parent
44a0297be7
commit
230507a67f
|
@ -343,9 +343,6 @@ export default {
|
||||||
this.$store.dispatch("players/clearRoles");
|
this.$store.dispatch("players/clearRoles");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
toggleRecordVoteHistory() {
|
|
||||||
this.$store.commit("session/toggleRecordVoteHistory");
|
|
||||||
},
|
|
||||||
clearVoteHistory() {
|
clearVoteHistory() {
|
||||||
this.$store.commit("session/clearVoteHistory");
|
this.$store.commit("session/clearVoteHistory");
|
||||||
},
|
},
|
||||||
|
@ -355,6 +352,7 @@ export default {
|
||||||
"toggleImageOptIn",
|
"toggleImageOptIn",
|
||||||
"toggleMuted",
|
"toggleMuted",
|
||||||
"toggleNight",
|
"toggleNight",
|
||||||
|
"toggleRecordVoteHistory",
|
||||||
"toggleNightOrder",
|
"toggleNightOrder",
|
||||||
"setZoom",
|
"setZoom",
|
||||||
"toggleModal"
|
"toggleModal"
|
||||||
|
|
|
@ -220,9 +220,7 @@ export default {
|
||||||
},
|
},
|
||||||
finish() {
|
finish() {
|
||||||
clearInterval(this.voteTimer);
|
clearInterval(this.voteTimer);
|
||||||
if (this.session.recordVoteHistory) {
|
|
||||||
this.$store.commit("session/addHistory", this.players);
|
this.$store.commit("session/addHistory", this.players);
|
||||||
}
|
|
||||||
this.$store.commit("session/nomination");
|
this.$store.commit("session/nomination");
|
||||||
},
|
},
|
||||||
vote(vote) {
|
vote(vote) {
|
||||||
|
|
|
@ -78,6 +78,7 @@ export default new Vuex.Store({
|
||||||
state: {
|
state: {
|
||||||
grimoire: {
|
grimoire: {
|
||||||
isNight: false,
|
isNight: false,
|
||||||
|
recordVoteHistory: true,
|
||||||
isNightOrder: true,
|
isNightOrder: true,
|
||||||
isPublic: true,
|
isPublic: true,
|
||||||
isMenuOpen: false,
|
isMenuOpen: false,
|
||||||
|
@ -147,6 +148,13 @@ export default new Vuex.Store({
|
||||||
toggleNight: toggle("isNight"),
|
toggleNight: toggle("isNight"),
|
||||||
toggleGrimoire: toggle("isPublic"),
|
toggleGrimoire: toggle("isPublic"),
|
||||||
toggleImageOptIn: toggle("isImageOptIn"),
|
toggleImageOptIn: toggle("isImageOptIn"),
|
||||||
|
toggleRecordVoteHistory(state, param) {
|
||||||
|
if (param === true || param === false) {
|
||||||
|
state.session.recordVoteHistory = param;
|
||||||
|
} else {
|
||||||
|
state.session.recordVoteHistory = !state.session.recordVoteHistory;
|
||||||
|
}
|
||||||
|
},
|
||||||
toggleModal({ modals }, name) {
|
toggleModal({ modals }, name) {
|
||||||
if (name) {
|
if (name) {
|
||||||
modals[name] = !modals[name];
|
modals[name] = !modals[name];
|
||||||
|
|
|
@ -71,6 +71,7 @@ const mutations = {
|
||||||
* @param players
|
* @param players
|
||||||
*/
|
*/
|
||||||
addHistory(state, players) {
|
addHistory(state, players) {
|
||||||
|
if (!state.recordVoteHistory) return;
|
||||||
if (!state.nomination || state.lockedVote <= players.length) return;
|
if (!state.nomination || state.lockedVote <= players.length) return;
|
||||||
const isBanishment = players[state.nomination[1]].role.team === "traveler";
|
const isBanishment = players[state.nomination[1]].role.team === "traveler";
|
||||||
state.voteHistory.push({
|
state.voteHistory.push({
|
||||||
|
@ -89,9 +90,6 @@ const mutations = {
|
||||||
clearVoteHistory(state) {
|
clearVoteHistory(state) {
|
||||||
state.voteHistory = [];
|
state.voteHistory = [];
|
||||||
},
|
},
|
||||||
toggleRecordVoteHistory(state) {
|
|
||||||
state.recordVoteHistory = !state.recordVoteHistory;
|
|
||||||
},
|
|
||||||
/**
|
/**
|
||||||
* Store a vote with and without syncing it to the live session.
|
* Store a vote with and without syncing it to the live session.
|
||||||
* This is necessary in order to prevent infinite voting loops.
|
* This is necessary in order to prevent infinite voting loops.
|
||||||
|
|
|
@ -172,6 +172,10 @@ class LiveSession {
|
||||||
if (!this._isSpectator) return;
|
if (!this._isSpectator) return;
|
||||||
this._store.commit("toggleNight", params);
|
this._store.commit("toggleNight", params);
|
||||||
break;
|
break;
|
||||||
|
case "recordVoteHistory":
|
||||||
|
if (!this._isSpectator) return;
|
||||||
|
this._store.commit("toggleRecordVoteHistory", params);
|
||||||
|
break;
|
||||||
case "votingSpeed":
|
case "votingSpeed":
|
||||||
if (!this._isSpectator) return;
|
if (!this._isSpectator) return;
|
||||||
this._store.commit("session/setVotingSpeed", params);
|
this._store.commit("session/setVotingSpeed", params);
|
||||||
|
@ -268,6 +272,7 @@ class LiveSession {
|
||||||
this._sendDirect(playerId, "gs", {
|
this._sendDirect(playerId, "gs", {
|
||||||
gamestate: this._gamestate,
|
gamestate: this._gamestate,
|
||||||
isNight: grimoire.isNight,
|
isNight: grimoire.isNight,
|
||||||
|
recordVoteHistory: session.recordVoteHistory,
|
||||||
nomination: session.nomination,
|
nomination: session.nomination,
|
||||||
votingSpeed: session.votingSpeed,
|
votingSpeed: session.votingSpeed,
|
||||||
lockedVote: session.lockedVote,
|
lockedVote: session.lockedVote,
|
||||||
|
@ -289,6 +294,7 @@ class LiveSession {
|
||||||
gamestate,
|
gamestate,
|
||||||
isLightweight,
|
isLightweight,
|
||||||
isNight,
|
isNight,
|
||||||
|
recordVoteHistory,
|
||||||
nomination,
|
nomination,
|
||||||
votingSpeed,
|
votingSpeed,
|
||||||
votes,
|
votes,
|
||||||
|
@ -340,6 +346,7 @@ class LiveSession {
|
||||||
});
|
});
|
||||||
if (!isLightweight) {
|
if (!isLightweight) {
|
||||||
this._store.commit("toggleNight", !!isNight);
|
this._store.commit("toggleNight", !!isNight);
|
||||||
|
this._store.commit("toggleRecordVoteHistory", recordVoteHistory);
|
||||||
this._store.commit("session/nomination", {
|
this._store.commit("session/nomination", {
|
||||||
nomination,
|
nomination,
|
||||||
votes,
|
votes,
|
||||||
|
@ -686,6 +693,17 @@ class LiveSession {
|
||||||
this._send("isNight", this._store.state.grimoire.isNight);
|
this._send("isNight", this._store.state.grimoire.isNight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send the recordVoteHistory state. ST only
|
||||||
|
*/
|
||||||
|
setRecordVoteHistory() {
|
||||||
|
if (this._isSpectator) return;
|
||||||
|
this._send(
|
||||||
|
"recordVoteHistory",
|
||||||
|
this._store.state.session.recordVoteHistory
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send the voting speed. ST only
|
* Send the voting speed. ST only
|
||||||
* @param votingSpeed voting speed in seconds, minimum 1
|
* @param votingSpeed voting speed in seconds, minimum 1
|
||||||
|
@ -843,6 +861,9 @@ export default store => {
|
||||||
case "toggleNight":
|
case "toggleNight":
|
||||||
session.setIsNight();
|
session.setIsNight();
|
||||||
break;
|
break;
|
||||||
|
case "toggleRecordVoteHistory":
|
||||||
|
session.setRecordVoteHistory();
|
||||||
|
break;
|
||||||
case "setEdition":
|
case "setEdition":
|
||||||
session.sendEdition();
|
session.sendEdition();
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue