diff --git a/README.md b/README.md
index a749f05..8c3fb4b 100644
--- a/README.md
+++ b/README.md
@@ -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`
- **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)
diff --git a/src/components/modals/EditionModal.vue b/src/components/modals/EditionModal.vue
index d3fce6f..3670a71 100644
--- a/src/components/modals/EditionModal.vue
+++ b/src/components/modals/EditionModal.vue
@@ -38,6 +38,7 @@
>the documentation
on how to write a custom character definition file.
+ Only load custom JSON files from sources that you trust!
Some popular custom scripts:
-
- 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
.map(role => {
diff --git a/src/store/persistence.js b/src/store/persistence.js
index 5026d6e..fe2eb71 100644
--- a/src/store/persistence.js
+++ b/src/store/persistence.js
@@ -15,6 +15,7 @@ module.exports = store => {
}
if (localStorage.roles !== undefined) {
store.commit("setCustomRoles", JSON.parse(localStorage.roles));
+ store.commit("setEdition", "custom");
}
if (localStorage.bluffs !== undefined) {
JSON.parse(localStorage.bluffs).forEach((role, index) => {
@@ -85,7 +86,10 @@ module.exports = store => {
if (!payload.length) {
localStorage.removeItem("roles");
} else {
- localStorage.setItem("roles", JSON.stringify(payload));
+ localStorage.setItem(
+ "roles",
+ JSON.stringify(store.getters.customRoles)
+ );
}
break;
case "players/setBluff":
diff --git a/src/store/socket.js b/src/store/socket.js
index 1504d02..8fb9d5e 100644
--- a/src/store/socket.js
+++ b/src/store/socket.js
@@ -320,7 +320,7 @@ class LiveSession {
const { edition } = this._store.state;
let roles;
if (edition === "custom") {
- roles = this._store.getters.customRoles;
+ roles = Array.from(this._store.state.roles.keys());
}
this._send("edition", {
edition,
@@ -338,7 +338,23 @@ class LiveSession {
if (!this._isSpectator) return;
this._store.commit("setEdition", edition);
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(", ")}`
+ );
+ }
}
}