diff --git a/modules/pegasus-actor-sheet.js b/modules/pegasus-actor-sheet.js index e5afece..e7b77e5 100644 --- a/modules/pegasus-actor-sheet.js +++ b/modules/pegasus-actor-sheet.js @@ -192,6 +192,12 @@ export class PegasusActorSheet extends ActorSheet { this.actor.equipItem( li.data("item-id") ); this.render(true); }); + html.find('.power-activate').click(ev => { + const li = $(ev.currentTarget).parents(".item"); + this.actor.activatePower( li.data("item-id") ); + this.render(true); + }); + html.find('.update-field').change(ev => { const fieldName = $(ev.currentTarget).data("field-name"); let value = ev.currentTarget.value; diff --git a/modules/pegasus-actor.js b/modules/pegasus-actor.js index adfb7fb..e5ce0f3 100644 --- a/modules/pegasus-actor.js +++ b/modules/pegasus-actor.js @@ -193,6 +193,15 @@ export class PegasusActor extends Actor { await this.updateEmbeddedDocuments('Item', [update]); // Updates one EmbeddedEntity } } + + /* -------------------------------------------- */ + async activatePower(itemId) { + let item = this.data.items.find(item => item.id == itemId); + if (item && item.data.data) { + let update = { _id: item.id, "data.activated": !item.data.data.activated }; + await this.updateEmbeddedDocuments('Item', [update]); // Updates one EmbeddedEntity + } + } /* -------------------------------------------- */ async equipItem(itemId) { diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index e8b4dee..e368f32 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -312,6 +312,8 @@ {{#if power.data.activated}}Activated{{/if}}
+ {{#if power.data.activated}}{{else}}{{/if}}