diff --git a/.eslintignore b/.eslintignore index 6c6f7f3..acafe3d 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,5 +1,6 @@ node_modules system/lib/ +system/packs/ .editorconfig .idea .vscode diff --git a/.prettierignore b/.prettierignore index a9e4d5b..b05e9fc 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,5 +1,6 @@ node_modules/ system/lib/ +system/packs/ *.hbs *.css .idea diff --git a/system/packs/macros.db b/system/packs/macros.db new file mode 100644 index 0000000..c35ac84 --- /dev/null +++ b/system/packs/macros.db @@ -0,0 +1 @@ +{"_id":"rWFmQHPlIpLB3qou","name":"L5R5e Dice Picker","permission":{"default":1,"5kJBcDAAfAognDuD":3},"type":"script","flags":{"furnace":{"runAsGM":false}},"scope":"global","command":"new game.l5r5e.DicePickerDialog().render();","author":"ZjNlNTgyMmI0ZjBj","img":"systems/l5r5e/assets/dices/default/skill_et.png","actorIds":[]} diff --git a/system/scripts/dice/dice-picker-dialog.js b/system/scripts/dice/dice-picker-dialog.js index b887a58..f74f5c6 100644 --- a/system/scripts/dice/dice-picker-dialog.js +++ b/system/scripts/dice/dice-picker-dialog.js @@ -8,7 +8,7 @@ export class DicePickerDialog extends Application { /** * Current Actor */ - actor = {}; + actor = null; /** * Selected Skill data from actor @@ -50,8 +50,6 @@ export class DicePickerDialog extends Application { this.actor = actor; } - console.log(this.actor); // TODO TMP - // Skill ? if (options?.skillId) { this.setSkillData(options.skillId); @@ -142,8 +140,14 @@ export class DicePickerDialog extends Application { await this.close(); }); - // Default Selected - html.find("#approach_air").trigger("click"); + // Check if a stance is selected + let selectedStance = "air"; + ["air", "earth", "fire", "water", "void"].forEach((e) => { + if (this.actor.data.data?.stances?.[e]?.isSelected?.value) { + selectedStance = e; + } + }); + html.find(`#approach_${selectedStance}`).trigger("click"); html.find("#skill_" + this.skillData.value).trigger("click"); } @@ -168,10 +172,8 @@ export class DicePickerDialog extends Application { } this.skillData.cat = cat; - this.skillData.value = this.actor.data.data.skills[cat]?.[this.skillData.id].value || 0; + this.skillData.value = this.actor.data?.data?.skills[cat]?.[this.skillData.id].value || 0; this.skillData.name = game.i18n.localize("l5r5e.skills." + cat + "." + this.skillData.id); - - console.log("****** skillData", this.skillData, this.actor.data.data.skills); } /** @@ -183,7 +185,7 @@ export class DicePickerDialog extends Application { return { id: e, label: game.i18n.localize(`l5r5e.rings.${e}`), - value: this.actor ? this.actor.data.data.rings[e] : 0, + value: this.actor?.data?.data?.rings?.[e] || 0, }; }); } diff --git a/system/system.json b/system/system.json index e908cf3..f12d9f0 100644 --- a/system/system.json +++ b/system/system.json @@ -7,11 +7,8 @@ "compatibleCoreVersion": "1.0.0", "author": "Team L5R", "scripts": ["./l5r-ui/scripts/l5rui-chat-color.js"], - "esmodules": ["./l5r-ui/scripts/help/l5rui-help.js", "./scripts/dice-l5r5e.js", "./scripts/main-l5r5e.js"], - "styles": ["./l5r-ui/css/l5rui.css", "./l5r-ui/css/cursor.css", "./styles/l5r5e.css"], - "languages": [ { "lang": "en", @@ -34,9 +31,15 @@ "path": "lang/pt-br.json" } ], - "background": "L5R-Header.webp", - "packs": [], + "packs": [ + { + "name": "macros", + "label": "L5R5e Macros", + "path": "packs/macros.db", + "entity": "Macro" + } + ], "url": "https://gitlab.com/teaml5r/l5r5e", "manifest": "https://gitlab.com/teaml5r/l5r5e/-/raw/master/system/system.json", "download": "https://gitlab.com/teaml5r/l5r5e/-/jobs/artifacts/v0.0.2/raw/l5r5e.zip?job=build"