Apply PR feedback
This commit is contained in:
parent
26534ec0ca
commit
ec5ad470f8
6 changed files with 51 additions and 33 deletions
|
|
@ -2,6 +2,10 @@ const { CombatTracker } = foundry.applications.sidebar.tabs;
|
||||||
|
|
||||||
export class RipCryptCombatTracker extends CombatTracker {
|
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
|
* @override
|
||||||
*/
|
*/
|
||||||
async _prepareTurnContext(combat, combatant, index) {
|
async _prepareTurnContext(combat, combatant, index) {
|
||||||
|
|
@ -14,7 +18,7 @@ export class RipCryptCombatTracker extends CombatTracker {
|
||||||
if (groupKey && combat.started) {
|
if (groupKey && combat.started) {
|
||||||
turn.active ||= combat.combatant?.groupKey === groupKey;
|
turn.active ||= combat.combatant?.groupKey === groupKey;
|
||||||
if (turn.active && !turn.css.includes(`active`)) {
|
if (turn.active && !turn.css.includes(`active`)) {
|
||||||
turn.css += `active`;
|
turn.css += ` active`;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -26,8 +30,8 @@ export class RipCryptCombatTracker extends CombatTracker {
|
||||||
|
|
||||||
// Purge the combat controls that I don't want to exist because they don't
|
// Purge the combat controls that I don't want to exist because they don't
|
||||||
// make sense in the system.
|
// make sense in the system.
|
||||||
this.element.querySelector(`[data-action="resetAll"]`)?.remove();
|
this.element?.querySelector(`[data-action="resetAll"]`)?.remove();
|
||||||
this.element.querySelector(`[data-action="rollNPC"]`)?.remove();
|
this.element?.querySelector(`[data-action="rollNPC"]`)?.remove();
|
||||||
this.element.querySelector(`[data-action="rollAll"]`)?.remove();
|
this.element?.querySelector(`[data-action="rollAll"]`)?.remove();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ export class RipCryptCombat extends Combat {
|
||||||
};
|
};
|
||||||
|
|
||||||
async nextTurn() {
|
async nextTurn() {
|
||||||
if ( this.round === 0 ) {return this.nextRound()}
|
if (this.round === 0) {return this.nextRound()}
|
||||||
|
|
||||||
const turn = this.turn ?? -1;
|
const turn = this.turn ?? -1;
|
||||||
|
|
||||||
|
|
@ -61,7 +61,7 @@ export class RipCryptCombat extends Combat {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Maybe advance to the next round
|
// 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);
|
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
|
* @protected
|
||||||
* @internal
|
* @internal
|
||||||
|
* @override
|
||||||
*/
|
*/
|
||||||
_updateTurnMarkers() {
|
_updateTurnMarkers() {
|
||||||
if (!canvas.ready) { return };
|
if (!canvas.ready) { return };
|
||||||
|
|
@ -133,12 +136,4 @@ export class RipCryptCombat extends Combat {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async _manageTurnEvents() {
|
|
||||||
try {
|
|
||||||
await super._manageTurnEvents();
|
|
||||||
} catch {
|
|
||||||
this._updateTurnMarkers();
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -24,11 +24,13 @@ export class RipCryptCombatant extends Combatant {
|
||||||
total += distanceBetweenFates(start, end);
|
total += distanceBetweenFates(start, end);
|
||||||
|
|
||||||
const whoFirst = game.settings.get(`ripcrypt`, `whoFirst`);
|
const whoFirst = game.settings.get(`ripcrypt`, `whoFirst`);
|
||||||
const disposition = this.disposition;
|
if (whoFirst) {
|
||||||
if (disposition === `unknown`) {
|
const disposition = this.disposition;
|
||||||
total += 0.25;
|
if (disposition === `unknown`) {
|
||||||
} else if (whoFirst && whoFirst !== disposition) {
|
total += 0.25;
|
||||||
total += 0.5;
|
} else if (whoFirst !== disposition) {
|
||||||
|
total += 0.5;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
return total;
|
return total;
|
||||||
|
|
@ -46,15 +48,23 @@ export class RipCryptCombatant extends Combatant {
|
||||||
return `${path}:${disposition}`;
|
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() {
|
_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() {
|
_onDelete() {
|
||||||
if (this.token) {
|
this.token?._object?._refreshTurnMarker();
|
||||||
this.token._object._refreshTurnMarker();
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,13 @@
|
||||||
const { TokenTurnMarker } = foundry.canvas.placeables.tokens;
|
const { TokenTurnMarker } = foundry.canvas.placeables.tokens;
|
||||||
|
|
||||||
export class RipCryptToken extends Token {
|
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() {
|
_refreshTurnMarker() {
|
||||||
// Should a Turn Marker be active?
|
// Should a Turn Marker be active?
|
||||||
const {turnMarker} = this.document;
|
const {turnMarker} = this.document;
|
||||||
|
|
@ -12,13 +19,13 @@ export class RipCryptToken extends Token {
|
||||||
const markerActive = markersEnabled && isTurn && !isDefeated;
|
const markerActive = markersEnabled && isTurn && !isDefeated;
|
||||||
|
|
||||||
// Activate a Turn Marker
|
// Activate a Turn Marker
|
||||||
if ( markerActive ) {
|
if (markerActive) {
|
||||||
if ( !this.turnMarker ) {
|
if (!this.turnMarker) {
|
||||||
this.turnMarker = this.addChildAt(new TokenTurnMarker(this), 0);
|
this.turnMarker = this.addChildAt(new TokenTurnMarker(this), 0);
|
||||||
};
|
};
|
||||||
canvas.tokens.turnMarkers.add(this);
|
canvas.tokens.turnMarkers.add(this);
|
||||||
this.turnMarker.draw();
|
this.turnMarker.draw();
|
||||||
} else if ( this.turnMarker ) {
|
} else if (this.turnMarker) {
|
||||||
canvas.tokens.turnMarkers.delete(this);
|
canvas.tokens.turnMarkers.delete(this);
|
||||||
this.turnMarker.destroy();
|
this.turnMarker.destroy();
|
||||||
this.turnMarker = null;
|
this.turnMarker = null;
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,10 @@ export function registerMetaSettings() {
|
||||||
type: String,
|
type: String,
|
||||||
config: false,
|
config: false,
|
||||||
requiresReload: false,
|
requiresReload: false,
|
||||||
onChange: () => {
|
onChange: async () => {
|
||||||
ui.crypt.render({ parts: [ `fate` ] });
|
await ui.crypt.render({ parts: [ `fate` ] });
|
||||||
|
await game.combat.setupTurns();
|
||||||
|
await ui.combat.render({ parts: [ `tracker` ] });
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,8 @@ import { Logger } from "./Logger.mjs";
|
||||||
const { FatePath } = gameTerms;
|
const { FatePath } = gameTerms;
|
||||||
|
|
||||||
export function isOppositeFates(a, b) {
|
export function isOppositeFates(a, b) {
|
||||||
return a === FatePath.NORTH && b === FatePath.SOUTH
|
return (a === FatePath.NORTH && b === FatePath.SOUTH)
|
||||||
|| a === FatePath.EAST && FatePath.WEST;
|
|| (a === FatePath.EAST && b === FatePath.WEST);
|
||||||
};
|
};
|
||||||
|
|
||||||
export function distanceBetweenFates(start, end) {
|
export function distanceBetweenFates(start, end) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue