updated sockets send and recieve logic for pronouns to allow ST to update players pronouns and block infinite loops between a seated player and ST updates

This commit is contained in:
Dave 2021-02-28 16:08:31 +00:00
parent 81af122458
commit 6ad516588c
1 changed files with 12 additions and 5 deletions

View File

@ -491,21 +491,28 @@ class LiveSession {
* @param value * @param value
*/ */
sendPlayerPronouns({ player, value }) { sendPlayerPronouns({ player, value }) {
//send pronoun only for the current player //send pronoun only for the seated player or storyteller
if (this._store.state.session.playerId !== player.id) return; if (this._isSpectator && this._store.state.session.playerId !== player.id)
return;
const index = this._store.state.players.players.indexOf(player); const index = this._store.state.players.players.indexOf(player);
this._send("pronouns", { index, value }); this._send("pronouns", { index, value, fromST: !this._isSpectator });
} }
/** /**
* Update a pronouns based on incoming data. Player only. * Update a pronouns based on incoming data. Player only.
* @param index * @param index
* @param value * @param value
* @param fromSt
* @private * @private
*/ */
_updatePlayerPronouns({ index, value }) { _updatePlayerPronouns({ index, value, fromST }) {
const player = this._store.state.players.players[index]; const player = this._store.state.players.players[index];
if (!player || this._store.state.session.playerId === player.id) return; if (
!player ||
(!fromST && this._store.state.session.playerId === player.id) ||
player.pronouns === value
)
return;
this._store.commit("players/update", { this._store.commit("players/update", {
player, player,
property: "pronouns", property: "pronouns",