mirror of https://github.com/bra1n/townsquare.git
adding code to transmit changes to player pronoun
This commit is contained in:
parent
e60def4226
commit
60fab2efe0
|
@ -170,6 +170,9 @@ class LiveSession {
|
|||
case "bye":
|
||||
this._handleBye(params);
|
||||
break;
|
||||
case "pronoun":
|
||||
this._updatePlayerPronoun(params);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -461,6 +464,24 @@ class LiveSession {
|
|||
}
|
||||
}
|
||||
|
||||
sendPlayerPronoun({ player, pronoun }) {
|
||||
if (!this._isSpectator) return;
|
||||
const index = this._store.state.players.players.indexOf(player);
|
||||
this._send("pronoun", { index, pronoun });
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a pronoun based on incoming data. Player only.
|
||||
* @param index
|
||||
* @param pronoun
|
||||
* @private
|
||||
*/
|
||||
_updatePlayerPronoun({ index, pronoun }) {
|
||||
const player = this._store.state.players.players[index];
|
||||
if (!player) return;
|
||||
this._store.commit("players/setPronoun", { player, pronoun });
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle a ping message by another player / storyteller
|
||||
* @param isSpectator
|
||||
|
@ -789,6 +810,9 @@ export default store => {
|
|||
case "players/update":
|
||||
session.sendPlayer(payload);
|
||||
break;
|
||||
case "players/setPronoun":
|
||||
session.sendPlayerPronoun(payload);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue