mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-06-21 17:12:44 +02:00
Update with Bertie's comments
Co-authored-by: Bertie690 <136088738+Bertie690@users.noreply.github.com>
This commit is contained in:
parent
ecc175f176
commit
855c956aad
@ -224,7 +224,8 @@ export class CommandPhase extends FieldPhase {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Helper method for {@linkcode handleFightCommand} that returns the moveID for the phase
|
/**
|
||||||
|
* Helper method for {@linkcode handleFightCommand} that returns the moveID for the phase
|
||||||
* based on the move passed in or the cursor.
|
* based on the move passed in or the cursor.
|
||||||
*
|
*
|
||||||
* Does not check if the move is usable or not, that should be handled by the caller.
|
* Does not check if the move is usable or not, that should be handled by the caller.
|
||||||
@ -234,10 +235,16 @@ export class CommandPhase extends FieldPhase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle fight logic
|
* Process the logic for executing a fight-related command
|
||||||
|
*
|
||||||
|
* @remarks
|
||||||
|
* - Validates whether the move can be used, using struggle if not
|
||||||
|
* - Constructs the turn command and inserts it into the battle's turn commands
|
||||||
|
*
|
||||||
* @param command - The command to handle (FIGHT or TERA)
|
* @param command - The command to handle (FIGHT or TERA)
|
||||||
* @param cursor - The index that the cursor is placed on, or -1 if no move can be selected.
|
* @param cursor - The index that the cursor is placed on, or -1 if no move can be selected.
|
||||||
* @param args - Any additional arguments to pass to the command
|
* @param ignorePP - Whether to ignore PP when checking if the move can be used.
|
||||||
|
* @param move - The move to force the command to use, if any.
|
||||||
*/
|
*/
|
||||||
private handleFightCommand(
|
private handleFightCommand(
|
||||||
command: Command.FIGHT | Command.TERA,
|
command: Command.FIGHT | Command.TERA,
|
||||||
@ -248,7 +255,6 @@ export class CommandPhase extends FieldPhase {
|
|||||||
const playerPokemon = this.getPokemon();
|
const playerPokemon = this.getPokemon();
|
||||||
const ignorePP = isIgnorePP(useMode);
|
const ignorePP = isIgnorePP(useMode);
|
||||||
|
|
||||||
let canUse = cursor === -1 || playerPokemon.trySelectMove(cursor, ignorePP);
|
|
||||||
let canUse = cursor === -1 || playerPokemon.trySelectMove(cursor, ignorePP);
|
let canUse = cursor === -1 || playerPokemon.trySelectMove(cursor, ignorePP);
|
||||||
|
|
||||||
// Ternary here ensures we don't compute struggle conditions unless necessary
|
// Ternary here ensures we don't compute struggle conditions unless necessary
|
||||||
@ -256,7 +262,9 @@ export class CommandPhase extends FieldPhase {
|
|||||||
? false
|
? false
|
||||||
: cursor > -1 && !playerPokemon.getMoveset().some(m => m.isUsable(playerPokemon));
|
: cursor > -1 && !playerPokemon.getMoveset().some(m => m.isUsable(playerPokemon));
|
||||||
|
|
||||||
if (!canUse && !useStruggle) {
|
canUse ||= useStruggle;
|
||||||
|
|
||||||
|
if (!canUse) {
|
||||||
this.queueFightErrorMessage(playerPokemon, cursor);
|
this.queueFightErrorMessage(playerPokemon, cursor);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -283,7 +291,7 @@ export class CommandPhase extends FieldPhase {
|
|||||||
multiple: move.targets.length > 1,
|
multiple: move.targets.length > 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (moveId === Moves.NONE) {
|
if (moveId === MoveId.NONE) {
|
||||||
turnCommand.targets = [this.fieldIndex];
|
turnCommand.targets = [this.fieldIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user