Translate skills for technique list

Fixed img following the technique_type
This commit is contained in:
Vlyan
2022-03-22 20:35:11 +01:00
parent 35a7bbf974
commit a1c6f0f373
7 changed files with 109 additions and 22 deletions

View File

@@ -58,6 +58,34 @@ export class HelpersL5r5e {
}, new Map());
}
/**
* Get a flat map for skill translation
* @param {boolean} bToSkillId if true flip props/values
* @return {Object}
*/
static getSkillsTranslationMap(bToSkillId) {
let map = Array.from(CONFIG.l5r5e.skills).reduce((acc, [id, cat]) => {
acc[id] = game.i18n.localize(`l5r5e.skills.${cat}.${id}`);
acc[cat] = game.i18n.localize(`l5r5e.skills.${cat}.title`);
return acc;
}, {});
if (bToSkillId) {
map = Object.entries(map).reduce((obj, [key, value]) => ({ ...obj, [value]: key }), {});
}
return map;
}
/**
* Translate a list of skill and category
* @param {string[]} aIn
* @param {boolean} bToSkillId
* @return {string[]}
*/
static translateSkillsList(aIn, bToSkillId) {
const map = HelpersL5r5e.getSkillsTranslationMap(bToSkillId);
return aIn.map((skill) => map[skill.trim()]);
}
/**
* Get Techniques for List / Select
* @param types core|school|title|custom