Finishing v0.0.3

This commit is contained in:
2020-12-01 17:20:38 +01:00
parent ce1e29aefb
commit 4cb6c390a4
10 changed files with 156 additions and 15 deletions

View File

@@ -200,6 +200,85 @@ export class ActorSheetKH extends ActorSheet {
},
]);
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"),
@@ -226,6 +305,20 @@ export class ActorSheetKH extends ActorSheet {
},
]);
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;
@@ -245,6 +338,33 @@ export class ActorSheetKH extends ActorSheet {
html.find(".item-delete").click((ev) => {
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"));
@@ -336,17 +456,25 @@ export class ActorSheetKH extends ActorSheet {
// 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 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 + " (" + skill.name + ")"
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")

View File

@@ -6,6 +6,9 @@ export default class KHHooks {
let actorbaseSkills;
if(game.settings.get("kopparhavet", "gameSystem") === "hjaltarnas-tid") {
// Set currency name
actor.update({ "data.currency.shekel.label": "CURRENCY.SILVER" });
actorbaseSkills = CONFIG.KH.baseSkillsHT
skillIndex = await game.packs.get("kopparhavet.skills-ht").getContent();
} else {

View File

@@ -169,6 +169,20 @@ function registerHandlebarsHelpers() {
}
});
Handlebars.registerHelper("spellRoll", function (roll) {
roll = normalize(roll, "roll");
switch (roll) {
case "roll":
return game.i18n.localize("SPELL.ROLL");
case "attackroll":
return game.i18n.localize("SPELL.ATTACKROLL");
case "opposite":
return game.i18n.localize("SPELL.OPPOSITE");
case "ritual":
return game.i18n.localize("SPELL.RITUAL");
}
});
Handlebars.registerHelper('plaintextToHTML', function(value) {
// strip tags, add <br/> tags
return new Handlebars.SafeString(value.replace(/(<([^>]+)>)/gi, "").replace(/(?:\r\n|\r|\n)/g, '<br/>'));