Fix various issues
This commit is contained in:
@ -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');
|
||||
|
Reference in New Issue
Block a user