From c1db6aa4479d965d307532816278a2068a0c7a17 Mon Sep 17 00:00:00 2001 From: Dave Date: Fri, 8 Jan 2021 17:55:46 +0000 Subject: [PATCH 01/21] adding propertie to state for travelers not in the selected edition --- src/store/index.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/store/index.js b/src/store/index.js index eea3ae8..ac50082 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -25,6 +25,15 @@ const getRolesByEdition = (edition = editionJSON[0]) => { ); }; +const getTravelersNotInEdition = (edition = editionJSON[0]) => { + return new Map( + rolesJSON + .filter(r => r.team === "traveler") + .filter(r => 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 +79,7 @@ export default new Vuex.Store({ }, edition: editionJSONbyId.get("tb"), roles: getRolesByEdition(), + extraTravelers: getTravelersNotInEdition(), fabled }, getters: { From 0df7d8386d53e45b76eaf159676c1f6fc24b7fed Mon Sep 17 00:00:00 2001 From: Dave Date: Fri, 8 Jan 2021 18:35:22 +0000 Subject: [PATCH 02/21] making non edition travelers appear in roleModal --- src/components/modals/RoleModal.vue | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/components/modals/RoleModal.vue b/src/components/modals/RoleModal.vue index cd0f520..87f6d94 100644 --- a/src/components/modals/RoleModal.vue +++ b/src/components/modals/RoleModal.vue @@ -20,6 +20,14 @@ > +
  • + +
  • @@ -33,6 +41,20 @@ export default { components: { Token, Modal }, props: ["playerIndex"], computed: { + extraTravelers() { + const extraTravelers = []; + const players = this.$store.state.players.players; + this.$store.state.extraTravelers.forEach(role => { + if ( + this.playerIndex >= 0 || + (this.playerIndex < 0 && + !players.some(player => player.role.id === role.id)) + ) { + extraTravelers.push(role); + } + }); + return extraTravelers; + }, availableRoles() { const availableRoles = []; const players = this.$store.state.players.players; From ea574fcc58ebaa085f5a8812ec0482e01f825782 Mon Sep 17 00:00:00 2001 From: Dave Date: Sat, 9 Jan 2021 00:21:45 +0000 Subject: [PATCH 03/21] cleaning up code pulling non edition travellers in to the role modal and fixing spelling of travellers --- src/components/modals/RoleModal.vue | 17 +++-------------- src/store/index.js | 4 ++-- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/src/components/modals/RoleModal.vue b/src/components/modals/RoleModal.vue index 87f6d94..b55bd39 100644 --- a/src/components/modals/RoleModal.vue +++ b/src/components/modals/RoleModal.vue @@ -21,7 +21,7 @@
  • { - if ( - this.playerIndex >= 0 || - (this.playerIndex < 0 && - !players.some(player => player.role.id === role.id)) - ) { - extraTravelers.push(role); - } - }); - return extraTravelers; + extraTravellers() { + return [...this.$store.state.extraTravellers.values()]; }, availableRoles() { const availableRoles = []; diff --git a/src/store/index.js b/src/store/index.js index ac50082..61ea65c 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -25,7 +25,7 @@ const getRolesByEdition = (edition = editionJSON[0]) => { ); }; -const getTravelersNotInEdition = (edition = editionJSON[0]) => { +const getTravellersNotInEdition = (edition = editionJSON[0]) => { return new Map( rolesJSON .filter(r => r.team === "traveler") @@ -79,7 +79,7 @@ export default new Vuex.Store({ }, edition: editionJSONbyId.get("tb"), roles: getRolesByEdition(), - extraTravelers: getTravelersNotInEdition(), + extraTravellers: getTravellersNotInEdition(), fabled }, getters: { From 016d7feb39555e8d22148c95089f177be0a34ebd Mon Sep 17 00:00:00 2001 From: Dave Date: Sat, 9 Jan 2021 13:23:59 +0000 Subject: [PATCH 04/21] adding tabs to role modal and moving non edition travellers in to second tab --- src/components/modals/RoleModal.vue | 59 +++++++++++++++++++++-------- 1 file changed, 43 insertions(+), 16 deletions(-) diff --git a/src/components/modals/RoleModal.vue b/src/components/modals/RoleModal.vue index b55bd39..e908ca2 100644 --- a/src/components/modals/RoleModal.vue +++ b/src/components/modals/RoleModal.vue @@ -11,23 +11,41 @@ : "bluffing" }} -
      -
    • - -
    • -
    • - +
        +
      • + Edtition Roles + Other Travellers
      • +
          +
        • + +
        • +
        +
          +
        • + +
        • +
      @@ -63,6 +81,11 @@ export default { ...mapState(["modals", "roles", "session"]), ...mapState("players", ["players"]) }, + data() { + return { + tab: "editionRoles" + }; + }, methods: { setRole(role) { if (this.playerIndex < 0) { @@ -118,6 +141,10 @@ ul.tokens li { } } +.button.active { + background: linear-gradient(to bottom, $townsfolk 0%, rgba(0, 0, 0, 0.7) 100%); +} + #townsquare.spectator ul.tokens li.traveler { display: none; } From 7ab4bcbc4d8d24ce1b0cecda7332cf65117cbf24 Mon Sep 17 00:00:00 2001 From: Dave Date: Sat, 9 Jan 2021 13:34:01 +0000 Subject: [PATCH 05/21] Hiding additional traveller roles when selecting bluffs as travellers will not be used as bluffs anyway. --- src/components/modals/RoleModal.vue | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/modals/RoleModal.vue b/src/components/modals/RoleModal.vue index e908ca2..c90b562 100644 --- a/src/components/modals/RoleModal.vue +++ b/src/components/modals/RoleModal.vue @@ -12,7 +12,7 @@ }}
        -
      • +
      • 0; + }, ...mapMutations(["toggleModal"]) } }; From af0d944d4520c9f9ef95852efc5e8971211cda2e Mon Sep 17 00:00:00 2001 From: Dave Date: Sat, 9 Jan 2021 13:42:25 +0000 Subject: [PATCH 06/21] linting fix --- src/components/modals/RoleModal.vue | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/modals/RoleModal.vue b/src/components/modals/RoleModal.vue index c90b562..e483c89 100644 --- a/src/components/modals/RoleModal.vue +++ b/src/components/modals/RoleModal.vue @@ -145,7 +145,11 @@ ul.tokens li { } .button.active { - background: linear-gradient(to bottom, $townsfolk 0%, rgba(0, 0, 0, 0.7) 100%); + background: linear-gradient( + to bottom, + $townsfolk 0%, + rgba(0, 0, 0, 0.7) 100% + ); } #townsquare.spectator ul.tokens li.traveler { From 5700184fff352a8e8a7f7bc37127a06551ea9147 Mon Sep 17 00:00:00 2001 From: Dave Date: Sat, 9 Jan 2021 20:40:59 +0000 Subject: [PATCH 07/21] fixing filter logic in index state to correctly get travelers not in the currently selected edition. --- src/store/index.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/store/index.js b/src/store/index.js index 61ea65c..3165dc2 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -28,8 +28,12 @@ const getRolesByEdition = (edition = editionJSON[0]) => { const getTravellersNotInEdition = (edition = editionJSON[0]) => { return new Map( rolesJSON - .filter(r => r.team === "traveler") - .filter(r => r.edition !== edition.id || !edition.roles.includes(r.id)) + .filter( + r => + r.team === "traveler" && + r.edition !== edition.id && + !edition.roles.includes(r.id) + ) .map(role => [role.id, role]) ); }; @@ -195,6 +199,7 @@ export default new Vuex.Store({ if (editionJSONbyId.has(edition.id)) { state.edition = editionJSONbyId.get(edition.id); state.roles = getRolesByEdition(state.edition); + state.extraTravellers = getTravellersNotInEdition(state.edition); } else { state.edition = edition; } From ce6b66a33ee6210f868f80a751510249d9ff5910 Mon Sep 17 00:00:00 2001 From: Dave Date: Sat, 9 Jan 2021 21:23:24 +0000 Subject: [PATCH 08/21] making roles modal reset selected tab on close, stops traveller tab from showing on bluff selection and a better user experience --- src/components/modals/RoleModal.vue | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/components/modals/RoleModal.vue b/src/components/modals/RoleModal.vue index e483c89..b113616 100644 --- a/src/components/modals/RoleModal.vue +++ b/src/components/modals/RoleModal.vue @@ -1,8 +1,5 @@