mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-06-28 12:32:44 +02:00
ddd
This commit is contained in:
parent
28f6b72f87
commit
de200542c0
@ -895,7 +895,8 @@ export default class BattleScene extends SceneBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getPokemonById(pokemonId: number): Pokemon | null {
|
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(
|
addPlayerPokemon(
|
||||||
@ -2599,7 +2600,6 @@ export default class BattleScene extends SceneBase {
|
|||||||
return Math.floor(moneyValue / 10) * 10;
|
return Math.floor(moneyValue / 10) * 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: refactor this
|
|
||||||
addModifier(
|
addModifier(
|
||||||
modifier: Modifier | null,
|
modifier: Modifier | null,
|
||||||
ignoreUpdate?: boolean,
|
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);
|
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
|
* Get all of the modifiers that pass the `modifierFilter` function
|
||||||
* @param modifierFilter - The function used to filter a target's modifiers
|
* @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`
|
* @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
|
* @returns the list of all modifiers that passed the `modifierFilter` function
|
||||||
*/
|
*/
|
||||||
findModifiers(modifierFilter: ModifierPredicate, isPlayer = true): PersistentModifier[] {
|
findModifiers(modifierFilter: ModifierPredicate, isPlayer = true): PersistentModifier[] {
|
||||||
return (isPlayer ? this.modifiers : this.enemyModifiers).filter(modifierFilter);
|
return (isPlayer ? this.modifiers : this.enemyModifiers).filter(modifierFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find the first modifier that passes the `modifierFilter` function
|
* Find the first modifier that pass the `modifierFilter` function
|
||||||
* @param modifierFilter - The function used to filter a target's modifiers
|
* @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`
|
* @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
|
* @returns the first modifier that passed the `modifierFilter` function; `undefined` if none passed
|
||||||
*/
|
*/
|
||||||
findModifier(modifierFilter: ModifierPredicate, player = true): PersistentModifier | undefined {
|
findModifier(modifierFilter: ModifierPredicate, player = true): PersistentModifier | undefined {
|
||||||
|
@ -2916,7 +2916,7 @@ export class HealStatusEffectAttr extends MoveEffectAttr {
|
|||||||
* Used by {@linkcode Moves.SNORE} and {@linkcode Moves.SLEEP_TALK}.
|
* Used by {@linkcode Moves.SNORE} and {@linkcode Moves.SLEEP_TALK}.
|
||||||
*/
|
*/
|
||||||
// TODO: Should this use a battler tag?
|
// TODO: Should this use a battler tag?
|
||||||
// TODO: Give this `userSleptOrComatoseCondition`
|
// TODO: Give this `userSleptOrComatoseCondition` by default
|
||||||
export class BypassSleepAttr extends MoveAttr {
|
export class BypassSleepAttr extends MoveAttr {
|
||||||
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
||||||
if (user.status?.effect === StatusEffect.SLEEP) {
|
if (user.status?.effect === StatusEffect.SLEEP) {
|
||||||
|
@ -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.
|
// 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;
|
const encoreTag = this.getPokemon().getTag(BattlerTagType.ENCORE) as EncoreTag | undefined;
|
||||||
if (encoreTag) {
|
if (encoreTag) {
|
||||||
this.getPokemon().lapseTag(BattlerTagType.ENCORE);
|
this.getPokemon().lapseTag(BattlerTagType.ENCORE);
|
||||||
|
Loading…
Reference in New Issue
Block a user