diff --git a/src/components/modals/ReminderModal.vue b/src/components/modals/ReminderModal.vue index 3320fdd..763a0c4 100644 --- a/src/components/modals/ReminderModal.vue +++ b/src/components/modals/ReminderModal.vue @@ -82,6 +82,21 @@ export default { })) ]; }); + + // add out of script traveler reminders + this.$store.state.otherTravelers.forEach(role => { + if (players.some(p => p.role.id === role.id)) { + reminders = [ + ...reminders, + ...role.reminders.map(name => ({ + role: role.id, + image: role.image, + name + })) + ]; + } + }); + reminders.push({ role: "good", name: "Good" }); reminders.push({ role: "evil", name: "Evil" }); reminders.push({ role: "custom", name: "Custom note" }); diff --git a/src/components/modals/RoleModal.vue b/src/components/modals/RoleModal.vue index cd0f520..4bb50c2 100644 --- a/src/components/modals/RoleModal.vue +++ b/src/components/modals/RoleModal.vue @@ -1,8 +1,5 @@ @@ -50,7 +74,13 @@ export default { return availableRoles; }, ...mapState(["modals", "roles", "session"]), - ...mapState("players", ["players"]) + ...mapState("players", ["players"]), + ...mapState(["otherTravelers"]) + }, + data() { + return { + tab: "editionRoles" + }; }, methods: { setRole(role) { @@ -72,6 +102,10 @@ export default { } this.$store.commit("toggleModal", "role"); }, + close() { + this.tab = "editionRoles"; + this.toggleModal("role"); + }, ...mapMutations(["toggleModal"]) } }; diff --git a/src/store/index.js b/src/store/index.js index eea3ae8..bbd0c60 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -25,6 +25,19 @@ const getRolesByEdition = (edition = editionJSON[0]) => { ); }; +const getTravelersNotInEdition = (edition = editionJSON[0]) => { + return new Map( + rolesJSON + .filter( + r => + r.team === "traveler" && + r.edition !== edition.id && + !edition.roles.includes(r.id) + ) + .map(role => [role.id, role]) + ); +}; + // base definition for custom roles const imageBase = "https://raw.githubusercontent.com/bra1n/townsquare/main/src/assets/icons/"; @@ -70,6 +83,7 @@ export default new Vuex.Store({ }, edition: editionJSONbyId.get("tb"), roles: getRolesByEdition(), + otherTravelers: getTravelersNotInEdition(), fabled }, getters: { @@ -180,11 +194,18 @@ export default new Vuex.Store({ // convert to Map .map(role => [role.id, role]) ); + // update extraTravelers map to only show travelers not in this script + state.otherTravelers = new Map( + rolesJSON + .filter(r => r.team === "traveler" && !roles.some(i => i.id === r.id)) + .map(role => [role.id, role]) + ); }, setEdition(state, edition) { if (editionJSONbyId.has(edition.id)) { state.edition = editionJSONbyId.get(edition.id); state.roles = getRolesByEdition(state.edition); + state.otherTravelers = getTravelersNotInEdition(state.edition); } else { state.edition = edition; }