Added convertSymbol for item's desc and actor's notes

This commit is contained in:
Vlyan
2021-01-02 12:35:08 +01:00
parent 2ceb501543
commit 331872e84f
6 changed files with 71 additions and 36 deletions

View File

@@ -1,4 +1,3 @@
import { L5R5E } from "./config.js";
import { ItemL5r5e } from "./item.js";
/**
@@ -21,7 +20,7 @@ export class HelpersL5r5e {
*/
static getSkillsList(useGroup = false) {
if (!useGroup) {
return Array.from(L5R5E.skills).map(([id, cat]) => ({
return Array.from(CONFIG.l5r5e.skills).map(([id, cat]) => ({
id: id,
cat: cat,
label: game.i18n.localize(`l5r5e.skills.${cat}.${id}`),
@@ -139,4 +138,18 @@ export class HelpersL5r5e {
}
return item;
}
/**
* Convert (op), (ex)... to associated symbols for content/descriptions
*/
static convertSymbols(text, toSymbol) {
CONFIG.l5r5e.symbols.forEach((cfg, tag) => {
if (toSymbol) {
text = text.replace(tag, `<i class="${cfg.class}" title="${game.i18n.localize(cfg.label)}"></i>`);
} else {
text = text.replace(new RegExp(`<i class="${cfg.class}" title="[^"]*"></i>`, "gi"), tag);
}
});
return text;
}
}