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

544 lines
18 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() {
2022-09-04 09:58:51 +02:00
const objectData = this.object
2022-02-16 17:43:51 +01:00
2022-09-04 09:58:51 +02:00
let itemData = foundry.utils.deepClone(objectData)
2021-12-02 07:38:59 +01:00
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(),
2022-09-04 09:58:51 +02:00
data: itemData.system,
2022-09-27 20:31:01 +02:00
description: await TextEditor.enrichHTML(this.object.system.description, {async: true}),
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-09-27 20:31:01 +02:00
if (this.object.type == "power") {
formData.effects = await TextEditor.enrichHTML(this.object.system.effects, {async: true})
formData.purchasedeffects = await TextEditor.enrichHTML(this.object.system.purchasedeffects, {async: true})
}
2022-02-16 17:43:51 +01:00
2022-09-27 20:31:01 +02:00
this.options.editable = true
2021-12-02 07:38:59 +01:00
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() {
2022-09-04 09:58:51 +02:00
let chatData = this.item.system
2021-12-02 07:38:59 +01:00
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'));
2022-09-04 09:58:51 +02:00
let itemData = this.object.system[field][idx];
2022-02-16 17:43:51 +01:00
if (itemData.name != 'None') {
let spec = await Item.create(itemData, { temporary: true });
2022-09-04 09:58:51 +02:00
spec.system.origin = "embeddedItem";
2021-12-08 13:53:22 +01:00
new PegasusItemSheet(spec).render(true);
}
}
/* -------------------------------------------- */
async deleteSubitem(ev) {
let field = $(ev.currentTarget).data('type');
let idx = Number($(ev.currentTarget).data('index'));
2022-09-04 09:58:51 +02:00
let oldArray = this.object.system[field];
let itemData = this.object.system[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-09-04 09:58:51 +02:00
this.object.update({ [`system.${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() {
2022-09-04 09:58:51 +02:00
let itemData = this.object.system.specialisation[0];
2022-02-16 17:43:51 +01:00
if (itemData.name != 'None') {
let spec = await Item.create(itemData, { temporary: true });
2022-09-04 09:58:51 +02:00
spec.system.origin = "embeddedItem";
2021-12-08 13:53:22 +01:00
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 => {
2022-09-04 09:58:51 +02:00
this.object.update({ "system.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");
2022-09-04 09:58:51 +02:00
let array = duplicate(this.object.system.statincreasechoice);
2021-12-08 13:53:22 +01:00
array[Number(idx)].flag = !array[Number(idx)].flag;
2022-09-04 09:58:51 +02:00
this.object.update({ "system.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-09-04 09:58:51 +02:00
async addAbility(event, item) {
let newItem = duplicate(item)
newItem._id = randomID(item.id.length);
console.log("ABB", event, item)
2022-02-16 17:43:51 +01:00
if (event.toElement.className == 'drop-abilities') {
2022-09-04 09:58:51 +02:00
let abilityArray = duplicate(this.object.system.abilities);
2022-02-16 17:43:51 +01:00
abilityArray.push(newItem);
2022-09-04 09:58:51 +02:00
await this.object.update({ 'system.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-09-04 09:58:51 +02:00
let abilityArray = duplicate(this.object.system.optionnalabilities);
2022-02-16 17:43:51 +01:00
abilityArray.push(newItem);
2022-09-04 09:58:51 +02:00
await this.object.update({ 'system.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
/* -------------------------------------------- */
2022-09-04 09:58:51 +02:00
async addRacePerk(event, item) {
let newItem = duplicate(item);
newItem._id = randomID(item.id);
2022-02-16 17:43:51 +01:00
if (event.toElement.className == 'drop-race-perk') {
2022-09-04 09:58:51 +02:00
let perkArray = duplicate(this.object.system.perks);
2022-02-16 17:43:51 +01:00
perkArray.push(newItem);
2022-09-04 09:58:51 +02:00
await this.object.update({ 'system.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
/* -------------------------------------------- */
2022-09-04 09:58:51 +02:00
async addSpecialisation(item) {
let newItem = duplicate(item)
newItem._id = randomID(item.id.length)
2022-02-16 17:43:51 +01:00
let specArray = [newItem];
2022-09-04 09:58:51 +02:00
await this.object.update({ 'system.specialisation': specArray });
2021-12-08 13:53:22 +01:00
}
/* -------------------------------------------- */
2022-09-04 09:58:51 +02:00
async addRoleSpecialisation(event, item) {
let newItem = duplicate(item);
newItem._id = randomID(item.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') {
2022-09-04 09:58:51 +02:00
let specArray = duplicate(this.object.system.specialisationsplus1);
2022-02-16 17:43:51 +01:00
specArray.push(newItem);
2022-09-04 09:58:51 +02:00
await this.object.update({ 'system.specialisationsplus1': specArray });
2021-12-08 13:53:22 +01:00
}
2022-02-16 17:43:51 +01:00
if (event.toElement.className == 'drop-spec2') {
2022-09-04 09:58:51 +02:00
let specArray = duplicate(this.object.system.specincrease);
2022-02-16 17:43:51 +01:00
specArray.push(newItem);
2022-09-04 09:58:51 +02:00
await this.object.update({ 'system.specincrease': specArray });
2021-12-08 13:53:22 +01:00
}
}
/* -------------------------------------------- */
2022-09-04 09:58:51 +02:00
async addRolePerk(event, item) {
let newItem = duplicate(item);
newItem._id = randomID(item.id.length);
2022-02-16 17:43:51 +01:00
if (event.toElement.className == 'drop-perk2') {
2022-09-04 09:58:51 +02:00
let perkArray = duplicate(this.object.system.perks);
2022-02-16 17:43:51 +01:00
perkArray.push(newItem);
2022-09-04 09:58:51 +02:00
await this.object.update({ 'system.perks': perkArray });
2022-02-16 17:43:51 +01:00
}
if (event.toElement.className == 'drop-specialperk1') {
2022-09-04 09:58:51 +02:00
let perkArray = duplicate(this.object.system.specialperk);
2022-02-16 17:43:51 +01:00
perkArray.push(newItem);
2022-09-04 09:58:51 +02:00
await this.object.update({ 'system.specialperk': perkArray });
2021-12-08 13:53:22 +01:00
}
}
2022-03-16 11:12:14 +01:00
/* -------------------------------------------- */
2022-09-04 09:58:51 +02:00
async addRoleAbility(event, item) {
let newItem = duplicate(item)
newItem._id = randomID(item.id.length)
2022-03-16 11:12:14 +01:00
if (event.toElement.className == 'drop-specialability') {
2022-09-04 09:58:51 +02:00
let abiArray = duplicate(this.object.system.specialability)
2022-03-16 11:12:14 +01:00
abiArray.push(newItem)
2022-09-04 09:58:51 +02:00
await this.object.update({ 'system.specialability': abiArray })
2022-03-16 11:12:14 +01:00
}
}
2022-02-16 17:43:51 +01:00
2021-12-16 21:41:09 +01:00
/* -------------------------------------------- */
2022-09-04 09:58:51 +02:00
async addPower(event, item) {
let newItem = duplicate(item);
newItem._id = randomID(item.id.length);
2022-02-16 17:43:51 +01:00
if (event.toElement.className == 'drop-spec-power') {
2022-09-04 09:58:51 +02:00
let powArray = duplicate(this.object.system.powers);
2022-02-16 17:43:51 +01:00
powArray.push(newItem);
2022-09-04 09:58:51 +02:00
await this.object.update({ 'system.powers': powArray });
2022-02-16 17:43:51 +01:00
}
2021-12-16 21:41:09 +01:00
}
/* -------------------------------------------- */
2022-09-04 09:58:51 +02:00
async addAbilityPower(event, item) {
let newItem = duplicate(item);
newItem._id = randomID(item.id.length);
2022-02-16 17:43:51 +01:00
if (event.toElement.className == 'drop-ability-power') {
2022-09-04 09:58:51 +02:00
let powArray = duplicate(this.object.system.powersgained);
2022-02-16 17:43:51 +01:00
powArray.push(newItem);
2022-09-04 09:58:51 +02:00
await this.object.update({ 'system.powersgained': powArray });
2022-02-16 17:43:51 +01:00
}
2021-12-16 21:41:09 +01:00
}
2022-02-10 15:53:42 +01:00
/* -------------------------------------------- */
2022-09-04 09:58:51 +02:00
async addAbilityEffect(event, item) {
let newItem = duplicate(item);
newItem._id = randomID(item.id.length);
2022-02-16 17:43:51 +01:00
if (event.toElement.className == 'drop-ability-effect') {
2022-09-04 09:58:51 +02:00
let powArray = duplicate(this.object.system.effectsgained);
2022-02-16 17:43:51 +01:00
powArray.push(newItem);
2022-09-04 09:58:51 +02:00
await this.object.update({ 'system.effectsgained': powArray });
2022-02-16 17:43:51 +01:00
}
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-09-04 09:58:51 +02:00
async addAbilitySpec(event, item) {
let newItem = duplicate(item);
newItem._id = randomID(item.id.length);
2022-02-16 17:43:51 +01:00
if (event.toElement.className == 'drop-ability-spec') {
2022-09-04 09:58:51 +02:00
let powArray = duplicate(this.object.system.specialisations);
2022-02-16 17:43:51 +01:00
powArray.push(newItem);
2022-09-04 09:58:51 +02:00
await this.object.update({ 'system.specialisations': powArray });
2022-02-16 17:43:51 +01:00
}
2021-12-16 21:41:09 +01:00
}
2022-01-08 18:28:01 +01:00
/* -------------------------------------------- */
2022-09-04 09:58:51 +02:00
async addAbilityWeaponArmor(event, item) {
let newItem = duplicate(item);
newItem._id = randomID(item.id.length);
2022-02-16 17:43:51 +01:00
if (event.toElement.className == 'drop-ability-weapon') {
2022-09-04 09:58:51 +02:00
let weaponArray = duplicate(this.object.system.attackgained);
2022-02-16 17:43:51 +01:00
weaponArray.push(newItem);
2022-09-04 09:58:51 +02:00
await this.object.update({ 'system.attackgained': weaponArray });
2022-02-16 17:43:51 +01:00
}
if (event.toElement.className == 'drop-ability-armor') {
2022-09-04 09:58:51 +02:00
let armorArray = duplicate(this.object.system.armorgained);
2022-02-16 17:43:51 +01:00
armorArray.push(newItem);
2022-09-04 09:58:51 +02:00
await this.object.update({ 'system.armorgained': armorArray });
2022-02-16 17:43:51 +01:00
}
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-09-04 09:58:51 +02:00
async addPerkSpecialisation(event, item) {
let newItem = duplicate(item);
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') {
2022-09-04 09:58:51 +02:00
await this.object.update({ 'system.features.affectedspec.value': newItem.name });
2021-12-23 15:31:56 +01:00
} else {
2022-09-04 09:58:51 +02:00
await this.object.update({ 'system.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-09-04 09:58:51 +02:00
async addPerkEffect(event, item) {
let newItem = duplicate(item)
2022-02-16 17:43:51 +01:00
if (event.toElement.className == 'drop-perk-effect') {
2022-09-04 09:58:51 +02:00
let effectArray = duplicate(this.object.system.effectsgained)
2022-02-16 17:43:51 +01:00
effectArray.push(newItem)
2022-09-04 09:58:51 +02:00
await this.object.update({ 'system.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-09-04 09:58:51 +02:00
async addEffectPower(event, item) {
let newItem = duplicate(item)
2022-02-16 17:43:51 +01:00
if (event.toElement.className == 'drop-power-effect') {
2022-09-04 09:58:51 +02:00
let effectArray = duplicate(this.object.system.effectsgained)
2022-02-16 17:43:51 +01:00
effectArray.push(newItem);
2022-09-04 09:58:51 +02:00
await this.object.update({ 'system.effectsgained': effectArray })
2022-02-10 21:58:19 +01:00
}
}
2022-01-12 16:25:55 +01:00
/* -------------------------------------------- */
2022-09-04 09:58:51 +02:00
async addEffectSpec(event, item) {
let newItem = duplicate(item);
2022-02-16 17:43:51 +01:00
if (event.toElement.className == 'drop-effect-spec') {
2022-09-04 09:58:51 +02:00
let specArray = duplicate(this.object.system.recoveryrollspec);
2022-02-16 17:43:51 +01:00
specArray.push(newItem);
2022-09-04 09:58:51 +02:00
await this.object.update({ 'system.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-09-04 09:58:51 +02:00
let specArray = duplicate(this.object.system.specaffected);
2022-02-16 17:43:51 +01:00
specArray.push(newItem);
2022-09-04 09:58:51 +02:00
await this.object.update({ 'system.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
/* -------------------------------------------- */
2022-09-04 09:58:51 +02:00
async addEffectItem(event, item) {
let newItem = duplicate(item);
2022-02-16 17:43:51 +01:00
if (event.toElement.className == 'drop-equipment-effect') {
2022-09-04 09:58:51 +02:00
let effectArray = duplicate(this.object.system.effects);
2022-02-16 17:43:51 +01:00
effectArray.push(newItem);
2022-09-04 09:58:51 +02:00
await this.object.update({ 'system.effects': effectArray });
2022-02-16 17:43:51 +01:00
}
}
2022-07-19 20:51:48 +02:00
/* -------------------------------------------- */
2022-09-04 09:58:51 +02:00
async addEffectVirtueVice(event, item) {
let newItem = duplicate(item);
2022-07-19 20:51:48 +02:00
if (event.toElement.className == 'drop-virtue-vice-effect') {
2022-09-04 09:58:51 +02:00
let effectArray = duplicate(this.object.system.effectsgained);
2022-07-19 20:51:48 +02:00
effectArray.push(newItem);
2022-09-04 09:58:51 +02:00
await this.object.update({ 'system.effectsgained': effectArray });
2022-07-19 20:51:48 +02:00
}
}
/* -------------------------------------------- */
2022-09-04 09:58:51 +02:00
async addViceToVirtue(event, item) {
let newItem = duplicate(item);
2022-07-19 20:51:48 +02:00
if (event.toElement.className == 'drop-virtue-vice') {
2022-09-04 09:58:51 +02:00
let viceArray = duplicate(this.object.system.unavailablevice);
2022-07-19 20:51:48 +02:00
viceArray.push(newItem);
2022-09-04 09:58:51 +02:00
await this.object.update({ 'system.unavailablevice': viceArray });
2022-07-19 20:51:48 +02:00
}
}
/* -------------------------------------------- */
2022-09-04 09:58:51 +02:00
async addVirtueToVice(event, item) {
let newItem = duplicate(item);
2022-07-19 20:51:48 +02:00
if (event.toElement.className == 'drop-vice-virtue') {
2022-09-04 09:58:51 +02:00
let virtueArray = duplicate(this.object.system.unavailablevirtue);
2022-07-19 20:51:48 +02:00
virtueArray.push(newItem);
2022-09-04 09:58:51 +02:00
await this.object.update({ 'system.unavailablevirtue': virtueArray });
2022-07-19 20:51:48 +02:00
}
}
2022-02-16 17:43:51 +01:00
2022-07-19 20:51:48 +02:00
2021-12-02 07:38:59 +01:00
/* -------------------------------------------- */
async _onDrop(event) {
2022-02-10 21:58:19 +01:00
2022-09-04 09:58:51 +02:00
let data = event.dataTransfer.getData('text/plain')
let dataItem = JSON.parse( data)
let item = fromUuidSync(dataItem.uuid)
if (item.pack) {
item = await PegasusUtility.searchItem(item)
}
2022-09-04 09:58:51 +02:00
if (!item) {
ui.notifications.warn("Unable to find relevant item - Aborting drag&drop " + data.uuid)
return
}
2022-07-19 20:51:48 +02:00
if (this.object.type == 'virtue' ) {
2022-09-04 09:58:51 +02:00
if (item.type == 'effect') {
return this.addEffectVirtueVice(event, item);
}
if (item.type == 'vice') {
return this.addViceToVirtue(event, item);
2022-07-19 20:51:48 +02:00
}
}
2022-09-04 09:58:51 +02:00
2022-07-19 20:51:48 +02:00
if (this.object.type == 'vice' ) {
2022-09-04 09:58:51 +02:00
if (item.type == 'effect') {
return this.addEffectVirtueVice(event, item);
}
if (item.type == 'virtue') {
return this.addVirtueToVice(event, item);
2022-07-19 20:51:48 +02:00
}
}
2022-02-25 14:53:19 +01:00
if (this.object.type == 'weapon' || this.object.type == 'armor' || this.object.type == 'shield'
2022-08-03 18:52:24 +02:00
|| this.object.type == 'equipment' || this.object.type == 'vehiclemodule'
|| this.object.type == 'vehicleweaponmodule') {
2022-09-04 09:58:51 +02:00
if (item.type == 'effect') {
return this.addEffectItem(event, item);
2022-02-10 21:58:19 +01:00
}
}
2022-02-16 17:43:51 +01:00
if (this.object.type == 'power') {
2022-09-04 09:58:51 +02:00
if (item.type == 'effect') {
return this.addEffectPower(event, item);
2022-01-12 16:25:55 +01:00
}
}
2022-02-16 17:43:51 +01:00
if (this.object.type == 'effect') {
2022-09-04 09:58:51 +02:00
if (item.type == 'specialisation') {
return this.addEffectSpec(event, item);
2022-02-16 17:43:51 +01:00
}
}
if (this.object.type == 'race') {
2022-09-04 09:58:51 +02:00
if (item.type == 'ability') {
return this.addAbility(event, item);
}
if (item.type == 'perk') {
return this.addRacePerk(event, item);
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-09-04 09:58:51 +02:00
if (item.type == 'specialisation') {
return this.addPerkSpecialisation(event, item)
}
if (item.type == 'effect') {
return this.addPerkEffect(event, item);
2021-12-19 15:35:54 +01:00
}
}
2022-02-16 17:43:51 +01:00
if (this.object.type == 'specialisation') {
2022-09-04 09:58:51 +02:00
if (item.type == 'power') {
return this.addPower(event, item);
2021-12-16 21:41:09 +01:00
}
}
2022-09-04 09:58:51 +02:00
2022-02-16 17:43:51 +01:00
if (this.object.type == 'ability') {
2022-09-04 09:58:51 +02:00
if (item.type == 'effect') {
return this.addAbilityEffect(event, item);
}
if (item.type == 'power') {
return this.addAbilityPower(event, item);
}
if (item.type == 'specialisation') {
return this.addAbilitySpec(event, item);
}
if (item.type == 'weapon' || item.type == 'armor') {
return this.addAbilityWeaponArmor(event, item);
2021-12-16 21:41:09 +01:00
}
}
2022-02-16 17:43:51 +01:00
if (this.object.type == 'role') {
2022-09-04 09:58:51 +02:00
if (item.type == 'specialisation') {
return this.addRoleSpecialisation(event, item)
}
if (item.type == 'perk') {
return this.addRolePerk(event, item)
}
if (item.type == 'ability') {
return this.addRoleAbility(event, item)
2021-12-08 13:53:22 +01:00
}
}
2022-03-16 11:12:14 +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);
}
}