mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-06-29 13:02:46 +02:00
* Added `MoveUseType` and refactored MEP * Fixed Wimp out tests & ME code finally i think all the booleans are gone i hope * Added version migration for last resort and co. buh gumbug * Fixed various bugs and added tests for previous bugfixes * Reverted a couple doc changes * WIP * Update pokemon-species.ts Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * Update pokemon-phase.ts Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * Fixed remaining tests (I think) * Reverted rollout test changes * Fixed command phase bug causing metronome test timeout * Revert early_bird.test.ts * Fix biome.jsonc * Made `MoveUseType` start at 1 As per @DayKev's request * Fixed a thing * Fixed bolt beak condition to be marginally less jank * Applied some review suggestions * Reverted move phase operations * Added helper functions complete with markdown tables * Fixed things * Update battler-tags.ts * Fixed random issues * Fixed code * Fixed comment * Fixed import issues * Fix disable.test.ts conflicts * Update instruct.test.ts * Update `biome.jsonc` * Renamed `MoveUseType` to `MoveUseMode`; applied review comments * Fixed space * Fixed phasemanager bugs * Fixed instruct test to not bork * Fixed gorilla tactics bug * Battler Tags doc fixes * Fixed formatting and suttff * Minor comment updates and remove unused imports in `move.ts` * Re-add `public`, remove unnecessary default value in `battler-tags.ts` * Restore `{}` in `turn-start-phase.ts` Fixes `lint/correctness/noSwitchDeclarations` * Remove extra space in TSDoc in `move-phase.ts` * Use `game.field` instead of `game.scene` in `instruct.test.ts` Also `game.toEndOfTurn()` instead of `game.phaseInterceptor.to("BerryPhase")` * Use `game.field` instead of `game.scene` in `metronome.test.ts` * Use `toEndOfTurn()` instead of `to("BerryPhase")` in `powder.test.ts` * Convert `MoveUseMode` enum to `const` object * Update move-phase.ts Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * Add `enumValueToKey` utility function * Apply Biome --------- Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
88 lines
2.8 KiB
TypeScript
88 lines
2.8 KiB
TypeScript
import type { BattlerIndex } from "#enums/battler-index";
|
|
import { BattlerTagType } from "#enums/battler-tag-type";
|
|
import { MoveId } from "#enums/move-id";
|
|
import { EFFECTIVE_STATS, BATTLE_STATS } from "#enums/stat";
|
|
import { PokemonMove } from "#app/data/moves/pokemon-move";
|
|
import { globalScene } from "#app/global-scene";
|
|
import { PokemonPhase } from "./pokemon-phase";
|
|
import { getPokemonNameWithAffix } from "#app/messages";
|
|
import i18next from "i18next";
|
|
|
|
/**
|
|
* Transforms a Pokemon into another Pokemon on the field.
|
|
* Used for Transform (move) and Imposter (ability)
|
|
*/
|
|
export class PokemonTransformPhase extends PokemonPhase {
|
|
public readonly phaseName = "PokemonTransformPhase";
|
|
protected targetIndex: BattlerIndex;
|
|
private playSound: boolean;
|
|
|
|
constructor(userIndex: BattlerIndex, targetIndex: BattlerIndex, playSound = false) {
|
|
super(userIndex);
|
|
|
|
this.targetIndex = targetIndex;
|
|
this.playSound = playSound;
|
|
}
|
|
|
|
public override start(): void {
|
|
const user = this.getPokemon();
|
|
const target = globalScene.getField(true).find(p => p.getBattlerIndex() === this.targetIndex);
|
|
|
|
if (!target) {
|
|
this.end();
|
|
return;
|
|
}
|
|
|
|
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);
|
|
|
|
// Copy all stats (except HP)
|
|
for (const s of EFFECTIVE_STATS) {
|
|
user.setStat(s, target.getStat(s, false), false);
|
|
}
|
|
|
|
// Copy all stat stages
|
|
for (const s of BATTLE_STATS) {
|
|
user.setStatStage(s, target.getStatStage(s));
|
|
}
|
|
|
|
user.summonData.moveset = target.getMoveset().map(m => {
|
|
if (m) {
|
|
// If PP value is less than 5, do nothing. If greater, we need to reduce the value to 5.
|
|
return new PokemonMove(m.moveId, 0, 0, Math.min(m.getMove().pp, 5));
|
|
}
|
|
console.warn(`Transform: somehow iterating over a ${m} value when copying moveset!`);
|
|
return new PokemonMove(MoveId.NONE);
|
|
});
|
|
user.summonData.types = target.getTypes();
|
|
|
|
const promises = [user.updateInfo()];
|
|
|
|
if (this.playSound) {
|
|
globalScene.playSound("battle_anims/PRSFX- Transform");
|
|
}
|
|
|
|
globalScene.phaseManager.queueMessage(
|
|
i18next.t("abilityTriggers:postSummonTransform", {
|
|
pokemonNameWithAffix: getPokemonNameWithAffix(user),
|
|
targetName: target.name,
|
|
}),
|
|
);
|
|
|
|
promises.push(
|
|
user.loadAssets(false).then(() => {
|
|
user.playAnim();
|
|
user.updateInfo();
|
|
// If the new ability activates immediately, it needs to happen after all the transform animations
|
|
user.setTempAbility(target.getAbility());
|
|
}),
|
|
);
|
|
|
|
Promise.allSettled(promises).then(() => this.end());
|
|
}
|
|
}
|