mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-21 06:49:35 +02:00
Put missing null
guards around some uses of getUserPokemon()
This commit is contained in:
parent
6c51e5560f
commit
369cf2c3d8
@ -313,8 +313,8 @@ export class ConditionalProtectTag extends ArenaTag {
|
|||||||
* protection effect.
|
* protection effect.
|
||||||
* @param arena {@linkcode Arena} The arena containing the protection effect
|
* @param arena {@linkcode Arena} The arena containing the protection effect
|
||||||
* @param moveId {@linkcode Moves} The move to check against this condition
|
* @param moveId {@linkcode Moves} The move to check against this condition
|
||||||
* @returns `true` if the incoming move's priority is greater than 0. This includes
|
* @returns `true` if the incoming move's priority is greater than 0.
|
||||||
* moves with modified priorities from abilities (e.g. Prankster)
|
* This includes moves with modified priorities from abilities (e.g. Prankster)
|
||||||
*/
|
*/
|
||||||
const QuickGuardConditionFunc: ProtectConditionFunc = (arena, moveId) => {
|
const QuickGuardConditionFunc: ProtectConditionFunc = (arena, moveId) => {
|
||||||
const move = allMoves[moveId];
|
const move = allMoves[moveId];
|
||||||
@ -322,10 +322,12 @@ const QuickGuardConditionFunc: ProtectConditionFunc = (arena, moveId) => {
|
|||||||
const effectPhase = arena.scene.getCurrentPhase();
|
const effectPhase = arena.scene.getCurrentPhase();
|
||||||
|
|
||||||
if (effectPhase instanceof MoveEffectPhase) {
|
if (effectPhase instanceof MoveEffectPhase) {
|
||||||
const attacker = effectPhase.getUserPokemon()!;
|
const attacker = effectPhase.getUserPokemon();
|
||||||
applyMoveAttrs(IncrementMovePriorityAttr, attacker, null, move, priority);
|
applyMoveAttrs(IncrementMovePriorityAttr, attacker, null, move, priority);
|
||||||
|
if (attacker) {
|
||||||
applyAbAttrs(ChangeMovePriorityAbAttr, attacker, null, false, move, priority);
|
applyAbAttrs(ChangeMovePriorityAbAttr, attacker, null, false, move, priority);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return priority.value > 0;
|
return priority.value > 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2480,7 +2480,10 @@ export class SubstituteTag extends BattlerTag {
|
|||||||
onHit(pokemon: Pokemon): void {
|
onHit(pokemon: Pokemon): void {
|
||||||
const moveEffectPhase = pokemon.scene.getCurrentPhase();
|
const moveEffectPhase = pokemon.scene.getCurrentPhase();
|
||||||
if (moveEffectPhase instanceof MoveEffectPhase) {
|
if (moveEffectPhase instanceof MoveEffectPhase) {
|
||||||
const attacker = moveEffectPhase.getUserPokemon()!;
|
const attacker = moveEffectPhase.getUserPokemon();
|
||||||
|
if (!attacker) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const move = moveEffectPhase.move.getMove();
|
const move = moveEffectPhase.move.getMove();
|
||||||
const firstHit = (attacker.turnData.hitCount === attacker.turnData.hitsLeft);
|
const firstHit = (attacker.turnData.hitCount === attacker.turnData.hitsLeft);
|
||||||
|
|
||||||
|
@ -52,11 +52,11 @@ import {
|
|||||||
HitHealModifier,
|
HitHealModifier,
|
||||||
PokemonMultiHitModifier,
|
PokemonMultiHitModifier,
|
||||||
} from "#app/modifier/modifier";
|
} from "#app/modifier/modifier";
|
||||||
|
import { PokemonPhase } from "#app/phases/pokemon-phase";
|
||||||
import { BooleanHolder, executeIf, NumberHolder } from "#app/utils";
|
import { BooleanHolder, executeIf, NumberHolder } from "#app/utils";
|
||||||
import { BattlerTagType } from "#enums/battler-tag-type";
|
import { BattlerTagType } from "#enums/battler-tag-type";
|
||||||
import { Moves } from "#enums/moves";
|
import { Moves } from "#enums/moves";
|
||||||
import i18next from "i18next";
|
import i18next from "i18next";
|
||||||
import { PokemonPhase } from "./pokemon-phase";
|
|
||||||
|
|
||||||
export class MoveEffectPhase extends PokemonPhase {
|
export class MoveEffectPhase extends PokemonPhase {
|
||||||
public move: PokemonMove;
|
public move: PokemonMove;
|
||||||
@ -517,7 +517,11 @@ export class MoveEffectPhase extends PokemonPhase {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const user = this.getUserPokemon()!; // TODO: is this bang correct?
|
const user = this.getUserPokemon();
|
||||||
|
|
||||||
|
if (!user) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Hit check only calculated on first hit for multi-hit moves unless flag is set to check all hits.
|
// Hit check only calculated on first hit for multi-hit moves unless flag is set to check all hits.
|
||||||
// However, if an ability with the MaxMultiHitAbAttr, namely Skill Link, is present, act as a normal
|
// However, if an ability with the MaxMultiHitAbAttr, namely Skill Link, is present, act as a normal
|
||||||
|
Loading…
Reference in New Issue
Block a user