import { TeDeumUtility } from "../common/tedeum-utility.js"; /* -------------------------------------------- */ export class TeDeumCombat extends Combat { /* -------------------------------------------- */ async rollInitiative(ids, formula = undefined, messageOptions = {} ) { console.log("Roll INIT !") ids = typeof ids === "string" ? [ids] : ids; for (let cId of ids) { const c = this.combatants.get(cId); let initBonus = c.actor ? c.actor.getInitiativeScore( this.id, cId ) : -1; await this.updateEmbeddedDocuments("Combatant", [ { _id: cId, initiative: initBonus } ]); } return this; } /* -------------------------------------------- */ _onUpdate(changed, options, userId) { } /* -------------------------------------------- */ static async checkTurnPosition() { while (game.combat.turn > 0) { await game.combat.previousTurn() } } /* -------------------------------------------- */ _onDelete() { let combatants = this.combatants.contents for (let c of combatants) { let actor = game.actors.get(c.actorId) actor.clearInitiative() } super._onDelete() } }