Added support for rolling skill on spells

This commit is contained in:
2020-12-01 09:04:03 +01:00
parent cbafeede44
commit 836875459c
6 changed files with 81 additions and 18 deletions

View File

@@ -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");