Race/Roles
This commit is contained in:
@@ -200,13 +200,21 @@ export class PegasusItemSheet extends ItemSheet {
|
||||
async searchItem( dataItem) {
|
||||
let item;
|
||||
if (dataItem.pack) {
|
||||
item = await fromUuid(dataItem.id);
|
||||
item = await fromUuid("Compendium."+dataItem.pack+"."+dataItem.id);
|
||||
} else {
|
||||
item = game.items.get(dataItem.id )
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async addAbility(item, dataItem) {
|
||||
let abilityArray = duplicate(this.object.data.data.abilities);
|
||||
let newItem = duplicate(item.data);
|
||||
newItem._id = randomID( dataItem.id.length );
|
||||
abilityArray.push( newItem);
|
||||
await this.object.update( { 'data.abilities': abilityArray} );
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async addSpecialisation(item, dataItem) {
|
||||
let newItem = duplicate(item.data);
|
||||
@@ -241,12 +249,28 @@ export class PegasusItemSheet extends ItemSheet {
|
||||
let perkArray = duplicate(this.object.data.data.perks);
|
||||
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} );
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async _onDrop(event) {
|
||||
console.log(event);
|
||||
//console.log(event);
|
||||
if (this.object.type == 'race' ) {
|
||||
let data = event.dataTransfer.getData('text/plain');
|
||||
if (data) {
|
||||
let dataItem = JSON.parse( data );
|
||||
let item = await this.searchItem( dataItem);
|
||||
if ( item.data.type == 'ability') {
|
||||
return this.addAbility( item, dataItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.object.type == 'perk' || this.object.type == 'ability') {
|
||||
let data = event.dataTransfer.getData('text/plain');
|
||||
if (data) {
|
||||
|
Reference in New Issue
Block a user