requested change

record marked player id in session
This commit is contained in:
nicfreeman1209 2021-05-08 11:01:23 +01:00
parent 205bd0ba79
commit 4d2afadc01
5 changed files with 15 additions and 20 deletions

View File

@ -101,7 +101,7 @@
<!-- On block icon -->
<font-awesome-icon
icon="skull"
v-if="player.isMarked"
v-if="session.markedPlayerId === index"
class="on-block"
/>

View File

@ -250,11 +250,11 @@ export default {
}
},
setMarked() {
this.$store.commit("players/setMarked", this.session.nomination[1]);
this.$store.commit("session/setMarkedPlayerId", this.session.nomination[1]);
this.finish();
},
removeMarked() {
this.$store.commit("players/setMarked", -1);
this.$store.commit("session/setMarkedPlayerId", -1);
this.finish();
}
}

View File

@ -5,7 +5,6 @@ const NEWPLAYER = {
reminders: [],
isVoteless: false,
isDead: false,
isMarked: false,
pronouns: ""
};
@ -137,14 +136,6 @@ const mutations = {
move(state, [from, to]) {
state.players.splice(to, 0, state.players.splice(from, 1)[0]);
},
setMarked(state, playerIndex) {
state.players.forEach(player => {
player.isMarked = false;
});
if (playerIndex >= 0) {
state.players[playerIndex].isMarked = true;
}
},
setBluff(state, { index, role } = {}) {
if (index !== undefined) {
state.bluffs.splice(index, 1, role);

View File

@ -25,6 +25,7 @@ const state = () => ({
votingSpeed: 3000,
isVoteInProgress: false,
voteHistory: [],
markedPlayerId: -1,
isRolesDistributed: false
});
@ -45,6 +46,7 @@ const mutations = {
setPing: set("ping"),
setVotingSpeed: set("votingSpeed"),
setVoteInProgress: set("isVoteInProgress"),
setMarkedPlayerId: set("markedPlayerId"),
claimSeat: set("claimedSeat"),
distributeRoles: set("isRolesDistributed"),
setSessionId(state, sessionId) {

View File

@ -168,9 +168,9 @@ class LiveSession {
if (!this._isSpectator) return;
this._store.commit("players/remove", params);
break;
case "onBlock":
case "marked":
if (!this._isSpectator) return;
this._store.commit("players/setMarked", params);
this._store.commit("session/setMarkedPlayerId", params);
break;
case "isNight":
if (!this._isSpectator) return;
@ -255,7 +255,6 @@ class LiveSession {
id: player.id,
isDead: player.isDead,
isVoteless: player.isVoteless,
isMarked: player.isMarked,
pronouns: player.pronouns,
...(player.role && player.role.team === "traveler"
? { roleId: player.role.id }
@ -277,6 +276,7 @@ class LiveSession {
votingSpeed: session.votingSpeed,
lockedVote: session.lockedVote,
isVoteInProgress: session.isVoteInProgress,
markedPlayerId: session.markedPlayerId,
fabled: fabled.map(({ id }) => id),
...(session.nomination ? { votes: session.votes } : {})
});
@ -299,6 +299,7 @@ class LiveSession {
votes,
lockedVote,
isVoteInProgress,
markedPlayerId,
fabled
} = data;
const players = this._store.state.players.players;
@ -317,7 +318,7 @@ class LiveSession {
const player = players[x];
const { roleId } = state;
// update relevant properties
["name", "id", "isDead", "isVoteless", "isMarked", "pronouns"].forEach(
["name", "id", "isDead", "isVoteless", "pronouns"].forEach(
property => {
const value = state[property];
if (player[property] !== value) {
@ -352,9 +353,10 @@ class LiveSession {
votes,
votingSpeed,
lockedVote,
isVoteInProgress
isVoteInProgress,
});
this._store.commit("players/setFabled", {
this._store.commit("session/setMarkedPlayerId", markedPlayerId);
this._store.commit("players/setFabled", {
fabled: fabled.map(id => this._store.state.fabled.get(id))
});
}
@ -710,7 +712,7 @@ class LiveSession {
*/
setMarked(playerIndex) {
if (this._isSpectator) return;
this._send("onBlock", playerIndex);
this._send("marked", playerIndex);
}
/**
@ -865,7 +867,7 @@ export default store => {
case "players/setFabled":
session.sendFabled();
break;
case "players/setMarked":
case "session/setMarkedPlayerId":
session.setMarked(payload);
break;
case "players/swap":