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

@ -44,7 +44,7 @@ export class RipCryptCombat extends Combat {
};
async nextTurn() {
if ( this.round === 0 ) {return this.nextRound()}
if (this.round === 0) {return this.nextRound()}
const turn = this.turn ?? -1;
@ -61,7 +61,7 @@ export class RipCryptCombat extends Combat {
};
// Maybe advance to the next round
if ( (nextTurn === null) || (nextTurn >= this.turns.length) ) {return this.nextRound()}
if ((nextTurn === null) || (nextTurn >= this.turns.length)) {return this.nextRound()}
const advanceTime = this.getTimeDelta(this.round, this.turn, this.round, nextTurn);
@ -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,11 +24,13 @@ export class RipCryptCombatant extends Combatant {
total += distanceBetweenFates(start, end);
const whoFirst = game.settings.get(`ripcrypt`, `whoFirst`);
const disposition = this.disposition;
if (disposition === `unknown`) {
total += 0.25;
} else if (whoFirst && whoFirst !== disposition) {
total += 0.5;
if (whoFirst) {
const disposition = this.disposition;
if (disposition === `unknown`) {
total += 0.25;
} 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;
@ -12,13 +19,13 @@ export class RipCryptToken extends Token {
const markerActive = markersEnabled && isTurn && !isDefeated;
// Activate a Turn Marker
if ( markerActive ) {
if ( !this.turnMarker ) {
if (markerActive) {
if (!this.turnMarker) {
this.turnMarker = this.addChildAt(new TokenTurnMarker(this), 0);
};
canvas.tokens.turnMarkers.add(this);
this.turnMarker.draw();
} else if ( this.turnMarker ) {
} else if (this.turnMarker) {
canvas.tokens.turnMarkers.delete(this);
this.turnMarker.destroy();
this.turnMarker = null;