v0.0.3
Finishing v0.0.3 Layout fixes Added support for rolling skill on spells Fixed migration Cleaned up the code Fixed Hjältarnas Tid skill error, updated layout, fixed buttons not working Fixed right click menu for weapons Added roll dialog and exceptional rolls Updated skills styling Co-Authored-By: erebus <erebus@rikspolisen.se> Co-Committed-By: erebus <erebus@rikspolisen.se>
This commit was merged in pull request #2.
This commit is contained in:
@@ -139,6 +139,186 @@ export class ActorSheetKH extends ActorSheet {
|
||||
},
|
||||
]);
|
||||
|
||||
new ContextMenu(html, "li.item-weapon", [
|
||||
{
|
||||
name: game.i18n.localize("MENU.SHOWROLLDIALOG"),
|
||||
icon: '<i class="far dice"></i>',
|
||||
callback: (li) => {
|
||||
let itemId = li.data("itemId");
|
||||
let _item = this.actor.items.find((element) => element._id == itemId);
|
||||
|
||||
// Retrieve skill based on name
|
||||
let skill = this.actor.items.find((element) => element.name === _item.data.data.skill.value);
|
||||
|
||||
let skillName = skill.name
|
||||
let skillValue = skill.data.data.value
|
||||
let showValue = false
|
||||
|
||||
if(this.actor.data.type === "character") {
|
||||
showValue = true
|
||||
}
|
||||
|
||||
this.khRoller.rollSkillDialogInChat(skillName, skillValue, showValue, this.actor)
|
||||
},
|
||||
},
|
||||
{
|
||||
name: game.i18n.localize("MENU.SENTTOCHAT"),
|
||||
icon: '<i class="far fa-comment"></i>',
|
||||
callback: (li) => {
|
||||
let itemId = li.data("itemId");
|
||||
this._itemDetailsToChat(itemId);
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
new ContextMenu(html, "li.item-skill", [
|
||||
{
|
||||
name: game.i18n.localize("MENU.SHOWROLLDIALOG"),
|
||||
icon: '<i class="far dice"></i>',
|
||||
callback: (li) => {
|
||||
let itemId = li.data("itemId");
|
||||
let _item = this.actor.items.find((element) => element._id == itemId);
|
||||
|
||||
let skillName = _item.name
|
||||
let skillValue = _item.data.data.value
|
||||
let showValue = false
|
||||
|
||||
if(this.actor.data.type === "character") {
|
||||
showValue = true
|
||||
}
|
||||
|
||||
this.khRoller.rollSkillDialogInChat(skillName, skillValue, showValue, this.actor)
|
||||
},
|
||||
},
|
||||
{
|
||||
name: game.i18n.localize("MENU.SENTTOCHAT"),
|
||||
icon: '<i class="far fa-comment"></i>',
|
||||
callback: (li) => {
|
||||
let itemId = li.data("itemId");
|
||||
this._itemDetailsToChat(itemId);
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
new ContextMenu(html, "li.item-spell", [
|
||||
{
|
||||
name: game.i18n.localize("MENU.SHOWROLLDIALOG"),
|
||||
icon: '<i class="far dice"></i>',
|
||||
callback: (li) => {
|
||||
let itemId = li.data("itemId");
|
||||
let _item = this.actor.items.find((element) => element._id == itemId);
|
||||
|
||||
if (!_item) {
|
||||
_item = game.items.get(itemId);
|
||||
|
||||
if (!_item) {
|
||||
console.log("IMPORT ERROR")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
let showValue = false
|
||||
let difficulty = 0
|
||||
|
||||
if(this.actor.data.type === "character") {
|
||||
showValue = true
|
||||
}
|
||||
|
||||
switch (_item.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(_item.data.data.roll.value === "roll" || _item.data.data.roll.value === "attackroll") {
|
||||
// Retrieve skill based on name
|
||||
let skill = this.actor.items.find((element) => element.name === _item.data.data.roll.skill);
|
||||
|
||||
let skillName = _item.name
|
||||
let skillValue = skill.data.data.value
|
||||
|
||||
if(this.actor.data.type === "character") {
|
||||
skillName = _item.name + " (" + skill.name + ")"
|
||||
}
|
||||
|
||||
this.khRoller.rollSkillDialogInChat(skillName, skillValue, showValue, this.actor, difficulty)
|
||||
} else if(_item.data.data.roll.value === "opposite") {
|
||||
// Retrieve skill based on name
|
||||
let skill = this.actor.items.find((element) => element.name === _item.data.data.roll.skill);
|
||||
|
||||
let skillName = _item.name
|
||||
let skillValue = skill.data.data.value
|
||||
|
||||
if(this.actor.data.type === "character") {
|
||||
skillName = _item.name + " (" + skill.name + ")"
|
||||
}
|
||||
|
||||
this.khRoller.rollSkillDialogInChat(skillName, skillValue, showValue, this.actor, difficulty)
|
||||
} else if(_item.data.data.roll.value === "ritual") {
|
||||
console.log("Not supported yet")
|
||||
this.khRoller.rollSkillDialogInChat("Ritual", -1, showValue, this.actor, difficulty)
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
name: game.i18n.localize("MENU.SENTTOCHAT"),
|
||||
icon: '<i class="far fa-comment"></i>',
|
||||
callback: (li) => {
|
||||
let itemId = li.data("itemId");
|
||||
this._itemDetailsToChat(itemId);
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
new ContextMenu(html, "li.item-attack", [
|
||||
{
|
||||
name: game.i18n.localize("MENU.SHOWROLLDIALOG"),
|
||||
icon: '<i class="far dice"></i>',
|
||||
callback: (li) => {
|
||||
let skillValue = li.data("ability");
|
||||
let skillName = "ITEM.ATTACK";
|
||||
let showValue = false
|
||||
|
||||
if(this.actor.data.type === "character") {
|
||||
showValue = true
|
||||
}
|
||||
|
||||
this.khRoller.rollSkillDialogInChat(skillName, skillValue, showValue, this.actor)
|
||||
},
|
||||
},
|
||||
{
|
||||
name: game.i18n.localize("MENU.SENTTOCHAT"),
|
||||
icon: '<i class="far fa-comment"></i>',
|
||||
callback: (li) => {
|
||||
let itemId = li.data("itemId");
|
||||
this._itemDetailsToChat(itemId);
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
new ContextMenu(html, "li.item-defence", [
|
||||
{
|
||||
name: game.i18n.localize("MENU.SHOWROLLDIALOG"),
|
||||
icon: '<i class="far dice"></i>',
|
||||
callback: (li) => {
|
||||
const skillValue = li.data("defence");
|
||||
|
||||
let skillName = "ADVERSARY.DEFENCE";
|
||||
|
||||
this.khRoller.rollSkillDialogInChat(skillName, skillValue, false, this.actor)
|
||||
},
|
||||
}
|
||||
]);
|
||||
|
||||
html.find(".feature").click(async (ev) => {
|
||||
const featureName = $(ev.currentTarget).data("feature");
|
||||
const featureValue = this.actor.data.data.feature[featureName].value;
|
||||
@@ -156,7 +336,35 @@ export class ActorSheetKH extends ActorSheet {
|
||||
|
||||
// Delete Inventory Item
|
||||
html.find(".item-delete").click((ev) => {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
let parent = $(ev.currentTarget).data("parent")
|
||||
const li = $(ev.currentTarget).parents(parent);
|
||||
const item = this.actor.getOwnedItem(li.data("itemId"));
|
||||
|
||||
if(item) {
|
||||
if (item.type === "armor") {
|
||||
let initValue = -1
|
||||
|
||||
if (item.data.data.equipable.equipped) {
|
||||
initValue = 4
|
||||
|
||||
this.actor.items.map((i) => {
|
||||
if (i.type === "armor") {
|
||||
if (i._id !== item._id && i.data.data.equipable.equipped && i.data?.data?.modifications) {
|
||||
for (let k of Object.keys(i.data.data.modifications)) {
|
||||
if (i.data.data.modifications[k].modtype === "init") {
|
||||
initValue = i.data.data.modifications[k].value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (initValue > 0) {
|
||||
this.actor.update({["data.combat.init"]: initValue});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.actor.deleteOwnedItem(li.data("itemId"));
|
||||
|
||||
@@ -165,7 +373,8 @@ export class ActorSheetKH extends ActorSheet {
|
||||
|
||||
// Edit Inventory Item
|
||||
html.find(".item-edit").click(async (ev) => {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
let parent = $(ev.currentTarget).data("parent")
|
||||
let li = $(ev.currentTarget).parents(parent);
|
||||
let itemId = li.data("itemId");
|
||||
let item = this.actor.getOwnedItem(itemId);
|
||||
|
||||
@@ -184,7 +393,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);
|
||||
|
||||
@@ -207,9 +416,74 @@ 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
|
||||
let skillValue = skill.data.data.value
|
||||
|
||||
if(this.actor.data.type === "character") {
|
||||
skillName = spell.name + " (" + skill.name + ")"
|
||||
}
|
||||
|
||||
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
|
||||
let skillValue = skill.data.data.value
|
||||
|
||||
if(this.actor.data.type === "character") {
|
||||
skillName = spell.name + " (" + skill.name + ")"
|
||||
}
|
||||
|
||||
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");
|
||||
const li = $(ev.currentTarget).parents(".item-skill");
|
||||
let itemId = li.data("itemId");
|
||||
let _item = this.actor.items.find((element) => element._id == itemId);
|
||||
|
||||
@@ -226,7 +500,7 @@ export class ActorSheetKH extends ActorSheet {
|
||||
|
||||
/* Roll weapon skill */
|
||||
html.find(".roll-weapon-skill").click((ev) => {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
const li = $(ev.currentTarget).parents(".item-weapon");
|
||||
let itemId = li.data("itemId");
|
||||
let weapon = this.actor.getOwnedItem(itemId);
|
||||
|
||||
@@ -255,7 +529,7 @@ export class ActorSheetKH extends ActorSheet {
|
||||
|
||||
/* Roll weapon damage */
|
||||
html.find(".roll-damage").click((ev) => {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
const li = $(ev.currentTarget).parents(".item-weapon");
|
||||
let itemId = li.data("itemId");
|
||||
let weapon = this.actor.getOwnedItem(itemId);
|
||||
|
||||
@@ -318,6 +592,7 @@ export class ActorSheetKH extends ActorSheet {
|
||||
|
||||
/* Toggle item equipped */
|
||||
html.find(".items .item a.toggle-equipped").click(this._toggleEquippedItem.bind(this));
|
||||
html.find(".items .item-weapon a.toggle-equipped").click(this._toggleEquippedItem.bind(this));
|
||||
|
||||
/* Handle increase of items in inventory */
|
||||
html.find(".item-quantity .quantity.increase").click(this._increaseQuantity.bind((this)));
|
||||
@@ -331,7 +606,7 @@ export class ActorSheetKH extends ActorSheet {
|
||||
|
||||
/* Adversary specific */
|
||||
html.find(".roll-adversary-attack").click((ev) => {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
const li = $(ev.currentTarget).parents(".item-attack");
|
||||
let skillValue = li.data("ability");
|
||||
|
||||
let skillName = "ITEM.ATTACK";
|
||||
@@ -339,6 +614,30 @@ export class ActorSheetKH extends ActorSheet {
|
||||
this.khRoller.rollSkillInChat(skillName, skillValue, false, this.actor)
|
||||
});
|
||||
|
||||
html.find(".roll-attack-damage").click((ev) => {
|
||||
const li = $(ev.currentTarget).parents(".item-attack");
|
||||
let itemId = li.data("itemId");
|
||||
let weapon = this.actor.getOwnedItem(itemId);
|
||||
|
||||
if (!weapon) {
|
||||
weapon = game.items.get(itemId);
|
||||
|
||||
if (!weapon) {
|
||||
console.log("IMPORT ERROR")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
let damage = weapon.data.data.damage.value;
|
||||
|
||||
let regex = /([0-9]*)t([0-9]*)/g;
|
||||
let regexMatch;
|
||||
|
||||
while (regexMatch = regex.exec(damage.toLowerCase())) {
|
||||
this.khRoller.rollDamageInChat(regexMatch[1], this.actor)
|
||||
}
|
||||
});
|
||||
|
||||
html.find(".roll-defence").click((ev) => {
|
||||
const skillValue = $(ev.currentTarget).data("defence");
|
||||
|
||||
@@ -480,7 +779,7 @@ export class ActorSheetKH extends ActorSheet {
|
||||
const item = this.actor.getOwnedItem(li.data("itemId"));
|
||||
const actor = this.actor;
|
||||
|
||||
if (item) {
|
||||
if(item) {
|
||||
if(item.type === "armor") {
|
||||
let initValue = -1
|
||||
|
||||
|
||||
@@ -12,7 +12,5 @@ export class ActorKH extends Actor {
|
||||
const data = actorData.data;
|
||||
const flags = actorData.flags;
|
||||
data.type = actorData.type;
|
||||
|
||||
console.log("ACTOR DATA")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user