diff --git a/modules/pegasus-item-sheet.js b/modules/pegasus-item-sheet.js index 6205d9a..727af97 100644 --- a/modules/pegasus-item-sheet.js +++ b/modules/pegasus-item-sheet.js @@ -256,7 +256,39 @@ export class PegasusItemSheet extends ItemSheet { await this.object.update( { 'data.specialperk': perkArray} ); } } - + + /* -------------------------------------------- */ + async addPower( event, item, dataItem) { + let newItem = duplicate(item.data); + 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} ); + } + } + + /* -------------------------------------------- */ + async addAbilityPower( event, item, dataItem) { + let newItem = duplicate(item.data); + 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} ); + } + } + /* -------------------------------------------- */ + async addAbilitySpec( event, item, dataItem) { + let newItem = duplicate(item.data); + 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} ); + } + } + /* -------------------------------------------- */ async _onDrop(event) { //console.log(event); @@ -270,6 +302,29 @@ export class PegasusItemSheet extends ItemSheet { } } } + if (this.object.type == 'specialisation' ) { + let data = event.dataTransfer.getData('text/plain'); + if (data) { + let dataItem = JSON.parse( data ); + let item = await this.searchItem( dataItem); + if ( item.data.type == 'power') { + return this.addPower( event, item, dataItem); + } + } + } + if (this.object.type == 'ability' ) { + let data = event.dataTransfer.getData('text/plain'); + if (data) { + let dataItem = JSON.parse( data ); + let item = await this.searchItem( dataItem); + if ( item.data.type == 'power') { + return this.addAbilityPower( event, item, dataItem); + } + if ( item.data.type == 'specialisation') { + return this.addAbilitySpec( event, item, dataItem); + } + } + } if (this.object.type == 'perk' || this.object.type == 'ability') { let data = event.dataTransfer.getData('text/plain'); diff --git a/styles/simple.css b/styles/simple.css index 2c8b0d3..fd21143 100644 --- a/styles/simple.css +++ b/styles/simple.css @@ -1147,6 +1147,9 @@ ul, li { padding-left: 2rem; } +.drop-ability-power, +.drop-ability-spec, +.drop-spec-power, .drop-abilities, .drop-specialperk1, .drop-perk2, diff --git a/system.json b/system.json index b7876aa..46af4cc 100644 --- a/system.json +++ b/system.json @@ -50,9 +50,9 @@ "styles": [ "styles/simple.css" ], - "templateVersion": 17, + "templateVersion": 18, "title": "Pegasus RPG", "url": "https://www.uberwald.me/data/files/fvtt-pegasus-rpg", - "version": "0.0.17", + "version": "0.0.18", "background" : "./images/ui/pegasus_welcome_page.webp" } \ No newline at end of file diff --git a/template.json b/template.json index 2db55aa..df90cf6 100644 --- a/template.json +++ b/template.json @@ -158,8 +158,8 @@ "otherdice": 0, "statusaffected": "", "statusmodifier": 0, - "powergained": 0, - "specialisation": [ {"name": "None"}], + "powersgained": [], + "specialisations": [], "aoe": "", "description": "" }, diff --git a/templates/item-ability-sheet.html b/templates/item-ability-sheet.html index 93d718a..92dca23 100644 --- a/templates/item-ability-sheet.html +++ b/templates/item-ability-sheet.html @@ -20,21 +20,25 @@