Race/Roles

This commit is contained in:
2021-12-09 18:40:50 +01:00
parent ed70c5848f
commit 71d61f1387
9 changed files with 199 additions and 29 deletions

View File

@@ -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) {