fvtt-pegasus-rpg/modules/pegasus-item-sheet.js

510 lines
17 KiB
JavaScript
Raw Normal View History

2021-12-02 07:38:59 +01:00
import { PegasusUtility } from "./pegasus-utility.js";
/**
* Extend the basic ItemSheet with some very simple modifications
* @extends {ItemSheet}
*/
export class PegasusItemSheet extends ItemSheet {
/** @override */
2022-02-16 17:43:51 +01:00
static get defaultOptions() {
2021-12-02 07:38:59 +01:00
return mergeObject(super.defaultOptions, {
2022-02-16 17:43:51 +01:00
classes: ["fvtt-pegasus-rpg", "sheet", "item"],
template: "systems/fvtt-pegasus-rpg/templates/item-sheet.html",
dragDrop: [{ dragSelector: null, dropSelector: null }],
width: 620,
2022-03-06 22:18:08 +01:00
height: 550,
tabs: [{navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "description"}]
2022-02-16 17:43:51 +01:00
});
2021-12-02 07:38:59 +01:00
}
/* -------------------------------------------- */
_getHeaderButtons() {
let buttons = super._getHeaderButtons();
// Add "Post to chat" button
// We previously restricted this to GM and editable items only. If you ever find this comment because it broke something: eh, sorry!
buttons.unshift(
{
class: "post",
icon: "fas fa-comment",
2022-02-16 17:43:51 +01:00
onclick: ev => { }
2021-12-02 07:38:59 +01:00
})
return buttons
}
/* -------------------------------------------- */
/** @override */
2022-02-16 17:43:51 +01:00
setPosition(options = {}) {
2021-12-02 07:38:59 +01:00
const position = super.setPosition(options);
const sheetBody = this.element.find(".sheet-body");
const bodyHeight = position.height - 192;
sheetBody.css("height", bodyHeight);
2022-02-16 17:43:51 +01:00
if (this.item.type.includes('weapon')) {
2021-12-02 07:38:59 +01:00
position.width = 640;
}
return position;
}
2022-02-16 17:43:51 +01:00
2021-12-02 07:38:59 +01:00
/* -------------------------------------------- */
async getData() {
const objectData = PegasusUtility.data(this.object);
2022-02-16 17:43:51 +01:00
2021-12-02 07:38:59 +01:00
let itemData = foundry.utils.deepClone(PegasusUtility.templateData(this.object));
let formData = {
title: this.title,
id: this.id,
type: objectData.type,
img: objectData.img,
name: objectData.name,
editable: this.isEditable,
cssClass: this.isEditable ? "editable" : "locked",
2021-12-02 20:18:21 +01:00
optionsDiceList: PegasusUtility.getOptionsDiceList(),
2021-12-05 20:36:34 +01:00
optionsStatusList: PegasusUtility.getOptionsStatusList(),
2022-02-16 17:43:51 +01:00
data: itemData,
2021-12-02 07:38:59 +01:00
limited: this.object.limited,
options: this.options,
owner: this.document.isOwner,
2022-01-12 16:25:55 +01:00
mr: (this.object.type == 'specialisation'),
2022-02-16 17:43:51 +01:00
isGM: game.user.isGM
2021-12-02 07:38:59 +01:00
}
2022-02-16 17:43:51 +01:00
2021-12-02 07:38:59 +01:00
this.options.editable = !(this.object.data.origin == "embeddedItem");
console.log("ITEM DATA", formData, this);
return formData;
}
/* -------------------------------------------- */
_getHeaderButtons() {
let buttons = super._getHeaderButtons();
buttons.unshift({
class: "post",
icon: "fas fa-comment",
onclick: ev => this.postItem()
});
return buttons
}
2022-02-16 17:43:51 +01:00
2021-12-02 07:38:59 +01:00
/* -------------------------------------------- */
postItem() {
let chatData = duplicate(PegasusUtility.data(this.item));
if (this.actor) {
chatData.actor = { id: this.actor.id };
}
// Don't post any image for the item (which would leave a large gap) if the default image is used
if (chatData.img.includes("/blank.png")) {
chatData.img = null;
}
// JSON object for easy creation
chatData.jsondata = JSON.stringify(
{
compendium: "postedItem",
payload: chatData,
});
renderTemplate('systems/fvtt-pegasus-rpg/templates/post-item.html', chatData).then(html => {
2022-02-10 19:03:09 +01:00
let chatOptions = PegasusUtility.chatDataSetup(html);
2021-12-02 07:38:59 +01:00
ChatMessage.create(chatOptions)
});
}
2021-12-08 13:53:22 +01:00
/* -------------------------------------------- */
async viewSubitem(ev) {
let field = $(ev.currentTarget).data('type');
let idx = Number($(ev.currentTarget).data('index'));
let itemData = this.object.data.data[field][idx];
2022-02-16 17:43:51 +01:00
if (itemData.name != 'None') {
let spec = await Item.create(itemData, { temporary: true });
2021-12-08 13:53:22 +01:00
spec.data.origin = "embeddedItem";
new PegasusItemSheet(spec).render(true);
}
}
/* -------------------------------------------- */
async deleteSubitem(ev) {
let field = $(ev.currentTarget).data('type');
let idx = Number($(ev.currentTarget).data('index'));
let oldArray = this.object.data.data[field];
let itemData = this.object.data.data[field][idx];
2022-02-16 17:43:51 +01:00
if (itemData.name != 'None') {
2021-12-08 13:53:22 +01:00
let newArray = [];
2022-02-16 17:43:51 +01:00
for (var i = 0; i < oldArray.length; i++) {
if (i != idx) {
newArray.push(oldArray[i]);
2021-12-08 13:53:22 +01:00
}
}
2022-02-16 17:43:51 +01:00
this.object.update({ [`data.${field}`]: newArray });
2021-12-08 13:53:22 +01:00
}
}
2022-02-16 17:43:51 +01:00
2021-12-08 13:53:22 +01:00
/* -------------------------------------------- */
2022-02-16 17:43:51 +01:00
async manageSpec() {
2021-12-08 13:53:22 +01:00
let itemData = this.object.data.data.specialisation[0];
2022-02-16 17:43:51 +01:00
if (itemData.name != 'None') {
let spec = await Item.create(itemData, { temporary: true });
2021-12-08 13:53:22 +01:00
spec.data.origin = "embeddedItem";
new PegasusItemSheet(spec).render(true);
}
}
2021-12-02 07:38:59 +01:00
/* -------------------------------------------- */
/** @override */
2022-02-16 17:43:51 +01:00
activateListeners(html) {
2021-12-02 07:38:59 +01:00
super.activateListeners(html);
// Everything below here is only needed if the sheet is editable
if (!this.options.editable) return;
2022-02-16 17:43:51 +01:00
2021-12-02 07:38:59 +01:00
// Update Inventory Item
html.find('.item-edit').click(ev => {
const li = $(ev.currentTarget).parents(".item");
const item = this.object.options.actor.getOwnedItem(li.data("item-id"));
item.sheet.render(true);
});
2022-02-16 17:43:51 +01:00
html.find('.delete-spec').click(ev => {
this.object.update({ "data.specialisation": [{ name: 'None' }] });
2021-12-08 13:53:22 +01:00
});
2022-02-16 17:43:51 +01:00
html.find('.delete-subitem').click(ev => {
this.deleteSubitem(ev);
2021-12-08 13:53:22 +01:00
});
2022-02-16 17:43:51 +01:00
html.find('.stat-choice-flag').click(ev => {
2021-12-08 13:53:22 +01:00
let idx = $(ev.currentTarget).data("stat-idx");
let array = duplicate(this.object.data.data.statincreasechoice);
array[Number(idx)].flag = !array[Number(idx)].flag;
2022-02-16 17:43:51 +01:00
this.object.update({ "data.statincreasechoice": array });
2021-12-08 13:53:22 +01:00
});
2021-12-02 07:38:59 +01:00
// Update Inventory Item
html.find('.item-delete').click(ev => {
const li = $(ev.currentTarget).parents(".item");
let itemId = li.data("item-id");
let itemType = li.data("item-type");
});
2021-12-08 13:53:22 +01:00
html.find('.view-subitem').click(ev => {
2022-02-16 17:43:51 +01:00
this.viewSubitem(ev);
2021-12-02 07:38:59 +01:00
});
2022-02-16 17:43:51 +01:00
2021-12-08 13:53:22 +01:00
html.find('.view-spec').click(ev => {
2022-02-16 17:43:51 +01:00
this.manageSpec();
2021-12-02 07:38:59 +01:00
});
}
2021-12-09 18:40:50 +01:00
/* -------------------------------------------- */
2022-01-07 20:40:40 +01:00
async addAbility(event, item, dataItem) {
2021-12-09 18:40:50 +01:00
let newItem = duplicate(item.data);
2022-02-16 17:43:51 +01:00
newItem._id = randomID(dataItem.id.length);
2022-01-07 20:40:40 +01:00
console.log("ABB", event, item, dataItem)
2022-02-16 17:43:51 +01:00
if (event.toElement.className == 'drop-abilities') {
2022-01-07 20:40:40 +01:00
let abilityArray = duplicate(this.object.data.data.abilities);
2022-02-16 17:43:51 +01:00
abilityArray.push(newItem);
await this.object.update({ 'data.abilities': abilityArray });
2022-01-07 20:40:40 +01:00
}
2022-02-16 17:43:51 +01:00
if (event.toElement.className == 'drop-optionnal-abilities') {
2022-01-07 20:40:40 +01:00
let abilityArray = duplicate(this.object.data.data.optionnalabilities);
2022-02-16 17:43:51 +01:00
abilityArray.push(newItem);
await this.object.update({ 'data.optionnalabilities': abilityArray });
2022-01-07 20:40:40 +01:00
}
2021-12-09 18:40:50 +01:00
}
2022-01-07 20:40:40 +01:00
2022-01-08 18:28:01 +01:00
/* -------------------------------------------- */
async addRacePerk(event, item, dataItem) {
let newItem = duplicate(item.data);
2022-02-16 17:43:51 +01:00
newItem._id = randomID(dataItem.id.length);
if (event.toElement.className == 'drop-race-perk') {
2022-01-08 18:28:01 +01:00
let perkArray = duplicate(this.object.data.data.perks);
2022-02-16 17:43:51 +01:00
perkArray.push(newItem);
await this.object.update({ 'data.perks': perkArray });
2022-01-08 18:28:01 +01:00
}
}
2022-02-16 17:43:51 +01:00
2021-12-08 13:53:22 +01:00
/* -------------------------------------------- */
async addSpecialisation(item, dataItem) {
let newItem = duplicate(item.data);
2022-02-16 17:43:51 +01:00
newItem._id = randomID(dataItem.id.length);
let specArray = [newItem];
await this.object.update({ 'data.specialisation': specArray });
2021-12-08 13:53:22 +01:00
}
/* -------------------------------------------- */
async addRoleSpecialisation(event, item, dataItem) {
let newItem = duplicate(item.data);
2022-02-16 17:43:51 +01:00
newItem._id = randomID(dataItem.id.length);
2021-12-08 13:53:22 +01:00
console.log("Add spec", event, newItem);
2022-02-16 17:43:51 +01:00
if (event.toElement.className == 'drop-spec1') {
2021-12-08 13:53:22 +01:00
let specArray = duplicate(this.object.data.data.specialisationsplus1);
2022-02-16 17:43:51 +01:00
specArray.push(newItem);
await this.object.update({ 'data.specialisationsplus1': specArray });
2021-12-08 13:53:22 +01:00
}
2022-02-16 17:43:51 +01:00
if (event.toElement.className == 'drop-spec2') {
2021-12-08 13:53:22 +01:00
let specArray = duplicate(this.object.data.data.specincrease);
2022-02-16 17:43:51 +01:00
specArray.push(newItem);
await this.object.update({ 'data.specincrease': specArray });
2021-12-08 13:53:22 +01:00
}
}
/* -------------------------------------------- */
async addRolePerk(event, item, dataItem) {
let newItem = duplicate(item.data);
2022-02-16 17:43:51 +01:00
newItem._id = randomID(dataItem.id.length);
2021-12-08 13:53:22 +01:00
console.log("Add spec", event, newItem);
2022-02-16 17:43:51 +01:00
if (event.toElement.className == 'drop-perk2') {
2021-12-08 13:53:22 +01:00
let perkArray = duplicate(this.object.data.data.perks);
2022-02-16 17:43:51 +01:00
perkArray.push(newItem);
await this.object.update({ 'data.perks': perkArray });
}
if (event.toElement.className == 'drop-specialperk1') {
2021-12-09 18:40:50 +01:00
let perkArray = duplicate(this.object.data.data.specialperk);
2022-02-16 17:43:51 +01:00
perkArray.push(newItem);
await this.object.update({ 'data.specialperk': perkArray });
2021-12-08 13:53:22 +01:00
}
}
2022-02-16 17:43:51 +01:00
2021-12-16 21:41:09 +01:00
/* -------------------------------------------- */
2022-02-16 17:43:51 +01:00
async addPower(event, item, dataItem) {
2021-12-16 21:41:09 +01:00
let newItem = duplicate(item.data);
2022-02-16 17:43:51 +01:00
newItem._id = randomID(dataItem.id.length);
if (event.toElement.className == 'drop-spec-power') {
2021-12-16 21:41:09 +01:00
let powArray = duplicate(this.object.data.data.powers);
2022-02-16 17:43:51 +01:00
powArray.push(newItem);
await this.object.update({ 'data.powers': powArray });
}
2021-12-16 21:41:09 +01:00
}
/* -------------------------------------------- */
2022-02-16 17:43:51 +01:00
async addAbilityPower(event, item, dataItem) {
2021-12-16 21:41:09 +01:00
let newItem = duplicate(item.data);
2022-02-16 17:43:51 +01:00
newItem._id = randomID(dataItem.id.length);
if (event.toElement.className == 'drop-ability-power') {
2021-12-16 21:41:09 +01:00
let powArray = duplicate(this.object.data.data.powersgained);
2022-02-16 17:43:51 +01:00
powArray.push(newItem);
await this.object.update({ 'data.powersgained': powArray });
}
2021-12-16 21:41:09 +01:00
}
2022-02-10 15:53:42 +01:00
/* -------------------------------------------- */
2022-02-16 17:43:51 +01:00
async addAbilityEffect(event, item, dataItem) {
2022-02-10 15:53:42 +01:00
let newItem = duplicate(item.data);
2022-02-16 17:43:51 +01:00
newItem._id = randomID(dataItem.id.length);
if (event.toElement.className == 'drop-ability-effect') {
2022-02-10 15:53:42 +01:00
let powArray = duplicate(this.object.data.data.effectsgained);
2022-02-16 17:43:51 +01:00
powArray.push(newItem);
await this.object.update({ 'data.effectsgained': powArray });
}
2022-02-10 15:53:42 +01:00
}
2022-01-08 18:28:01 +01:00
2021-12-16 21:41:09 +01:00
/* -------------------------------------------- */
2022-02-16 17:43:51 +01:00
async addAbilitySpec(event, item, dataItem) {
2021-12-16 21:41:09 +01:00
let newItem = duplicate(item.data);
2022-02-16 17:43:51 +01:00
newItem._id = randomID(dataItem.id.length);
if (event.toElement.className == 'drop-ability-spec') {
2021-12-16 21:41:09 +01:00
let powArray = duplicate(this.object.data.data.specialisations);
2022-02-16 17:43:51 +01:00
powArray.push(newItem);
await this.object.update({ 'data.specialisations': powArray });
}
2021-12-16 21:41:09 +01:00
}
2022-01-08 18:28:01 +01:00
/* -------------------------------------------- */
2022-02-16 17:43:51 +01:00
async addAbilityWeaponArmor(event, item, dataItem) {
2022-01-08 18:28:01 +01:00
let newItem = duplicate(item.data);
2022-02-16 17:43:51 +01:00
newItem._id = randomID(dataItem.id.length);
if (event.toElement.className == 'drop-ability-weapon') {
2022-01-08 18:28:01 +01:00
let weaponArray = duplicate(this.object.data.data.attackgained);
2022-02-16 17:43:51 +01:00
weaponArray.push(newItem);
await this.object.update({ 'data.attackgained': weaponArray });
}
if (event.toElement.className == 'drop-ability-armor') {
2022-01-08 18:28:01 +01:00
let armorArray = duplicate(this.object.data.data.armorgained);
2022-02-16 17:43:51 +01:00
armorArray.push(newItem);
await this.object.update({ 'data.armorgained': armorArray });
}
2022-01-08 18:28:01 +01:00
}
2022-02-16 17:43:51 +01:00
2021-12-19 15:35:54 +01:00
/* -------------------------------------------- */
2022-02-16 17:43:51 +01:00
async addPerkSpecialisation(event, item, dataItem) {
2021-12-19 15:35:54 +01:00
let newItem = duplicate(item.data);
2022-02-16 17:43:51 +01:00
if (event.toElement.className == 'drop-spec-perk') {
2021-12-23 15:31:56 +01:00
//console.log("PER SPEC", event)
let key = event.toElement.dataset["key"];
2022-02-16 17:43:51 +01:00
if (key == 'affectedspec') {
await this.object.update({ 'data.features.affectedspec.value': newItem.name });
2021-12-23 15:31:56 +01:00
} else {
2022-02-16 17:43:51 +01:00
await this.object.update({ 'data.features.gainspecdice.value': newItem.name });
2021-12-23 15:31:56 +01:00
}
}
2021-12-19 15:35:54 +01:00
}
2022-01-12 16:25:55 +01:00
2022-02-10 19:03:09 +01:00
/* -------------------------------------------- */
2022-02-16 17:43:51 +01:00
async addPerkEffect(event, item, dataItem) {
2022-02-10 19:03:09 +01:00
let newItem = duplicate(item.data)
2022-02-16 17:43:51 +01:00
if (event.toElement.className == 'drop-perk-effect') {
2022-02-10 19:03:09 +01:00
let effectArray = duplicate(this.object.data.data.effectsgained)
2022-02-16 17:43:51 +01:00
effectArray.push(newItem)
await this.object.update({ 'data.effectsgained': effectArray })
2022-02-10 19:03:09 +01:00
}
}
2022-02-16 17:43:51 +01:00
2022-02-10 21:58:19 +01:00
/* -------------------------------------------- */
2022-02-16 17:43:51 +01:00
async addEffectPower(event, item, dataItem) {
2022-02-10 21:58:19 +01:00
let newItem = duplicate(item.data)
2022-02-16 17:43:51 +01:00
if (event.toElement.className == 'drop-power-effect') {
2022-02-10 21:58:19 +01:00
let effectArray = duplicate(this.object.data.data.effectsgained)
2022-02-16 17:43:51 +01:00
effectArray.push(newItem);
await this.object.update({ 'data.effectsgained': effectArray })
2022-02-10 21:58:19 +01:00
}
}
2022-01-12 16:25:55 +01:00
/* -------------------------------------------- */
2022-02-16 17:43:51 +01:00
async addEffectSpec(event, item, dataItem) {
2022-01-12 16:25:55 +01:00
let newItem = duplicate(item.data);
2022-02-16 17:43:51 +01:00
if (event.toElement.className == 'drop-effect-spec') {
2022-01-12 16:25:55 +01:00
let specArray = duplicate(this.object.data.data.recoveryrollspec);
2022-02-16 17:43:51 +01:00
specArray.push(newItem);
await this.object.update({ 'data.recoveryrollspec': specArray });
2022-01-12 16:25:55 +01:00
}
2022-02-16 17:43:51 +01:00
if (event.toElement.className == 'drop-effect-specaffected') {
2022-01-12 17:21:37 +01:00
let specArray = duplicate(this.object.data.data.specaffected);
2022-02-16 17:43:51 +01:00
specArray.push(newItem);
await this.object.update({ 'data.specaffected': specArray });
2022-01-12 17:21:37 +01:00
}
2022-01-12 16:25:55 +01:00
}
2022-02-16 17:43:51 +01:00
/* -------------------------------------------- */
async addEffectItem(event, item, dataItem) {
let newItem = duplicate(item.data);
if (event.toElement.className == 'drop-equipment-effect') {
let effectArray = duplicate(this.object.data.data.effects);
effectArray.push(newItem);
await this.object.update({ 'data.effects': effectArray });
}
}
2021-12-02 07:38:59 +01:00
/* -------------------------------------------- */
async _onDrop(event) {
2022-02-10 21:58:19 +01:00
2022-02-25 14:53:19 +01:00
if (this.object.type == 'weapon' || this.object.type == 'armor' || this.object.type == 'shield'
|| this.object.type == 'equipment') {
2022-02-10 21:58:19 +01:00
let data = event.dataTransfer.getData('text/plain');
if (data) {
2022-02-16 17:43:51 +01:00
let dataItem = JSON.parse(data);
let item = await PegasusUtility.searchItem(dataItem);
if (item.data.type == 'effect') {
return this.addEffectItem(event, item, dataItem);
2022-02-10 21:58:19 +01:00
}
}
}
2022-02-16 17:43:51 +01:00
if (this.object.type == 'power') {
2022-01-12 16:25:55 +01:00
let data = event.dataTransfer.getData('text/plain');
if (data) {
2022-02-16 17:43:51 +01:00
let dataItem = JSON.parse(data);
let item = await PegasusUtility.searchItem(dataItem);
if (item.data.type == 'effect') {
return this.addEffectPower(event, item, dataItem);
2022-01-12 16:25:55 +01:00
}
}
}
2022-02-16 17:43:51 +01:00
if (this.object.type == 'effect') {
2021-12-09 18:40:50 +01:00
let data = event.dataTransfer.getData('text/plain');
if (data) {
2022-02-16 17:43:51 +01:00
let dataItem = JSON.parse(data);
let item = await PegasusUtility.searchItem(dataItem);
if (item.data.type == 'specialisation') {
return this.addEffectSpec(event, item, dataItem);
2021-12-09 18:40:50 +01:00
}
2022-02-16 17:43:51 +01:00
}
}
if (this.object.type == 'race') {
let data = event.dataTransfer.getData('text/plain');
if (data) {
let dataItem = JSON.parse(data);
let item = await PegasusUtility.searchItem(dataItem);
if (item.data.type == 'ability') {
return this.addAbility(event, item, dataItem);
}
if (item.data.type == 'perk') {
return this.addRacePerk(event, item, dataItem);
2022-01-08 18:28:01 +01:00
}
2021-12-09 18:40:50 +01:00
}
}
2021-12-19 15:35:54 +01:00
2022-02-16 17:43:51 +01:00
if (this.object.type == 'perk') {
2022-02-10 19:03:09 +01:00
let data = event.dataTransfer.getData('text/plain')
2021-12-19 15:35:54 +01:00
if (data) {
2022-02-16 17:43:51 +01:00
let dataItem = JSON.parse(data);
let item = await PegasusUtility.searchItem(dataItem)
if (item.data.type == 'specialisation') {
return this.addPerkSpecialisation(event, item, dataItem)
}
if (item.data.type == 'effect') {
return this.addPerkEffect(event, item, dataItem);
2021-12-19 15:35:54 +01:00
}
}
}
2022-02-16 17:43:51 +01:00
if (this.object.type == 'specialisation') {
2021-12-16 21:41:09 +01:00
let data = event.dataTransfer.getData('text/plain');
if (data) {
2022-02-16 17:43:51 +01:00
let dataItem = JSON.parse(data);
let item = await PegasusUtility.searchItem(dataItem);
if (item.data.type == 'power') {
return this.addPower(event, item, dataItem);
2021-12-16 21:41:09 +01:00
}
}
}
2022-02-16 17:43:51 +01:00
if (this.object.type == 'ability') {
2021-12-16 21:41:09 +01:00
let data = event.dataTransfer.getData('text/plain');
if (data) {
2022-02-16 17:43:51 +01:00
let dataItem = JSON.parse(data);
let item = await PegasusUtility.searchItem(dataItem);
if (item.data.type == 'effect') {
return this.addAbilityEffect(event, item, dataItem);
2022-02-10 15:53:42 +01:00
}
2022-02-16 17:43:51 +01:00
if (item.data.type == 'power') {
return this.addAbilityPower(event, item, dataItem);
2021-12-16 21:41:09 +01:00
}
2022-02-16 17:43:51 +01:00
if (item.data.type == 'specialisation') {
return this.addAbilitySpec(event, item, dataItem);
2021-12-16 21:41:09 +01:00
}
2022-02-16 17:43:51 +01:00
if (item.data.type == 'weapon' || item.data.type == 'armor') {
return this.addAbilityWeaponArmor(event, item, dataItem);
2022-01-08 18:28:01 +01:00
}
2021-12-16 21:41:09 +01:00
}
}
2022-02-16 17:43:51 +01:00
if (this.object.type == 'role') {
2021-12-08 13:53:22 +01:00
let data = event.dataTransfer.getData('text/plain');
if (data) {
2022-02-16 17:43:51 +01:00
let dataItem = JSON.parse(data);
let item = await PegasusUtility.searchItem(dataItem);
if (item.data.type == 'specialisation') {
return this.addRoleSpecialisation(event, item, dataItem);
2021-12-08 13:53:22 +01:00
}
2022-02-16 17:43:51 +01:00
if (item.data.type == 'perk') {
return this.addRolePerk(event, item, dataItem);
2021-12-08 13:53:22 +01:00
}
}
}
2021-12-02 07:38:59 +01:00
2021-12-08 13:53:22 +01:00
ui.notifications.warn("This item can not be dropped over another item");
2021-12-02 07:38:59 +01:00
}
2022-02-16 17:43:51 +01:00
2021-12-02 07:38:59 +01:00
/* -------------------------------------------- */
get template() {
let type = this.item.type;
return `systems/fvtt-pegasus-rpg/templates/item-${type}-sheet.html`;
}
/* -------------------------------------------- */
/** @override */
_updateObject(event, formData) {
return this.object.update(formData);
}
}