Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Misc] Rename DamagePhase to DamageAnimPhase #4880

Open
wants to merge 2 commits into
base: beta
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/field/pokemon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import { Biome } from "#enums/biome";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import { getPokemonNameWithAffix } from "#app/messages";
import { DamagePhase } from "#app/phases/damage-phase";
import { DamageAnimPhase } from "#app/phases/damage-anim-phase";
import { FaintPhase } from "#app/phases/faint-phase";
import { LearnMovePhase } from "#app/phases/learn-move-phase";
import { MoveEffectPhase } from "#app/phases/move-effect-phase";
Expand Down Expand Up @@ -2996,7 +2996,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
* @returns integer of damage done
*/
damageAndUpdate(damage: integer, result?: DamageResult, critical: boolean = false, ignoreSegments: boolean = false, preventEndure: boolean = false, ignoreFaintPhase: boolean = false, source?: Pokemon): integer {
const damagePhase = new DamagePhase(this.scene, this.getBattlerIndex(), damage, result as DamageResult, critical);
const damagePhase = new DamageAnimPhase(this.scene, this.getBattlerIndex(), damage, result as DamageResult, critical);
this.scene.unshiftPhase(damagePhase);
damage = this.damage(damage, ignoreSegments, preventEndure, ignoreFaintPhase);
// Damage amount may have changed, but needed to be queued before calling damage function
Expand Down
16 changes: 8 additions & 8 deletions src/phases/damage-phase.ts → src/phases/damage-anim-phase.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import BattleScene from "#app/battle-scene";
import { BattlerIndex } from "#app/battle";
import { BattleSpec } from "#app/enums/battle-spec";
import { DamageResult, HitResult } from "#app/field/pokemon";
import * as Utils from "#app/utils";
import { PokemonPhase } from "./pokemon-phase";
import type BattleScene from "#app/battle-scene";
import { type BattlerIndex } from "#app/battle";
import { BattleSpec } from "#enums/battle-spec";
import { type DamageResult, HitResult } from "#app/field/pokemon";
import { fixedInt } from "#app/utils";
Comment on lines +1 to +4
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the types here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type-only imports are not added to the transpiled js. All imports should be type-only when they are only used as type hints (btw VSCode users, enable "prefer type only imports" from your settings which for some insane reason isn't enabled by default).

import { PokemonPhase } from "#app/phases/pokemon-phase";

export class DamagePhase extends PokemonPhase {
export class DamageAnimPhase extends PokemonPhase {
private amount: integer;
private damageResult: DamageResult;
private critical: boolean;
Expand All @@ -25,7 +25,7 @@ export class DamagePhase extends PokemonPhase {
if (this.scene.moveAnimations) {
this.scene.toggleInvert(true);
}
this.scene.time.delayedCall(Utils.fixedInt(1000), () => {
this.scene.time.delayedCall(fixedInt(1000), () => {
this.scene.toggleInvert(false);
this.applyDamage();
});
Expand Down
4 changes: 2 additions & 2 deletions src/phases/faint-phase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { getPokemonNameWithAffix } from "#app/messages";
import { PokemonInstantReviveModifier } from "#app/modifier/modifier";
import { SwitchType } from "#enums/switch-type";
import i18next from "i18next";
import { DamagePhase } from "./damage-phase";
import { DamageAnimPhase } from "./damage-anim-phase";
import { GameOverPhase } from "./game-over-phase";
import { PokemonPhase } from "./pokemon-phase";
import { SwitchPhase } from "./switch-phase";
Expand Down Expand Up @@ -206,7 +206,7 @@ export class FaintPhase extends PokemonPhase {
} else {
// Final boss' HP threshold has been bypassed; cancel faint and force check for 2nd phase
enemy.hp++;
this.scene.unshiftPhase(new DamagePhase(this.scene, enemy.getBattlerIndex(), 0, HitResult.OTHER));
this.scene.unshiftPhase(new DamageAnimPhase(this.scene, enemy.getBattlerIndex(), 0, HitResult.OTHER));
this.end();
}
return true;
Expand Down
4 changes: 2 additions & 2 deletions src/test/abilities/forecast.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { BattlerIndex } from "#app/battle";
import { allAbilities } from "#app/data/ability";
import { Abilities } from "#app/enums/abilities";
import { WeatherType } from "#app/enums/weather-type";
import { DamagePhase } from "#app/phases/damage-phase";
import { DamageAnimPhase } from "#app/phases/damage-anim-phase";
import { MovePhase } from "#app/phases/move-phase";
import { PostSummonPhase } from "#app/phases/post-summon-phase";
import { QuietFormChangePhase } from "#app/phases/quiet-form-change-phase";
Expand Down Expand Up @@ -273,7 +273,7 @@ describe("Abilities - Forecast", () => {
const castform = game.scene.getPlayerPokemon()!;

// Damage phase should come first
await game.phaseInterceptor.to(DamagePhase);
await game.phaseInterceptor.to(DamageAnimPhase);
expect(castform.hp).toBeLessThan(castform.getMaxHp());

// Then change form
Expand Down
6 changes: 3 additions & 3 deletions src/test/abilities/hustle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe("Abilities - Hustle", () => {

game.move.select(Moves.TACKLE);
await game.move.forceHit();
await game.phaseInterceptor.to("DamagePhase");
await game.phaseInterceptor.to("DamageAnimPhase");

expect(pikachu.getEffectiveStat).toHaveReturnedWith(Math.floor(atk * 1.5));
});
Expand All @@ -68,7 +68,7 @@ describe("Abilities - Hustle", () => {
vi.spyOn(pikachu, "getAccuracyMultiplier");

game.move.select(Moves.GIGA_DRAIN);
await game.phaseInterceptor.to("DamagePhase");
await game.phaseInterceptor.to("DamageAnimPhase");

expect(pikachu.getEffectiveStat).toHaveReturnedWith(spatk);
expect(pikachu.getAccuracyMultiplier).toHaveReturnedWith(1);
Expand All @@ -86,7 +86,7 @@ describe("Abilities - Hustle", () => {
vi.spyOn(allMoves[Moves.FISSURE], "calculateBattleAccuracy");

game.move.select(Moves.FISSURE);
await game.phaseInterceptor.to("DamagePhase");
await game.phaseInterceptor.to("DamageAnimPhase");

expect(enemyPokemon.turnData.damageTaken).toBe(enemyPokemon.getMaxHp());
expect(pikachu.getAccuracyMultiplier).toHaveReturnedWith(1);
Expand Down
24 changes: 12 additions & 12 deletions src/test/abilities/parental_bond.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe("Abilities - Parental Bond", () => {

game.move.select(Moves.TACKLE);

await game.phaseInterceptor.to("DamagePhase");
await game.phaseInterceptor.to("DamageAnimPhase");
const firstStrikeDamage = enemyStartingHp - enemyPokemon.hp;
enemyStartingHp = enemyPokemon.hp;

Expand Down Expand Up @@ -129,7 +129,7 @@ describe("Abilities - Parental Bond", () => {

game.move.select(Moves.SELF_DESTRUCT);

await game.phaseInterceptor.to("DamagePhase", false);
await game.phaseInterceptor.to("DamageAnimPhase", false);

expect(leadPokemon.turnData.hitCount).toBe(1);
}
Expand All @@ -147,7 +147,7 @@ describe("Abilities - Parental Bond", () => {
game.move.select(Moves.ROLLOUT);
await game.move.forceHit();

await game.phaseInterceptor.to("DamagePhase", false);
await game.phaseInterceptor.to("DamageAnimPhase", false);

expect(leadPokemon.turnData.hitCount).toBe(1);
}
Expand Down Expand Up @@ -181,7 +181,7 @@ describe("Abilities - Parental Bond", () => {
const enemyPokemon = game.scene.getEnemyPokemon()!;

game.move.select(Moves.COUNTER);
await game.phaseInterceptor.to("DamagePhase");
await game.phaseInterceptor.to("DamageAnimPhase");

const playerDamage = leadPokemon.getMaxHp() - leadPokemon.hp;

Expand Down Expand Up @@ -221,7 +221,7 @@ describe("Abilities - Parental Bond", () => {
const leadPokemon = game.scene.getPlayerPokemon()!;

game.move.select(Moves.EARTHQUAKE);
await game.phaseInterceptor.to("DamagePhase", false);
await game.phaseInterceptor.to("DamageAnimPhase", false);

expect(leadPokemon.turnData.hitCount).toBe(2);
}
Expand All @@ -238,7 +238,7 @@ describe("Abilities - Parental Bond", () => {

game.move.select(Moves.MIND_BLOWN);

await game.phaseInterceptor.to("DamagePhase", false);
await game.phaseInterceptor.to("DamageAnimPhase", false);

expect(leadPokemon.turnData.hitCount).toBe(2);

Expand Down Expand Up @@ -285,7 +285,7 @@ describe("Abilities - Parental Bond", () => {

game.move.select(Moves.TACKLE);

await game.phaseInterceptor.to("DamagePhase");
await game.phaseInterceptor.to("DamageAnimPhase");

expect(leadPokemon.turnData.hitCount).toBe(3);
}
Expand All @@ -307,7 +307,7 @@ describe("Abilities - Parental Bond", () => {
game.move.select(Moves.SEISMIC_TOSS);
await game.move.forceHit();

await game.phaseInterceptor.to("DamagePhase");
await game.phaseInterceptor.to("DamageAnimPhase");

expect(leadPokemon.turnData.hitCount).toBe(3);

Expand All @@ -329,7 +329,7 @@ describe("Abilities - Parental Bond", () => {
game.move.select(Moves.HYPER_BEAM);
await game.move.forceHit();

await game.phaseInterceptor.to("DamagePhase");
await game.phaseInterceptor.to("DamageAnimPhase");

expect(leadPokemon.turnData.hitCount).toBe(2);
expect(leadPokemon.getTag(BattlerTagType.RECHARGING)).toBeUndefined();
Expand All @@ -353,7 +353,7 @@ describe("Abilities - Parental Bond", () => {
game.move.select(Moves.ANCHOR_SHOT);
await game.move.forceHit();

await game.phaseInterceptor.to("DamagePhase");
await game.phaseInterceptor.to("DamageAnimPhase");

expect(leadPokemon.turnData.hitCount).toBe(2);
expect(enemyPokemon.getTag(BattlerTagType.TRAPPED)).toBeUndefined();
Expand All @@ -380,7 +380,7 @@ describe("Abilities - Parental Bond", () => {
game.move.select(Moves.SMACK_DOWN);
await game.move.forceHit();

await game.phaseInterceptor.to("DamagePhase");
await game.phaseInterceptor.to("DamageAnimPhase");

expect(leadPokemon.turnData.hitCount).toBe(2);
expect(enemyPokemon.getTag(BattlerTagType.IGNORE_FLYING)).toBeUndefined();
Expand Down Expand Up @@ -424,7 +424,7 @@ describe("Abilities - Parental Bond", () => {
game.move.select(Moves.WAKE_UP_SLAP);
await game.move.forceHit();

await game.phaseInterceptor.to("DamagePhase");
await game.phaseInterceptor.to("DamageAnimPhase");

expect(leadPokemon.turnData.hitCount).toBe(2);
expect(enemyPokemon.status?.effect).toBe(StatusEffect.SLEEP);
Expand Down
16 changes: 10 additions & 6 deletions src/test/abilities/speed_boost.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ describe("Abilities - Speed Boost", () => {

game.override
.battleType("single")
.enemySpecies(Species.DRAGAPULT)
.enemySpecies(Species.SHUCKLE)
.enemyAbility(Abilities.BALL_FETCH)
.enemyLevel(100)
.ability(Abilities.SPEED_BOOST)
.enemyMoveset(Moves.SPLASH)
.moveset([ Moves.SPLASH, Moves.U_TURN ]);
Expand Down Expand Up @@ -70,21 +72,23 @@ describe("Abilities - Speed Boost", () => {
Species.NINJASK
]);

const [ shuckle, ninjask ] = game.scene.getPlayerParty();

game.move.select(Moves.U_TURN);
game.doSelectPartyPokemon(1);
await game.toNextTurn();
let playerPokemon = game.scene.getPlayerPokemon()!;
expect(playerPokemon.getStatStage(Stat.SPD)).toBe(0);
expect(game.scene.getPlayerPokemon()!).toBe(ninjask);
expect(ninjask.getStatStage(Stat.SPD)).toBe(0);

game.move.select(Moves.U_TURN);
game.doSelectPartyPokemon(1);
await game.toNextTurn();
playerPokemon = game.scene.getPlayerPokemon()!;
expect(playerPokemon.getStatStage(Stat.SPD)).toBe(0);
expect(game.scene.getPlayerPokemon()!).toBe(shuckle);
expect(shuckle.getStatStage(Stat.SPD)).toBe(0);

game.move.select(Moves.SPLASH);
await game.toNextTurn();
expect(playerPokemon.getStatStage(Stat.SPD)).toBe(1);
expect(shuckle.getStatStage(Stat.SPD)).toBe(1);
});

it("should not trigger this turn if pokemon was switched into combat via normal switch, but the turn after",
Expand Down
6 changes: 3 additions & 3 deletions src/test/abilities/sturdy.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EnemyPokemon } from "#app/field/pokemon";
import { DamagePhase } from "#app/phases/damage-phase";
import { DamageAnimPhase } from "#app/phases/damage-anim-phase";
import { MoveEndPhase } from "#app/phases/move-end-phase";
import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves";
Expand Down Expand Up @@ -55,7 +55,7 @@ describe("Abilities - Sturdy", () => {
enemyPokemon.hp = enemyPokemon.getMaxHp() - 1;

game.move.select(Moves.CLOSE_COMBAT);
await game.phaseInterceptor.to(DamagePhase);
await game.phaseInterceptor.to(DamageAnimPhase);

expect(enemyPokemon.hp).toBe(0);
expect(enemyPokemon.isFainted()).toBe(true);
Expand All @@ -81,7 +81,7 @@ describe("Abilities - Sturdy", () => {

await game.startBattle();
game.move.select(Moves.CLOSE_COMBAT);
await game.phaseInterceptor.to(DamagePhase);
await game.phaseInterceptor.to(DamageAnimPhase);

const enemyPokemon: EnemyPokemon = game.scene.getEnemyParty()[0];
expect(enemyPokemon.hp).toBe(0);
Expand Down
4 changes: 2 additions & 2 deletions src/test/battle/battle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Stat } from "#enums/stat";
import { GameModes, getGameMode } from "#app/game-mode";
import { BattleEndPhase } from "#app/phases/battle-end-phase";
import { CommandPhase } from "#app/phases/command-phase";
import { DamagePhase } from "#app/phases/damage-phase";
import { DamageAnimPhase } from "#app/phases/damage-anim-phase";
import { EncounterPhase } from "#app/phases/encounter-phase";
import { EnemyCommandPhase } from "#app/phases/enemy-command-phase";
import { LoginPhase } from "#app/phases/login-phase";
Expand Down Expand Up @@ -267,7 +267,7 @@ describe("Test Battle Phase", () => {
]);

game.move.select(moveToUse);
await game.phaseInterceptor.to(DamagePhase, false);
await game.phaseInterceptor.to(DamageAnimPhase, false);
await game.killPokemon(game.scene.currentBattle.enemyParty[0]);
expect(game.scene.currentBattle.enemyParty[0].isFainted()).toBe(true);
await game.phaseInterceptor.to(VictoryPhase, false);
Expand Down
2 changes: 1 addition & 1 deletion src/test/battle/damage_calculation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ describe("Battle Mechanics - Damage Calculation", () => {

game.move.select(Moves.JUMP_KICK);

await game.phaseInterceptor.to("DamagePhase");
await game.phaseInterceptor.to("DamageAnimPhase");

expect(shedinja.hp).toBe(shedinja.getMaxHp() - 1);
});
Expand Down
4 changes: 2 additions & 2 deletions src/test/items/leftovers.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DamagePhase } from "#app/phases/damage-phase";
import { DamageAnimPhase } from "#app/phases/damage-anim-phase";
import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves";
Expand Down Expand Up @@ -48,7 +48,7 @@ describe("Items - Leftovers", () => {
game.move.select(Moves.SPLASH);

// We should have less hp after the attack
await game.phaseInterceptor.to(DamagePhase, false);
await game.phaseInterceptor.to(DamageAnimPhase, false);
expect(leadPokemon.hp).toBeLessThan(leadPokemon.getMaxHp());

const leadHpAfterDamage = leadPokemon.hp;
Expand Down
Loading
Loading