mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-06-29 21:12:45 +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>
42 lines
1.3 KiB
TypeScript
42 lines
1.3 KiB
TypeScript
import { globalScene } from "#app/global-scene";
|
|
import { BattlerIndex } from "#enums/battler-index";
|
|
import type Pokemon from "#app/field/pokemon";
|
|
import { FieldPhase } from "./field-phase";
|
|
|
|
export abstract class PokemonPhase extends FieldPhase {
|
|
/**
|
|
* The battler index this phase refers to, or the pokemon ID if greater than 3.
|
|
* TODO: Make this either use IDs or `BattlerIndex`es, not a weird mix of both
|
|
*/
|
|
protected battlerIndex: BattlerIndex | number;
|
|
public player: boolean;
|
|
public fieldIndex: number;
|
|
|
|
constructor(battlerIndex?: BattlerIndex | number) {
|
|
super();
|
|
|
|
battlerIndex =
|
|
battlerIndex ??
|
|
globalScene
|
|
.getField()
|
|
.find(p => p?.isActive())
|
|
?.getBattlerIndex();
|
|
if (battlerIndex === undefined) {
|
|
// TODO: figure out a suitable fallback behavior
|
|
console.warn("There are no Pokemon on the field!");
|
|
battlerIndex = BattlerIndex.PLAYER;
|
|
}
|
|
|
|
this.battlerIndex = battlerIndex;
|
|
this.player = battlerIndex < 2;
|
|
this.fieldIndex = battlerIndex % 2;
|
|
}
|
|
|
|
getPokemon(): Pokemon {
|
|
if (this.battlerIndex > BattlerIndex.ENEMY_2) {
|
|
return globalScene.getPokemonById(this.battlerIndex)!; //TODO: is this bang correct?
|
|
}
|
|
return globalScene.getField()[this.battlerIndex]!; //TODO: is this bang correct?
|
|
}
|
|
}
|