From 04afb7a424577dbb59f74fffe4e853fc2c3efd0f Mon Sep 17 00:00:00 2001 From: sladecraven Date: Wed, 16 Feb 2022 17:43:51 +0100 Subject: [PATCH] Allow items --- modules/pegasus-actor-sheet.js | 13 +- modules/pegasus-actor.js | 38 ++- modules/pegasus-item-sheet.js | 395 ++++++++++++----------- modules/pegasus-utility.js | 3 +- styles/simple.css | 1 + system.json | 4 +- template.json | 8 + templates/actor-sheet.html | 45 +++ templates/chat-perk-ready.html | 7 + templates/item-ability-sheet.html | 4 +- templates/item-armor-sheet.html | 2 + templates/item-equipment-sheet.html | 1 + templates/item-shield-sheet.html | 3 + templates/item-weapon-sheet.html | 2 + templates/partial-equipment-effects.html | 16 + 15 files changed, 348 insertions(+), 194 deletions(-) create mode 100644 templates/chat-perk-ready.html create mode 100644 templates/partial-equipment-effects.html diff --git a/modules/pegasus-actor-sheet.js b/modules/pegasus-actor-sheet.js index 27ba189..a386cc3 100644 --- a/modules/pegasus-actor-sheet.js +++ b/modules/pegasus-actor-sheet.js @@ -115,7 +115,18 @@ export class PegasusActorSheet extends ActorSheet { let itemId = li.data("item-id"); this.actor.specPowerDeactivate( itemId) }); - + + html.find('.equip-activate').click(ev => { + const li = $(ev.currentTarget).parents(".item") + let itemId = li.data("item-id") + this.actor.equipActivate( itemId) + }); + html.find('.equip-deactivate').click(ev => { + const li = $(ev.currentTarget).parents(".item") + let itemId = li.data("item-id") + this.actor.equipDeactivate( itemId) + }); + html.find('.effect-used').click(ev => { const li = $(ev.currentTarget).parents(".item"); let itemId = li.data("item-id"); diff --git a/modules/pegasus-actor.js b/modules/pegasus-actor.js index 92ce6ca..da4b46a 100644 --- a/modules/pegasus-actor.js +++ b/modules/pegasus-actor.js @@ -435,6 +435,36 @@ export class PegasusActor extends Actor { this.updateEmbeddedDocuments('Item', [{ _id: specId, 'data.powersactivated': false }]) } + /* -------------------------------------------- */ + equipActivate(itemId) { + let item = this.items.get(itemId) + if (item) { + let effects = [] + for (let effect of item.data.data.effects) { + effect.data.itemId = itemId // Keep link + effects.push(effect) + } + if (effects.length > 0) { + this.createEmbeddedDocuments('Item', effects ) + } + this.updateEmbeddedDocuments('Item', [{ _id: itemId, 'data.activated': true }]) + } + } + + /* -------------------------------------------- */ + equipDeactivate(itemId) { + let toRem = [] + for (let item of this.data.items) { + if (item.data.data.itemId && item.data.data.itemId == itemId) { + toRem.push(item.id) + } + } + if (toRem.length > 0) { + this.deleteEmbeddedDocuments('Item', toRem) + } + this.updateEmbeddedDocuments('Item', [{ _id: itemId, 'data.activated': false }]) + } + /* -------------------------------------------- */ async perkEffectUsed(itemId) { let effect = this.items.get(itemId) @@ -547,6 +577,10 @@ export class PegasusActor extends Actor { await this.update({ 'data.nrg': nrg }) } this.disableWeaverPerk(item) + PegasusUtility.createChatWithRollMode(item.name, { + content: await renderTemplate(`systems/fvtt-pegasus-rpg/templates/chat-perk-ready.html`, { name: this.name, perk: item }) + }); + } if (status == "activated") { // Add effects linked to the perk @@ -875,10 +909,10 @@ export class PegasusActor extends Actor { && (effect.data.stataffected != "notapplicable" || effect.data.specaffected.length > 0) && effect.data.stataffected != "special") { if (effect.data.effectstatlevel) { - if ( effect.data.effectstat == rollData.statKey ) { + if (effect.data.effectstat == rollData.statKey) { effect.data.effectlevel = rollData.statDicesLevel } - if ( effect.data.stataffected == "all") { // Real nightmare + if (effect.data.stataffected == "all") { // Real nightmare effect.data.effectlevel = this.data.data.statistics[effect.data.effectstat].value } } diff --git a/modules/pegasus-item-sheet.js b/modules/pegasus-item-sheet.js index 50e5c5f..eb88917 100644 --- a/modules/pegasus-item-sheet.js +++ b/modules/pegasus-item-sheet.js @@ -7,16 +7,16 @@ import { PegasusUtility } from "./pegasus-utility.js"; export class PegasusItemSheet extends ItemSheet { /** @override */ - static get defaultOptions() { + static get defaultOptions() { return mergeObject(super.defaultOptions, { - classes: ["fvtt-pegasus-rpg", "sheet", "item"], - template: "systems/fvtt-pegasus-rpg/templates/item-sheet.html", - dragDrop: [{dragSelector: null, dropSelector: null}], - width: 620, - height: 550 + classes: ["fvtt-pegasus-rpg", "sheet", "item"], + template: "systems/fvtt-pegasus-rpg/templates/item-sheet.html", + dragDrop: [{ dragSelector: null, dropSelector: null }], + width: 620, + height: 550 //tabs: [{navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "description"}] - }); + }); } /* -------------------------------------------- */ @@ -28,28 +28,28 @@ export class PegasusItemSheet extends ItemSheet { { class: "post", icon: "fas fa-comment", - onclick: ev => {} + onclick: ev => { } }) return buttons } /* -------------------------------------------- */ /** @override */ - setPosition(options={}) { + setPosition(options = {}) { const position = super.setPosition(options); const sheetBody = this.element.find(".sheet-body"); const bodyHeight = position.height - 192; sheetBody.css("height", bodyHeight); - if ( this.item.type.includes('weapon')) { + if (this.item.type.includes('weapon')) { position.width = 640; } return position; } - + /* -------------------------------------------- */ async getData() { const objectData = PegasusUtility.data(this.object); - + let itemData = foundry.utils.deepClone(PegasusUtility.templateData(this.object)); let formData = { title: this.title, @@ -61,14 +61,14 @@ export class PegasusItemSheet extends ItemSheet { cssClass: this.isEditable ? "editable" : "locked", optionsDiceList: PegasusUtility.getOptionsDiceList(), optionsStatusList: PegasusUtility.getOptionsStatusList(), - data: itemData, + data: itemData, limited: this.object.limited, options: this.options, owner: this.document.isOwner, mr: (this.object.type == 'specialisation'), - isGM: game.user.isGM + isGM: game.user.isGM } - + this.options.editable = !(this.object.data.origin == "embeddedItem"); console.log("ITEM DATA", formData, this); return formData; @@ -85,7 +85,7 @@ export class PegasusItemSheet extends ItemSheet { }); return buttons } - + /* -------------------------------------------- */ postItem() { let chatData = duplicate(PegasusUtility.data(this.item)); @@ -114,8 +114,8 @@ export class PegasusItemSheet extends ItemSheet { let field = $(ev.currentTarget).data('type'); let idx = Number($(ev.currentTarget).data('index')); let itemData = this.object.data.data[field][idx]; - if ( itemData.name != 'None') { - let spec = await Item.create(itemData, {temporary: true}); + if (itemData.name != 'None') { + let spec = await Item.create(itemData, { temporary: true }); spec.data.origin = "embeddedItem"; new PegasusItemSheet(spec).render(true); } @@ -127,22 +127,22 @@ export class PegasusItemSheet extends ItemSheet { let idx = Number($(ev.currentTarget).data('index')); let oldArray = this.object.data.data[field]; let itemData = this.object.data.data[field][idx]; - if ( itemData.name != 'None') { + if (itemData.name != 'None') { let newArray = []; - for( var i = 0; i < oldArray.length; i++) { - if ( i != idx) { - newArray.push( oldArray[i]); + for (var i = 0; i < oldArray.length; i++) { + if (i != idx) { + newArray.push(oldArray[i]); } } - this.object.update( { [`data.${field}`]: newArray} ); + this.object.update({ [`data.${field}`]: newArray }); } } - + /* -------------------------------------------- */ - async manageSpec( ) { + async manageSpec() { let itemData = this.object.data.data.specialisation[0]; - if ( itemData.name != 'None') { - let spec = await Item.create(itemData, {temporary: true}); + if (itemData.name != 'None') { + let spec = await Item.create(itemData, { temporary: true }); spec.data.origin = "embeddedItem"; new PegasusItemSheet(spec).render(true); } @@ -150,12 +150,12 @@ export class PegasusItemSheet extends ItemSheet { /* -------------------------------------------- */ /** @override */ - activateListeners(html) { + activateListeners(html) { super.activateListeners(html); // Everything below here is only needed if the sheet is editable if (!this.options.editable) return; - + // Update Inventory Item html.find('.item-edit').click(ev => { @@ -163,20 +163,20 @@ export class PegasusItemSheet extends ItemSheet { const item = this.object.options.actor.getOwnedItem(li.data("item-id")); item.sheet.render(true); }); - - html.find('.delete-spec').click( ev => { - this.object.update( {"data.specialisation": [ { name: 'None'} ]} ); + + html.find('.delete-spec').click(ev => { + this.object.update({ "data.specialisation": [{ name: 'None' }] }); }); - html.find('.delete-subitem').click( ev => { - this.deleteSubitem( ev ); + html.find('.delete-subitem').click(ev => { + this.deleteSubitem(ev); }); - html.find('.stat-choice-flag').click( ev => { + html.find('.stat-choice-flag').click(ev => { let idx = $(ev.currentTarget).data("stat-idx"); let array = duplicate(this.object.data.data.statincreasechoice); array[Number(idx)].flag = !array[Number(idx)].flag; - this.object.update( {"data.statincreasechoice": array} ); + this.object.update({ "data.statincreasechoice": array }); }); // Update Inventory Item @@ -187,11 +187,11 @@ export class PegasusItemSheet extends ItemSheet { }); html.find('.view-subitem').click(ev => { - this.viewSubitem( ev ); + this.viewSubitem(ev); }); - + html.find('.view-spec').click(ev => { - this.manageSpec( ); + this.manageSpec(); }); } @@ -199,280 +199,301 @@ export class PegasusItemSheet extends ItemSheet { /* -------------------------------------------- */ async addAbility(event, item, dataItem) { let newItem = duplicate(item.data); - newItem._id = randomID( dataItem.id.length ); + newItem._id = randomID(dataItem.id.length); console.log("ABB", event, item, dataItem) - if ( event.toElement.className == 'drop-abilities') { + if (event.toElement.className == 'drop-abilities') { let abilityArray = duplicate(this.object.data.data.abilities); - abilityArray.push( newItem); - await this.object.update( { 'data.abilities': abilityArray} ); + abilityArray.push(newItem); + await this.object.update({ 'data.abilities': abilityArray }); } - if ( event.toElement.className == 'drop-optionnal-abilities') { + if (event.toElement.className == 'drop-optionnal-abilities') { let abilityArray = duplicate(this.object.data.data.optionnalabilities); - abilityArray.push( newItem); - await this.object.update( { 'data.optionnalabilities': abilityArray} ); + abilityArray.push(newItem); + await this.object.update({ 'data.optionnalabilities': abilityArray }); } } /* -------------------------------------------- */ async addRacePerk(event, item, dataItem) { let newItem = duplicate(item.data); - newItem._id = randomID( dataItem.id.length ); - if ( event.toElement.className == 'drop-race-perk') { + newItem._id = randomID(dataItem.id.length); + if (event.toElement.className == 'drop-race-perk') { let perkArray = duplicate(this.object.data.data.perks); - perkArray.push( newItem); - await this.object.update( { 'data.perks': perkArray} ); + perkArray.push(newItem); + await this.object.update({ 'data.perks': perkArray }); } } - + /* -------------------------------------------- */ async addSpecialisation(item, dataItem) { let newItem = duplicate(item.data); - newItem._id = randomID( dataItem.id.length ); - let specArray = [ newItem ]; - await this.object.update( { 'data.specialisation': specArray} ); + newItem._id = randomID(dataItem.id.length); + let specArray = [newItem]; + await this.object.update({ 'data.specialisation': specArray }); } /* -------------------------------------------- */ async addRoleSpecialisation(event, item, dataItem) { let newItem = duplicate(item.data); - newItem._id = randomID( dataItem.id.length ); + newItem._id = randomID(dataItem.id.length); console.log("Add spec", event, newItem); - if ( event.toElement.className == 'drop-spec1') { + if (event.toElement.className == 'drop-spec1') { let specArray = duplicate(this.object.data.data.specialisationsplus1); - specArray.push( newItem ); - await this.object.update( { 'data.specialisationsplus1': specArray} ); + specArray.push(newItem); + await this.object.update({ 'data.specialisationsplus1': specArray }); } - if ( event.toElement.className == 'drop-spec2') { + if (event.toElement.className == 'drop-spec2') { let specArray = duplicate(this.object.data.data.specincrease); - specArray.push( newItem ); - await this.object.update( { 'data.specincrease': specArray} ); + specArray.push(newItem); + await this.object.update({ 'data.specincrease': specArray }); } } /* -------------------------------------------- */ async addRolePerk(event, item, dataItem) { let newItem = duplicate(item.data); - newItem._id = randomID( dataItem.id.length ); + newItem._id = randomID(dataItem.id.length); console.log("Add spec", event, newItem); - if ( event.toElement.className == 'drop-perk2') { + if (event.toElement.className == 'drop-perk2') { let perkArray = duplicate(this.object.data.data.perks); - perkArray.push( newItem ); - await this.object.update( { 'data.perks': perkArray} ); - } - if ( event.toElement.className == 'drop-specialperk1') { + perkArray.push(newItem); + await this.object.update({ 'data.perks': perkArray }); + } + if (event.toElement.className == 'drop-specialperk1') { let perkArray = duplicate(this.object.data.data.specialperk); - perkArray.push( newItem ); - await this.object.update( { 'data.specialperk': perkArray} ); + perkArray.push(newItem); + await this.object.update({ 'data.specialperk': perkArray }); } } - + /* -------------------------------------------- */ - async addPower( event, item, dataItem) { + async addPower(event, item, dataItem) { let newItem = duplicate(item.data); - newItem._id = randomID( dataItem.id.length ); - if ( event.toElement.className == 'drop-spec-power') { + newItem._id = randomID(dataItem.id.length); + if (event.toElement.className == 'drop-spec-power') { let powArray = duplicate(this.object.data.data.powers); - powArray.push( newItem ); - await this.object.update( { 'data.powers': powArray} ); - } + powArray.push(newItem); + await this.object.update({ 'data.powers': powArray }); + } } /* -------------------------------------------- */ - async addAbilityPower( event, item, dataItem) { + async addAbilityPower(event, item, dataItem) { let newItem = duplicate(item.data); - newItem._id = randomID( dataItem.id.length ); - if ( event.toElement.className == 'drop-ability-power') { + newItem._id = randomID(dataItem.id.length); + if (event.toElement.className == 'drop-ability-power') { let powArray = duplicate(this.object.data.data.powersgained); - powArray.push( newItem ); - await this.object.update( { 'data.powersgained': powArray} ); - } + powArray.push(newItem); + await this.object.update({ 'data.powersgained': powArray }); + } } /* -------------------------------------------- */ - async addAbilityEffect( event, item, dataItem) { + async addAbilityEffect(event, item, dataItem) { let newItem = duplicate(item.data); - newItem._id = randomID( dataItem.id.length ); - if ( event.toElement.className == 'drop-ability-effect') { + newItem._id = randomID(dataItem.id.length); + if (event.toElement.className == 'drop-ability-effect') { let powArray = duplicate(this.object.data.data.effectsgained); - powArray.push( newItem ); - await this.object.update( { 'data.effectsgained': powArray} ); - } + powArray.push(newItem); + await this.object.update({ 'data.effectsgained': powArray }); + } } /* -------------------------------------------- */ - async addAbilitySpec( event, item, dataItem) { + async addAbilitySpec(event, item, dataItem) { let newItem = duplicate(item.data); - newItem._id = randomID( dataItem.id.length ); - if ( event.toElement.className == 'drop-ability-spec') { + newItem._id = randomID(dataItem.id.length); + if (event.toElement.className == 'drop-ability-spec') { let powArray = duplicate(this.object.data.data.specialisations); - powArray.push( newItem ); - await this.object.update( { 'data.specialisations': powArray} ); - } + powArray.push(newItem); + await this.object.update({ 'data.specialisations': powArray }); + } } /* -------------------------------------------- */ - async addAbilityWeaponArmor( event, item, dataItem) { + async addAbilityWeaponArmor(event, item, dataItem) { let newItem = duplicate(item.data); - newItem._id = randomID( dataItem.id.length ); - if ( event.toElement.className == 'drop-ability-weapon') { + newItem._id = randomID(dataItem.id.length); + if (event.toElement.className == 'drop-ability-weapon') { let weaponArray = duplicate(this.object.data.data.attackgained); - weaponArray.push( newItem ); - await this.object.update( { 'data.attackgained': weaponArray} ); - } - if ( event.toElement.className == 'drop-ability-armor') { + weaponArray.push(newItem); + await this.object.update({ 'data.attackgained': weaponArray }); + } + if (event.toElement.className == 'drop-ability-armor') { let armorArray = duplicate(this.object.data.data.armorgained); - armorArray.push( newItem ); - await this.object.update( { 'data.armorgained': armorArray} ); - } + armorArray.push(newItem); + await this.object.update({ 'data.armorgained': armorArray }); + } } - + /* -------------------------------------------- */ - async addPerkSpecialisation( event, item, dataItem) { + async addPerkSpecialisation(event, item, dataItem) { let newItem = duplicate(item.data); - if ( event.toElement.className == 'drop-spec-perk') { + if (event.toElement.className == 'drop-spec-perk') { //console.log("PER SPEC", event) let key = event.toElement.dataset["key"]; - if ( key == 'affectedspec') { - await this.object.update( { 'data.features.affectedspec.value': newItem.name} ); + if (key == 'affectedspec') { + await this.object.update({ 'data.features.affectedspec.value': newItem.name }); } else { - await this.object.update( { 'data.features.gainspecdice.value': newItem.name} ); + await this.object.update({ 'data.features.gainspecdice.value': newItem.name }); } } } /* -------------------------------------------- */ - async addPerkEffect( event, item, dataItem) { + async addPerkEffect(event, item, dataItem) { let newItem = duplicate(item.data) - if ( event.toElement.className == 'drop-perk-effect') { + if (event.toElement.className == 'drop-perk-effect') { let effectArray = duplicate(this.object.data.data.effectsgained) - effectArray.push( newItem ) - await this.object.update( { 'data.effectsgained': effectArray} ) - } - } - - /* -------------------------------------------- */ - async addEffectPower( event, item, dataItem) { - let newItem = duplicate(item.data) - if ( event.toElement.className == 'drop-power-effect') { - let effectArray = duplicate(this.object.data.data.effectsgained) - effectArray.push( newItem ); - await this.object.update( { 'data.effectsgained': effectArray} ) + effectArray.push(newItem) + await this.object.update({ 'data.effectsgained': effectArray }) } } /* -------------------------------------------- */ - async addEffectSpec( event, item, dataItem) { - let newItem = duplicate(item.data); - if ( event.toElement.className == 'drop-effect-spec') { - let specArray = duplicate(this.object.data.data.recoveryrollspec); - specArray.push( newItem ); - await this.object.update( { 'data.recoveryrollspec': specArray} ); - } - if ( event.toElement.className =='drop-effect-specaffected') { - let specArray = duplicate(this.object.data.data.specaffected); - specArray.push( newItem ); - await this.object.update( { 'data.specaffected': specArray} ); + async addEffectPower(event, item, dataItem) { + let newItem = duplicate(item.data) + if (event.toElement.className == 'drop-power-effect') { + let effectArray = duplicate(this.object.data.data.effectsgained) + effectArray.push(newItem); + await this.object.update({ 'data.effectsgained': effectArray }) } } - + + /* -------------------------------------------- */ + async addEffectSpec(event, item, dataItem) { + let newItem = duplicate(item.data); + if (event.toElement.className == 'drop-effect-spec') { + let specArray = duplicate(this.object.data.data.recoveryrollspec); + specArray.push(newItem); + await this.object.update({ 'data.recoveryrollspec': specArray }); + } + if (event.toElement.className == 'drop-effect-specaffected') { + let specArray = duplicate(this.object.data.data.specaffected); + specArray.push(newItem); + await this.object.update({ 'data.specaffected': specArray }); + } + } + + /* -------------------------------------------- */ + 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 }); + } + } + /* -------------------------------------------- */ async _onDrop(event) { - if (this.object.type == 'power' ) { + if (this.object.type == 'weapon' || this.object.type == 'shield' || this.object.type == 'armor' || this.object.type == 'shield') { let data = event.dataTransfer.getData('text/plain'); if (data) { - let dataItem = JSON.parse( data ); - let item = await PegasusUtility.searchItem( dataItem); - if ( item.data.type == 'effect') { - return this.addEffectPower( event, item, dataItem); + let dataItem = JSON.parse(data); + let item = await PegasusUtility.searchItem(dataItem); + if (item.data.type == 'effect') { + return this.addEffectItem(event, item, dataItem); } } } - if (this.object.type == 'effect' ) { + if (this.object.type == 'power') { let data = event.dataTransfer.getData('text/plain'); if (data) { - let dataItem = JSON.parse( data ); - let item = await PegasusUtility.searchItem( dataItem); - if ( item.data.type == 'specialisation') { - return this.addEffectSpec( event, item, dataItem); + let dataItem = JSON.parse(data); + let item = await PegasusUtility.searchItem(dataItem); + if (item.data.type == 'effect') { + return this.addEffectPower(event, item, dataItem); } } } - if (this.object.type == 'race' ) { + if (this.object.type == 'effect') { 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); + let dataItem = JSON.parse(data); + let item = await PegasusUtility.searchItem(dataItem); + if (item.data.type == 'specialisation') { + return this.addEffectSpec(event, item, dataItem); } } } - if (this.object.type == 'perk' ) { + 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); + } + } + } + + if (this.object.type == 'perk') { let data = event.dataTransfer.getData('text/plain') if (data) { - let dataItem = JSON.parse( data ); - let item = await PegasusUtility.searchItem( dataItem) - if ( item.data.type == 'specialisation') { - return this.addPerkSpecialisation( event, item, dataItem) + 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); } - if ( item.data.type == 'effect') { - return this.addPerkEffect( event, item, dataItem); - } } } - if (this.object.type == 'specialisation' ) { + if (this.object.type == 'specialisation') { let data = event.dataTransfer.getData('text/plain'); if (data) { - let dataItem = JSON.parse( data ); - let item = await PegasusUtility.searchItem( dataItem); - if ( item.data.type == 'power') { - return this.addPower( event, item, dataItem); + let dataItem = JSON.parse(data); + let item = await PegasusUtility.searchItem(dataItem); + if (item.data.type == 'power') { + return this.addPower(event, item, dataItem); } } } - if (this.object.type == 'ability' ) { + if (this.object.type == 'ability') { let data = event.dataTransfer.getData('text/plain'); if (data) { - let dataItem = JSON.parse( data ); - let item = await PegasusUtility.searchItem( dataItem); - if ( item.data.type == 'effect') { - return this.addAbilityEffect( event, item, dataItem); + let dataItem = JSON.parse(data); + let item = await PegasusUtility.searchItem(dataItem); + if (item.data.type == 'effect') { + return this.addAbilityEffect(event, item, dataItem); } - if ( item.data.type == 'power') { - return this.addAbilityPower( event, item, dataItem); + if (item.data.type == 'power') { + return this.addAbilityPower(event, item, dataItem); } - if ( item.data.type == 'specialisation') { - return this.addAbilitySpec( event, item, dataItem); + if (item.data.type == 'specialisation') { + return this.addAbilitySpec(event, item, dataItem); } - if ( item.data.type == 'weapon' || item.data.type == 'armor') { - return this.addAbilityWeaponArmor( event, item, dataItem); + if (item.data.type == 'weapon' || item.data.type == 'armor') { + return this.addAbilityWeaponArmor(event, item, dataItem); } } } - - if (this.object.type == 'role' ) { + + if (this.object.type == 'role') { let data = event.dataTransfer.getData('text/plain'); if (data) { - let dataItem = JSON.parse( data ); - let item = await PegasusUtility.searchItem( dataItem); - if ( item.data.type == 'specialisation') { - return this.addRoleSpecialisation( event, item, dataItem); + let dataItem = JSON.parse(data); + let item = await PegasusUtility.searchItem(dataItem); + if (item.data.type == 'specialisation') { + return this.addRoleSpecialisation(event, item, dataItem); } - if ( item.data.type == 'perk') { - return this.addRolePerk( event, item, dataItem); + if (item.data.type == 'perk') { + return this.addRolePerk(event, item, dataItem); } } } ui.notifications.warn("This item can not be dropped over another item"); } - + /* -------------------------------------------- */ get template() { let type = this.item.type; diff --git a/modules/pegasus-utility.js b/modules/pegasus-utility.js index dd0e4ba..b296835 100644 --- a/modules/pegasus-utility.js +++ b/modules/pegasus-utility.js @@ -187,7 +187,8 @@ export class PegasusUtility { 'systems/fvtt-pegasus-rpg/templates/partial-options-statistics.html', 'systems/fvtt-pegasus-rpg/templates/partial-options-level.html', 'systems/fvtt-pegasus-rpg/templates/partial-options-range.html', - 'systems/fvtt-pegasus-rpg/templates/partial-options-equipment-types.html' + 'systems/fvtt-pegasus-rpg/templates/partial-options-equipment-types.html', + 'systems/fvtt-pegasus-rpg/templates/partial-equipment-effects.html' ] return loadTemplates(templatePaths); } diff --git a/styles/simple.css b/styles/simple.css index 1a08b96..b427cd2 100644 --- a/styles/simple.css +++ b/styles/simple.css @@ -1164,6 +1164,7 @@ ul, li { padding-left: 2rem; } +.drop-equipment-effect, .drop-power-effect, .drop-perk-effect, .drop-ability-effect, diff --git a/system.json b/system.json index fbb9cd6..940d300 100644 --- a/system.json +++ b/system.json @@ -180,9 +180,9 @@ "styles": [ "styles/simple.css" ], - "templateVersion": 78, + "templateVersion": 80, "title": "Pegasus RPG", "url": "https://www.uberwald.me/data/files/fvtt-pegasus-rpg", - "version": "0.4.14", + "version": "0.4.16", "background" : "./images/ui/pegasus_welcome_page.webp" } diff --git a/template.json b/template.json index 35c56e7..154cccb 100644 --- a/template.json +++ b/template.json @@ -339,6 +339,8 @@ "idr": "", "equipped": false, "locationprotected": "", + "effects": [], + "activated": false, "description":"" }, "shield": { @@ -348,6 +350,8 @@ "cost": 0, "idr": "", "equipped": false, + "effects": [], + "activated": false, "description":"" }, "equipment": { @@ -362,6 +366,8 @@ "statdice": false, "bonusdice": false, "otherdice": false, + "effects": [], + "activated": false, "description":"" }, "money" : { @@ -390,6 +396,8 @@ "ammocurrent": 0, "ammomax": 0, "equipped": false, + "effects": [], + "activated": false, "description": "" } } diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index fad599b..7cd5af1 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -406,6 +406,18 @@ {{equip.name}} {{upperFirst equip.data.type}} + Qty {{equip.data.quantity}} + + {{#if (count equip.data.effects)}} + {{#if equip.data.activated}} + Deactivate + {{else}} + Activate + {{/if}} + {{else}} +   + {{/if}} + Qty {{equip.data.quantity}}
{{#if equip.data.equipped}} {{weapon.name}} + + {{#if (count weapon.data.effects)}} + {{#if weapon.data.activated}} + Deactivate + {{else}} + Activate + {{/if}} + {{else}} +   + {{/if}} +
{{#if weapon.data.equipped}}{{else}}{{/if}} @@ -445,6 +468,17 @@
  • {{armor.name}} + + {{#if (count armor.data.effects)}} + {{#if armor.data.activated}} + Deactivate + {{else}} + Activate + {{/if}} + {{else}} +   + {{/if}} +
  • {{shield.name}} + + {{#if (count shield.data.effects)}} + {{#if shield.data.activated}} + Deactivate + {{else}} + Activate + {{/if}} + {{else}} +   + {{/if}} +
    {{#if shield.data.equipped}}{{else}}{{/if}} diff --git a/templates/chat-perk-ready.html b/templates/chat-perk-ready.html new file mode 100644 index 0000000..8925b2a --- /dev/null +++ b/templates/chat-perk-ready.html @@ -0,0 +1,7 @@ +
    +

    {{name}}

    + {{#if img}} + + {{/if}} +
    {{name}} has Just Deactivated the Perk: {{perk.name}}, make sure to manually delete all Effects provided by this Perk from Targets.
    +
    diff --git a/templates/item-ability-sheet.html b/templates/item-ability-sheet.html index 7885d7c..b666729 100644 --- a/templates/item-ability-sheet.html +++ b/templates/item-ability-sheet.html @@ -83,6 +83,7 @@
  • + +
    • diff --git a/templates/item-armor-sheet.html b/templates/item-armor-sheet.html index cdd43bd..45e59f8 100644 --- a/templates/item-armor-sheet.html +++ b/templates/item-armor-sheet.html @@ -30,6 +30,8 @@ + {{> systems/fvtt-pegasus-rpg/templates/partial-equipment-effects.html}} +
    • diff --git a/templates/item-equipment-sheet.html b/templates/item-equipment-sheet.html index bb41315..033fefb 100644 --- a/templates/item-equipment-sheet.html +++ b/templates/item-equipment-sheet.html @@ -43,6 +43,7 @@ + {{> systems/fvtt-pegasus-rpg/templates/partial-equipment-effects.html}}
    • diff --git a/templates/item-shield-sheet.html b/templates/item-shield-sheet.html index 0c9f859..b976b14 100644 --- a/templates/item-shield-sheet.html +++ b/templates/item-shield-sheet.html @@ -26,6 +26,9 @@ {{/select}}
    • + + {{> systems/fvtt-pegasus-rpg/templates/partial-equipment-effects.html}} +
    • diff --git a/templates/item-weapon-sheet.html b/templates/item-weapon-sheet.html index 8e57cea..50824be 100644 --- a/templates/item-weapon-sheet.html +++ b/templates/item-weapon-sheet.html @@ -88,6 +88,8 @@ + {{> systems/fvtt-pegasus-rpg/templates/partial-equipment-effects.html}} +
    • diff --git a/templates/partial-equipment-effects.html b/templates/partial-equipment-effects.html new file mode 100644 index 0000000..1736d89 --- /dev/null +++ b/templates/partial-equipment-effects.html @@ -0,0 +1,16 @@ +
    • +
    • +
    • +
        +
      • +
      • + {{#each data.effects as |effect idx|}} +
      • + +
        + +
        +
      • + {{/each}} +
      +