Updated doc comments for test-related functions

This commit is contained in:
Bertie690 2025-05-31 12:32:45 -04:00
parent 831381e4ce
commit 92c4ca58bf
2 changed files with 34 additions and 21 deletions

View File

@ -20,9 +20,9 @@ export class FieldHelper extends GameManagerHelper {
* Passthrough for {@linkcode globalScene.getPlayerPokemon} that adds an `undefined` check for * Passthrough for {@linkcode globalScene.getPlayerPokemon} that adds an `undefined` check for
* the Pokemon so that the return type for the function doesn't have `undefined`. * the Pokemon so that the return type for the function doesn't have `undefined`.
* This removes the need to add a `!` like when calling `game.scene.getPlayerPokemon()!`. * This removes the need to add a `!` like when calling `game.scene.getPlayerPokemon()!`.
* @param includeSwitching Whether a pokemon that is currently switching out is valid, default `true` * @param includeSwitching - Whether a pokemon that is currently switching out is valid, default `true`
* @returns The first {@linkcode PlayerPokemon} that is {@linkcode globalScene.getPlayerField on the field} * @returns The first {@linkcode PlayerPokemon} that is {@linkcode globalScene.getPlayerField | on the field}
* and {@linkcode PlayerPokemon.isActive is active} * and {@linkcode PlayerPokemon.isActive | is active}
* (aka {@linkcode PlayerPokemon.isAllowedInBattle is allowed in battle}). * (aka {@linkcode PlayerPokemon.isAllowedInBattle is allowed in battle}).
*/ */
public getPlayerPokemon(includeSwitching = true): PlayerPokemon { public getPlayerPokemon(includeSwitching = true): PlayerPokemon {
@ -36,9 +36,9 @@ export class FieldHelper extends GameManagerHelper {
* the Pokemon so that the return type for the function doesn't have `undefined`. * the Pokemon so that the return type for the function doesn't have `undefined`.
* This removes the need to add a `!` like when calling `game.scene.getEnemyPokemon()!`. * This removes the need to add a `!` like when calling `game.scene.getEnemyPokemon()!`.
* @param includeSwitching Whether a pokemon that is currently switching out is valid, default `true` * @param includeSwitching Whether a pokemon that is currently switching out is valid, default `true`
* @returns The first {@linkcode EnemyPokemon} that is {@linkcode globalScene.getEnemyField on the field} * @returns The first {@linkcode EnemyPokemon} that is {@linkcode globalScene.getEnemyField | on the field}
* and {@linkcode EnemyPokemon.isActive is active} * and {@linkcode EnemyPokemon.isActive | is active}
* (aka {@linkcode EnemyPokemon.isAllowedInBattle is allowed in battle}). * (aka {@linkcode EnemyPokemon.isAllowedInBattle | is allowed in battle}).
*/ */
public getEnemyPokemon(includeSwitching = true): EnemyPokemon { public getEnemyPokemon(includeSwitching = true): EnemyPokemon {
const pokemon = this.game.scene.getEnemyPokemon(includeSwitching); const pokemon = this.game.scene.getEnemyPokemon(includeSwitching);
@ -50,7 +50,9 @@ export class FieldHelper extends GameManagerHelper {
* @returns The {@linkcode BattlerIndex | indexes} of Pokemon on the field in order of decreasing Speed. * @returns The {@linkcode BattlerIndex | indexes} of Pokemon on the field in order of decreasing Speed.
* Speed ties are returned in increasing order of index. * Speed ties are returned in increasing order of index.
* *
* Note: Trick Room does not modify the speed of Pokemon on the field. * @remarks
* This does not account for Trick Room as it does not modify the _speed_ of Pokemon on the field,
* only their turn order.
*/ */
public getSpeedOrder(): BattlerIndex[] { public getSpeedOrder(): BattlerIndex[] {
return this.game.scene return this.game.scene
@ -60,7 +62,8 @@ export class FieldHelper extends GameManagerHelper {
} }
/** /**
* Mocks a pokemon's ability, overriding its existing ability (takes precedence over global overrides) * Mocks a pokemon's ability, overriding its existing ability (takes precedence over global overrides).
* Useful for giving exactly 1 Pokemon in a double battle a certain ability (rather than all pokemon).
* @param pokemon - The pokemon to mock the ability of * @param pokemon - The pokemon to mock the ability of
* @param ability - The ability to be mocked * @param ability - The ability to be mocked
* @returns A {@linkcode MockInstance} object * @returns A {@linkcode MockInstance} object
@ -72,14 +75,14 @@ export class FieldHelper extends GameManagerHelper {
} }
/** /**
* Forces a pokemon to be terastallized. Defaults to the pokemon's primary type if not specified. * Force a given Pokemon to be terastallized to the given type.
*
* This function only mocks the Pokemon's tera-related variables; it does NOT activate any tera-related abilities.
* *
* @param pokemon - The pokemon to terastallize. * @param pokemon - The pokemon to terastallize.
* @param teraType - (optional) The {@linkcode PokemonType} to terastallize it as. * @param teraType - The {@linkcode PokemonType} to terastallize into; defaults to the pokemon's primary type.
* @remarks
* This function only mocks the Pokemon's tera-related variables; it does NOT activate any tera-related abilities.
*/ */
public forceTera(pokemon: Pokemon, teraType?: PokemonType): void { public forceTera(pokemon: Pokemon, teraType: PokemonType = pokemon.getSpeciesForm(true).type1): void {
vi.spyOn(pokemon, "isTerastallized", "get").mockReturnValue(true); vi.spyOn(pokemon, "isTerastallized", "get").mockReturnValue(true);
teraType ??= pokemon.getSpeciesForm(true).type1; teraType ??= pokemon.getSpeciesForm(true).type1;
vi.spyOn(pokemon, "teraType", "get").mockReturnValue(teraType); vi.spyOn(pokemon, "teraType", "get").mockReturnValue(teraType);

View File

@ -148,6 +148,8 @@ export class MoveHelper extends GameManagerHelper {
* Used when the normal moveset override can't be used (such as when it's necessary to check or update properties of the moveset). * Used when the normal moveset override can't be used (such as when it's necessary to check or update properties of the moveset).
* @param pokemon - The {@linkcode Pokemon} being modified * @param pokemon - The {@linkcode Pokemon} being modified
* @param moveset - The {@linkcode Moves} (single or array) to change the Pokemon's moveset to * @param moveset - The {@linkcode Moves} (single or array) to change the Pokemon's moveset to
* @remarks
* This will be overriden by any prior moveset overrides.
*/ */
public changeMoveset(pokemon: Pokemon, moveset: Moves | Moves[]): void { public changeMoveset(pokemon: Pokemon, moveset: Moves | Moves[]): void {
if (!Array.isArray(moveset)) { if (!Array.isArray(moveset)) {
@ -162,10 +164,14 @@ export class MoveHelper extends GameManagerHelper {
} }
/** /**
* Forces the next enemy selecting a move to use the given move in its moveset * Forces the next enemy selecting a move to use the given move _in its moveset_
* against the given target (if applicable). * against the given target (if applicable).
* @param moveId The {@linkcode MoveId | move} the enemy will use * @param moveId - The {@linkcode Move | move ID} the enemy will be forced to use.
* @param target (Optional) the {@linkcode BattlerIndex | target} which the enemy will use the given move against * @param target - The {@linkcode BattlerIndex | target} against which the enemy will use the given move;
* defaults to normal target selection priorities if omitted or not single-target.
* @remarks
* If you do not need to check for changes in the enemy's moveset as part of the test, it may be
* best to use {@linkcode forceEnemyMove} instead.
*/ */
public async selectEnemyMove(moveId: Moves, target?: BattlerIndex) { public async selectEnemyMove(moveId: Moves, target?: BattlerIndex) {
// Wait for the next EnemyCommandPhase to start // Wait for the next EnemyCommandPhase to start
@ -191,14 +197,18 @@ export class MoveHelper extends GameManagerHelper {
} }
/** /**
* Forces the next enemy selecting a move to use the given move against the given target (if applicable). * Modify the moveset of the next enemy selecting a move to contain only the given move, and then
* selects it to be used during the next {@linkcode EnemyCommandPhase} against the given targets.
* *
* Warning: Overwrites the pokemon's moveset and disables the moveset override! * Does not require the given move to be in the enemy's moveset beforehand,
* but **overwrites the pokemon's moveset** and **disables any prior moveset overrides**!
* *
* Note: If you need to check for changes in the enemy's moveset as part of the test, it may be * @param moveId - The {@linkcode Move | move ID} the enemy will be forced to use.
* @param target - The {@linkcode BattlerIndex | target} against which the enemy will use the given move;
* defaults to normal target selection priorities if omitted or not single-target.
* @remarks
* If you need to check for changes in the enemy's moveset as part of the test, it may be
* best to use {@linkcode changeMoveset} and {@linkcode selectEnemyMove} instead. * best to use {@linkcode changeMoveset} and {@linkcode selectEnemyMove} instead.
* @param moveId The {@linkcode MoveId | move} the enemy will use
* @param target (Optional) the {@linkcode BattlerIndex | target} which the enemy will use the given move against
*/ */
public async forceEnemyMove(moveId: Moves, target?: BattlerIndex) { public async forceEnemyMove(moveId: Moves, target?: BattlerIndex) {
// Wait for the next EnemyCommandPhase to start // Wait for the next EnemyCommandPhase to start