refactor: use noImplicitOverride option

This commit is contained in:
Johannes Loher 2022-05-29 17:47:27 +02:00
parent c9a3818571
commit 12bc76ba54
18 changed files with 45 additions and 85 deletions

View file

@ -59,8 +59,7 @@ export class DS4ActiveEffect extends ActiveEffect {
return this.originatingItem?.activeEffectFactor ?? 1; return this.originatingItem?.activeEffectFactor ?? 1;
} }
/** @override */ override apply(actor: DS4Actor, change: foundry.data.ActiveEffectData["changes"][number]): unknown {
apply(actor: DS4Actor, change: foundry.data.ActiveEffectData["changes"][number]): unknown {
change.value = Roll.replaceFormulaData(change.value, actor.data); change.value = Roll.replaceFormulaData(change.value, actor.data);
try { try {
change.value = Roll.safeEval(change.value).toString(); change.value = Roll.safeEval(change.value).toString();

View file

@ -21,8 +21,7 @@ import type { DS4Item } from "../item/item";
* The base sheet class for all {@link DS4Actor}s. * The base sheet class for all {@link DS4Actor}s.
*/ */
export class DS4ActorSheet extends ActorSheet<ActorSheet.Options, DS4ActorSheetData> { export class DS4ActorSheet extends ActorSheet<ActorSheet.Options, DS4ActorSheetData> {
/** @override */ static override get defaultOptions(): ActorSheet.Options {
static get defaultOptions(): ActorSheet.Options {
return foundry.utils.mergeObject(super.defaultOptions, { return foundry.utils.mergeObject(super.defaultOptions, {
classes: ["sheet", "ds4-actor-sheet"], classes: ["sheet", "ds4-actor-sheet"],
height: 625, height: 625,
@ -37,14 +36,12 @@ export class DS4ActorSheet extends ActorSheet<ActorSheet.Options, DS4ActorSheetD
}); });
} }
/** @override */ override get template(): string {
get template(): string {
const basePath = "systems/ds4/templates/sheets/actor"; const basePath = "systems/ds4/templates/sheets/actor";
return `${basePath}/${this.actor.data.type}-sheet.hbs`; return `${basePath}/${this.actor.data.type}-sheet.hbs`;
} }
/** @override */ override async getData(): Promise<DS4ActorSheetData> {
async getData(): Promise<DS4ActorSheetData> {
const itemsByType = Object.fromEntries( const itemsByType = Object.fromEntries(
Object.entries(this.actor.itemTypes).map(([itemType, items]) => { Object.entries(this.actor.itemTypes).map(([itemType, items]) => {
return [itemType, items.map((item) => item.data).sort((a, b) => (a.sort || 0) - (b.sort || 0))]; return [itemType, items.map((item) => item.data).sort((a, b) => (a.sort || 0) - (b.sort || 0))];
@ -96,8 +93,7 @@ export class DS4ActorSheet extends ActorSheet<ActorSheet.Options, DS4ActorSheetD
}`; }`;
} }
/** @override */ override activateListeners(html: JQuery): void {
activateListeners(html: JQuery): void {
super.activateListeners(html); super.activateListeners(html);
if (!this.options.editable) return; if (!this.options.editable) return;
@ -327,8 +323,7 @@ export class DS4ActorSheet extends ActorSheet<ActorSheet.Options, DS4ActorSheetD
this.actor.rollCheck(check).catch((e) => notifications.error(e, { log: true })); this.actor.rollCheck(check).catch((e) => notifications.error(e, { log: true }));
} }
/** @override */ override _onDragStart(event: DragEvent): void {
_onDragStart(event: DragEvent): void {
const target = event.currentTarget as HTMLElement; const target = event.currentTarget as HTMLElement;
if (!(target instanceof HTMLElement)) return super._onDragStart(event); if (!(target instanceof HTMLElement)) return super._onDragStart(event);
@ -391,8 +386,7 @@ export class DS4ActorSheet extends ActorSheet<ActorSheet.Options, DS4ActorSheetD
this.actor.updateEmbeddedDocuments("Item", updates); this.actor.updateEmbeddedDocuments("Item", updates);
} }
/** @override */ protected override async _onDropItem(event: DragEvent, data: ActorSheet.DropData.Item): Promise<unknown> {
protected async _onDropItem(event: DragEvent, data: ActorSheet.DropData.Item): Promise<unknown> {
const item = await Item.fromDropData(data); const item = await Item.fromDropData(data);
if (item && !this.actor.canOwnItemType(item.data.type)) { if (item && !this.actor.canOwnItemType(item.data.type)) {
notifications.warn( notifications.warn(

View file

@ -25,8 +25,7 @@ declare global {
* The Actor class for DS4 * The Actor class for DS4
*/ */
export class DS4Actor extends Actor { export class DS4Actor extends Actor {
/** @override */ override prepareData(): void {
prepareData(): void {
this.data.reset(); this.data.reset();
this.prepareBaseData(); this.prepareBaseData();
this.prepareEmbeddedDocuments(); this.prepareEmbeddedDocuments();
@ -36,8 +35,7 @@ export class DS4Actor extends Actor {
this.prepareFinalDerivedData(); this.prepareFinalDerivedData();
} }
/** @override */ override prepareBaseData(): void {
prepareBaseData(): void {
const data = this.data; const data = this.data;
data.data.rolling = { data.data.rolling = {
@ -57,11 +55,10 @@ export class DS4Actor extends Actor {
} }
/** /**
* @override
* We override this with an empty implementation because we have our own custom way of applying * We override this with an empty implementation because we have our own custom way of applying
* {@link ActiveEffect}s and {@link Actor#prepareEmbeddedDocuments} calls this. * {@link ActiveEffect}s and {@link Actor#prepareEmbeddedDocuments} calls this.
*/ */
applyActiveEffects(): void { override applyActiveEffects(): void {
return; return;
} }
@ -117,9 +114,8 @@ export class DS4Actor extends Actor {
/** /**
* Apply transformations to the Actor data after effects have been applied to the base data. * Apply transformations to the Actor data after effects have been applied to the base data.
* @override
*/ */
prepareDerivedData(): void { override prepareDerivedData(): void {
this.prepareCombatValues(); this.prepareCombatValues();
this.prepareChecks(); this.prepareChecks();
} }
@ -281,9 +277,8 @@ export class DS4Actor extends Actor {
/** /**
* Handle how changes to a Token attribute bar are applied to the Actor. * Handle how changes to a Token attribute bar are applied to the Actor.
* This only differs from the base implementation by also allowing negative values. * This only differs from the base implementation by also allowing negative values.
* @override
*/ */
async modifyTokenAttribute( override async modifyTokenAttribute(
attribute: string, attribute: string,
value: number, value: number,
isDelta = false, isDelta = false,

View file

@ -8,8 +8,7 @@ import { DS4ActorSheet } from "../actor-sheet";
* The Sheet class for DS4 Character Actors * The Sheet class for DS4 Character Actors
*/ */
export class DS4CharacterActorSheet extends DS4ActorSheet { export class DS4CharacterActorSheet extends DS4ActorSheet {
/** @override */ static override get defaultOptions(): ActorSheet.Options {
static get defaultOptions(): ActorSheet.Options {
return foundry.utils.mergeObject(super.defaultOptions, { return foundry.utils.mergeObject(super.defaultOptions, {
classes: ["sheet", "ds4-actor-sheet", "ds4-character-sheet"], classes: ["sheet", "ds4-actor-sheet", "ds4-character-sheet"],
}); });

View file

@ -7,19 +7,16 @@ import { DS4Actor } from "../actor";
import type { ItemType } from "../../item/item-data-source"; import type { ItemType } from "../../item/item-data-source";
export class DS4Character extends DS4Actor { export class DS4Character extends DS4Actor {
/** @override */ override prepareFinalDerivedData(): void {
prepareFinalDerivedData(): void {
super.prepareFinalDerivedData(); super.prepareFinalDerivedData();
this.data.data.slayerPoints.max = 3; this.data.data.slayerPoints.max = 3;
} }
/** @override */ override get finalDerivedDataProperties(): string[] {
get finalDerivedDataProperties(): string[] {
return [...super.finalDerivedDataProperties, "data.slayerPoints.max"]; return [...super.finalDerivedDataProperties, "data.slayerPoints.max"];
} }
/** @override */ override get ownableItemTypes(): Array<ItemType> {
get ownableItemTypes(): Array<ItemType> {
return [...super.ownableItemTypes, "talent", "racialAbility", "language", "alphabet"]; return [...super.ownableItemTypes, "talent", "racialAbility", "language", "alphabet"];
} }
} }

View file

@ -8,8 +8,7 @@ import { DS4ActorSheet } from "../actor-sheet";
* The Sheet class for DS4 Creature Actors * The Sheet class for DS4 Creature Actors
*/ */
export class DS4CreatureActorSheet extends DS4ActorSheet { export class DS4CreatureActorSheet extends DS4ActorSheet {
/** @override */ static override get defaultOptions(): ActorSheet.Options {
static get defaultOptions(): ActorSheet.Options {
return foundry.utils.mergeObject(super.defaultOptions, { return foundry.utils.mergeObject(super.defaultOptions, {
classes: ["sheet", "ds4-actor-sheet", "ds4-creature-sheet"], classes: ["sheet", "ds4-actor-sheet", "ds4-creature-sheet"],
}); });

View file

@ -7,8 +7,7 @@ import { DS4Actor } from "../actor";
import type { ItemType } from "../../item/item-data-source"; import type { ItemType } from "../../item/item-data-source";
export class DS4Creature extends DS4Actor { export class DS4Creature extends DS4Actor {
/** @override */ override get ownableItemTypes(): Array<ItemType> {
get ownableItemTypes(): Array<ItemType> {
return [...super.ownableItemTypes, "specialCreatureAbility"]; return [...super.ownableItemTypes, "specialCreatureAbility"];
} }
} }

View file

@ -6,8 +6,7 @@
* A simple extension to the {@link Dialog} class that allows attaching additional listeners. * A simple extension to the {@link Dialog} class that allows attaching additional listeners.
*/ */
export class DialogWithListeners extends Dialog<DialogWithListenersOptions> { export class DialogWithListeners extends Dialog<DialogWithListenersOptions> {
/** @inheritdoc */ override activateListeners(html: JQuery): void {
activateListeners(html: JQuery): void {
super.activateListeners(html); super.activateListeners(html);
if (this.options.activateAdditionalListeners !== undefined) { if (this.options.activateAdditionalListeners !== undefined) {
this.options.activateAdditionalListeners(html, this); this.options.activateAdditionalListeners(html, this);

View file

@ -15,8 +15,7 @@ declare global {
} }
export class DS4ChatMessage extends ChatMessage { export class DS4ChatMessage extends ChatMessage {
/** @override */ override prepareData(): void {
prepareData(): void {
super.prepareData(); super.prepareData();
if (this.data.flavor) { if (this.data.flavor) {
const game = getGame(); const game = getGame();

View file

@ -15,8 +15,7 @@ import { isDS4ItemDataTypePhysical } from "./item-data-source-base";
* The Sheet class for DS4 Items * The Sheet class for DS4 Items
*/ */
export class DS4ItemSheet extends ItemSheet<ItemSheet.Options, DS4ItemSheetData> { export class DS4ItemSheet extends ItemSheet<ItemSheet.Options, DS4ItemSheetData> {
/** @override */ static override get defaultOptions(): ItemSheet.Options {
static get defaultOptions(): ItemSheet.Options {
return foundry.utils.mergeObject(super.defaultOptions, { return foundry.utils.mergeObject(super.defaultOptions, {
classes: ["sheet", "ds4-item-sheet"], classes: ["sheet", "ds4-item-sheet"],
height: 400, height: 400,
@ -26,14 +25,12 @@ export class DS4ItemSheet extends ItemSheet<ItemSheet.Options, DS4ItemSheetData>
}); });
} }
/** @override */ override get template(): string {
get template(): string {
const basePath = "systems/ds4/templates/sheets/item"; const basePath = "systems/ds4/templates/sheets/item";
return `${basePath}/${this.item.data.type}-sheet.hbs`; return `${basePath}/${this.item.data.type}-sheet.hbs`;
} }
/** @override */ override async getData(): Promise<DS4ItemSheetData> {
async getData(): Promise<DS4ItemSheetData> {
const data = { const data = {
...(await super.getData()), ...(await super.getData()),
config: DS4, config: DS4,
@ -44,8 +41,9 @@ export class DS4ItemSheet extends ItemSheet<ItemSheet.Options, DS4ItemSheetData>
return data; return data;
} }
/** @override */ override setPosition(
setPosition(options: Partial<Application.Position> = {}): (Application.Position & { height: number }) | void { options: Partial<Application.Position> = {},
): (Application.Position & { height: number }) | void {
const position = super.setPosition(options); const position = super.setPosition(options);
if (position) { if (position) {
const sheetBody = this.element.find(".sheet-body"); const sheetBody = this.element.find(".sheet-body");
@ -56,8 +54,7 @@ export class DS4ItemSheet extends ItemSheet<ItemSheet.Options, DS4ItemSheetData>
return position; return position;
} }
/** @override */ override activateListeners(html: JQuery): void {
activateListeners(html: JQuery): void {
super.activateListeners(html); super.activateListeners(html);
if (!this.options.editable) return; if (!this.options.editable) return;

View file

@ -24,13 +24,7 @@ declare global {
* The Item class for DS4 * The Item class for DS4
*/ */
export class DS4Item extends Item { export class DS4Item extends Item {
/** @override */ override prepareDerivedData(): void {
prepareData(): void {
super.prepareData();
}
/** @override */
prepareDerivedData(): void {
this.data.data.rollable = false; this.data.data.rollable = false;
} }

View file

@ -9,14 +9,12 @@ import { DS4Item } from "../item";
import { calculateSpellPrice } from "./calculate-spell-price"; import { calculateSpellPrice } from "./calculate-spell-price";
export class DS4Spell extends DS4Item { export class DS4Spell extends DS4Item {
/** @override */ override prepareDerivedData(): void {
prepareDerivedData(): void {
this.data.data.rollable = this.data.data.equipped; this.data.data.rollable = this.data.data.equipped;
this.data.data.price = calculateSpellPrice(this.data.data); this.data.data.price = calculateSpellPrice(this.data.data);
} }
/** @override */ override async roll(options: { speaker?: { token?: TokenDocument; alias?: string } } = {}): Promise<void> {
async roll(options: { speaker?: { token?: TokenDocument; alias?: string } } = {}): Promise<void> {
const game = getGame(); const game = getGame();
if (!this.data.data.equipped) { if (!this.data.data.equipped) {

View file

@ -5,15 +5,13 @@
import { DS4Item } from "../item"; import { DS4Item } from "../item";
export class DS4Talent extends DS4Item { export class DS4Talent extends DS4Item {
/** @override */ override prepareDerivedData(): void {
prepareDerivedData(): void {
super.prepareDerivedData(); super.prepareDerivedData();
const data = this.data.data; const data = this.data.data;
data.rank.total = data.rank.base + data.rank.mod; data.rank.total = data.rank.base + data.rank.mod;
} }
/** @override */ override get activeEffectFactor(): number | undefined {
get activeEffectFactor(): number | undefined {
return this.data.data.rank.total; return this.data.data.rank.total;
} }
} }

View file

@ -11,13 +11,11 @@ import { DS4Item } from "../item";
import type { AttackType } from "./weapon-data-source"; import type { AttackType } from "./weapon-data-source";
export class DS4Weapon extends DS4Item { export class DS4Weapon extends DS4Item {
/** @override */ override prepareDerivedData(): void {
prepareDerivedData(): void {
this.data.data.rollable = this.data.data.equipped; this.data.data.rollable = this.data.data.equipped;
} }
/** @override */ override async roll(options: { speaker?: { token?: TokenDocument; alias?: string } } = {}): Promise<void> {
async roll(options: { speaker?: { token?: TokenDocument; alias?: string } } = {}): Promise<void> {
const game = getGame(); const game = getGame();
if (!this.data.data.equipped) { if (!this.data.data.equipped) {
return notifications.warn( return notifications.warn(

View file

@ -72,26 +72,22 @@ export class DS4Check extends DiceTerm {
minimumFumbleResult = DS4Check.DEFAULT_MINIMUM_FUMBLE_RESULT; minimumFumbleResult = DS4Check.DEFAULT_MINIMUM_FUMBLE_RESULT;
maximumCoupResult = DS4Check.DEFAULT_MAXIMUM_COUP_RESULT; maximumCoupResult = DS4Check.DEFAULT_MAXIMUM_COUP_RESULT;
/** @override */ override get expression(): string {
get expression(): string {
return `ds${this.modifiers.join("")}`; return `ds${this.modifiers.join("")}`;
} }
/** @override */ override get total(): string | number | null | undefined {
get total(): string | number | null | undefined {
if (this.fumble) return 0; if (this.fumble) return 0;
return super.total; return super.total;
} }
/** @override */ override _evaluateSync({ minimize = false, maximize = false } = {}): this {
_evaluateSync({ minimize = false, maximize = false } = {}): this {
super._evaluateSync({ minimize, maximize }); super._evaluateSync({ minimize, maximize });
this.evaluateResults(); this.evaluateResults();
return this; return this;
} }
/** @override */ override roll({ minimize = false, maximize = false } = {}): DiceTerm.Result {
roll({ minimize = false, maximize = false } = {}): DiceTerm.Result {
// Swap minimize / maximize because in DS4, the best possible roll is a 1 and the worst possible roll is a 20 // Swap minimize / maximize because in DS4, the best possible roll is a 1 and the worst possible roll is a 20
return super.roll({ minimize: maximize, maximize: minimize }); return super.roll({ minimize: maximize, maximize: minimize });
} }
@ -109,20 +105,19 @@ export class DS4Check extends DiceTerm {
} }
/** /**
* @override
* @remarks "min" and "max" are filtered out because they are irrelevant for * @remarks "min" and "max" are filtered out because they are irrelevant for
* {@link DS4Check}s and only result in some dice rolls being highlighted * {@link DS4Check}s and only result in some dice rolls being highlighted
* incorrectly. * incorrectly.
*/ */
getResultCSS(result: DiceTerm.Result): (string | null)[] { override getResultCSS(result: DiceTerm.Result): (string | null)[] {
return super.getResultCSS(result).filter((cssClass) => cssClass !== "min" && cssClass !== "max"); return super.getResultCSS(result).filter((cssClass) => cssClass !== "min" && cssClass !== "max");
} }
static readonly DEFAULT_CHECK_TARGET_NUMBER = 10; static readonly DEFAULT_CHECK_TARGET_NUMBER = 10;
static readonly DEFAULT_MAXIMUM_COUP_RESULT = 1; static readonly DEFAULT_MAXIMUM_COUP_RESULT = 1;
static readonly DEFAULT_MINIMUM_FUMBLE_RESULT = 20; static readonly DEFAULT_MINIMUM_FUMBLE_RESULT = 20;
static DENOMINATION = "s"; static override DENOMINATION = "s";
static MODIFIERS = { static override MODIFIERS = {
c: (): void => undefined, // Modifier is consumed in constructor for maximumCoupResult / minimumFumbleResult c: (): void => undefined, // Modifier is consumed in constructor for maximumCoupResult / minimumFumbleResult
v: (): void => undefined, // Modifier is consumed in constructor for checkTargetNumber v: (): void => undefined, // Modifier is consumed in constructor for checkTargetNumber
n: (): void => undefined, // Modifier is consumed in constructor for canFumble n: (): void => undefined, // Modifier is consumed in constructor for canFumble

View file

@ -6,15 +6,14 @@ import { getGame } from "../helpers";
import { DS4Check } from "./check"; import { DS4Check } from "./check";
export class DS4Roll<D extends Record<string, unknown> = Record<string, unknown>> extends Roll<D> { export class DS4Roll<D extends Record<string, unknown> = Record<string, unknown>> extends Roll<D> {
static CHAT_TEMPLATE = "systems/ds4/templates/dice/roll.hbs"; static override CHAT_TEMPLATE = "systems/ds4/templates/dice/roll.hbs";
/** /**
* @override
* @remarks * @remarks
* This only differs from {@link Roll#render} in that it provides `isCoup` and `isFumble` properties to the roll * This only differs from {@link Roll#render} in that it provides `isCoup` and `isFumble` properties to the roll
* template if the first dice term is a ds4 check. * template if the first dice term is a ds4 check.
*/ */
async render({ override async render({
flavor, flavor,
template = (this.constructor as typeof DS4Roll).CHAT_TEMPLATE, template = (this.constructor as typeof DS4Roll).CHAT_TEMPLATE,
isPrivate = false, isPrivate = false,

View file

@ -21,7 +21,7 @@ function getFallbackData() {
} }
export class DS4TokenDocument extends TokenDocument { export class DS4TokenDocument extends TokenDocument {
static getTrackedAttributes(data?: foundry.data.ActorData["data"], _path: string[] = []) { static override getTrackedAttributes(data?: foundry.data.ActorData["data"], _path: string[] = []) {
if (!data) { if (!data) {
data = getFallbackData(); data = getFallbackData();
} }

View file

@ -8,6 +8,7 @@
"forceConsistentCasingInFileNames": true, "forceConsistentCasingInFileNames": true,
"strict": true, "strict": true,
"noUncheckedIndexedAccess": true, "noUncheckedIndexedAccess": true,
"noImplicitOverride": true,
"resolveJsonModule": true, "resolveJsonModule": true,
"importsNotUsedAsValues": "error" "importsNotUsedAsValues": "error"
}, },