Apply PR feedback

This commit is contained in:
Oliver-Akins 2025-02-15 15:41:48 -07:00
parent 26534ec0ca
commit ec5ad470f8
6 changed files with 51 additions and 33 deletions

View file

@ -2,6 +2,10 @@ const { CombatTracker } = foundry.applications.sidebar.tabs;
export class RipCryptCombatTracker extends CombatTracker {
/**
* Changes the way the combat tracker renders combatant rows to account for
* multiple combatants being in the same combat "group", thus all going at the
* same time.
*
* @override
*/
async _prepareTurnContext(combat, combatant, index) {
@ -26,8 +30,8 @@ export class RipCryptCombatTracker extends CombatTracker {
// Purge the combat controls that I don't want to exist because they don't
// make sense in the system.
this.element.querySelector(`[data-action="resetAll"]`)?.remove();
this.element.querySelector(`[data-action="rollNPC"]`)?.remove();
this.element.querySelector(`[data-action="rollAll"]`)?.remove();
this.element?.querySelector(`[data-action="resetAll"]`)?.remove();
this.element?.querySelector(`[data-action="rollNPC"]`)?.remove();
this.element?.querySelector(`[data-action="rollAll"]`)?.remove();
};
};

View file

@ -107,9 +107,12 @@ export class RipCryptCombat extends Combat {
};
/**
* Update display of Token combat turn markers.
* Overridden to make it so that there can be multiple tokens with turn markers
* visible at the same time.
*
* @protected
* @internal
* @override
*/
_updateTurnMarkers() {
if (!canvas.ready) { return };
@ -133,12 +136,4 @@ export class RipCryptCombat extends Combat {
}
}
}
async _manageTurnEvents() {
try {
await super._manageTurnEvents();
} catch {
this._updateTurnMarkers();
};
};
};

View file

@ -24,12 +24,14 @@ export class RipCryptCombatant extends Combatant {
total += distanceBetweenFates(start, end);
const whoFirst = game.settings.get(`ripcrypt`, `whoFirst`);
if (whoFirst) {
const disposition = this.disposition;
if (disposition === `unknown`) {
total += 0.25;
} else if (whoFirst && whoFirst !== disposition) {
} else if (whoFirst !== disposition) {
total += 0.5;
};
};
return total;
};
@ -46,15 +48,23 @@ export class RipCryptCombatant extends Combatant {
return `${path}:${disposition}`;
};
/**
* Used to create the turn marker when the combatant is added if they're in
* the group whose turn it is.
*
* @override
*/
_onCreate() {
if (this.token) {
this.token._object._refreshTurnMarker();
};
this.token?._object?._refreshTurnMarker();
};
/**
* Used to remove the turn marker when the combatant is removed from combat
* if they had it visible so that it doesn't stick around infinitely.
*
* @override
*/
_onDelete() {
if (this.token) {
this.token._object._refreshTurnMarker();
};
this.token?._object?._refreshTurnMarker();
};
};

View file

@ -1,6 +1,13 @@
const { TokenTurnMarker } = foundry.canvas.placeables.tokens;
export class RipCryptToken extends Token {
/**
* Overridden using a slightly modified implementation in order to make it so
* that the turn marker shows up on tokens if they're in the same group as the
* currently active combatant
*
* @override
*/
_refreshTurnMarker() {
// Should a Turn Marker be active?
const {turnMarker} = this.document;

View file

@ -14,8 +14,10 @@ export function registerMetaSettings() {
type: String,
config: false,
requiresReload: false,
onChange: () => {
ui.crypt.render({ parts: [ `fate` ] });
onChange: async () => {
await ui.crypt.render({ parts: [ `fate` ] });
await game.combat.setupTurns();
await ui.combat.render({ parts: [ `tracker` ] });
},
});

View file

@ -4,8 +4,8 @@ import { Logger } from "./Logger.mjs";
const { FatePath } = gameTerms;
export function isOppositeFates(a, b) {
return a === FatePath.NORTH && b === FatePath.SOUTH
|| a === FatePath.EAST && FatePath.WEST;
return (a === FatePath.NORTH && b === FatePath.SOUTH)
|| (a === FatePath.EAST && b === FatePath.WEST);
};
export function distanceBetweenFates(start, end) {