Fixing and cleaning up

This commit is contained in:
WBHarry 2025-06-06 22:25:57 +02:00
parent 2cf68b7f17
commit ece1c7e6c1
8 changed files with 14 additions and 26 deletions

View file

@ -17,6 +17,3 @@ export { default as DhpAdversaryRoll } from './adversaryRoll.mjs';
export { default as DhpDamageRoll } from './damageRoll.mjs'; export { default as DhpDamageRoll } from './damageRoll.mjs';
export { default as DhpAbilityUse } from './abilityUse.mjs'; export { default as DhpAbilityUse } from './abilityUse.mjs';
export { default as DhpEnvironment } from './environment.mjs'; export { default as DhpEnvironment } from './environment.mjs';
export * as items from './item/_module.mjs';
export * as messages from './chat-message/_modules.mjs';

View file

@ -1,9 +1,6 @@
export default class DhCombat extends foundry.abstract.TypeDataModel { export default class DhCombat extends foundry.abstract.TypeDataModel {
static defineSchema() { static defineSchema() {
const fields = foundry.data.fields; const fields = foundry.data.fields;
return { return {};
actions: new fields.NumberField({ initial: 0, integer: true }),
started: new fields.BooleanField({ required: true, initial: false })
};
} }
} }

View file

@ -3,8 +3,7 @@ export default class DhCombatant extends foundry.abstract.TypeDataModel {
const fields = foundry.data.fields; const fields = foundry.data.fields;
return { return {
spotlight: new fields.SchemaField({ spotlight: new fields.SchemaField({
requesting: new fields.BooleanField({ required: true, initial: false }), requesting: new fields.BooleanField({ required: true, initial: false })
active: new fields.BooleanField({ required: true, initial: false })
}), }),
actionTokens: new fields.NumberField({ required: true, integer: true, initial: 3 }) actionTokens: new fields.NumberField({ required: true, integer: true, initial: 3 })
}; };

View file

@ -1,11 +1,7 @@
export default class DhpCombat extends Combat { export default class DhpCombat extends Combat {
get combatant() {
return this.combatants.contents.find(x => x.system.spotlight.active) ?? null;
}
async startCombat() { async startCombat() {
this._playCombatSound('startEncounter'); this._playCombatSound('startEncounter');
const updateData = { 'system.started': true }; const updateData = { round: 1, turn: null };
Hooks.callAll('combatStart', this, updateData); Hooks.callAll('combatStart', this, updateData);
await this.update(updateData); await this.update(updateData);
return this; return this;

View file

@ -71,16 +71,15 @@ export default class DhCombatTracker extends foundry.applications.sidebar.tabs.C
static async toggleSpotlight(_, target) { static async toggleSpotlight(_, target) {
const { combatantId } = target.closest('[data-combatant-id]')?.dataset ?? {}; const { combatantId } = target.closest('[data-combatant-id]')?.dataset ?? {};
for (var combatant of this.viewed.combatants) { const combatant = this.viewed.combatants.get(combatantId);
const giveSpotlight = combatant.id === combatantId;
await combatant.update({ const toggleTurn = this.viewed.combatants.contents
'system.spotlight': { .sort(this.viewed._sortCombatants)
requesting: giveSpotlight ? false : combatant.system.spotlight.requesting, .map(x => x.id)
active: giveSpotlight ? !combatant.system.spotlight.active : false .indexOf(combatantId);
}
}); await this.viewed.update({ turn: this.viewed.turn === toggleTurn ? null : toggleTurn });
} await combatant.update({ 'system.spotlight.requesting': false });
} }
static async setActionTokens(_, target) { static async setActionTokens(_, target) {

View file

@ -41,7 +41,7 @@
</div> </div>
{{/if}} {{/if}}
{{#if ../combat.system.started}} {{#if ../combat.round}}
<div class="token-actions"> <div class="token-actions">
{{#if isOwner}} {{#if isOwner}}
{{#if (and (not isNPC) ../actionTokens.enabled)}} {{#if (and (not isNPC) ../actionTokens.enabled)}}

View file

@ -1,7 +1,7 @@
<nav class="combat-controls" data-tooltip-direction="UP"> <nav class="combat-controls" data-tooltip-direction="UP">
{{~#if hasCombat~}} {{~#if hasCombat~}}
{{#if user.isGM}} {{#if user.isGM}}
{{#if combat.system.started}} {{#if combat.round}}
<button type="button" class="combat-control combat-control-lg" data-action="endCombat"> <button type="button" class="combat-control combat-control-lg" data-action="endCombat">
<i class="fa-solid fa-xmark" inert></i> <i class="fa-solid fa-xmark" inert></i>
<span>{{ localize "COMBAT.End" }}</span> <span>{{ localize "COMBAT.End" }}</span>

View file

@ -62,7 +62,7 @@
{{!-- Combat Status --}} {{!-- Combat Status --}}
<strong class="encounter-title"> <strong class="encounter-title">
{{#if combats.length}} {{#if combats.length}}
{{#if combat.system.started}} {{#if combat.round}}
{{ localize "DAGGERHEART.Combat.combatStarted" }} {{ localize "DAGGERHEART.Combat.combatStarted" }}
{{else}} {{else}}
{{ localize "COMBAT.NotStarted" }} {{ localize "COMBAT.NotStarted" }}