Add ability to role
This commit is contained in:
@@ -1036,13 +1036,12 @@ export class PegasusActor extends Actor {
|
||||
let updates = { 'data.biodata.rolename': role.name }
|
||||
let newItems = []
|
||||
await this.deleteAllItemsByType('role')
|
||||
newItems.push(role);
|
||||
newItems.push(role)
|
||||
|
||||
this.getIncreaseStatValue(updates, role.data.statincrease1)
|
||||
this.getIncreaseStatValue(updates, role.data.statincrease2)
|
||||
|
||||
//newItems = newItems.concat(duplicate(role.data.specialisationsplus1))
|
||||
newItems = newItems.concat(duplicate(role.data.specialperk))
|
||||
newItems = newItems.concat( duplicate(role.data.specialability) ) // Add new ability
|
||||
|
||||
await this.update(updates)
|
||||
await this.createEmbeddedDocuments('Item', newItems)
|
||||
|
@@ -253,7 +253,6 @@ export class PegasusItemSheet extends ItemSheet {
|
||||
async addRolePerk(event, item, dataItem) {
|
||||
let newItem = duplicate(item.data);
|
||||
newItem._id = randomID(dataItem.id.length);
|
||||
console.log("Add spec", event, newItem);
|
||||
if (event.toElement.className == 'drop-perk2') {
|
||||
let perkArray = duplicate(this.object.data.data.perks);
|
||||
perkArray.push(newItem);
|
||||
@@ -265,6 +264,16 @@ export class PegasusItemSheet extends ItemSheet {
|
||||
await this.object.update({ 'data.specialperk': perkArray });
|
||||
}
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
async addRoleAbility(event, item, dataItem) {
|
||||
let newItem = duplicate(item.data)
|
||||
newItem._id = randomID(dataItem.id.length)
|
||||
if (event.toElement.className == 'drop-specialability') {
|
||||
let abiArray = duplicate(this.object.data.data.specialability)
|
||||
abiArray.push(newItem)
|
||||
await this.object.update({ 'data.specialability': abiArray })
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async addPower(event, item, dataItem) {
|
||||
@@ -479,20 +488,22 @@ export class PegasusItemSheet extends ItemSheet {
|
||||
}
|
||||
|
||||
if (this.object.type == 'role') {
|
||||
let data = event.dataTransfer.getData('text/plain');
|
||||
let data = event.dataTransfer.getData('text/plain')
|
||||
if (data) {
|
||||
let dataItem = JSON.parse(data);
|
||||
let item = await PegasusUtility.searchItem(dataItem);
|
||||
let dataItem = JSON.parse(data)
|
||||
let item = await PegasusUtility.searchItem(dataItem)
|
||||
if (item.data.type == 'specialisation') {
|
||||
return this.addRoleSpecialisation(event, item, dataItem);
|
||||
return this.addRoleSpecialisation(event, item, dataItem)
|
||||
}
|
||||
if (item.data.type == 'perk') {
|
||||
return this.addRolePerk(event, item, dataItem);
|
||||
return this.addRolePerk(event, item, dataItem)
|
||||
}
|
||||
if (item.data.type == 'ability') {
|
||||
return this.addRoleAbility(event, item, dataItem)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ui.notifications.warn("This item can not be dropped over another item");
|
||||
ui.notifications.warn("This item can not be dropped over another item")
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
Reference in New Issue
Block a user