mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-06-21 00:52:47 +02:00
[Bug][UI/UX] Fix type hint after enemy disappears (#5677)
* Fix type hint after enemy disappears * Add automated test for type hint bugfix * Make onField default to true * Replace reference to Mode with UiMode and battleType with BattleStyle
This commit is contained in:
parent
5854b21da0
commit
65294f408e
@ -8183,7 +8183,7 @@ export type MoveTargetSet = {
|
|||||||
|
|
||||||
export function getMoveTargets(user: Pokemon, move: Moves, replaceTarget?: MoveTarget): MoveTargetSet {
|
export function getMoveTargets(user: Pokemon, move: Moves, replaceTarget?: MoveTarget): MoveTargetSet {
|
||||||
const variableTarget = new NumberHolder(0);
|
const variableTarget = new NumberHolder(0);
|
||||||
user.getOpponents().forEach(p => applyMoveAttrs(VariableTargetAttr, user, p, allMoves[move], variableTarget));
|
user.getOpponents(false).forEach(p => applyMoveAttrs(VariableTargetAttr, user, p, allMoves[move], variableTarget));
|
||||||
|
|
||||||
let moveTarget: MoveTarget | undefined;
|
let moveTarget: MoveTarget | undefined;
|
||||||
if (allMoves[move].hasAttr(VariableTargetAttr)) {
|
if (allMoves[move].hasAttr(VariableTargetAttr)) {
|
||||||
@ -8195,7 +8195,7 @@ export function getMoveTargets(user: Pokemon, move: Moves, replaceTarget?: MoveT
|
|||||||
} else if (move === undefined) {
|
} else if (move === undefined) {
|
||||||
moveTarget = MoveTarget.NEAR_ENEMY;
|
moveTarget = MoveTarget.NEAR_ENEMY;
|
||||||
}
|
}
|
||||||
const opponents = user.getOpponents();
|
const opponents = user.getOpponents(false);
|
||||||
|
|
||||||
let set: Pokemon[] = [];
|
let set: Pokemon[] = [];
|
||||||
let multiple = false;
|
let multiple = false;
|
||||||
|
@ -59,7 +59,7 @@ export class Terrain {
|
|||||||
// Cancels move if the move has positive priority and targets a Pokemon grounded on the Psychic Terrain
|
// Cancels move if the move has positive priority and targets a Pokemon grounded on the Psychic Terrain
|
||||||
return (
|
return (
|
||||||
move.getPriority(user) > 0 &&
|
move.getPriority(user) > 0 &&
|
||||||
user.getOpponents().some(o => targets.includes(o.getBattlerIndex()) && o.isGrounded())
|
user.getOpponents(true).some(o => targets.includes(o.getBattlerIndex()) && o.isGrounded())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3852,12 +3852,17 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
getOpponents(): Pokemon[] {
|
/**
|
||||||
|
* Returns the pokemon that oppose this one and are active
|
||||||
|
*
|
||||||
|
* @param onField - whether to also check if the pokemon is currently on the field (defaults to true)
|
||||||
|
*/
|
||||||
|
getOpponents(onField = true): Pokemon[] {
|
||||||
return (
|
return (
|
||||||
(this.isPlayer()
|
(this.isPlayer()
|
||||||
? globalScene.getEnemyField()
|
? globalScene.getEnemyField()
|
||||||
: globalScene.getPlayerField()) as Pokemon[]
|
: globalScene.getPlayerField()) as Pokemon[]
|
||||||
).filter(p => p.isActive());
|
).filter(p => p.isActive(onField));
|
||||||
}
|
}
|
||||||
|
|
||||||
getOpponentDescriptor(): string {
|
getOpponentDescriptor(): string {
|
||||||
|
@ -654,7 +654,7 @@ export class MovePhase extends BattlePhase {
|
|||||||
}),
|
}),
|
||||||
500,
|
500,
|
||||||
);
|
);
|
||||||
applyMoveAttrs(PreMoveMessageAttr, this.pokemon, this.pokemon.getOpponents()[0], this.move.getMove());
|
applyMoveAttrs(PreMoveMessageAttr, this.pokemon, this.pokemon.getOpponents(false)[0], this.move.getMove());
|
||||||
}
|
}
|
||||||
|
|
||||||
public showFailedText(failedText: string = i18next.t("battle:attackFailed")): void {
|
public showFailedText(failedText: string = i18next.t("battle:attackFailed")): void {
|
||||||
|
@ -40,7 +40,7 @@ describe("UI - Type Hints", () => {
|
|||||||
.moveset([Moves.DRAGON_CLAW]);
|
.moveset([Moves.DRAGON_CLAW]);
|
||||||
game.settings.typeHints(true); //activate type hints
|
game.settings.typeHints(true); //activate type hints
|
||||||
|
|
||||||
await game.startBattle([Species.RAYQUAZA]);
|
await game.classicMode.startBattle([Species.RAYQUAZA]);
|
||||||
|
|
||||||
game.onNextPrompt("CommandPhase", UiMode.COMMAND, () => {
|
game.onNextPrompt("CommandPhase", UiMode.COMMAND, () => {
|
||||||
const { ui } = game.scene;
|
const { ui } = game.scene;
|
||||||
@ -65,7 +65,7 @@ describe("UI - Type Hints", () => {
|
|||||||
it("check status move color", async () => {
|
it("check status move color", async () => {
|
||||||
game.override.enemySpecies(Species.FLORGES).moveset([Moves.GROWL]);
|
game.override.enemySpecies(Species.FLORGES).moveset([Moves.GROWL]);
|
||||||
|
|
||||||
await game.startBattle([Species.RAYQUAZA]);
|
await game.classicMode.startBattle([Species.RAYQUAZA]);
|
||||||
|
|
||||||
game.onNextPrompt("CommandPhase", UiMode.COMMAND, () => {
|
game.onNextPrompt("CommandPhase", UiMode.COMMAND, () => {
|
||||||
const { ui } = game.scene;
|
const { ui } = game.scene;
|
||||||
@ -86,4 +86,41 @@ describe("UI - Type Hints", () => {
|
|||||||
});
|
});
|
||||||
await game.phaseInterceptor.to(CommandPhase);
|
await game.phaseInterceptor.to(CommandPhase);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should show the proper hint for a move in doubles after one of the enemy pokemon flees", async () => {
|
||||||
|
game.override
|
||||||
|
.enemySpecies(Species.ABRA)
|
||||||
|
.moveset([Moves.SPLASH, Moves.SHADOW_BALL, Moves.SOAK])
|
||||||
|
.enemyMoveset([Moves.SPLASH, Moves.TELEPORT])
|
||||||
|
.battleStyle("double");
|
||||||
|
|
||||||
|
await game.classicMode.startBattle([Species.MAGIKARP, Species.MAGIKARP]);
|
||||||
|
game.move.select(Moves.SPLASH);
|
||||||
|
// Use soak to change type of remaining abra to water
|
||||||
|
game.move.select(Moves.SOAK, 1);
|
||||||
|
|
||||||
|
await game.forceEnemyMove(Moves.SPLASH);
|
||||||
|
await game.forceEnemyMove(Moves.TELEPORT);
|
||||||
|
await game.toNextTurn();
|
||||||
|
|
||||||
|
game.onNextPrompt("CommandPhase", UiMode.COMMAND, () => {
|
||||||
|
const { ui } = game.scene;
|
||||||
|
const handler = ui.getHandler<FightUiHandler>();
|
||||||
|
handler.processInput(Button.ACTION); // select "Fight"
|
||||||
|
game.phaseInterceptor.unlock();
|
||||||
|
});
|
||||||
|
|
||||||
|
game.onNextPrompt("CommandPhase", UiMode.FIGHT, () => {
|
||||||
|
const { ui } = game.scene;
|
||||||
|
const movesContainer = ui.getByName<Phaser.GameObjects.Container>(FightUiHandler.MOVES_CONTAINER_NAME);
|
||||||
|
const shadowBallText = movesContainer
|
||||||
|
.getAll<Phaser.GameObjects.Text>()
|
||||||
|
.find(text => text.text === i18next.t("move:shadowBall.name"))! as unknown as MockText;
|
||||||
|
expect.soft(shadowBallText).toBeDefined();
|
||||||
|
|
||||||
|
expect.soft(shadowBallText.color).toBe(undefined);
|
||||||
|
ui.getHandler().processInput(Button.ACTION);
|
||||||
|
});
|
||||||
|
await game.phaseInterceptor.to(CommandPhase);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user