diff --git a/modules/vadentis-combat.js b/modules/vadentis-combat.js index 681bdc6..b599d96 100644 --- a/modules/vadentis-combat.js +++ b/modules/vadentis-combat.js @@ -10,22 +10,24 @@ export class VadentisCombat extends Combat { ids = typeof ids === "string" ? [ids] : ids; const currentId = this.combatant._id; for (let cId = 0; cId < ids.length; cId++) { - const c = this.getCombatant(ids[cId]); + const c = this.combatants.get(ids[cId]); let initBonus = c.actor ? c.actor.getInitiativeScore() : 0; console.log("Init for ", initBonus); - const roll = super._getInitiativeRoll(c, "1d20+"+initBonus); - + const roll = c.getInitiativeRoll("1d20+"+initBonus); + if ( !roll.total) { + roll.evaluate( {async: false}); + } if (roll.total <= 0) roll.total = 0; - console.log("Compute init for", roll.total); - await this.updateEmbeddedEntity("Combatant", { _id: c._id, initiative: roll.total }); + let id = c._id || c.id; + await this.updateEmbeddedDocuments("Combatant", [ { _id: id, initiative: roll.total } ]); // Send a chat message let rollMode = messageOptions.rollMode || game.settings.get("core", "rollMode"); let messageData = mergeObject( { speaker: { - scene: canvas.scene._id, - actor: c.actor ? c.actor._id : null, + scene: canvas.scene.id, + actor: id, token: c.token._id, alias: c.token.name, sound: CONFIG.sounds.dice, diff --git a/system.json b/system.json index bb03ed8..e29999f 100644 --- a/system.json +++ b/system.json @@ -2,7 +2,7 @@ "name": "foundryvtt-vadentis", "title": "Vadentis", "description": "Système Vadentis pour FoundryVTT", - "version": "0.3.1", + "version": "0.3.2", "manifestPlusVersion": "1.0.0", "minimumCoreVersion": "0.8.9", "compatibleCoreVersion": "9",