Test fixes

This commit is contained in:
innerthunder 2024-12-06 20:18:35 -08:00 committed by Sirz Benjie
parent 23ca531534
commit 837d81e1b0
No known key found for this signature in database
GPG Key ID: 4A524B4D196C759E
8 changed files with 28 additions and 29 deletions

View File

@ -1415,16 +1415,10 @@ export default class BattleScene extends SceneBase {
}
updateFieldScale(): Promise<void> {
return new Promise((resolve) => {
const fieldScale =
Math.floor(
Math.pow(
1 /
this.getField(true)
.map((p) => p.getSpriteScale())
.reduce((highestScale: number, scale: number) => (highestScale = Math.max(scale, highestScale)), 0),
0.7,
) * 40,
return new Promise(resolve => {
const fieldScale = Math.floor(Math.pow(1 / this.getField(true)
.map(p => p.getSpriteScale())
.reduce((highestScale: number, scale: number) => highestScale = Math.max(scale, highestScale), 0), 0.7) * 40
) / 40;
this.setFieldScale(fieldScale).then(() => resolve());
});

View File

@ -63,6 +63,7 @@ export class BattleEndPhase extends BattlePhase {
}
}
globalScene.updateModifiers().then(() => this.end());
globalScene.updateModifiers();
this.end();
}
}

View File

@ -44,11 +44,10 @@ export class MoveChargePhase extends PokemonPhase {
new MoveChargeAnim(move.chargeAnim, move.id, user).play(false, () => {
move.showChargeText(user, target);
applyMoveChargeAttrs(MoveEffectAttr, user, target, move).then(() => {
applyMoveChargeAttrs(MoveEffectAttr, user, target, move);
user.addTag(BattlerTagType.CHARGING, 1, move.id, user.id);
this.end();
});
});
}
/** Checks the move's instant charge conditions, then ends this phase. */

View File

@ -22,9 +22,8 @@ export class MoveHeaderPhase extends BattlePhase {
super.start();
if (this.canMove()) {
applyMoveAttrs(MoveHeaderAttr, this.pokemon, null, this.move.getMove()).then(() => this.end());
} else {
applyMoveAttrs(MoveHeaderAttr, this.pokemon, null, this.move.getMove());
}
this.end();
}
}
}

View File

@ -29,6 +29,10 @@ export class PokemonTransformPhase extends PokemonPhase {
return this.end();
}
user.summonData.speciesForm = target.getSpeciesForm();
user.summonData.ability = target.getAbility().id;
user.summonData.gender = target.getGender();
// Power Trick's effect is removed after using Transform
user.removeTag(BattlerTagType.POWER_TRICK);

View File

@ -391,7 +391,7 @@ describe("Abilities - Unburden", () => {
await game.forceEnemyMove(Moves.THIEF, BattlerIndex.PLAYER);
await game.forceEnemyMove(Moves.SPLASH);
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2 ]);
game.doSelectPartyPokemon(0, "MoveEffectPhase");
game.doSelectPartyPokemon(0, "RevivalBlessingPhase");
await game.toNextTurn();
expect(game.scene.getPlayerField()[0]).toBe(treecko);

View File

@ -123,8 +123,6 @@ describe("Dancing Lessons - Mystery Encounter", () => {
partyLead.level = 1000;
partyLead.calculateStats();
await runMysteryEncounterToEnd(game, 1, undefined, true);
// For some reason updateModifiers breaks in this test and does not resolve promise
vi.spyOn(game.scene, "updateModifiers").mockImplementation(() => new Promise(resolve => resolve()));
await skipBattleRunMysteryEncounterRewardsPhase(game);
await game.phaseInterceptor.to(SelectModifierPhase, false);
expect(scene.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);

View File

@ -60,6 +60,7 @@ import { RibbonModifierRewardPhase } from "#app/phases/ribbon-modifier-reward-ph
import { GameOverModifierRewardPhase } from "#app/phases/game-over-modifier-reward-phase";
import { UnlockPhase } from "#app/phases/unlock-phase";
import { PostGameOverPhase } from "#app/phases/post-game-over-phase";
import { RevivalBlessingPhase } from "#app/phases/revival-blessing-phase";
export interface PromptHandler {
phaseTarget?: string;
@ -126,7 +127,8 @@ type PhaseClass =
| typeof EncounterPhase
| typeof GameOverPhase
| typeof UnlockPhase
| typeof PostGameOverPhase;
| typeof PostGameOverPhase
| typeof RevivalBlessingPhase;
type PhaseString =
| "LoginPhase"
@ -185,7 +187,8 @@ type PhaseString =
| "EncounterPhase"
| "GameOverPhase"
| "UnlockPhase"
| "PostGameOverPhase";
| "PostGameOverPhase"
| "RevivalBlessingPhase";
type PhaseInterceptorPhase = PhaseClass | PhaseString;
@ -269,6 +272,7 @@ export default class PhaseInterceptor {
[ GameOverPhase, this.startPhase ],
[ UnlockPhase, this.startPhase ],
[ PostGameOverPhase, this.startPhase ],
[ RevivalBlessingPhase, this.startPhase ],
];
private endBySetMode = [
@ -511,11 +515,11 @@ export default class PhaseInterceptor {
if (expireFn) {
this.prompts.shift();
} else if (
currentMode === actionForNextPrompt.mode
&& currentPhase === actionForNextPrompt.phaseTarget
&& currentHandler.active
&& (!actionForNextPrompt.awaitingActionInput
|| (actionForNextPrompt.awaitingActionInput && currentHandler.awaitingActionInput))
currentMode === actionForNextPrompt.mode &&
currentPhase === actionForNextPrompt.phaseTarget &&
currentHandler.active &&
(!actionForNextPrompt.awaitingActionInput ||
(actionForNextPrompt.awaitingActionInput && currentHandler.awaitingActionInput))
) {
const prompt = this.prompts.shift();
if (prompt?.callback) {