Merge branch 'issue/38/characters-in-script-order'

This commit is contained in:
Steffen 2020-06-30 09:46:23 +02:00
commit 8a982eace2
No known key found for this signature in database
GPG Key ID: 764D74E98267DFC6
1 changed files with 9 additions and 5 deletions

View File

@ -9,6 +9,8 @@ import rolesJSON from "../roles.json";
Vue.use(Vuex); Vue.use(Vuex);
const rolesJSONbyId = new Map(rolesJSON.map(role => [role.id, role]));
const getRolesByEdition = (edition = "tb") => { const getRolesByEdition = (edition = "tb") => {
const selectedEdition = const selectedEdition =
editionJSON.find(({ id }) => id === edition) || editionJSON[0]; editionJSON.find(({ id }) => id === edition) || editionJSON[0];
@ -96,12 +98,14 @@ export default new Vuex.Store({
grimoire.isScreenshot = false; grimoire.isScreenshot = false;
} }
}, },
setRoles(state, roles) { setRoles(state, roleIds) {
state.roles = new Map( state.roles = new Map(
rolesJSON roleIds
.filter(r => roles.includes(r.id)) .filter(roleId => rolesJSONbyId.has(roleId))
.sort((a, b) => b.team.localeCompare(a.team)) .sort((a, b) =>
.map(role => [role.id, role]) rolesJSONbyId.get(b).team.localeCompare(rolesJSONbyId.get(a).team)
)
.map(roleId => [roleId, rolesJSONbyId.get(roleId)])
); );
}, },
setEdition(state, edition) { setEdition(state, edition) {