mirror of https://github.com/bra1n/townsquare.git
load custom script roles in live sessions
This commit is contained in:
parent
395619afb4
commit
5b6b36b645
|
@ -89,6 +89,9 @@ class LiveSession {
|
||||||
this.sendGamestate();
|
this.sendGamestate();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "edition":
|
||||||
|
this._updateEdition(params);
|
||||||
|
break;
|
||||||
case "gs":
|
case "gs":
|
||||||
this._updateGamestate(params);
|
this._updateGamestate(params);
|
||||||
break;
|
break;
|
||||||
|
@ -164,9 +167,9 @@ class LiveSession {
|
||||||
? { roleId: player.role.id }
|
? { roleId: player.role.id }
|
||||||
: {})
|
: {})
|
||||||
}));
|
}));
|
||||||
|
this.sendEdition();
|
||||||
this._send("gs", {
|
this._send("gs", {
|
||||||
gamestate: this._gamestate,
|
gamestate: this._gamestate,
|
||||||
edition: this._store.state.edition,
|
|
||||||
nomination: this._store.state.session.nomination,
|
nomination: this._store.state.session.nomination,
|
||||||
votingSpeed: this._store.state.session.votingSpeed
|
votingSpeed: this._store.state.session.votingSpeed
|
||||||
});
|
});
|
||||||
|
@ -179,8 +182,7 @@ class LiveSession {
|
||||||
*/
|
*/
|
||||||
_updateGamestate(data) {
|
_updateGamestate(data) {
|
||||||
if (!this._isSpectator) return;
|
if (!this._isSpectator) return;
|
||||||
const { gamestate, edition, nomination, votingSpeed } = data;
|
const { gamestate, nomination, votingSpeed } = data;
|
||||||
this._store.commit("setEdition", edition);
|
|
||||||
this._store.commit("session/nomination", nomination);
|
this._store.commit("session/nomination", nomination);
|
||||||
this._store.commit("session/setVotingSpeed", votingSpeed);
|
this._store.commit("session/setVotingSpeed", votingSpeed);
|
||||||
const players = this._store.state.players.players;
|
const players = this._store.state.players.players;
|
||||||
|
@ -223,6 +225,36 @@ class LiveSession {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Publish an edition update. ST only
|
||||||
|
*/
|
||||||
|
sendEdition() {
|
||||||
|
if (this._isSpectator) return;
|
||||||
|
const { edition } = this._store.state;
|
||||||
|
let roles;
|
||||||
|
if (edition === "custom") {
|
||||||
|
roles = Array.from(this._store.state.roles.keys());
|
||||||
|
}
|
||||||
|
this._send("edition", {
|
||||||
|
edition,
|
||||||
|
...(roles ? { roles } : {})
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update edition and roles for custom editions.
|
||||||
|
* @param edition
|
||||||
|
* @param roles
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
_updateEdition({ edition, roles }) {
|
||||||
|
if (!this._isSpectator) return;
|
||||||
|
this._store.commit("setEdition", edition);
|
||||||
|
if (roles) {
|
||||||
|
this._store.commit("setRoles", roles);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Publish a player update.
|
* Publish a player update.
|
||||||
* @param player
|
* @param player
|
||||||
|
@ -487,13 +519,15 @@ export default store => {
|
||||||
case "session/setVotingSpeed":
|
case "session/setVotingSpeed":
|
||||||
session.setVotingSpeed(payload);
|
session.setVotingSpeed(payload);
|
||||||
break;
|
break;
|
||||||
|
case "setEdition":
|
||||||
|
session.sendEdition();
|
||||||
|
break;
|
||||||
case "players/set":
|
case "players/set":
|
||||||
case "players/swap":
|
case "players/swap":
|
||||||
case "players/move":
|
case "players/move":
|
||||||
case "players/clear":
|
case "players/clear":
|
||||||
case "players/remove":
|
case "players/remove":
|
||||||
case "players/add":
|
case "players/add":
|
||||||
case "setEdition":
|
|
||||||
session.sendGamestate();
|
session.sendGamestate();
|
||||||
break;
|
break;
|
||||||
case "players/update":
|
case "players/update":
|
||||||
|
|
Loading…
Reference in New Issue