add ST reveal grimoire

This commit is contained in:
nicfreeman1209 2021-05-08 16:59:43 +01:00
parent fb87f6f8cb
commit bd0f343fc1
4 changed files with 75 additions and 11 deletions

View file

@ -130,6 +130,10 @@
Send Characters Send Characters
<em><font-awesome-icon icon="theater-masks"/></em> <em><font-awesome-icon icon="theater-masks"/></em>
</li> </li>
<li v-if="!session.isSpectator" @click="revealGrimoire">
Reveal Grimoire
<em><font-awesome-icon icon="satellite-dish"/></em>
</li>
<li <li
v-if="session.voteHistory.length" v-if="session.voteHistory.length"
@click="toggleModal('voteHistory')" @click="toggleModal('voteHistory')"
@ -274,6 +278,13 @@ export default {
); );
} }
}, },
revealGrimoire() {
if (this.session.isSpectator) return;
const popup = "Do you want to reveal the GRIMOIRE to players?";
if (confirm(popup)) {
this.$store.commit("session/revealGrimoire", true);
}
},
imageOptIn() { imageOptIn() {
const popup = const popup =
"Are you sure you want to allow custom images? A malicious script file author might track your IP address this way."; "Are you sure you want to allow custom images? A malicious script file author might track your IP address this way.";

View file

@ -33,6 +33,7 @@ const faIcons = [
"Question", "Question",
"Random", "Random",
"RedoAlt", "RedoAlt",
"SatelliteDish",
"SearchMinus", "SearchMinus",
"SearchPlus", "SearchPlus",
"Square", "Square",

View file

@ -25,7 +25,8 @@ const state = () => ({
votingSpeed: 3000, votingSpeed: 3000,
isVoteInProgress: false, isVoteInProgress: false,
voteHistory: [], voteHistory: [],
isRolesDistributed: false isRolesDistributed: false,
isGrimoireRevealed: false
}); });
const getters = {}; const getters = {};
@ -47,6 +48,7 @@ const mutations = {
setVoteInProgress: set("isVoteInProgress"), setVoteInProgress: set("isVoteInProgress"),
claimSeat: set("claimedSeat"), claimSeat: set("claimedSeat"),
distributeRoles: set("isRolesDistributed"), distributeRoles: set("isRolesDistributed"),
revealGrimoire: set("isGrimoireRevealed"),
setSessionId(state, sessionId) { setSessionId(state, sessionId) {
state.sessionId = sessionId state.sessionId = sessionId
.toLocaleLowerCase() .toLocaleLowerCase()

View file

@ -240,11 +240,17 @@ class LiveSession {
/** /**
* Publish the current gamestate. * Publish the current gamestate.
* Optional param to reduce traffic. (send only player data) * Optional param isLightweight to reduce traffic (=send only player data)
* Optional param isRevealGrimoire to reveal grimoire (=include ALL player roles, reminders & bluffs), overrides isLightweight
* @param playerId * @param playerId
* @param isLightweight * @param isLightweight
* @param isRevealGrimoire
*/ */
sendGamestate(playerId = "", isLightweight = false) { sendGamestate(
playerId = "",
isLightweight = false,
isRevealGrimoire = false
) {
if (this._isSpectator) return; if (this._isSpectator) return;
this._gamestate = this._store.state.players.players.map(player => ({ this._gamestate = this._store.state.players.players.map(player => ({
name: player.name, name: player.name,
@ -252,28 +258,39 @@ class LiveSession {
isDead: player.isDead, isDead: player.isDead,
isVoteless: player.isVoteless, isVoteless: player.isVoteless,
pronouns: player.pronouns, pronouns: player.pronouns,
...(player.role && player.role.team === "traveler" ...(player.role && (player.role.team === "traveler" || isRevealGrimoire)
? { roleId: player.role.id } ? { roleId: player.role.id }
: {}) : {}),
reminders: isRevealGrimoire
? player.reminders.map(reminder => ({
name: reminder.name,
role: reminder.role
}))
: {}
})); }));
if (isLightweight) { if (isLightweight && !isRevealGrimoire) {
this._sendDirect(playerId, "gs", { this._sendDirect(playerId, "gs", {
gamestate: this._gamestate, gamestate: this._gamestate,
isLightweight isLightweight
}); });
} else { } else {
const { session, grimoire } = this._store.state; const { session, grimoire } = this._store.state;
const { fabled } = this._store.state.players; const { fabled, bluffs } = this._store.state.players;
this.sendEdition(playerId); this.sendEdition(playerId);
this._sendDirect(playerId, "gs", { this._sendDirect(playerId, "gs", {
gamestate: this._gamestate, gamestate: this._gamestate,
isLightweight: isLightweight,
isRevealGrimoire: isRevealGrimoire,
isNight: grimoire.isNight, isNight: grimoire.isNight,
nomination: session.nomination, nomination: session.nomination,
votingSpeed: session.votingSpeed, votingSpeed: session.votingSpeed,
lockedVote: session.lockedVote, lockedVote: session.lockedVote,
isVoteInProgress: session.isVoteInProgress, isVoteInProgress: session.isVoteInProgress,
fabled: fabled.map(({ id }) => id), fabled: fabled.map(({ id }) => id),
...(session.nomination ? { votes: session.votes } : {}) ...(session.nomination ? { votes: session.votes } : {}),
bluffs: isRevealGrimoire
? bluffs.map(bluff => ({ roleId: bluff.id }))
: []
}); });
} }
} }
@ -288,14 +305,24 @@ class LiveSession {
const { const {
gamestate, gamestate,
isLightweight, isLightweight,
isRevealGrimoire,
isNight, isNight,
nomination, nomination,
votingSpeed, votingSpeed,
votes, votes,
lockedVote, lockedVote,
isVoteInProgress, isVoteInProgress,
fabled fabled,
bluffs
} = data; } = data;
if (isRevealGrimoire) {
// includes ALL roles, reminders & bluffs
const popup =
"Reveal the Storyteller's grimoire? This will overwrite your grimoire.";
if (!confirm(popup)) {
return;
}
}
const players = this._store.state.players.players; const players = this._store.state.players.players;
// adjust number of players // adjust number of players
if (players.length < gamestate.length) { if (players.length < gamestate.length) {
@ -337,6 +364,14 @@ class LiveSession {
value: {} value: {}
}); });
} }
// reminder tokens
if (isRevealGrimoire) {
this._store.commit("players/update", {
player,
property: "reminders",
value: state.reminders
});
}
}); });
if (!isLightweight) { if (!isLightweight) {
this._store.commit("toggleNight", !!isNight); this._store.commit("toggleNight", !!isNight);
@ -350,6 +385,18 @@ class LiveSession {
this._store.commit("players/setFabled", { this._store.commit("players/setFabled", {
fabled: fabled.map(id => this._store.state.fabled.get(id)) fabled: fabled.map(id => this._store.state.fabled.get(id))
}); });
if (isRevealGrimoire) {
this._store.commit("session/revealGrimoire", true);
bluffs.forEach((bluff, i) => {
const role =
this._store.state.roles.get(bluff.roleId) ||
this._store.getters.rolesJSONbyId.get(bluff.roleId) || {};
this._store.commit("players/setBluff", {
index: i,
role
});
});
}
} }
} }
@ -462,8 +509,8 @@ class LiveSession {
if (!this._isSpectator) return; if (!this._isSpectator) return;
const player = this._store.state.players.players[index]; const player = this._store.state.players.players[index];
if (!player) return; if (!player) return;
// special case where a player stops being a traveler
if (property === "role") { if (property === "role") {
// special case where a player stops being a traveler
if (!value && player.role.team === "traveler") { if (!value && player.role.team === "traveler") {
// reset to an unknown role // reset to an unknown role
this._store.commit("players/update", { this._store.commit("players/update", {
@ -472,7 +519,7 @@ class LiveSession {
value: {} value: {}
}); });
} else { } else {
// load role, first from session, the global, then fail gracefully // load role, first from session, then global, then fail gracefully
const role = const role =
this._store.state.roles.get(value) || this._store.state.roles.get(value) ||
this._store.getters.rolesJSONbyId.get(value) || this._store.getters.rolesJSONbyId.get(value) ||
@ -822,6 +869,9 @@ export default store => {
session.distributeRoles(); session.distributeRoles();
} }
break; break;
case "session/revealGrimoire":
session.sendGamestate("", false, true);
break;
case "session/nomination": case "session/nomination":
session.nomination(payload); session.nomination(payload);
break; break;