Update with minor fixes/updates

This commit is contained in:
2022-07-19 20:51:48 +02:00
parent 2ab1cbe24c
commit a2e0eb213f
11 changed files with 214 additions and 105 deletions

View File

@ -391,10 +391,65 @@ export class PegasusItemSheet extends ItemSheet {
await this.object.update({ 'data.effects': effectArray });
}
}
/* -------------------------------------------- */
async addEffectVirtueVice(event, item, dataItem) {
let newItem = duplicate(item.data);
if (event.toElement.className == 'drop-virtue-vice-effect') {
let effectArray = duplicate(this.object.data.data.effectsgained);
effectArray.push(newItem);
await this.object.update({ 'data.effectsgained': effectArray });
}
}
/* -------------------------------------------- */
async addViceToVirtue(event, item, dataItem) {
let newItem = duplicate(item.data);
if (event.toElement.className == 'drop-virtue-vice') {
let viceArray = duplicate(this.object.data.data.unavailablevice);
viceArray.push(newItem);
await this.object.update({ 'data.unavailablevice': viceArray });
}
}
/* -------------------------------------------- */
async addVirtueToVice(event, item, dataItem) {
let newItem = duplicate(item.data);
if (event.toElement.className == 'drop-vice-virtue') {
let virtueArray = duplicate(this.object.data.data.unavailablevirtue);
virtueArray.push(newItem);
await this.object.update({ 'data.unavailablevirtue': virtueArray });
}
}
/* -------------------------------------------- */
async _onDrop(event) {
if (this.object.type == 'virtue' ) {
let data = event.dataTransfer.getData('text/plain');
if (data) {
let dataItem = JSON.parse(data);
let item = await PegasusUtility.searchItem(dataItem);
if (item.data.type == 'effect') {
return this.addEffectVirtueVice(event, item, dataItem);
}
if (item.data.type == 'vice') {
return this.addViceToVirtue(event, item, dataItem);
}
}
}
if (this.object.type == 'vice' ) {
let data = event.dataTransfer.getData('text/plain');
if (data) {
let dataItem = JSON.parse(data);
let item = await PegasusUtility.searchItem(dataItem);
if (item.data.type == 'effect') {
return this.addEffectVirtueVice(event, item, dataItem);
}
if (item.data.type == 'virtue') {
return this.addVirtueToVice(event, item, dataItem);
}
}
}
if (this.object.type == 'weapon' || this.object.type == 'armor' || this.object.type == 'shield'
|| this.object.type == 'equipment') {
let data = event.dataTransfer.getData('text/plain');