From 399c22d6238f3cef62700ef71c94017c7ff7bf57 Mon Sep 17 00:00:00 2001 From: sladecraven Date: Fri, 2 Dec 2022 13:15:48 +0100 Subject: [PATCH] Init again !!!! --- module/actor/actor.js | 10 ++++++---- module/controllers/bol-rolls.js | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/module/actor/actor.js b/module/actor/actor.js index 79b4da5..464dcf4 100644 --- a/module/actor/actor.js +++ b/module/actor/actor.js @@ -648,14 +648,16 @@ export class BoLActor extends Actor { } /*-------------------------------------------- */ - registerInit(rollData) { + async registerInit(rollData) { rollData.actor = undefined // Cleanup if present - this.setFlag("world", "last-initiative", rollData) + await this.setFlag("world", "last-initiative", rollData) } /*-------------------------------------------- */ - getInitiativeRank() { - let rollData = this.getFlag("world", "last-initiative") + getInitiativeRank(rollData = undefined) { + if (!rollData) { + rollData = this.getFlag("world", "last-initiative") + } let fvttInit = 4 // Pietaille par defaut if (this.type == 'character' ) { fvttInit = 5 diff --git a/module/controllers/bol-rolls.js b/module/controllers/bol-rolls.js index 9e4e00e..b026c31 100644 --- a/module/controllers/bol-rolls.js +++ b/module/controllers/bol-rolls.js @@ -548,7 +548,7 @@ export class BoLDefaultRoll { async roll() { const r = new Roll(this.rollData.formula) - // console.log("Roll formula", this.rollData.formula) + //console.log("Roll formula", this.rollData.formula) await r.roll({ "async": false }) const activeDice = r.terms[0].results.filter(r => r.active) const diceTotal = activeDice.map(r => r.result).reduce((a, b) => a + b) @@ -571,7 +571,7 @@ export class BoLDefaultRoll { if (this.rollData.registerInit) { actor.registerInit(this.rollData) - this.rollData.initiativeRank = actor.getInitiativeRank() + this.rollData.initiativeRank = actor.getInitiativeRank(this.rollData) } if (this.rollData.isSuccess && this.rollData.mode == "spell") { // PP cost management this.rollData.remainingPP = actor.spendPowerPoint(this.rollData.ppCost + this.rollData.ppCostArmor)