From 55efa32739ee95aaafebcbbb941841b54362b88d Mon Sep 17 00:00:00 2001 From: sladecraven Date: Wed, 16 Mar 2022 15:08:34 +0100 Subject: [PATCH] Add ability to role --- modules/pegasus-actor.js | 11 +++++++++-- modules/pegasus-utility.js | 3 +++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/modules/pegasus-actor.js b/modules/pegasus-actor.js index 1eaab02..655b991 100644 --- a/modules/pegasus-actor.js +++ b/modules/pegasus-actor.js @@ -468,6 +468,8 @@ export class PegasusActor extends Actor { console.log("Pre-process !!!", item) if (item.data.type == 'race') { this.applyRace(item.data) + } else if (item.data.type == 'role') { + this.applyRole(item.data) } else if (item.data.type == 'ability') { this.applyAbility(item.data, [], true) if (!onDrop) { @@ -996,6 +998,7 @@ export class PegasusActor extends Actor { newItems.push(armor); } } + console.log("Ability : adding", newItems) await this.createEmbeddedDocuments('Item', newItems) } @@ -1041,10 +1044,14 @@ export class PegasusActor extends Actor { this.getIncreaseStatValue(updates, role.data.statincrease1) this.getIncreaseStatValue(updates, role.data.statincrease2) - newItems = newItems.concat( duplicate(role.data.specialability) ) // Add new ability - + if ( role.data.specialability.length > 0) { + console.log("Adding ability", role.data.specialability) + newItems = newItems.concat( duplicate(role.data.specialability) ) // Add new ability + this.applyAbility(role.data.specialability[0], newItems) + } await this.update(updates) await this.createEmbeddedDocuments('Item', newItems) + } diff --git a/modules/pegasus-utility.js b/modules/pegasus-utility.js index 15fe683..71087fb 100644 --- a/modules/pegasus-utility.js +++ b/modules/pegasus-utility.js @@ -279,6 +279,9 @@ export class PegasusUtility { /* -------------------------------------------- */ static getDiceValue(level = 0) { let diceString = this.diceList[level] + if ( !diceString) { + console.log("Level error", level) + } let diceTab = diceString.split(" ") let diceValue = 0 for (let dice of diceTab) {