From 6d6b7075dfe6dfd5b05fb1f67ca12c198ebb8858 Mon Sep 17 00:00:00 2001 From: LeRatierBretonnien Date: Fri, 7 Jul 2023 15:35:24 +0200 Subject: [PATCH] Combat tracker fixes --- lang/en.json | 6 ++++++ modules/hero6-actor.js | 6 ++++-- modules/hero6-combat.js | 24 +++++++++++++++++++----- system.json | 6 +++--- 4 files changed, 32 insertions(+), 10 deletions(-) diff --git a/lang/en.json b/lang/en.json index b6bfba9..dd3e162 100644 --- a/lang/en.json +++ b/lang/en.json @@ -14,5 +14,11 @@ "TypeEquipment": "Equipment", "TypeCurrency": "Currency", "TypeManeuver": "Maneuver" + }, + "COMBAT": { + "TurnPrev": "Previous initiative", + "RoundPrev": "Previous segment", + "TurnNext": "Next initiative", + "RoundNext": "Next segment" } } \ No newline at end of file diff --git a/modules/hero6-actor.js b/modules/hero6-actor.js index 2ec8d33..13ec176 100644 --- a/modules/hero6-actor.js +++ b/modules/hero6-actor.js @@ -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") diff --git a/modules/hero6-combat.js b/modules/hero6-combat.js index a2dca3a..9ba6613 100644 --- a/modules/hero6-combat.js +++ b/modules/hero6-combat.js @@ -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. diff --git a/system.json b/system.json index 3290da1..434b315 100644 --- a/system.json +++ b/system.json @@ -91,7 +91,7 @@ "styles": [ "styles/simple.css" ], - "version": "10.0.45", + "version": "10.0.46", "compatibility": { "minimum": "10", "verified": "10", @@ -99,8 +99,8 @@ }, "title": "Hero System v6 for FoundrtVTT (Official)", "manifest": "https://www.uberwald.me/gitea/uberwald/fvtt-hero-system-6/raw/branch/main/system.json", - "download": "https://www.uberwald.me/gitea/uberwald/fvtt-hero-system-6/archive/fvtt-hero-system-6-v10.0.45.zip", + "download": "https://www.uberwald.me/gitea/uberwald/fvtt-hero-system-6/archive/fvtt-hero-system-6-v10.0.46.zip", "url": "https://www.uberwald.me/gitea/uberwald/", - "background": "images/ui/hro6_welcome_page.webp", + "background": "images/ui/hero6_welcome_page.webp", "id": "fvtt-hero-system-6" } \ No newline at end of file