diff --git a/system/scripts/actors/base-sheet.js b/system/scripts/actors/base-sheet.js index e534694..a07a177 100644 --- a/system/scripts/actors/base-sheet.js +++ b/system/scripts/actors/base-sheet.js @@ -41,7 +41,11 @@ export class BaseSheetL5r5e extends ActorSheet { // *** Skills *** html.find(".skill-name").on("click", (ev) => { const li = $(ev.currentTarget).parents(".skill"); - new game.l5r5e.DicePickerDialog({ skillId: li.data("skill"), actor: this.actor }).render(true); + new game.l5r5e.DicePickerDialog({ + skillId: li.data("skill"), + skillCatId: li.data("skillcat"), + actor: this.actor, + }).render(true); }); // *** Everything below here is only needed if the sheet is editable *** diff --git a/system/scripts/dice/dice-picker-dialog.js b/system/scripts/dice/dice-picker-dialog.js index 11556f1..f381596 100644 --- a/system/scripts/dice/dice-picker-dialog.js +++ b/system/scripts/dice/dice-picker-dialog.js @@ -67,7 +67,7 @@ export class DicePickerDialog extends FormApplication { * difficulty number (0-9) * difficultyHidden boolean * - * @param options actor, actorId, ringId, skillId, difficulty, difficultyHidden + * @param options actor, actorId, ringId, skillId, skillCatId, difficulty, difficultyHidden */ constructor(options = null) { super(options); @@ -89,13 +89,16 @@ export class DicePickerDialog extends FormApplication { this.ringId = options.ringId; } - // TODO SkillCategory ? - - // Skill + // Skill / SkillCategory if (options?.skillId) { this.skillId = options.skillId; } + // SkillCategory skillCatId + if (options?.skillCatId) { + this.skillCatId = options.skillCatId; + } + // Difficulty if (options?.difficulty) { this.difficulty = options.difficulty; @@ -139,24 +142,36 @@ export class DicePickerDialog extends FormApplication { name: "", }; - const cat = L5R5E.skills.get(skillId); - if (!cat) { + this.skillCatId = L5R5E.skills.get(skillId); + } + + /** + * Set and load skill's required data from actor and skillCatId + * @param skillId + */ + set skillCatId(skillCatId) { + if (!skillCatId) { return; } - this._skillData.cat = cat; - this._skillData.name = game.i18n.localize("l5r5e.skills." + cat + "." + this._skillData.id); + + this._skillData = { + ...this._skillData, + value: 0, + cat: skillCatId.toLowerCase().trim(), + name: game.i18n.localize("l5r5e.skills." + skillCatId + "." + (this._skillData.id || "title")), + }; if (!this._actor) { return; } switch (this._actor.data.type) { case "character": - this._skillData.value = this._actor.data.data.skills[cat]?.[this._skillData.id]?.value || 0; + this._skillData.value = this._actor.data.data.skills[skillCatId]?.[this._skillData.id] || 0; break; case "npc": // Skill value is in categories for npc - this._skillData.value = this._actor.data.data.skills[cat] || 0; + this._skillData.value = this._actor.data.data.skills[skillCatId] || 0; break; } } @@ -367,6 +382,7 @@ export class DicePickerDialog extends FormApplication { roll.actor = this._actor; roll.l5r5e.stance = approach; roll.l5r5e.skillId = this._skillData.id; + roll.l5r5e.skillCatId = this._skillData.cat; roll.l5r5e.summary.difficulty = this._difficulty.difficulty; roll.l5r5e.summary.difficultyHidden = this._difficulty.isHidden; diff --git a/system/scripts/dice/roll.js b/system/scripts/dice/roll.js index f502302..b8c91eb 100644 --- a/system/scripts/dice/roll.js +++ b/system/scripts/dice/roll.js @@ -14,6 +14,7 @@ export class RollL5r5e extends Roll { this.l5r5e = { stance: "", skillId: "", + skillCatId: "", actor: null, dicesTypes: { std: false, @@ -197,9 +198,6 @@ export class RollL5r5e extends Roll { this.roll(); } - const skillName = - game.i18n.translations.l5r5e.skills?.[L5R5E.skills.get(this.l5r5e.skillId)]?.[this.l5r5e.skillId] || ""; - // Define chat data const chatData = { formula: isPrivate ? "???" : this._formula, diff --git a/system/template.json b/system/template.json index f9b1b23..4c91e54 100644 --- a/system/template.json +++ b/system/template.json @@ -168,6 +168,7 @@ "templates": ["item"], "category": "", "skill": "melee", + "readied": false, "range": 0, "damage": 0, "deadliness": 0, diff --git a/system/templates/actors/character/skill.html b/system/templates/actors/character/skill.html index 5d51a4b..99a1166 100644 --- a/system/templates/actors/character/skill.html +++ b/system/templates/actors/character/skill.html @@ -1,7 +1,6 @@
  • -
  • \ No newline at end of file diff --git a/system/templates/actors/npc/skill.html b/system/templates/actors/npc/skill.html index 118594d..5a0d96c 100644 --- a/system/templates/actors/npc/skill.html +++ b/system/templates/actors/npc/skill.html @@ -1,10 +1,10 @@ \ No newline at end of file diff --git a/system/templates/dice/chat-roll.html b/system/templates/dice/chat-roll.html index b77664b..af0b1c9 100644 --- a/system/templates/dice/chat-roll.html +++ b/system/templates/dice/chat-roll.html @@ -19,7 +19,11 @@ - {{#if l5r5e.skillId}}{{localizeSkillId l5r5e.skillId}}{{/if}} + {{#if l5r5e.skillId}} + {{localizeSkillId l5r5e.skillId}} + {{else}} + {{#if l5r5e.skillCatId}}{{localizeSkill l5r5e.skillCatId 'title'}}{{/if}} + {{/if}} diff --git a/system/templates/items/weapon/weapon-sheet.html b/system/templates/items/weapon/weapon-sheet.html index c741504..824c5e8 100644 --- a/system/templates/items/weapon/weapon-sheet.html +++ b/system/templates/items/weapon/weapon-sheet.html @@ -30,7 +30,11 @@ +