From 54ac488e7335729a5d64b46d4c85e7f0da2b0ff4 Mon Sep 17 00:00:00 2001 From: Erebus Date: Tue, 1 Dec 2020 05:11:08 +0100 Subject: [PATCH] =?UTF-8?q?Fixed=20Hj=C3=A4ltarnas=20Tid=20skill=20error,?= =?UTF-8?q?=20updated=20layout,=20fixed=20buttons=20not=20working?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/actors/actor-sheet.js | 108 ++++++++++++++++++++++++++- module/items/item-sheet.js | 8 +- styles/items.css | 7 ++ templates/dice/roll.html | 4 +- templates/parts/actor/combat.html | 18 ++--- templates/parts/actor/gear.html | 4 +- templates/parts/actor/ht-combat.html | 16 ++-- templates/parts/actor/ht-skills.html | 4 +- templates/parts/actor/skills.html | 6 +- templates/roll-dialog.html | 2 +- 10 files changed, 146 insertions(+), 31 deletions(-) diff --git a/module/actors/actor-sheet.js b/module/actors/actor-sheet.js index c1b85cf..ca55af7 100644 --- a/module/actors/actor-sheet.js +++ b/module/actors/actor-sheet.js @@ -200,6 +200,32 @@ export class ActorSheetKH extends ActorSheet { }, ]); + new ContextMenu(html, "li.item-attack", [ + { + name: game.i18n.localize("MENU.SHOWROLLDIALOG"), + icon: '', + 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: '', + callback: (li) => { + let itemId = li.data("itemId"); + this._itemDetailsToChat(itemId); + }, + }, + ]); + html.find(".feature").click(async (ev) => { const featureName = $(ev.currentTarget).data("feature"); const featureValue = this.actor.data.data.feature[featureName].value; @@ -224,9 +250,61 @@ export class ActorSheetKH extends ActorSheet { li.slideUp(200, () => this.render(false)); }); + html.find(".item-attack-delete").click((ev) => { + const li = $(ev.currentTarget).parents(".item-attack"); + + this.actor.deleteOwnedItem(li.data("itemId")); + + li.slideUp(200, () => this.render(false)); + }); + + html.find(".item-weapon-delete").click((ev) => { + const li = $(ev.currentTarget).parents(".item-weapon"); + + this.actor.deleteOwnedItem(li.data("itemId")); + + li.slideUp(200, () => this.render(false)); + }); + // Edit Inventory Item html.find(".item-edit").click(async (ev) => { - const li = $(ev.currentTarget).parents(".item"); + let li = $(ev.currentTarget).parents(".item"); + let itemId = li.data("itemId"); + let item = this.actor.getOwnedItem(itemId); + + if (!item) { + item = game.items.get(itemId); + + if (!item) { + console.log("IMPORT ERROR") + } + } + + if (item?.sheet) { + item.sheet.render(true); + } + }); + + html.find(".item-attack-edit").click(async (ev) => { + let li = $(ev.currentTarget).parents(".item-attack"); + let itemId = li.data("itemId"); + let item = this.actor.getOwnedItem(itemId); + + if (!item) { + item = game.items.get(itemId); + + if (!item) { + console.log("IMPORT ERROR") + } + } + + if (item?.sheet) { + item.sheet.render(true); + } + }); + + html.find(".item-weapon-edit").click(async (ev) => { + let li = $(ev.currentTarget).parents(".item-weapon"); let itemId = li.data("itemId"); let item = this.actor.getOwnedItem(itemId); @@ -316,7 +394,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); @@ -392,7 +470,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"; @@ -400,6 +478,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"); diff --git a/module/items/item-sheet.js b/module/items/item-sheet.js index a740701..0d765bd 100644 --- a/module/items/item-sheet.js +++ b/module/items/item-sheet.js @@ -36,7 +36,13 @@ export class ItemSheetKH extends ItemSheet { switch (this.object.data.type) { case "weapon": // Load Skills Compendium skills - let skillList2 = await game.packs.get("kopparhavet.skills").getContent(); + let skillList2 + + if(game.settings.get("kopparhavet", "gameSystem") === "hjaltarnas-tid") { + skillList2 = await game.packs.get("kopparhavet.skills-ht").getContent(); + } else { + skillList2 = await game.packs.get("kopparhavet.skills").getContent(); + } for (let item of skillList2) { if(item.data.type === "skill" && item.data.data.type.value === "combat") { diff --git a/styles/items.css b/styles/items.css index e8ca394..a08d39f 100644 --- a/styles/items.css +++ b/styles/items.css @@ -104,6 +104,13 @@ text-align: center; } +.items .items-list .item-nor { + line-height: 24px; + padding: 3px 0; + border-bottom: 1px solid #bbb; + text-align: center; +} + .items .items-list .item .toggle-equipped { color: #888; } diff --git a/templates/dice/roll.html b/templates/dice/roll.html index 0a492bc..3095534 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}} diff --git a/templates/parts/actor/combat.html b/templates/parts/actor/combat.html index 64e682d..404ca17 100644 --- a/templates/parts/actor/combat.html +++ b/templates/parts/actor/combat.html @@ -2,16 +2,16 @@
- - + +
{{/each}} diff --git a/templates/parts/actor/ht-combat.html b/templates/parts/actor/ht-combat.html index e287d61..7c6ce32 100644 --- a/templates/parts/actor/ht-combat.html +++ b/templates/parts/actor/ht-combat.html @@ -2,17 +2,17 @@
      -
    • +
    • {{localize "MOD.INIT"}}
    • -
    • +
    • {{localize "ADVERSARY.DEFENCE"}}
    • -
    • +
    • {{localize "ITEM.DEFENCE"}}
    • @@ -25,7 +25,7 @@
          {{#each actor.skills as |skill key|}} -
        • +
        • {{skill.name}}
        • @@ -44,7 +44,7 @@
            {{#each actor.attacks as |item key|}} -
          • +
          • {{item.name}}
            @@ -53,12 +53,12 @@
            -
            {{item.data.damage.value}}
            +
            {{item.data.damage.value}}
            - - + +
          • {{/each}} diff --git a/templates/parts/actor/ht-skills.html b/templates/parts/actor/ht-skills.html index 4241aa4..901a6c7 100644 --- a/templates/parts/actor/ht-skills.html +++ b/templates/parts/actor/ht-skills.html @@ -8,7 +8,7 @@
          • {{skill.name}}
            -
            +
            @@ -28,7 +28,7 @@
          • {{skill.name}}
            -
            +
            diff --git a/templates/parts/actor/skills.html b/templates/parts/actor/skills.html index f6f710c..e413f5f 100644 --- a/templates/parts/actor/skills.html +++ b/templates/parts/actor/skills.html @@ -8,7 +8,7 @@
          • {{skill.name}}
            -
            +
            @@ -28,7 +28,7 @@
          • {{skill.name}}
            -
            +
            @@ -48,7 +48,7 @@
          • {{skill.name}}
            -
            +
            diff --git a/templates/roll-dialog.html b/templates/roll-dialog.html index 780b5e7..0add7c7 100644 --- a/templates/roll-dialog.html +++ b/templates/roll-dialog.html @@ -1,5 +1,5 @@
            -

            {{skillName}} ({{skillValue}})

            +

            {{localize skillName}} ({{skillValue}})