Review initiative

This commit is contained in:
2023-05-01 18:50:32 +02:00
parent 59ee6684ab
commit 268ac0a25a
8 changed files with 36 additions and 17 deletions

View File

@ -20,12 +20,15 @@ export class BoLCombatManager extends Combat {
console.log(`${game.system.title} | Combat.rollInitiative()`, ids, formula, messageOptions);
// Structure input data
ids = typeof ids === "string" ? [ids] : ids;
//const currentId = this.combatant.id;
// Get initiative malus from tough/adversary
let malusInit = 0
for (let combatant of this.combatants) {
malusInit = Math.max(malusInit, combatant.actor.getInitiativeMalus())
}
// calculate initiative
for (let cId = 0; cId < ids.length; cId++) {
for (let cId = 0; cId < ids.length; cId++) {
const combatant = this.combatants.get(ids[cId])
let fvttInit = combatant.actor.getInitiativeRank(false, true, { combatId: this.id, combatantId: combatant.id })
let fvttInit = combatant.actor.getInitiativeRank(false, true, { combatId: this.id, combatantId: combatant.id, malusInit })
fvttInit += (cId / 100)
await this.updateEmbeddedDocuments("Combatant", [{ _id: ids[cId], initiative: fvttInit }]);
}
@ -64,7 +67,7 @@ export class BoLCombatManager extends Combat {
return super.startCombat()
}
/************************************************************************************/
/*-***********************************************************************************/
_onDelete() {
if (game.user.isGM) {
let combatants = this.combatants.contents