Combat tracker fixes

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

View File

@ -14,5 +14,11 @@
"TypeEquipment": "Equipment", "TypeEquipment": "Equipment",
"TypeCurrency": "Currency", "TypeCurrency": "Currency",
"TypeManeuver": "Maneuver" "TypeManeuver": "Maneuver"
},
"COMBAT": {
"TurnPrev": "Previous initiative",
"RoundPrev": "Previous segment",
"TurnNext": "Next initiative",
"RoundNext": "Next segment"
} }
} }

View File

@ -393,10 +393,11 @@ export class Hero6Actor extends Actor {
async holdAction() { async holdAction() {
if (this.getFlag("world", "hold-action")) { if (this.getFlag("world", "hold-action")) {
await this.setFlag("world", "hold-action", false) await this.setFlag("world", "hold-action", false)
return false
} else { } else {
await this.setFlag("world", "hold-action", true) await this.setFlag("world", "hold-action", true)
return true
} }
game.combat.rebuildInitiative()
} }
async disableHoldAction() { async disableHoldAction() {
await this.setFlag("world", "hold-action", false) await this.setFlag("world", "hold-action", false)
@ -408,10 +409,11 @@ export class Hero6Actor extends Actor {
let abort = this.getFlag("world", "abort-action") let abort = this.getFlag("world", "abort-action")
if (abort.state) { if (abort.state) {
await this.setFlag("world", "abort-action", { state: false, count: 0 }) await this.setFlag("world", "abort-action", { state: false, count: 0 })
game.combat.abortAction(this.id, false)
} else { } else {
await this.setFlag("world", "abort-action", { state: true, count: 0 }) await this.setFlag("world", "abort-action", { state: true, count: 0 })
game.combat.abortAction(this.id, true)
} }
game.combat.rebuildInitiative()
} }
getHoldAction() { getHoldAction() {
return this.getFlag("world", "hold-action") 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) 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) { if (updList.length > 0) {
await this.updateEmbeddedDocuments("Combatant", updList); await this.updateEmbeddedDocuments("Combatant", updList);
console.log("Rebuild INIT", updList) console.log("Rebuild INIT", updList)
for(let c of updList) { for (let c of updList) {
if ( c.initiative != 0) { if (c.initiative != 0) {
return true return true
} }
} }
@ -137,7 +151,7 @@ export class Hero6Combat extends Combat {
let advanceTime = 0 let advanceTime = 0
let turn = this.turn === null ? null : 0; // Preserve the fact that it's no-one's turn currently. 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") let turnData = this.getFlag("world", "hero6-turn-data")
console.log("Next round called....", nextRound, turnData) console.log("Next round called....", nextRound, turnData)
while (!hasCombatants) { while (!hasCombatants) {
turn = turn; // Preserve the fact that it's no-one's turn currently. turn = turn; // Preserve the fact that it's no-one's turn currently.

View File

@ -91,7 +91,7 @@
"styles": [ "styles": [
"styles/simple.css" "styles/simple.css"
], ],
"version": "10.0.45", "version": "10.0.46",
"compatibility": { "compatibility": {
"minimum": "10", "minimum": "10",
"verified": "10", "verified": "10",
@ -99,8 +99,8 @@
}, },
"title": "Hero System v6 for FoundrtVTT (Official)", "title": "Hero System v6 for FoundrtVTT (Official)",
"manifest": "https://www.uberwald.me/gitea/uberwald/fvtt-hero-system-6/raw/branch/main/system.json", "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/", "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" "id": "fvtt-hero-system-6"
} }