Combat Tracker + power enhancements

This commit is contained in:
2023-04-06 20:15:04 +02:00
parent 5b91041a3f
commit 41fbc094bb
7 changed files with 132 additions and 36 deletions

View File

@ -25,7 +25,7 @@ export class BoLCombatManager extends Combat {
// calculate initiative
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 })
fvttInit += (cId / 100)
await this.updateEmbeddedDocuments("Combatant", [{ _id: ids[cId], initiative: fvttInit }]);
}
@ -34,9 +34,18 @@ export class BoLCombatManager extends Combat {
/************************************************************************************/
nextRound() {
let combatants = this.combatants.contents
let autoRemoveDead = game.settings.get("bol", "auto-remove-dead") // Optionnal auto-removal of dead char.
for (let c of combatants) {
let actor = game.actors.get( c.actorId )
actor.clearRoundModifiers()
//let actor = game.actors.get(c.actorId)
c.actor.clearRoundModifiers()
let toRemove = []
if (autoRemoveDead && c.actor.type == "encounter" && (c.actor.system.chartype == "tough" || c.actor.system.chartype == "creature" || c.actor.system.chartype == "base") && c.actor.system.resources.hp.value <= 0) {
toRemove.push( c.id || c._id)
}
//console.log("REM", autoRemoveDead, toRemove, c.actor)
if (toRemove.length>0) {
this.deleteEmbeddedDocuments('Combatant', toRemove)
}
}
super.nextRound()
}
@ -45,12 +54,12 @@ export class BoLCombatManager extends Combat {
startCombat() {
let combatants = this.combatants.contents
for (let c of combatants) {
let actor = game.actors.get( c.actorId )
let actor = game.actors.get(c.actorId)
actor.storeVitaliteCombat()
}
return super.startCombat()
}
/************************************************************************************/
_onDelete() {
let combatants = this.combatants.contents
@ -63,4 +72,4 @@ export class BoLCombatManager extends Combat {
}
}