This commit is contained in:
Bertie690 2025-06-16 16:44:42 -04:00
parent 28f6b72f87
commit de200542c0
3 changed files with 11 additions and 14 deletions

View File

@ -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 {

View File

@ -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) {

View File

@ -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);