diff --git a/module/actor-sheet.js b/module/actor-sheet.js index 22cb24a..ba0c757 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -98,47 +98,4 @@ export class BladesActorSheet extends ActorSheet { } /* -------------------------------------------- */ - - /** @override */ - async _onDrop (event) { - - event.preventDefault(); - - // Get dropped data - let data; - let item; - try { - data = JSON.parse(event.dataTransfer.getData('text/plain')); - } catch (err) { - return false; - } - - // Add only Items. - if (data.type === "Item") { - - // Import from Compendium - if (data.pack) { - const pack = game.packs.find(p => p.collection === data.pack); - await pack.getEntity(data.id).then(ent => { - item = ent; - }); - } - // Get from Items list. - else { - // Class must be distinct. - item = game.items.get(data.id); - } - - if (item) { - const actor = this.actor; - BladesHelpers.removeDuplicatedItemType(item.data.type, actor); - } - - // Call parent on drop logic - return super._onDrop(event); - } - - } - - /* -------------------------------------------- */ } diff --git a/module/blades.js b/module/blades.js index 082d3aa..c1213e1 100644 --- a/module/blades.js +++ b/module/blades.js @@ -94,10 +94,14 @@ Hooks.once("init", async function() { /* * Hooks */ -Hooks.on("createOwnedItem", (parent, child, options, userId) => { - BladesHelpers.callItemLogic(child, parent); +Hooks.on("preCreateOwnedItem", (parent_entity, child_data, options, userId) => { + BladesHelpers.removeDuplicatedItemType(child_data.type, parent_entity); }); -Hooks.on("deleteOwnedItem", (parent, child, options, userId) => { - BladesHelpers.undoItemLogic(child, parent); +Hooks.on("createOwnedItem", (parent_entity, child_data, options, userId) => { + BladesHelpers.callItemLogic(child_data, parent_entity); +}); + +Hooks.on("deleteOwnedItem", (parent_entity, child_data, options, userId) => { + BladesHelpers.undoItemLogic(child_data, parent_entity); }); diff --git a/module/crew-sheet.js b/module/crew-sheet.js index e8121f1..0739fd0 100644 --- a/module/crew-sheet.js +++ b/module/crew-sheet.js @@ -95,48 +95,4 @@ export class BladesCrewSheet extends ActorSheet { /* -------------------------------------------- */ - /** @override */ - async _onDrop (event) { - - event.preventDefault(); - - // Get dropped data - let data; - let item; - try { - data = JSON.parse(event.dataTransfer.getData('text/plain')); - } catch (err) { - return false; - } - - // Add only Items. - if (data.type === "Item") { - - // Import from Compendium - if (data.pack) { - const pack = game.packs.find(p => p.collection === data.pack); - await pack.getEntity(data.id).then(ent => { - item = ent; - }); - } - // Get from Items list. - else { - // Class must be distinct. - item = game.items.get(data.id); - } - - if (item) { - const actor = this.actor; - BladesHelpers.removeDuplicatedItemType(item.data.type, actor); - BladesHelpers.callItemLogic(item, actor); - } - - // Call parent on drop logic - return super._onDrop(event); - } - - } - - /* -------------------------------------------- */ - } diff --git a/packs/crew_upgrades.db b/packs/crew_upgrades.db index a69e4d6..4284598 100644 --- a/packs/crew_upgrades.db +++ b/packs/crew_upgrades.db @@ -1 +1 @@ -{"_id":"M7k3sdhua5qmJ93M","name":"Vault 1","permission":{"default":0,"BwbqQh8sHfeKmUax":3},"type":"crew_upgrade","data":{"description":"Adds the Vault providing additional 4 Coin space","logic":"{\"attribute\":\"data.vault.max\",\"operator\":\"addition\",\"value\":4,\"requirement\":\"\"}","crew_type":""},"folder":null,"sort":300000,"flags":{}} \ No newline at end of file +{"_id":"M7k3sdhua5qmJ93M","name":"Vault 1","permission":{"default":0,"BwbqQh8sHfeKmUax":3},"type":"crew_upgrade","data":{"description":"Adds the Vault providing additional 4 Coin space","logic":"{\"attribute\":\"data.vault.max\",\"operator\":\"addition\",\"value\":4,\"requirement\":\"\"}","crew_type":""},"folder":null,"sort":300000,"flags":{}}