Files
fvtt-hawkmoon-cyd/modules/hawkmoon-combat.js
LeRatierBretonnien 71b384c963
All checks were successful
Release Creation / build (release) Successful in 51s
Correction initiative et meilleur affichage sur jet D20
2026-03-10 20:50:43 +01:00

32 lines
1.0 KiB
JavaScript

import { HawkmoonUtility } from "./hawkmoon-utility.js";
/* -------------------------------------------- */
export class HawkmoonCombat extends Combat {
/* -------------------------------------------- */
async rollInitiative(ids, formula = undefined, messageOptions = {} ) {
ids = typeof ids === "string" ? [ids] : ids;
for (let cId of ids) {
const c = this.combatants.get(cId);
console.log("Init for combattant", c, ids)
let id = c._id || c.id
let initValue = 0
if (c.actor) {
const combat = c.actor.getCombatValues()
const roll = await new Roll(`1d10 + ${combat.initTotal}`).roll()
await HawkmoonUtility.showDiceSoNice(roll, game.settings.get("core", "rollMode"))
initValue = roll.total
await c.actor.setFlag("world", "last-initiative", initValue)
}
await this.updateEmbeddedDocuments("Combatant", [ { _id: id, initiative: initValue } ]);
}
return this;
}
/* -------------------------------------------- */
_onUpdate(changed, options, userId) {
}
}