diff --git a/src/battle-scene.ts b/src/battle-scene.ts index 2a2308307eb..68029fe3d90 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -895,7 +895,8 @@ export default class BattleScene extends SceneBase { } getPokemonById(pokemonId: number): Pokemon | null { - return (this.getPlayerParty() as Pokemon[]).concat(this.getEnemyParty()).find(p => p.id === pokemonId) ?? null; + const findInParty = (party: Pokemon[]) => party.find(p => p.id === pokemonId); + return (findInParty(this.getPlayerParty()) || findInParty(this.getEnemyParty())) ?? null; } addPlayerPokemon( @@ -2599,7 +2600,6 @@ export default class BattleScene extends SceneBase { return Math.floor(moneyValue / 10) * 10; } - // TODO: refactor this addModifier( modifier: Modifier | null, ignoreUpdate?: boolean, @@ -3038,22 +3038,20 @@ export default class BattleScene extends SceneBase { return (player ? this.modifiers : this.enemyModifiers).filter((m): m is T => m instanceof modifierType); } - // TODO: Add overload signature to `findModifier` and `findModifiers` for functions of the form `(x): X is T` - /** * Get all of the modifiers that pass the `modifierFilter` function - * @param modifierFilter - The function used to filter a target's modifiers - * @param isPlayer - Whether to search the player (`true`) or the enemy (`false`); Defaults to `true` - * @returns an array of {@linkcode PersistentModifier}s that passed the `modifierFilter` function + * @param modifierFilter The function used to filter a target's modifiers + * @param isPlayer Whether to search the player (`true`) or the enemy (`false`); Defaults to `true` + * @returns the list of all modifiers that passed the `modifierFilter` function */ findModifiers(modifierFilter: ModifierPredicate, isPlayer = true): PersistentModifier[] { return (isPlayer ? this.modifiers : this.enemyModifiers).filter(modifierFilter); } /** - * Find the first modifier that passes the `modifierFilter` function - * @param modifierFilter - The function used to filter a target's modifiers - * @param player - Whether to search the player (`true`) or the enemy (`false`); Defaults to `true` + * Find the first modifier that pass the `modifierFilter` function + * @param modifierFilter The function used to filter a target's modifiers + * @param player Whether to search the player (`true`) or the enemy (`false`); Defaults to `true` * @returns the first modifier that passed the `modifierFilter` function; `undefined` if none passed */ findModifier(modifierFilter: ModifierPredicate, player = true): PersistentModifier | undefined { diff --git a/src/data/moves/move.ts b/src/data/moves/move.ts index 1c76a4cbdc5..08e38dddbef 100644 --- a/src/data/moves/move.ts +++ b/src/data/moves/move.ts @@ -132,10 +132,10 @@ export default abstract class Move implements Localizable { /** * Check if the move is of the given subclass without requiring `instanceof`. - * + * * ⚠️ Does _not_ work for {@linkcode ChargingAttackMove} and {@linkcode ChargingSelfStatusMove} subclasses. For those, * use {@linkcode isChargingMove} instead. - * + * * @param moveKind - The string name of the move to check against * @returns Whether this move is of the provided type. */ @@ -2916,7 +2916,7 @@ export class HealStatusEffectAttr extends MoveEffectAttr { * Used by {@linkcode Moves.SNORE} and {@linkcode Moves.SLEEP_TALK}. */ // TODO: Should this use a battler tag? -// TODO: Give this `userSleptOrComatoseCondition` +// TODO: Give this `userSleptOrComatoseCondition` by default export class BypassSleepAttr extends MoveAttr { apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { if (user.status?.effect === StatusEffect.SLEEP) { diff --git a/src/phases/command-phase.ts b/src/phases/command-phase.ts index 5ab857ad67b..edacea338dd 100644 --- a/src/phases/command-phase.ts +++ b/src/phases/command-phase.ts @@ -86,7 +86,6 @@ export class CommandPhase extends FieldPhase { } // Checks if the Pokemon is under the effects of Encore. If so, Encore can end early if the encored move has no more PP. - // TODO: Why do we handle this here of all places const encoreTag = this.getPokemon().getTag(BattlerTagType.ENCORE) as EncoreTag | undefined; if (encoreTag) { this.getPokemon().lapseTag(BattlerTagType.ENCORE);