From 5420e099695ae7d380c454b3d1a138292672586f Mon Sep 17 00:00:00 2001 From: Dread134 Date: Mon, 13 May 2024 08:01:58 -0400 Subject: [PATCH] Added More Documentation Add comment into Phases for what sourcePokemon is for. Renamed source to sourcePokemon onto trySetStatus and canSetStatus. Added TSDoc head for what sourcePokemon is and anything else I am aware of what they are used for. --- src/field/pokemon.ts | 29 +++++++++++++++++++++++------ src/phases.ts | 2 +- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index efa24f7e3b5..d93b4d619e9 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -1987,7 +1987,15 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { return this.gender !== Gender.GENDERLESS && pokemon.gender === (this.gender === Gender.MALE ? Gender.FEMALE : Gender.MALE); } - canSetStatus(effect: StatusEffect, quiet: boolean = false, overrideStatus: boolean = false, source: Pokemon = null): boolean { + /** + * + * @param effect - effect to try and set + * @param quiet - whether to suppress trigger messages + * @param overrideStatus + * @param sourcePokemon - source Pokemon of the status effect + * @returns + */ + canSetStatus(effect: StatusEffect, quiet: boolean = false, overrideStatus: boolean = false, sourcePokemon: Pokemon = null): boolean { if (effect !== StatusEffect.FAINT) { if (overrideStatus ? this.status?.effect === effect : this.status) return false; @@ -2009,8 +2017,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { return false; // Check if the source Pokemon has an ability that cancels the Poison/Toxic immunity - if (source) { - applyAbAttrs(IgnoreTypeStatusEffectImmunityAbAttr, source, cancelImmunity, effect, defType); + if (sourcePokemon) { + applyAbAttrs(IgnoreTypeStatusEffectImmunityAbAttr, sourcePokemon, cancelImmunity, effect, defType); if (cancelImmunity.value) return false; else @@ -2053,12 +2061,21 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { return true; } - trySetStatus(effect: StatusEffect, asPhase: boolean = false, cureTurn: integer = 0, sourceText: string = null, source: Pokemon = null): boolean { - if (!this.canSetStatus(effect, asPhase, false, source)) + /** + * + * @param effect - effect to try and set + * @param asPhase + * @param cureTurn + * @param sourceText + * @param sourcePokemon - source Pokemon of the status effect + * @returns + */ + trySetStatus(effect: StatusEffect, asPhase: boolean = false, cureTurn: integer = 0, sourceText: string = null, sourcePokemon: Pokemon = null): boolean { + if (!this.canSetStatus(effect, asPhase, false, sourcePokemon)) return false; if (asPhase) { - this.scene.unshiftPhase(new ObtainStatusEffectPhase(this.scene, this.getBattlerIndex(), effect, cureTurn, sourceText, source)); + this.scene.unshiftPhase(new ObtainStatusEffectPhase(this.scene, this.getBattlerIndex(), effect, cureTurn, sourceText, sourcePokemon)); return true; } diff --git a/src/phases.ts b/src/phases.ts index b14db52327f..37ad565beef 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -2939,7 +2939,7 @@ export class ObtainStatusEffectPhase extends PokemonPhase { this.statusEffect = statusEffect; this.cureTurn = cureTurn; this.sourceText = sourceText; - this.sourcePokemon = sourcePokemon; + this.sourcePokemon = sourcePokemon; // For tracking which Pokemon caused the status effect } start() {