parent
6962d6fc04
commit
58c3fbcd42
|
@ -157,10 +157,10 @@ export class ActorSheetKH extends ActorSheet {
|
||||||
let _item = this.actor.items.find((element) => element.id == itemId);
|
let _item = this.actor.items.find((element) => element.id == itemId);
|
||||||
|
|
||||||
// Retrieve skill based on name
|
// Retrieve skill based on name
|
||||||
let skill = this.actor.items.find((element) => element.name === _item.data.data.skill.value);
|
let skill = this.actor.items.find((element) => element.name === _item.data.skill.value);
|
||||||
|
|
||||||
let skillName = skill.name
|
let skillName = skill.name
|
||||||
let skillValue = skill.data.data.value
|
let skillValue = skill.data.value
|
||||||
let showValue = false
|
let showValue = false
|
||||||
|
|
||||||
if(this.actor.data.type === "character") {
|
if(this.actor.data.type === "character") {
|
||||||
|
@ -189,7 +189,7 @@ export class ActorSheetKH extends ActorSheet {
|
||||||
let _item = this.actor.items.find((element) => element.id == itemId);
|
let _item = this.actor.items.find((element) => element.id == itemId);
|
||||||
|
|
||||||
let skillName = _item.name
|
let skillName = _item.name
|
||||||
let skillValue = _item.data.data.value
|
let skillValue = _item.data.value
|
||||||
let showValue = false
|
let showValue = false
|
||||||
|
|
||||||
if(this.actor.data.type === "character") {
|
if(this.actor.data.type === "character") {
|
||||||
|
@ -233,7 +233,7 @@ export class ActorSheetKH extends ActorSheet {
|
||||||
showValue = true
|
showValue = true
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (_item.data.data.difficulty.value) {
|
switch (_item.data.difficulty.value) {
|
||||||
case "simple":
|
case "simple":
|
||||||
difficulty = 5
|
difficulty = 5
|
||||||
break;
|
break;
|
||||||
|
@ -248,24 +248,24 @@ export class ActorSheetKH extends ActorSheet {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(_item.data.data.roll.value === "roll" || _item.data.data.roll.value === "attackroll") {
|
if(_item.data.roll.value === "roll" || _item.data.roll.value === "attackroll") {
|
||||||
// Retrieve skill based on name
|
// Retrieve skill based on name
|
||||||
let skill = this.actor.items.find((element) => element.name === _item.data.data.roll.skill);
|
let skill = this.actor.items.find((element) => element.name === _item.data.roll.skill);
|
||||||
|
|
||||||
let skillName = _item.name
|
let skillName = _item.name
|
||||||
let skillValue = skill.data.data.value
|
let skillValue = skill.data.value
|
||||||
|
|
||||||
if(this.actor.data.type === "character") {
|
if(this.actor.data.type === "character") {
|
||||||
skillName = _item.name + " (" + skill.name + ")"
|
skillName = _item.name + " (" + skill.name + ")"
|
||||||
}
|
}
|
||||||
|
|
||||||
this.khRoller.rollSkillDialogInChat(skillName, skillValue, showValue, this.actor, difficulty)
|
this.khRoller.rollSkillDialogInChat(skillName, skillValue, showValue, this.actor, difficulty)
|
||||||
} else if(_item.data.data.roll.value === "opposite") {
|
} else if(_item.data.roll.value === "opposite") {
|
||||||
// Retrieve skill based on name
|
// Retrieve skill based on name
|
||||||
let skill = this.actor.items.find((element) => element.name === _item.data.data.roll.skill);
|
let skill = this.actor.items.find((element) => element.name === _item.data.roll.skill);
|
||||||
|
|
||||||
let skillName = _item.name
|
let skillName = _item.name
|
||||||
let skillValue = skill.data.data.value
|
let skillValue = skill.data.value
|
||||||
|
|
||||||
if(this.actor.data.type === "character") {
|
if(this.actor.data.type === "character") {
|
||||||
skillName = _item.name + " (" + skill.name + ")"
|
skillName = _item.name + " (" + skill.name + ")"
|
||||||
|
@ -274,62 +274,62 @@ export class ActorSheetKH extends ActorSheet {
|
||||||
let opposite = []
|
let opposite = []
|
||||||
// Retrieve skill based on name
|
// Retrieve skill based on name
|
||||||
|
|
||||||
if(_item.data.data.roll.oppositeskill !== "") {
|
if(_item.data.roll.oppositeskill !== "") {
|
||||||
let skill1 = this.actor.items.find((element) => element.name === _item.data.data.roll.oppositeskill);
|
let skill1 = this.actor.items.find((element) => element.name === _item.data.roll.oppositeskill);
|
||||||
opposite.push(skill1.name)
|
opposite.push(skill1.name)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(_item.data.data.roll.oppositeskilltwo !== "") {
|
if(_item.data.roll.oppositeskilltwo !== "") {
|
||||||
let skill2 = this.actor.items.find((element) => element.name === _item.data.data.roll.oppositeskilltwo);
|
let skill2 = this.actor.items.find((element) => element.name === _item.data.roll.oppositeskilltwo);
|
||||||
opposite.push(skill2.name)
|
opposite.push(skill2.name)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.khRoller.rollSkillDialogInChat(skillName, skillValue, showValue, this.actor, difficulty, opposite)
|
this.khRoller.rollSkillDialogInChat(skillName, skillValue, showValue, this.actor, difficulty, opposite)
|
||||||
} else if(_item.data.data.roll.value === "ritual") {
|
} else if(_item.data.roll.value === "ritual") {
|
||||||
let skills = []
|
let skills = []
|
||||||
|
|
||||||
if(_item.data.data.roll.ritual.skillone !== "") {
|
if(_item.data.roll.ritual.skillone !== "") {
|
||||||
let skill1 = this.actor.items.find((element) => element.name === _item.data.data.roll.ritual.skillone);
|
let skill1 = this.actor.items.find((element) => element.name === _item.data.roll.ritual.skillone);
|
||||||
|
|
||||||
skills.push({
|
skills.push({
|
||||||
name: skill1.name,
|
name: skill1.name,
|
||||||
value: skill1.data.data.value
|
value: skill1.data.value
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if(_item.data.data.roll.ritual.skilltwo !== "") {
|
if(_item.data.roll.ritual.skilltwo !== "") {
|
||||||
let skill2 = this.actor.items.find((element) => element.name === _item.data.data.roll.ritual.skilltwo);
|
let skill2 = this.actor.items.find((element) => element.name === _item.data.roll.ritual.skilltwo);
|
||||||
|
|
||||||
skills.push({
|
skills.push({
|
||||||
name: skill2.name,
|
name: skill2.name,
|
||||||
value: skill2.data.data.value
|
value: skill2.data.value
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if(_item.data.data.roll.ritual.skillthree !== "") {
|
if(_item.data.roll.ritual.skillthree !== "") {
|
||||||
let skill3 = this.actor.items.find((element) => element.name === _item.data.data.roll.ritual.skillthree);
|
let skill3 = this.actor.items.find((element) => element.name === _item.data.roll.ritual.skillthree);
|
||||||
|
|
||||||
skills.push({
|
skills.push({
|
||||||
name: skill3.name,
|
name: skill3.name,
|
||||||
value: skill3.data.data.value
|
value: skill3.data.value
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if(_item.data.data.roll.ritual.skillfour !== "") {
|
if(_item.data.roll.ritual.skillfour !== "") {
|
||||||
let skill4 = this.actor.items.find((element) => element.name === _item.data.data.roll.ritual.skillfour);
|
let skill4 = this.actor.items.find((element) => element.name === _item.data.roll.ritual.skillfour);
|
||||||
|
|
||||||
skills.push({
|
skills.push({
|
||||||
name: skill4.name,
|
name: skill4.name,
|
||||||
value: skill4.data.data.value
|
value: skill4.data.value
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if(_item.data.data.roll.ritual.skillfive !== "") {
|
if(_item.data.roll.ritual.skillfive !== "") {
|
||||||
let skill5 = this.actor.items.find((element) => element.name === _item.data.data.roll.ritual.skillfive);
|
let skill5 = this.actor.items.find((element) => element.name === _item.data.roll.ritual.skillfive);
|
||||||
|
|
||||||
skills.push({
|
skills.push({
|
||||||
name: skill5.name,
|
name: skill5.name,
|
||||||
value: skill5.data.data.value
|
value: skill5.data.value
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -388,6 +388,7 @@ export class ActorSheetKH extends ActorSheet {
|
||||||
]);
|
]);
|
||||||
|
|
||||||
html.find(".feature").click(async (ev) => {
|
html.find(".feature").click(async (ev) => {
|
||||||
|
console.log("feature")
|
||||||
const featureName = $(ev.currentTarget).data("feature");
|
const featureName = $(ev.currentTarget).data("feature");
|
||||||
const featureValue = this.actor.data.data.feature[featureName].value;
|
const featureValue = this.actor.data.data.feature[featureName].value;
|
||||||
if (featureName === "one") {
|
if (featureName === "one") {
|
||||||
|
@ -417,10 +418,10 @@ export class ActorSheetKH extends ActorSheet {
|
||||||
|
|
||||||
this.actor.items.map((i) => {
|
this.actor.items.map((i) => {
|
||||||
if (i.type === "armor") {
|
if (i.type === "armor") {
|
||||||
if (i.id !== item.id && i.data.data.equipable.equipped && i.data?.data?.modifications) {
|
if (i.id !== item.id && i.data.equipable.equipped && i.data?.data?.modifications) {
|
||||||
for (let k of Object.keys(i.data.data.modifications)) {
|
for (let k of Object.keys(i.data.modifications)) {
|
||||||
if (i.data.data.modifications[k].modtype === "init") {
|
if (i.data.modifications[k].modtype === "init") {
|
||||||
initValue = i.data.data.modifications[k].value;
|
initValue = i.data.modifications[k].value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -434,13 +435,16 @@ export class ActorSheetKH extends ActorSheet {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.actor.deleteOwnedItem(li.data("itemId"));
|
this.actor.deleteEmbeddedDocuments("Item", [li.data("itemId")]);
|
||||||
|
|
||||||
|
//this.actor.deleteOwnedItem(li.data("itemId"));
|
||||||
|
|
||||||
li.slideUp(200, () => this.render(false));
|
li.slideUp(200, () => this.render(false));
|
||||||
});
|
});
|
||||||
|
|
||||||
// Edit Inventory Item
|
// Edit Inventory Item
|
||||||
html.find(".item-edit").click(async (ev) => {
|
html.find(".item-edit").click(async (ev) => {
|
||||||
|
console.log("item-edit")
|
||||||
let parent = $(ev.currentTarget).data("parent")
|
let parent = $(ev.currentTarget).data("parent")
|
||||||
let li = $(ev.currentTarget).parents(parent);
|
let li = $(ev.currentTarget).parents(parent);
|
||||||
let itemId = li.data("itemId");
|
let itemId = li.data("itemId");
|
||||||
|
@ -617,11 +621,6 @@ export class ActorSheetKH extends ActorSheet {
|
||||||
let itemId = li.data("item-id");
|
let itemId = li.data("item-id");
|
||||||
let _item = this.actor.items.find((element) => element.id === itemId);
|
let _item = this.actor.items.find((element) => element.id === itemId);
|
||||||
|
|
||||||
console.log(li)
|
|
||||||
console.log(li.data)
|
|
||||||
console.log(itemId)
|
|
||||||
console.log(_item)
|
|
||||||
|
|
||||||
let skillName = _item.name
|
let skillName = _item.name
|
||||||
let skillValue = _item.data.data.value
|
let skillValue = _item.data.data.value
|
||||||
let showValue = false
|
let showValue = false
|
||||||
|
@ -812,6 +811,12 @@ export class ActorSheetKH extends ActorSheet {
|
||||||
|
|
||||||
// Add or Remove relationship
|
// Add or Remove relationship
|
||||||
html.find(".learning-control").click(this._onClickLearningControl.bind(this));
|
html.find(".learning-control").click(this._onClickLearningControl.bind(this));
|
||||||
|
html.find(".learning-delete").click(async (event) => {
|
||||||
|
event.preventDefault();
|
||||||
|
const a = event.currentTarget.closest(".learning");
|
||||||
|
const id = a.dataset["attribute"];
|
||||||
|
this.object.update({ "data.learning": { ["-=" + id]: null } });
|
||||||
|
});
|
||||||
html.find(".learning-click").click(this._onClickLearingLearned.bind(this));
|
html.find(".learning-click").click(this._onClickLearingLearned.bind(this));
|
||||||
|
|
||||||
/* Hjältarnas Tid specefic */
|
/* Hjältarnas Tid specefic */
|
||||||
|
@ -823,6 +828,7 @@ export class ActorSheetKH extends ActorSheet {
|
||||||
}
|
}
|
||||||
|
|
||||||
async _onClickLearingLearned(event) {
|
async _onClickLearingLearned(event) {
|
||||||
|
console.log("_onClickLearingLearned")
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
const li1 = $(event.currentTarget);
|
const li1 = $(event.currentTarget);
|
||||||
const li2 = $(event.currentTarget).parents(".learning");
|
const li2 = $(event.currentTarget).parents(".learning");
|
||||||
|
@ -842,13 +848,11 @@ export class ActorSheetKH extends ActorSheet {
|
||||||
|
|
||||||
async _onClickLearningControl(event) {
|
async _onClickLearningControl(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const a = event.currentTarget;
|
const action = event.currentTarget.dataset.action;
|
||||||
const action = a.dataset.action;
|
|
||||||
const attrs = this.object.data.data.learning;
|
|
||||||
const form = this.form;
|
|
||||||
|
|
||||||
// Add new modification
|
// Add new modification
|
||||||
if (action === "create") {
|
if (action === "create") {
|
||||||
|
const form = this.form;
|
||||||
const nk = new Date().getTime();
|
const nk = new Date().getTime();
|
||||||
let newKey = document.createElement("div");
|
let newKey = document.createElement("div");
|
||||||
|
|
||||||
|
@ -858,41 +862,43 @@ export class ActorSheetKH extends ActorSheet {
|
||||||
await this._onSubmit(event);
|
await this._onSubmit(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
// Remove existing modification
|
// Remove existing modification
|
||||||
else if (action === "delete") {
|
else if (action === "delete") {
|
||||||
const li = a.closest(".learning");
|
const a = event.currentTarget.closest(".learning");
|
||||||
li.parentElement.removeChild(li);
|
const id = a.dataset["attribute"];
|
||||||
await this._onSubmit(event);
|
this.object.update({ "data.learning": { ["-=" + id]: null } });
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
async _onClickRelationshipControl(event) {
|
async _onClickRelationshipControl(event) {
|
||||||
|
console.log("_onClickRelationshipControl")
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const a = event.currentTarget;
|
const action = event.currentTarget.dataset.action;
|
||||||
const action = a.dataset.action;
|
|
||||||
const attrs = this.object.data.data.relationships;
|
|
||||||
const form = this.form;
|
|
||||||
|
|
||||||
// Add new modification
|
// Add new modification
|
||||||
if (action === "create") {
|
if (action === "create") {
|
||||||
|
const form = this.form;
|
||||||
const nk = new Date().getTime();
|
const nk = new Date().getTime();
|
||||||
let newKey = document.createElement("div");
|
let newKey = document.createElement("div");
|
||||||
|
|
||||||
newKey.innerHTML = `<input class="relation-key" type="text" name="data.relationships.attr${nk}.key" value="attr${nk}" style="display: none;" /><input class="relation-key" type="text" name="data.relationships.attr${nk}.value" value="" style="display: none;" />`;
|
newKey.innerHTML = `<input class="relation-key" type="text" name="data.relationships.attr${nk}.key" value="attr${nk}" style="display: none;" /><input class="relation-key" type="text" name="data.relationships.attr${nk}.value" value="" style="display: none;" />`;
|
||||||
|
|
||||||
form.appendChild(newKey);
|
form.appendChild(newKey);
|
||||||
await this._onSubmit(event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove existing modification
|
// Remove existing modification
|
||||||
else if (action === "delete") {
|
else if (action === "delete") {
|
||||||
const li = a.closest(".relation");
|
const ability = $(event.currentTarget).closest(".relation").data("attribute");
|
||||||
li.parentElement.removeChild(li);
|
await this.object.update({ "data.relationships": { ["-=" + ability]: null } });
|
||||||
await this._onSubmit(event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await this._onSubmit(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
async _onClickRelationshipUsed(event) {
|
async _onClickRelationshipUsed(event) {
|
||||||
|
console.log("_onClickRelationshipUsed")
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
||||||
const li = $(event.currentTarget).parents(".relation");
|
const li = $(event.currentTarget).parents(".relation");
|
||||||
|
@ -910,6 +916,7 @@ export class ActorSheetKH extends ActorSheet {
|
||||||
}
|
}
|
||||||
|
|
||||||
async _toggleEquippedItem(event) {
|
async _toggleEquippedItem(event) {
|
||||||
|
console.log("_toggleEquippedItem")
|
||||||
const li = $(event.currentTarget);
|
const li = $(event.currentTarget);
|
||||||
const item = this.actor.items.get(li.data("itemId"));
|
const item = this.actor.items.get(li.data("itemId"));
|
||||||
const actor = this.actor;
|
const actor = this.actor;
|
||||||
|
@ -954,6 +961,7 @@ export class ActorSheetKH extends ActorSheet {
|
||||||
}
|
}
|
||||||
|
|
||||||
async _increaseQuantity(event) {
|
async _increaseQuantity(event) {
|
||||||
|
console.log("_increaseQuantity")
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
||||||
const li = $(event.currentTarget).parents(".item");
|
const li = $(event.currentTarget).parents(".item");
|
||||||
|
@ -968,6 +976,7 @@ export class ActorSheetKH extends ActorSheet {
|
||||||
}
|
}
|
||||||
|
|
||||||
async _decreaseQuantity(event) {
|
async _decreaseQuantity(event) {
|
||||||
|
console.log("_decreaseQuantity")
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
||||||
const li = $(event.currentTarget).parents(".item");
|
const li = $(event.currentTarget).parents(".item");
|
||||||
|
@ -984,6 +993,7 @@ export class ActorSheetKH extends ActorSheet {
|
||||||
}
|
}
|
||||||
|
|
||||||
async _onChangeSkillValue(event) {
|
async _onChangeSkillValue(event) {
|
||||||
|
console.log("_decreaseQuantity")
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
const itemId = $(event.currentTarget).data("item-id");
|
const itemId = $(event.currentTarget).data("item-id");
|
||||||
|
@ -994,31 +1004,29 @@ export class ActorSheetKH extends ActorSheet {
|
||||||
_id: _item.id,
|
_id: _item.id,
|
||||||
data: { value: $(event.currentTarget).val() },
|
data: { value: $(event.currentTarget).val() },
|
||||||
};
|
};
|
||||||
await this.actor.updateEmbeddedEntity("Item", [update]);
|
await this.actor.updateEmbeddedDocuments("Item", [update]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async _onClickSkill(event) {
|
async _onClickSkill(event) {
|
||||||
|
console.log("_onClickSkill")
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
const itemId = $(event.currentTarget).data("item-id");
|
const itemId = $(event.currentTarget).data("item-id");
|
||||||
let _item = this.actor.items.find((element) => element.id == itemId);
|
let _item = this.actor.items.find((element) => element.id == itemId);
|
||||||
|
|
||||||
console.log(_item)
|
|
||||||
console.log(itemId)
|
|
||||||
|
|
||||||
if (_item) {
|
if (_item) {
|
||||||
let newVal = true;
|
let newVal = true;
|
||||||
|
|
||||||
if(_item.data.used !== undefined) {
|
if(_item.data.data.used !== undefined) {
|
||||||
newVal = !_item.data.used;
|
newVal = !_item.data.data.used;
|
||||||
}
|
}
|
||||||
|
|
||||||
let update = {
|
let update = {
|
||||||
_id: _item.id,
|
_id: _item.id,
|
||||||
data: { used: newVal },
|
data: { used: newVal },
|
||||||
};
|
};
|
||||||
await this.actor.updateEmbeddedEntity("Item", [update]);
|
await this.actor.updateEmbeddedDocuments("Item", [update]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1034,6 +1042,7 @@ export class ActorSheetKH extends ActorSheet {
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
async _itemDetailsToChat(itemId) {
|
async _itemDetailsToChat(itemId) {
|
||||||
|
console.log("_itemDetailsToChat")
|
||||||
let item = this.actor.items.get(itemId);
|
let item = this.actor.items.get(itemId);
|
||||||
|
|
||||||
if (!item) {
|
if (!item) {
|
||||||
|
|
|
@ -13,8 +13,8 @@ export default class ActorHelpers {
|
||||||
}, {});
|
}, {});
|
||||||
|
|
||||||
// Remove modifications which are no longer used
|
// Remove modifications which are no longer used
|
||||||
if (this.object.data?.data?.relationships) {
|
if (this.object.data?.relationships) {
|
||||||
for (let k of Object.keys(this.object.data.data.relationships)) {
|
for (let k of Object.keys(this.object.data.relationships)) {
|
||||||
if (!relationships.hasOwnProperty(k)) relationships[`-=${k}`] = null;
|
if (!relationships.hasOwnProperty(k)) relationships[`-=${k}`] = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,8 +36,8 @@ export default class ActorHelpers {
|
||||||
}, {});
|
}, {});
|
||||||
|
|
||||||
// Remove modifications which are no longer used
|
// Remove modifications which are no longer used
|
||||||
if (this.object.data?.data?.learning) {
|
if (this.object.data?.learning) {
|
||||||
for (let k of Object.keys(this.object.data.data.learning)) {
|
for (let k of Object.keys(this.object.data.learning)) {
|
||||||
if (!learning.hasOwnProperty(k)) learning[`-=${k}`] = null;
|
if (!learning.hasOwnProperty(k)) learning[`-=${k}`] = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,11 +4,11 @@ export default class KHDiceRoller {
|
||||||
|
|
||||||
const roll = new Roll(formula);
|
const roll = new Roll(formula);
|
||||||
|
|
||||||
let res = roll.roll();
|
await roll.evaluate();
|
||||||
|
|
||||||
let rollData = {
|
let rollData = {
|
||||||
name: "SPELL.COST",
|
name: "SPELL.COST",
|
||||||
res: res,
|
res: roll,
|
||||||
showFormula: true
|
showFormula: true
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -37,11 +37,11 @@ export default class KHDiceRoller {
|
||||||
|
|
||||||
const roll = new Roll(formula);
|
const roll = new Roll(formula);
|
||||||
|
|
||||||
let res = roll.roll();
|
await roll.evaluate();
|
||||||
|
|
||||||
let rollData = {
|
let rollData = {
|
||||||
name: "ITEM.DAMAGE",
|
name: "ITEM.DAMAGE",
|
||||||
res: res,
|
res: roll,
|
||||||
showFormula: true
|
showFormula: true
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -68,11 +68,11 @@ export default class KHDiceRoller {
|
||||||
|
|
||||||
const roll = new Roll(formula);
|
const roll = new Roll(formula);
|
||||||
|
|
||||||
let res = roll.roll();
|
await roll.evaluate();
|
||||||
|
|
||||||
let rollData = {
|
let rollData = {
|
||||||
name: "ITEM.DEFENCE",
|
name: "ITEM.DEFENCE",
|
||||||
res: res,
|
res: roll,
|
||||||
showFormula: true
|
showFormula: true
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ export default class KHDiceRoller {
|
||||||
async rollSkillInChat(skillName, skillValue, showValue, speaker, openclosed, opposite) {
|
async rollSkillInChat(skillName, skillValue, showValue, speaker, openclosed, opposite) {
|
||||||
const roll = new Roll(`1d100`);
|
const roll = new Roll(`1d100`);
|
||||||
|
|
||||||
let res = roll.roll();
|
await roll.evaluate();
|
||||||
|
|
||||||
let computedName = skillName
|
let computedName = skillName
|
||||||
|
|
||||||
|
@ -120,13 +120,13 @@ export default class KHDiceRoller {
|
||||||
|
|
||||||
let rollData = {
|
let rollData = {
|
||||||
name: computedName,
|
name: computedName,
|
||||||
res: res,
|
res: roll,
|
||||||
opposite: oppositeValue
|
opposite: oppositeValue
|
||||||
};
|
};
|
||||||
|
|
||||||
if(skillValue > 0) {
|
if(skillValue > 0) {
|
||||||
let oneRes = Math.floor((res.total / 1) % 10);
|
let oneRes = Math.floor((roll.total / 1) % 10);
|
||||||
let tenRes = Math.floor((res.total / 10) % 10);
|
let tenRes = Math.floor((roll.total / 10) % 10);
|
||||||
|
|
||||||
if(openclosed < 0) {
|
if(openclosed < 0) {
|
||||||
rollData.closed = Math.abs(openclosed)
|
rollData.closed = Math.abs(openclosed)
|
||||||
|
@ -143,7 +143,7 @@ export default class KHDiceRoller {
|
||||||
// roll is opened
|
// roll is opened
|
||||||
rollData.success = true
|
rollData.success = true
|
||||||
} else {
|
} else {
|
||||||
if (res.total <= skillValue) {
|
if (roll.total <= skillValue) {
|
||||||
rollData.success = true
|
rollData.success = true
|
||||||
} else {
|
} else {
|
||||||
rollData.failure = true
|
rollData.failure = true
|
||||||
|
@ -295,7 +295,7 @@ export default class KHDiceRoller {
|
||||||
totalrolls++
|
totalrolls++
|
||||||
const roll = new Roll(`1d100`);
|
const roll = new Roll(`1d100`);
|
||||||
|
|
||||||
let res = roll.roll();
|
await roll.evaluate();
|
||||||
|
|
||||||
let skillName = skill.name
|
let skillName = skill.name
|
||||||
let success = false
|
let success = false
|
||||||
|
@ -307,7 +307,7 @@ export default class KHDiceRoller {
|
||||||
|
|
||||||
let rollData2 = {
|
let rollData2 = {
|
||||||
name: skillName,
|
name: skillName,
|
||||||
res: res,
|
res: roll,
|
||||||
};
|
};
|
||||||
|
|
||||||
if(openclosed < 0) {
|
if(openclosed < 0) {
|
||||||
|
@ -319,7 +319,7 @@ export default class KHDiceRoller {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(skill.value > 0) {
|
if(skill.value > 0) {
|
||||||
let oneRes = Math.floor((res.total / 1) % 10);
|
let oneRes = Math.floor((roll.total / 1) % 10);
|
||||||
//let tenRes = Math.floor((res.total / 10) % 10);
|
//let tenRes = Math.floor((res.total / 10) % 10);
|
||||||
|
|
||||||
if(openclosed < 0 && oneRes !== 0 && Math.abs(openclosed) >= oneRes) {
|
if(openclosed < 0 && oneRes !== 0 && Math.abs(openclosed) >= oneRes) {
|
||||||
|
@ -330,7 +330,7 @@ export default class KHDiceRoller {
|
||||||
success = true
|
success = true
|
||||||
successes++
|
successes++
|
||||||
} else {
|
} else {
|
||||||
if (res.total <= skill.value) {
|
if (roll.total <= skill.value) {
|
||||||
success = true
|
success = true
|
||||||
successes++
|
successes++
|
||||||
} else {
|
} else {
|
||||||
|
@ -343,7 +343,7 @@ export default class KHDiceRoller {
|
||||||
name: skillName,
|
name: skillName,
|
||||||
failure: failure,
|
failure: failure,
|
||||||
success: success,
|
success: success,
|
||||||
result: res,
|
result: roll,
|
||||||
})
|
})
|
||||||
|
|
||||||
rollData2.success = success
|
rollData2.success = success
|
||||||
|
|
|
@ -17,8 +17,8 @@ export default class ItemHelpers {
|
||||||
}, {});
|
}, {});
|
||||||
|
|
||||||
// Remove modifications which are no longer used
|
// Remove modifications which are no longer used
|
||||||
if (this.object.data?.data?.modifications) {
|
if (this.object.data?.modifications) {
|
||||||
for (let k of Object.keys(this.object.data.data.modifications)) {
|
for (let k of Object.keys(this.object.data.modifications)) {
|
||||||
if (!modifications.hasOwnProperty(k)) modifications[`-=${k}`] = null;
|
if (!modifications.hasOwnProperty(k)) modifications[`-=${k}`] = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ export class ItemSheetKH extends ItemSheet {
|
||||||
data.dtypes = ["String", "Number", "Boolean"];
|
data.dtypes = ["String", "Number", "Boolean"];
|
||||||
|
|
||||||
if (data?.data?.modifications) {
|
if (data?.data?.modifications) {
|
||||||
for (let attr of Object.values(data.data.modifications)) {
|
for (let attr of Object.values(data.modifications)) {
|
||||||
attr.isCheckbox = attr.dtype === "Boolean";
|
attr.isCheckbox = attr.dtype === "Boolean";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,11 +51,19 @@ export class ItemSheetKH extends ItemSheet {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve any created skills as well
|
// Retrieve any created skills as well
|
||||||
for (let item of game.items.entities) {
|
game.items.forEach((item) => {
|
||||||
if(item.data.type === "skill" && item.data.data.type.value === "combat") {
|
if(item.data.type === "skill" && item.data.data.type.value === "combat") {
|
||||||
skillList.push(item.data)
|
skillList.push(item.data)
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
|
for (let item of game.items.entities) {
|
||||||
|
if(item.data.type === "skill" && item.data.type.value === "combat") {
|
||||||
|
skillList.push(item.data)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
this.position.width = 530;
|
this.position.width = 530;
|
||||||
this.position.height = 750;
|
this.position.height = 750;
|
||||||
|
@ -89,12 +97,21 @@ export class ItemSheetKH extends ItemSheet {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Retrieve any created skills as well
|
||||||
|
game.items.forEach((item) => {
|
||||||
|
if(item.data.type === "skill") {
|
||||||
|
skillList.push(item.data)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
// Retrieve any created skills as well
|
// Retrieve any created skills as well
|
||||||
for (let item of game.items.entities) {
|
for (let item of game.items.entities) {
|
||||||
if(item.data.data.type === "skill") {
|
if(item.data.type === "skill") {
|
||||||
skillList.push(item.data)
|
skillList.push(item.data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
this.position.width = 450;
|
this.position.width = 450;
|
||||||
this.position.height = 605;
|
this.position.height = 605;
|
||||||
|
@ -115,12 +132,21 @@ export class ItemSheetKH extends ItemSheet {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Retrieve any created skills as well
|
||||||
|
game.items.forEach((item) => {
|
||||||
|
if(item.data.type === "skill" && item.data.data.type.value === "combat") {
|
||||||
|
skillList.push(item.data)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
// Retrieve any created skills as well
|
// Retrieve any created skills as well
|
||||||
for (let item of game.items.entities) {
|
for (let item of game.items.entities) {
|
||||||
if(item.data.type === "skill" && item.data.data.type.value === "combat") {
|
if(item.data.type === "skill" && item.data.data.type.value === "combat") {
|
||||||
skillList.push(item.data)
|
skillList.push(item.data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
this.position.width = 530;
|
this.position.width = 530;
|
||||||
this.position.height = 750;
|
this.position.height = 750;
|
||||||
break;
|
break;
|
||||||
|
@ -148,11 +174,11 @@ export class ItemSheetKH extends ItemSheet {
|
||||||
const clickedName = $(ev.currentTarget).data("name");
|
const clickedName = $(ev.currentTarget).data("name");
|
||||||
|
|
||||||
if(clickedName === "equipped") {
|
if(clickedName === "equipped") {
|
||||||
const equppiedValue = this.item.data.data.equipable.equipped;
|
const equppiedValue = this.item.data.equipable.equipped;
|
||||||
|
|
||||||
this.item.update({ "data.equipped.equipped": !equppiedValue });
|
this.item.update({ "data.equipped.equipped": !equppiedValue });
|
||||||
} else {
|
} else {
|
||||||
const clickedValue = (this.item.data.data[clickedName].value == undefined ? false : this.item.data.data[clickedName].value);
|
const clickedValue = (this.item.data[clickedName].value == undefined ? false : this.item.data[clickedName].value);
|
||||||
let dataName = "data." + clickedName + ".value"
|
let dataName = "data." + clickedName + ".value"
|
||||||
let tempData = {}
|
let tempData = {}
|
||||||
|
|
||||||
|
@ -176,7 +202,7 @@ export class ItemSheetKH extends ItemSheet {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const a = event.currentTarget;
|
const a = event.currentTarget;
|
||||||
const action = a.dataset.action;
|
const action = a.dataset.action;
|
||||||
const attrs = this.object.data.data.modifications;
|
const attrs = this.object.data.modifications;
|
||||||
const form = this.form;
|
const form = this.form;
|
||||||
|
|
||||||
// Add new modification
|
// Add new modification
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
"name": "kopparhavet",
|
"name": "kopparhavet",
|
||||||
"title": "Kopparhavets Hjältar",
|
"title": "Kopparhavets Hjältar",
|
||||||
"description": "The Molten Sea is a dangerous but exciting place, where pirates, sorcerers and secretive orders of knighthood struggle for power, wealth and ancient lore.",
|
"description": "The Molten Sea is a dangerous but exciting place, where pirates, sorcerers and secretive orders of knighthood struggle for power, wealth and ancient lore.",
|
||||||
"version": "0.0.7",
|
"version": "0.1.0",
|
||||||
"minimumCoreVersion": "0.8.6",
|
"minimumCoreVersion": "9",
|
||||||
"compatibleCoreVersion": "0.8.8",
|
"compatibleCoreVersion": "9",
|
||||||
"templateVersion": 4,
|
"templateVersion": 4,
|
||||||
"author": "Erebus",
|
"author": "Erebus",
|
||||||
"scripts": [],
|
"scripts": [],
|
||||||
|
@ -95,6 +95,6 @@
|
||||||
"url": "https://pi.rikspolisen.se/foundryvtt/kopparhavet",
|
"url": "https://pi.rikspolisen.se/foundryvtt/kopparhavet",
|
||||||
"socket": true,
|
"socket": true,
|
||||||
"manifest": "https://pi.rikspolisen.se/foundryvtt/kopparhavet/raw/branch/master/system.json",
|
"manifest": "https://pi.rikspolisen.se/foundryvtt/kopparhavet/raw/branch/master/system.json",
|
||||||
"download": "https://pi.rikspolisen.se/foundryvtt/kopparhavet/archive/v0.0.7.zip",
|
"download": "https://pi.rikspolisen.se/foundryvtt/kopparhavet/archive/v0.0.8.zip",
|
||||||
"license": "LICENCE.txt"
|
"license": "LICENCE.txt"
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,7 @@
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<a style="margin: auto;" class="learning-control" data-action="delete"><i class="fas fa-trash"></i></a>
|
<a style="margin: auto;" class="learning-delete" data-action="delete"><i class="fas fa-trash"></i></a>
|
||||||
</li>
|
</li>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</ol>
|
</ol>
|
||||||
|
|
|
@ -69,7 +69,7 @@
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<a style="margin: auto;" class="learning-control" data-action="delete"><i class="fas fa-trash"></i></a>
|
<a style="margin: auto;" class="learning-delete" data-action="delete"><i class="fas fa-trash"></i></a>
|
||||||
</li>
|
</li>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</ol>
|
</ol>
|
||||||
|
|
Loading…
Reference in New Issue