Fixed Hjältarnas Tid skill error, updated layout, fixed buttons not working

pull/2/head
Erebus 2020-12-01 05:11:08 +01:00
parent 6f8200c82a
commit 54ac488e73
10 changed files with 146 additions and 31 deletions

View File

@ -200,6 +200,32 @@ export class ActorSheetKH extends ActorSheet {
},
]);
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);
},
},
]);
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");

View File

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

View File

@ -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;
}

View File

@ -5,12 +5,12 @@
<div class="roll">
<div class="dice-roll">
{{#if closed}}
<div>
<div style="margin: auto;">
{{localize "ROLL.CLOSED"}}: {{closed}}
</div>
{{/if}}
{{#if opened}}
<div>
<div style="margin: auto;">
{{localize "ROLL.OPENED"}}: {{opened}}
</div>
{{/if}}

View File

@ -2,16 +2,16 @@
<div class="combat border">
<ul class="items">
<ul class="items-list">
<li class="item flexrow">
<li class="item-nor flexrow">
<div class="item-name" style="flex-grow: 8;">{{localize "MOD.INIT"}}</div>
<div class="item-value" style="flex: none;"><input name="data.combat.init" class="skill-value" type="number" value="{{data.combat.init}}" data-dtype="Number" /></div>
</li>
<li class="item flexrow">
<li class="item-nor flexrow">
<div class="item-name roll-defence rollable" data-defence="{{data.combat.defence}}" style="flex-grow: 8;">{{localize "ADVERSARY.DEFENCE"}}</div>
<div class="item-value" style="flex: none;"><input name="data.combat.defence" class="skill-value" type="text" value="{{data.combat.defence}}" /></div>
</li>
<li class="item flexrow">
<li class="item-nor flexrow">
<div class="item-name" style="flex-grow: 8;">{{localize "ADVERSARY.HASHELMET"}}</div>
<div style="align-self: flex-end">
<a style="margin: auto;" class="adversary-helmet-click {{#if data.combat.helmet}}active{{/if}}">
@ -20,7 +20,7 @@
</div>
</li>
<li class="item flexrow">
<li class="item-nor flexrow">
<div class="item-name roll-adversary-armor rollable" data-armor="{{data.combat.armor}}" style="flex-grow: 8;">{{localize "ITEM.DEFENCE"}}</div>
<div class="item-value" style="flex: none;"><input name="data.combat.armor" class="skill-value" type="text" value="{{data.combat.armor}}" /></div>
</li>
@ -33,7 +33,7 @@
<ul class="items">
<ul class="items-list">
{{#each actor.skills as |skill key|}}
<li class="item flexrow" data-item-id="{{skill._id}}">
<li class="item-skill flexrow" data-item-id="{{skill._id}}">
<div class="item-name roll-skill rollable" style="flex-grow: 8;">{{skill.name}}</div>
<div class="item-value" style="flex: none;"><input class="skill-value" type="number" value="{{skill.data.value}}" min="0" data-item-id="{{skill._id}}" data-dtype="Number" /></div>
</li>
@ -52,7 +52,7 @@
<ul class="items-list">
{{#each actor.attacks as |item key|}}
<li class="item flexrow" data-item-id="{{item._id}}" data-ability="{{item.data.skill.value}}">
<li class="item-attack flexrow" data-item-id="{{item._id}}" data-ability="{{item.data.skill.value}}">
<div class="item-name">{{item.name}}</div>
<div class="skill-roll">
<div class="roll-button">
@ -61,12 +61,12 @@
</div>
<div class="skill-roll">
<div class="roll-button">
<div class="roll-damage rollable">{{item.data.damage.value}}</div>
<div class="roll-attack-damage rollable">{{item.data.damage.value}}</div>
</div>
</div>
<div class="item-controls">
<a class="item-control item-edit" title="Edit Item"><i class="fas fa-edit"></i></a>
<a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
<a class="item-control item-attack-edit" title="Edit Item"><i class="fas fa-edit"></i></a>
<a class="item-control item-attack-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
</div>
</li>
{{/each}}

View File

@ -40,8 +40,8 @@
</div>
</div>
<div class="item-controls">
<a class="item-control item-edit" title="Edit Item"><i class="fas fa-edit"></i></a>
<a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
<a class="item-control item-weapon-edit" title="Edit Item"><i class="fas fa-edit"></i></a>
<a class="item-control item-weapon-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
</div>
</li>
{{/each}}

View File

@ -2,17 +2,17 @@
<div class="combat border">
<ul class="items">
<ul class="items-list">
<li class="item flexrow">
<li class="item-nor flexrow">
<div class="item-name" style="flex-grow: 8;">{{localize "MOD.INIT"}}</div>
<div class="item-value" style="flex: none;"><input name="data.combat.init" class="skill-value" type="number" value="{{data.combat.init}}" data-dtype="Number" /></div>
</li>
<li class="item flexrow">
<li class="item-nor flexrow">
<div class="item-name roll-defence rollable" data-defence="{{data.combat.defence}}" style="flex-grow: 8;">{{localize "ADVERSARY.DEFENCE"}}</div>
<div class="item-value" style="flex: none;"><input name="data.combat.defence" class="skill-value" type="text" value="{{data.combat.defence}}" /></div>
</li>
<li class="item flexrow">
<li class="item-nor flexrow">
<div class="item-name roll-adversary-armor rollable" data-armor="{{data.combat.armor}}" style="flex-grow: 8;">{{localize "ITEM.DEFENCE"}}</div>
<div class="item-value" style="flex: none;"><input name="data.combat.armor" class="skill-value" type="text" value="{{data.combat.armor}}" /></div>
</li>
@ -25,7 +25,7 @@
<ul class="items">
<ul class="items-list">
{{#each actor.skills as |skill key|}}
<li class="item flexrow" data-item-id="{{skill._id}}">
<li class="item-skill flexrow" data-item-id="{{skill._id}}">
<div class="item-name roll-skill rollable" style="flex-grow: 8;">{{skill.name}}</div>
<div class="item-value" style="flex: none;"><input class="skill-value" type="number" value="{{skill.data.value}}" min="0" data-item-id="{{skill._id}}" data-dtype="Number" /></div>
</li>
@ -44,7 +44,7 @@
<ul class="items-list">
{{#each actor.attacks as |item key|}}
<li class="item flexrow" data-item-id="{{item._id}}" data-ability="{{item.data.skill.value}}">
<li class="item-attack flexrow" data-item-id="{{item._id}}" data-ability="{{item.data.skill.value}}">
<div class="item-name">{{item.name}}</div>
<div class="skill-roll">
<div class="roll-button">
@ -53,12 +53,12 @@
</div>
<div class="skill-roll">
<div class="roll-button">
<div class="roll-damage rollable">{{item.data.damage.value}}</div>
<div class="roll-attack-damage rollable">{{item.data.damage.value}}</div>
</div>
</div>
<div class="item-controls">
<a class="item-control item-edit" title="Edit Item"><i class="fas fa-edit"></i></a>
<a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
<a class="item-control item-attack-edit" title="Edit Item"><i class="fas fa-edit"></i></a>
<a class="item-control item-attack-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
</div>
</li>
{{/each}}

View File

@ -8,7 +8,7 @@
<li class="item-skill flexrow" data-item-id="{{skill._id}}">
<div class="item-name roll-skill rollable" style="flex-grow: 8;">{{skill.name}}</div>
<div class="item-value" style="flex: none;"><input class="skill-value" type="number" value="{{skill.data.value}}" min="0" data-item-id="{{skill._id}}" data-dtype="Number" /></div>
<div style="align-self: flex-end">
<div style="align-self: flex-end; margin-top: auto; margin-bottom: auto;">
<a style="margin: auto;" class="click-skill {{#if skill.data.used}}active{{/if}}" data-item-id="{{skill._id}}">
<i class="far {{#if skill.data.used}}fa-times-circle{{else}}fa-circle{{/if}}"></i>
</a>
@ -28,7 +28,7 @@
<li class="item-skill flexrow" data-item-id="{{skill._id}}">
<div class="item-name roll-skill rollable" style="flex-grow: 8;">{{skill.name}}</div>
<div class="item-value" style="flex: none;"><input class="skill-value" type="number" value="{{skill.data.value}}" min="0" data-item-id="{{skill._id}}" data-dtype="Number" /></div>
<div style="align-self: flex-end">
<div style="align-self: flex-end; margin-top: auto; margin-bottom: auto;">
<a style="margin: auto;" class="click-skill {{#if skill.data.used}}active{{/if}}" data-item-id="{{skill._id}}">
<i class="far {{#if skill.data.used}}fa-times-circle{{else}}fa-circle{{/if}}"></i>
</a>

View File

@ -8,7 +8,7 @@
<li class="item-skill flexrow" data-item-id="{{skill._id}}">
<div class="item-name roll-skill rollable" style="flex-grow: 8;">{{skill.name}}</div>
<div class="item-value" style="flex: none;"><input class="skill-value" type="number" value="{{skill.data.value}}" min="0" data-item-id="{{skill._id}}" data-dtype="Number" /></div>
<div style="align-self: flex-end">
<div style="align-self: flex-end; margin-top: auto; margin-bottom: auto;">
<a style="margin: auto;" class="click-skill {{#if skill.data.used}}active{{/if}}" data-item-id="{{skill._id}}">
<i class="far {{#if skill.data.used}}fa-times-circle{{else}}fa-circle{{/if}}"></i>
</a>
@ -28,7 +28,7 @@
<li class="item-skill flexrow" data-item-id="{{skill._id}}">
<div class="item-name roll-skill rollable" style="flex-grow: 8;">{{skill.name}}</div>
<div class="item-value" style="flex: none;"><input class="skill-value" type="number" value="{{skill.data.value}}" min="0" data-item-id="{{skill._id}}" data-dtype="Number" /></div>
<div style="align-self: flex-end">
<div style="align-self: flex-end; margin-top: auto; margin-bottom: auto;">
<a style="margin: auto;" class="click-skill {{#if skill.data.used}}active{{/if}}" data-item-id="{{skill._id}}">
<i class="far {{#if skill.data.used}}fa-times-circle{{else}}fa-circle{{/if}}"></i>
</a>
@ -48,7 +48,7 @@
<li class="item-skill flexrow" data-item-id="{{skill._id}}">
<div class="item-name roll-skill rollable" style="flex-grow: 8;">{{skill.name}}</div>
<div class="item-value" style="flex: none;"><input class="skill-value" type="number" value="{{skill.data.value}}" min="0" data-item-id="{{skill._id}}" data-dtype="Number" /></div>
<div style="align-self: flex-end">
<div style="align-self: flex-end; margin-top: auto; margin-bottom: auto;">
<a style="margin: auto;" class="click-skill {{#if skill.data.used}}active{{/if}}" data-item-id="{{skill._id}}">
<i class="far {{#if skill.data.used}}fa-times-circle{{else}}fa-circle{{/if}}"></i>
</a>

View File

@ -1,5 +1,5 @@
<div id="{{id}}" class="roll-dialog">
<h1 style="text-align: center;">{{skillName}} ({{skillValue}})</h1>
<h1 style="text-align: center;">{{localize skillName}} ({{skillValue}})</h1>
<label>{{localize "ROLL.OPENCLOSE"}}</label>
<input type="button" name="openclosed" min="0" value="{{startopen}}" style="margin-bottom: 10px; min-height: 26px; min-width: 30px;" />
<label name="notopenedorclosed" style="display: inline-block;">&nbsp;</label>