custom roles are no longer synced in live games due to traffic and security concerns (closes #60)

This commit is contained in:
Steffen 2020-12-10 22:30:34 +01:00
parent c09d1c7101
commit 200c7f9b7d
5 changed files with 29 additions and 5 deletions

View File

@ -69,7 +69,8 @@ For base game characters, it is sufficient to only provide the ID, similar to wh
- **team**: the team of the character, has to be one of `townsfolk`, `outsider`, `minion`, `demon` or `traveler` - **team**: the team of the character, has to be one of `townsfolk`, `outsider`, `minion`, `demon` or `traveler`
- **ability**: the displayed ability text of the character - **ability**: the displayed ability text of the character
_Note:_ custom characters are currently not supported in live sessions and will not be synchronised to other players. _Note:_ in order to use custom characters in live sessions, your players have to load the same JSON file that the storyteller
has loaded before joining the live session.
## [Code of Conduct](CODE_OF_CONDUCT.md) ## [Code of Conduct](CODE_OF_CONDUCT.md)

View File

@ -38,6 +38,7 @@
>the documentation</a >the documentation</a
> >
on how to write a custom character definition file. on how to write a custom character definition file.
<b>Only load custom JSON files from sources that you trust!</b>
<h3>Some popular custom scripts:</h3> <h3>Some popular custom scripts:</h3>
<ul class="scripts"> <ul class="scripts">
<li <li

View File

@ -163,7 +163,9 @@ export default new Vuex.Store({
// map existing roles to base definition or pre-populate custom roles to ensure all properties // map existing roles to base definition or pre-populate custom roles to ensure all properties
.map( .map(
role => role =>
rolesJSONbyId.get(role.id) || Object.assign({}, customRole, role) rolesJSONbyId.get(role.id) ||
state.roles.get(role.id) ||
Object.assign({}, customRole, role)
) )
// default empty icons to good / evil / traveler // default empty icons to good / evil / traveler
.map(role => { .map(role => {

View File

@ -15,6 +15,7 @@ module.exports = store => {
} }
if (localStorage.roles !== undefined) { if (localStorage.roles !== undefined) {
store.commit("setCustomRoles", JSON.parse(localStorage.roles)); store.commit("setCustomRoles", JSON.parse(localStorage.roles));
store.commit("setEdition", "custom");
} }
if (localStorage.bluffs !== undefined) { if (localStorage.bluffs !== undefined) {
JSON.parse(localStorage.bluffs).forEach((role, index) => { JSON.parse(localStorage.bluffs).forEach((role, index) => {
@ -85,7 +86,10 @@ module.exports = store => {
if (!payload.length) { if (!payload.length) {
localStorage.removeItem("roles"); localStorage.removeItem("roles");
} else { } else {
localStorage.setItem("roles", JSON.stringify(payload)); localStorage.setItem(
"roles",
JSON.stringify(store.getters.customRoles)
);
} }
break; break;
case "players/setBluff": case "players/setBluff":

View File

@ -320,7 +320,7 @@ class LiveSession {
const { edition } = this._store.state; const { edition } = this._store.state;
let roles; let roles;
if (edition === "custom") { if (edition === "custom") {
roles = this._store.getters.customRoles; roles = Array.from(this._store.state.roles.keys());
} }
this._send("edition", { this._send("edition", {
edition, edition,
@ -338,7 +338,23 @@ class LiveSession {
if (!this._isSpectator) return; if (!this._isSpectator) return;
this._store.commit("setEdition", edition); this._store.commit("setEdition", edition);
if (roles) { if (roles) {
this._store.commit("setCustomRoles", roles); this._store.commit(
"setCustomRoles",
roles.map(id => ({ id }))
);
if (this._store.state.roles.size !== roles.length) {
const missing = [];
roles.forEach(id => {
if (!this._store.state.roles.get(id)) {
missing.push(id);
}
});
alert(
`This session contains custom characters that can't be found. ` +
`Please load them before joining! ` +
`Missing roles: ${missing.join(", ")}`
);
}
} }
} }