diff --git a/module/actors/actor-sheet.js b/module/actors/actor-sheet.js index a7667a3..252183a 100644 --- a/module/actors/actor-sheet.js +++ b/module/actors/actor-sheet.js @@ -273,7 +273,7 @@ export class ActorSheetKH extends ActorSheet { /* Roll spell cost */ html.find(".roll-spell-cost").click((ev) => { - const li = $(ev.currentTarget).parents(".item"); + const li = $(ev.currentTarget).parents(".item-spell"); let itemId = li.data("itemId"); let spell = this.actor.getOwnedItem(itemId); @@ -296,6 +296,63 @@ export class ActorSheetKH extends ActorSheet { } }); + html.find(".roll-spell-skill").click((ev) => { + const li = $(ev.currentTarget).parents(".item-spell"); + let itemId = li.data("itemId"); + let spell = this.actor.getOwnedItem(itemId); + + if (!spell) { + spell = game.items.get(itemId); + + if (!spell) { + console.log("IMPORT ERROR") + return + } + } + + let showValue = false + let difficulty = 0 + + if(this.actor.data.type === "character") { + showValue = true + } + + switch (spell.data.data.difficulty.value) { + case "simple": + difficulty = 5 + break; + case "easy": + difficulty = 2 + break; + case "hard": + difficulty = -2 + break; + case "daunting": + difficulty = -5 + break; + } + + if(spell.data.data.roll.value === "roll" || spell.data.data.roll.value === "attackroll") { + // Retrieve skill based on name + let skill = this.actor.items.find((element) => element.name === spell.data.data.roll.skill); + + let skillName = spell.name + " (" + skill.name + ")" + let skillValue = skill.data.data.value + + this.khRoller.rollSkillInChat(skillName, skillValue, showValue, this.actor, difficulty) + } else if(spell.data.data.roll.value === "opposite") { + // Retrieve skill based on name + let skill = this.actor.items.find((element) => element.name === spell.data.data.roll.skill); + + let skillName = spell.name + " (" + skill.name + ")" + let skillValue = skill.data.data.value + + this.khRoller.rollSkillInChat(skillName, skillValue, showValue, this.actor, difficulty) + } else if(spell.data.data.roll.value === "ritual") { + console.log("Not supported yet") + } + }); + /* Roll skill */ html.find(".roll-skill").click((ev) => { const li = $(ev.currentTarget).parents(".item-skill"); diff --git a/styles/items.css b/styles/items.css index 6d46ffe..12964f9 100644 --- a/styles/items.css +++ b/styles/items.css @@ -97,7 +97,10 @@ margin: auto; } -.items .items-list .item { +.items .items-list .item, +.items .items-list .item-spell, +.items .items-list .item-weapon, +.items .items-list .item-skill { line-height: 24px; padding: 3px 0; border-bottom: 1px solid #bbb; diff --git a/template.json b/template.json index ef81933..ab74347 100644 --- a/template.json +++ b/template.json @@ -233,7 +233,8 @@ "value": "roll", "type": "String", "label": "SPELL.ROLLTITLE", - "skill": "Trolldom" + "skill": "Trolldom", + "ritual": {} }, "cost": { "value": "", diff --git a/templates/dice/roll.html b/templates/dice/roll.html index 3095534..160d58b 100644 --- a/templates/dice/roll.html +++ b/templates/dice/roll.html @@ -5,12 +5,12 @@
{{#if closed}} -
+
{{localize "ROLL.CLOSED"}}: {{closed}}
{{/if}} {{#if opened}} -
+
{{localize "ROLL.OPENED"}}: {{opened}}
{{/if}} @@ -23,14 +23,14 @@
{{#if success}} -
+

{{#if excetional}}{{localize "ROLL.EXCEPTIONAL"}}{{/if}} {{localize "ROLL.SUCCESS"}} -

+ {{/if}} {{#if failure}} -
+

{{#if excetional}}{{localize "ROLL.EXCEPTIONAL"}}{{/if}} {{localize "ROLL.FAILURE"}} -

+ {{/if}}
diff --git a/templates/parts/actor/talent.html b/templates/parts/actor/talent.html index 4f75767..696929c 100644 --- a/templates/parts/actor/talent.html +++ b/templates/parts/actor/talent.html @@ -25,13 +25,13 @@