From 396990cd1d8f701cbcc5ec227852a8af3f22dcba Mon Sep 17 00:00:00 2001 From: Ben Finney Date: Wed, 24 Jun 2020 22:32:08 +1000 Subject: [PATCH 1/3] Define Map of all known characters. --- src/store/index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/store/index.js b/src/store/index.js index ebdcde2..d266d3b 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -9,6 +9,8 @@ import rolesJSON from "../roles.json"; Vue.use(Vuex); +const rolesJSONbyId = new Map(rolesJSON.map(role => [role.id, role])); + const getRolesByEdition = (edition = "tb") => { const selectedEdition = editionJSON.find(({ id }) => id === edition) || editionJSON[0]; From 8aebece218f620bf2c68f5b071cc17442bd830a6 Mon Sep 17 00:00:00 2001 From: Ben Finney Date: Wed, 24 Jun 2020 22:33:31 +1000 Subject: [PATCH 2/3] Rename a parameter to more accurately reflect its usage. --- src/store/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/store/index.js b/src/store/index.js index d266d3b..0c52dbd 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -98,10 +98,10 @@ export default new Vuex.Store({ grimoire.isScreenshot = false; } }, - setRoles(state, roles) { + setRoles(state, roleIds) { state.roles = new Map( rolesJSON - .filter(r => roles.includes(r.id)) + .filter(r => roleIds.includes(r.id)) .sort((a, b) => b.team.localeCompare(a.team)) .map(role => [role.id, role]) ); From ac475e39ce1d014ddacd72a6e6e0ecc76eefd0c5 Mon Sep 17 00:00:00 2001 From: Ben Finney Date: Wed, 24 Jun 2020 22:40:01 +1000 Subject: [PATCH 3/3] Store characters in the order specified in the script. This corrects issue #38 by following the script sequence (not the catalogue of characters) for storing the characters. --- src/store/index.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/store/index.js b/src/store/index.js index 0c52dbd..3355e9d 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -100,10 +100,12 @@ export default new Vuex.Store({ }, setRoles(state, roleIds) { state.roles = new Map( - rolesJSON - .filter(r => roleIds.includes(r.id)) - .sort((a, b) => b.team.localeCompare(a.team)) - .map(role => [role.id, role]) + roleIds + .filter(roleId => rolesJSONbyId.has(roleId)) + .sort((a, b) => + rolesJSONbyId.get(b).team.localeCompare(rolesJSONbyId.get(a).team) + ) + .map(roleId => [roleId, rolesJSONbyId.get(roleId)]) ); }, setEdition(state, edition) {