fvtt-te-deum/modules/app/tedeum-combat.js

37 lines
1.0 KiB
JavaScript
Raw Normal View History

2023-12-11 21:41:51 +01:00
import { TeDeumUtility } from "../common/tedeum-utility.js";
2023-12-11 20:11:10 +01:00
/* -------------------------------------------- */
2023-12-11 21:41:51 +01:00
export class TeDeumCombat extends Combat {
2023-12-11 20:11:10 +01:00
/* -------------------------------------------- */
async rollInitiative(ids, formula = undefined, messageOptions = {} ) {
2025-02-25 21:29:52 +01:00
//console.log("Roll INIT !")
2023-12-11 20:11:10 +01:00
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 } ]);
2023-12-11 20:11:10 +01:00
}
return this;
}
/* -------------------------------------------- */
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()
}
}