Translate skills for technique list
Fixed img following the technique_type
This commit is contained in:
@@ -430,7 +430,7 @@ export class CharacterGenerator {
|
||||
*/
|
||||
_generateDemeanor(actorDatas) {
|
||||
// demeanor { id: "adaptable", mod: { fire: 2, earth: -2 } },
|
||||
const demeanor = CharacterGenerator._getRandomArrayValue(CONFIG.l5r5e.demeanorList);
|
||||
const demeanor = CharacterGenerator._getRandomArrayValue(CONFIG.l5r5e.demeanors);
|
||||
actorDatas.attitude = game.i18n.localize("l5r5e.demeanor." + demeanor.id);
|
||||
actorDatas.rings_affinities = foundry.utils.mergeObject(
|
||||
{
|
||||
|
||||
@@ -69,7 +69,7 @@ export class NpcSheetL5r5e extends BaseCharacterSheetL5r5e {
|
||||
game.l5r5e.HelpersL5r5e.autocomplete(
|
||||
html,
|
||||
"data.attitude",
|
||||
CONFIG.l5r5e.demeanorList.map((e) => {
|
||||
CONFIG.l5r5e.demeanors.map((e) => {
|
||||
let modifiers = [];
|
||||
Object.entries(e.mod).forEach(([k, v]) => {
|
||||
modifiers.push(`${game.i18n.localize(`l5r5e.rings.${k}`)} ${v}`);
|
||||
|
||||
@@ -152,7 +152,7 @@ L5R5E.families.set("qamarist", []);
|
||||
L5R5E.families.set("ujik", []);
|
||||
|
||||
// *** demeanor ***
|
||||
L5R5E.demeanorList = [
|
||||
L5R5E.demeanors = [
|
||||
{ id: "adaptable", mod: { fire: 2, earth: -2 } },
|
||||
{ id: "adaptable", mod: { water: 2, earth: -2 } },
|
||||
{ id: "aggressive", mod: { fire: 2, air: -2 } },
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -27,8 +27,11 @@ export class TechniqueSheetL5r5e extends ItemSheetL5r5e {
|
||||
sheetData.data.techniquesList = game.l5r5e.HelpersL5r5e.getTechniquesList({ types });
|
||||
|
||||
// Sanitize Difficulty and Skill list
|
||||
sheetData.data.data.skill = TechniqueSheetL5r5e.formatSkillList(sheetData.data.data.skill);
|
||||
sheetData.data.data.difficulty = TechniqueSheetL5r5e.formatDifficulty(sheetData.data.data.difficulty);
|
||||
sheetData.data.data.skill = game.l5r5e.HelpersL5r5e.translateSkillsList(
|
||||
TechniqueSheetL5r5e.formatSkillList(sheetData.data.data.skill.split(",")),
|
||||
false
|
||||
).join(", ");
|
||||
|
||||
return sheetData;
|
||||
}
|
||||
@@ -41,9 +44,19 @@ export class TechniqueSheetL5r5e extends ItemSheetL5r5e {
|
||||
* @override
|
||||
*/
|
||||
async _updateObject(event, formData) {
|
||||
// Change the image according to the type if this is already the case
|
||||
if (
|
||||
formData["data.technique_type"] &&
|
||||
formData.img === `${CONFIG.l5r5e.paths.assets}icons/techs/${this.object.data.data.technique_type}.svg`
|
||||
) {
|
||||
formData.img = `${CONFIG.l5r5e.paths.assets}icons/techs/${formData["data.technique_type"]}.svg`;
|
||||
}
|
||||
|
||||
// Sanitize Difficulty and Skill list
|
||||
formData["data.skill"] = TechniqueSheetL5r5e.formatSkillList(formData["data.skill"]);
|
||||
formData["data.difficulty"] = TechniqueSheetL5r5e.formatDifficulty(formData["data.difficulty"]);
|
||||
formData["data.skill"] = TechniqueSheetL5r5e.formatSkillList(
|
||||
game.l5r5e.HelpersL5r5e.translateSkillsList(formData["data.skill"].split(","), true)
|
||||
).join(",");
|
||||
|
||||
return super._updateObject(event, formData);
|
||||
}
|
||||
@@ -62,13 +75,26 @@ export class TechniqueSheetL5r5e extends ItemSheetL5r5e {
|
||||
}
|
||||
|
||||
// Autocomplete
|
||||
game.l5r5e.HelpersL5r5e.autocomplete(
|
||||
html,
|
||||
"data.difficulty",
|
||||
[
|
||||
"@T:intrigueRank",
|
||||
"@T:focus",
|
||||
"@T:martialRank",
|
||||
"@T:statusRank|max",
|
||||
"@T:strife.value|max",
|
||||
"@T:vigilance",
|
||||
"@T:vigilance|max",
|
||||
"@T:vigilance|min",
|
||||
"@T:vigilance|max(@T:statusRank)",
|
||||
],
|
||||
","
|
||||
);
|
||||
game.l5r5e.HelpersL5r5e.autocomplete(
|
||||
html,
|
||||
"data.skill",
|
||||
Array.from(game.l5r5e.HelpersL5r5e.getCategoriesSkillsList()).reduce((acc, [cat, skills]) => {
|
||||
acc.push(cat, ...skills);
|
||||
return acc;
|
||||
}, []),
|
||||
Object.values(game.l5r5e.HelpersL5r5e.getSkillsTranslationMap(false)),
|
||||
","
|
||||
);
|
||||
}
|
||||
@@ -87,8 +113,8 @@ export class TechniqueSheetL5r5e extends ItemSheetL5r5e {
|
||||
|
||||
/**
|
||||
* Sanitize the technique skill list
|
||||
* @param {string} skillList
|
||||
* @return {string}
|
||||
* @param {string[]} skillList
|
||||
* @return {string[]}
|
||||
*/
|
||||
static formatSkillList(skillList) {
|
||||
if (!skillList) {
|
||||
@@ -98,18 +124,18 @@ export class TechniqueSheetL5r5e extends ItemSheetL5r5e {
|
||||
|
||||
// List categories
|
||||
const unqCatList = new Set();
|
||||
skillList.split(",").forEach((s) => {
|
||||
s = s.trim();
|
||||
if (categories.has(s)) {
|
||||
skillList.forEach((s) => {
|
||||
s = s?.trim();
|
||||
if (!!s && categories.has(s)) {
|
||||
unqCatList.add(s);
|
||||
}
|
||||
});
|
||||
|
||||
// List skill (not include in cat)
|
||||
const unqSkillList = new Set();
|
||||
skillList.split(",").forEach((s) => {
|
||||
s = s.trim();
|
||||
if (CONFIG.l5r5e.skills.has(s)) {
|
||||
skillList.forEach((s) => {
|
||||
s = s?.trim();
|
||||
if (!!s && CONFIG.l5r5e.skills.has(s)) {
|
||||
const cat = CONFIG.l5r5e.skills.get(s);
|
||||
if (!unqCatList.has(cat)) {
|
||||
unqSkillList.add(s);
|
||||
@@ -117,6 +143,6 @@ export class TechniqueSheetL5r5e extends ItemSheetL5r5e {
|
||||
}
|
||||
});
|
||||
|
||||
return [...unqCatList, ...unqSkillList].join(",");
|
||||
return [...unqCatList, ...unqSkillList];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user