Combat tracker fixes

This commit is contained in:
2023-07-07 15:35:24 +02:00
parent 3762e6185b
commit 6d6b7075df
4 changed files with 32 additions and 10 deletions

View File

@@ -393,10 +393,11 @@ export class Hero6Actor extends Actor {
async holdAction() {
if (this.getFlag("world", "hold-action")) {
await this.setFlag("world", "hold-action", false)
return false
} else {
await this.setFlag("world", "hold-action", true)
return true
}
game.combat.rebuildInitiative()
}
async disableHoldAction() {
await this.setFlag("world", "hold-action", false)
@@ -408,10 +409,11 @@ export class Hero6Actor extends Actor {
let abort = this.getFlag("world", "abort-action")
if (abort.state) {
await this.setFlag("world", "abort-action", { state: false, count: 0 })
game.combat.abortAction(this.id, false)
} else {
await this.setFlag("world", "abort-action", { state: true, count: 0 })
game.combat.abortAction(this.id, true)
}
game.combat.rebuildInitiative()
}
getHoldAction() {
return this.getFlag("world", "hold-action")

View File

@@ -40,9 +40,23 @@ export class Hero6Combat extends Combat {
}
/* -------------------------------------------- */
static holdAction(combatantId) {
static async holdAction(combatantId) {
const combatant = game.combat.combatants.get(combatantId)
combatant.actor.holdAction()
if (combatant.actor.holdAction()) {
let id = combatant._id || combatant.id
let name = combatant.actor.name + " (H)"
await game.combat.updateEmbeddedDocuments("Combatant", [{ _id: id, name: name, holdAction: true }]);
}
}
/* -------------------------------------------- */
static async abortAction(actorId, abortState) {
const combatant = game.combat.combatants.find(c => c.actor.id == actorId)
if (abortState) {
let id = combatant._id || combatant.id
let name = combatant.actor.name + " (A)"
await game.combat.updateEmbeddedDocuments("Combatant", [{ _id: id, name: name }]);
}
}
/* -------------------------------------------- */
@@ -121,8 +135,8 @@ export class Hero6Combat extends Combat {
if (updList.length > 0) {
await this.updateEmbeddedDocuments("Combatant", updList);
console.log("Rebuild INIT", updList)
for(let c of updList) {
if ( c.initiative != 0) {
for (let c of updList) {
if (c.initiative != 0) {
return true
}
}
@@ -137,7 +151,7 @@ export class Hero6Combat extends Combat {
let advanceTime = 0
let turn = this.turn === null ? null : 0; // Preserve the fact that it's no-one's turn currently.
let turnData = this.getFlag("world", "hero6-turn-data")
console.log("Next round called....", nextRound, turnData)
while (!hasCombatants) {
turn = turn; // Preserve the fact that it's no-one's turn currently.