Apply kev's suggestions from code review

Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
This commit is contained in:
Sirz Benjie 2025-06-11 11:28:18 -04:00
parent 20c1932c61
commit 134bf76d44
No known key found for this signature in database
GPG Key ID: 38AC42D68CF5E138
2 changed files with 12 additions and 6 deletions

View File

@ -102,10 +102,6 @@ export class Ability implements Localizable {
this.attrs = []; this.attrs = [];
this.conditions = []; this.conditions = [];
this.isSuppressable = true;
this.isCopiable = true;
this.isReplaceable = true;
this.localize(); this.localize();
} }

View File

@ -158,7 +158,15 @@ export abstract class Modifier {
this.type = type; this.type = type;
} }
/** */ /**
* Return whether this modifier is of the given class
*
* @remarks
* Used to avoid requiring the caller to have imported the specific modifier class, avoiding circular dependencies.
*
* @param modifier - The modifier to check against
* @returns Whether the modiifer is an instance of the given type
*/
public is<T extends ModifierString>(modifier: T): this is ModifierInstanceMap[T] { public is<T extends ModifierString>(modifier: T): this is ModifierInstanceMap[T] {
const targetModifier = ModifierClassMap[modifier]; const targetModifier = ModifierClassMap[modifier];
if (!targetModifier) { if (!targetModifier) {
@ -191,7 +199,9 @@ export abstract class PersistentModifier extends Modifier {
public stackCount: number; public stackCount: number;
public virtualStackCount: number; public virtualStackCount: number;
/** */ /** This field does not exist at runtime and must not be used.
* Its sole purpose is to ensure that typescript is able to properly narrow when the `is` method is called.
*/
private declare _: never; private declare _: never;
constructor(type: ModifierType, stackCount = 1) { constructor(type: ModifierType, stackCount = 1) {