Update gameManager.ts

This commit is contained in:
Bertie690 2025-04-20 14:19:57 -04:00 committed by GitHub
parent 6b4aefc598
commit df7736eb3c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -310,8 +310,8 @@ export default class GameManager {
/** /**
* Emulate a player's target selection after a move is chosen, usually called automatically by {@linkcode MoveHelper.select}. * Emulate a player's target selection after a move is chosen, usually called automatically by {@linkcode MoveHelper.select}.
* Will trigger during the next {@linkcode SelectTargetPhase} * Will trigger during the next {@linkcode SelectTargetPhase}
* @param {BattlerIndex} targetIndex The index of the attack target, or `undefined` for multi-target attacks * @param targetIndex - The {@linkcode BattlerIndex} of the attack target, or `undefined` for multi-target attacks
* @param movePosition The index of the move in the pokemon's moveset array * @param movePosition - The 0-indexed position of the move in the pokemon's moveset array
*/ */
selectTarget(movePosition: number, targetIndex?: BattlerIndex) { selectTarget(movePosition: number, targetIndex?: BattlerIndex) {
this.onNextPrompt( this.onNextPrompt(
@ -380,8 +380,9 @@ export default class GameManager {
/** /**
* Forces the next enemy selecting a move to use the given move in its moveset against the * Forces the next enemy selecting a move to use the given move in its moveset against the
* given target (if applicable). * given target (if applicable).
* @param moveId {@linkcode Moves} the move the enemy will use * @param moveId - The {@linkcode Moves | move} the enemy will use
* @param target {@linkcode BattlerIndex} the target on which the enemy will use the given move * @param target - The {@linkcode BattlerIndex} of the target against which the enemy will use the given move;
* will use normal target selection priorities if omitted.
*/ */
async forceEnemyMove(moveId: Moves, target?: BattlerIndex) { async forceEnemyMove(moveId: Moves, target?: BattlerIndex) {
// Wait for the next EnemyCommandPhase to start // Wait for the next EnemyCommandPhase to start
@ -442,8 +443,8 @@ export default class GameManager {
} }
/** /**
* Checks if the player has won the battle. * Check if the player has won the battle.
* @returns True if the player has won, otherwise false. * @returns whether the player has won the battle (all opposinc Pokemon have been fainted)
*/ */
isVictory() { isVictory() {
return this.scene.currentBattle.enemyParty.every(pokemon => pokemon.isFainted()); return this.scene.currentBattle.enemyParty.every(pokemon => pokemon.isFainted());
@ -452,7 +453,7 @@ export default class GameManager {
/** /**
* Checks if the current phase matches the target phase. * Checks if the current phase matches the target phase.
* @param phaseTarget - The target phase. * @param phaseTarget - The target phase.
* @returns True if the current phase matches the target phase, otherwise false. * @returns Whether the current phase matches the target phase
*/ */
isCurrentPhase(phaseTarget) { isCurrentPhase(phaseTarget) {
const targetName = typeof phaseTarget === "string" ? phaseTarget : phaseTarget.name; const targetName = typeof phaseTarget === "string" ? phaseTarget : phaseTarget.name;
@ -461,8 +462,8 @@ export default class GameManager {
/** /**
* Checks if the current mode matches the target mode. * Checks if the current mode matches the target mode.
* @param mode - The target mode. * @param mode - The target {@linkcode Mode} to check.
* @returns True if the current mode matches the target mode, otherwise false. * @returns Whether the current mode matches the target mode.
*/ */
isCurrentMode(mode: Mode) { isCurrentMode(mode: Mode) {
return this.scene.ui?.getMode() === mode; return this.scene.ui?.getMode() === mode;
@ -502,7 +503,7 @@ export default class GameManager {
/** /**
* Faints a player or enemy pokemon instantly by setting their HP to 0. * Faints a player or enemy pokemon instantly by setting their HP to 0.
* @param pokemon The player/enemy pokemon being fainted * @param pokemon - The player/enemy pokemon being fainted
* @returns A promise that resolves once the fainted pokemon's FaintPhase finishes running. * @returns A promise that resolves once the fainted pokemon's FaintPhase finishes running.
*/ */
async killPokemon(pokemon: PlayerPokemon | EnemyPokemon) { async killPokemon(pokemon: PlayerPokemon | EnemyPokemon) {
@ -517,7 +518,7 @@ export default class GameManager {
/** /**
* Command an in-battle switch to another {@linkcode Pokemon} via the main battle menu. * Command an in-battle switch to another {@linkcode Pokemon} via the main battle menu.
* @param pokemonIndex - The 0-indexed position of the party pokemon to switch to. * @param pokemonIndex - The 0-indexed position of the party pokemon to switch to.
* Should never be called with 0 as that will select the currently active pokemon. * Should never be called with 0 as that will select the currently active pokemon and freeze.
*/ */
doSwitchPokemon(pokemonIndex: number) { doSwitchPokemon(pokemonIndex: number) {
this.onNextPrompt("CommandPhase", Mode.COMMAND, () => { this.onNextPrompt("CommandPhase", Mode.COMMAND, () => {
@ -530,7 +531,7 @@ export default class GameManager {
/** /**
* Revive pokemon, currently players only. * Revive pokemon, currently players only.
* @param pokemonIndex the index of the pokemon in your party to revive * @param pokemonIndex - The 0-indexed position of the pokemon in your party to revive
*/ */
doRevivePokemon(pokemonIndex: number) { doRevivePokemon(pokemonIndex: number) {
const party = this.scene.getPlayerParty(); const party = this.scene.getPlayerParty();
@ -540,13 +541,12 @@ export default class GameManager {
} }
/** /**
* Select a pokemon from the party menu. Only really handles the basic cases * Select a pokemon from the party menu during the given phase.
* of the party UI, where you just need to navigate to a party slot and press * Only really handles the basic case of "navigate to party slot and press Action twice" -
* Action twice - navigating any menus that come up after you select a party member * any menus that come up afterwards are ignored and must be handled separately by the caller.
* is not supported. * @param slot - The 0-indexed position of the pokemon in your party to switch to
* @param slot the 0-indexed position of the pokemon in your party to switch to * @param inPhase - Which phase to expect the selection to occur in. Defaults to `SwitchPhase`
* @param inPhase Which phase to expect the selection to occur in. Typically * (which is where the majority of non-command switch operations occur).
* non-command switch actions happen in SwitchPhase.
*/ */
doSelectPartyPokemon(slot: number, inPhase = "SwitchPhase") { doSelectPartyPokemon(slot: number, inPhase = "SwitchPhase") {
this.onNextPrompt(inPhase, Mode.PARTY, () => { this.onNextPrompt(inPhase, Mode.PARTY, () => {
@ -561,7 +561,7 @@ export default class GameManager {
/** /**
* Select the BALL option from the command menu, then press Action; in the BALL * Select the BALL option from the command menu, then press Action; in the BALL
* menu, select a pokéball type and press Action again to throw it. * menu, select a pokéball type and press Action again to throw it.
* @param ballIndex the index of the pokeball to throw * @param ballIndex - The index of the pokeball to throw
*/ */
public doThrowPokeball(ballIndex: number) { public doThrowPokeball(ballIndex: number) {
this.onNextPrompt("CommandPhase", Mode.COMMAND, () => { this.onNextPrompt("CommandPhase", Mode.COMMAND, () => {