mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-06-21 00:52:47 +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>
150 lines
6.6 KiB
TypeScript
150 lines
6.6 KiB
TypeScript
import type { PostDancingMoveAbAttr } from "#app/data/abilities/ability";
|
|
import type { BattlerTagLapseType } from "#enums/battler-tag-lapse-type";
|
|
|
|
/**
|
|
* Enum representing all the possible means through which a given move can be executed.
|
|
* Each one inherits the properties (or exclusions) of all types preceding it.
|
|
* Properties newly found on a given use mode will be **bolded**,
|
|
* while oddities breaking a previous trend will be listed in _italics_.
|
|
|
|
* Callers should refrain from performing non-equality checks on `MoveUseMode`s directly,
|
|
* instead using the available helper functions
|
|
* ({@linkcode isVirtual}, {@linkcode isIgnoreStatus}, {@linkcode isIgnorePP} and {@linkcode isReflected}).
|
|
*/
|
|
export const MoveUseMode = {
|
|
/**
|
|
* This move was used normally (i.e. clicking on the button) or called via Instruct.
|
|
* It deducts PP from the user's moveset (failing if out of PP), and interacts normally with other moves and abilities.
|
|
*/
|
|
NORMAL: 1,
|
|
|
|
/**
|
|
* This move was called by an effect that ignores PP, such as a consecutively executed move (e.g. Outrage).
|
|
*
|
|
* PP-ignoring moves (as their name implies) **do not consume PP** when used
|
|
* and **will not fail** if none is left prior to execution.
|
|
* All other effects remain identical to {@linkcode MoveUseMode.NORMAL}.
|
|
*
|
|
* PP can still be reduced by other effects (such as Spite or Eerie Spell).
|
|
*/
|
|
IGNORE_PP: 2,
|
|
|
|
/**
|
|
* This move was called indirectly by an out-of-turn effect other than Instruct or the user's previous move.
|
|
* Currently only used by {@linkcode PostDancingMoveAbAttr | Dancer}.
|
|
*
|
|
* Indirect moves ignore PP checks similar to {@linkcode MoveUseMode.IGNORE_PP}, but additionally **cannot be copied**
|
|
* by all move-copying effects (barring reflection).
|
|
* They are also **"skipped over" by most moveset and move history-related effects** (PP reduction, Last Resort, etc).
|
|
*
|
|
* They still respect the user's volatile status conditions and confusion (though will uniquely _cure freeze and sleep before use_).
|
|
*/
|
|
INDIRECT: 3,
|
|
|
|
/**
|
|
* This move was called as part of another move's effect (such as for most {@link https://bulbapedia.bulbagarden.net/wiki/Category:Moves_that_call_other_moves | Move-calling moves}).
|
|
|
|
* Follow-up moves **bypass cancellation** from all **non-volatile status conditions** and **{@linkcode BattlerTagLapseType.MOVE}-type effects**
|
|
* (having been checked already on the calling move).
|
|
|
|
* They are _not ignored_ by other move-calling moves and abilities (unlike {@linkcode MoveUseMode.FOLLOW_UP} and {@linkcode MoveUseMode.REFLECTED}),
|
|
* but still inherit the former's disregard for moveset-related effects.
|
|
*/
|
|
FOLLOW_UP: 4,
|
|
|
|
/**
|
|
* This move was reflected by Magic Coat or Magic Bounce.
|
|
|
|
* Reflected moves ignore all the same cancellation checks as {@linkcode MoveUseMode.INDIRECT}
|
|
* and retain the same copy prevention as {@linkcode MoveUseMode.FOLLOW_UP}, but additionally
|
|
* **cannot be reflected by other reflecting effects**.
|
|
*/
|
|
REFLECTED: 5
|
|
// TODO: Add use type TRANSPARENT for Future Sight and Doom Desire to prevent move history pushing
|
|
} as const;
|
|
|
|
export type MoveUseMode = (typeof MoveUseMode)[keyof typeof MoveUseMode];
|
|
|
|
// # HELPER FUNCTIONS
|
|
// Please update the markdown tables if any new `MoveUseMode`s get added.
|
|
|
|
/**
|
|
* Check if a given {@linkcode MoveUseMode} is virtual (i.e. called by another move or effect).
|
|
* Virtual moves are ignored by most moveset-related effects due to not being executed directly.
|
|
* @returns Whether {@linkcode useMode} is virtual.
|
|
* @remarks
|
|
* This function is equivalent to the following truth table:
|
|
*
|
|
* | Use Type | Returns |
|
|
* |------------------------------------|---------|
|
|
* | {@linkcode MoveUseMode.NORMAL} | `false` |
|
|
* | {@linkcode MoveUseMode.IGNORE_PP} | `false` |
|
|
* | {@linkcode MoveUseMode.INDIRECT} | `true` |
|
|
* | {@linkcode MoveUseMode.FOLLOW_UP} | `true` |
|
|
* | {@linkcode MoveUseMode.REFLECTED} | `true` |
|
|
*/
|
|
export function isVirtual(useMode: MoveUseMode): boolean {
|
|
return useMode >= MoveUseMode.INDIRECT
|
|
}
|
|
|
|
/**
|
|
* Check if a given {@linkcode MoveUseMode} should ignore pre-move cancellation checks
|
|
* from {@linkcode StatusEffect.PARALYSIS} and {@linkcode BattlerTagLapseType.MOVE}-type effects.
|
|
* @param useMode - The {@linkcode MoveUseMode} to check.
|
|
* @returns Whether {@linkcode useMode} should ignore status and otehr cancellation checks.
|
|
* @remarks
|
|
* This function is equivalent to the following truth table:
|
|
*
|
|
* | Use Type | Returns |
|
|
* |------------------------------------|---------|
|
|
* | {@linkcode MoveUseMode.NORMAL} | `false` |
|
|
* | {@linkcode MoveUseMode.IGNORE_PP} | `false` |
|
|
* | {@linkcode MoveUseMode.INDIRECT} | `false` |
|
|
* | {@linkcode MoveUseMode.FOLLOW_UP} | `true` |
|
|
* | {@linkcode MoveUseMode.REFLECTED} | `true` |
|
|
*/
|
|
export function isIgnoreStatus(useMode: MoveUseMode): boolean {
|
|
return useMode >= MoveUseMode.FOLLOW_UP;
|
|
}
|
|
|
|
/**
|
|
* Check if a given {@linkcode MoveUseMode} should ignore PP.
|
|
* PP-ignoring moves will ignore normal PP consumption as well as associated failure checks.
|
|
* @param useMode - The {@linkcode MoveUseMode} to check.
|
|
* @returns Whether {@linkcode useMode} ignores PP.
|
|
* @remarks
|
|
* This function is equivalent to the following truth table:
|
|
*
|
|
* | Use Type | Returns |
|
|
* |------------------------------------|---------|
|
|
* | {@linkcode MoveUseMode.NORMAL} | `false` |
|
|
* | {@linkcode MoveUseMode.IGNORE_PP} | `true` |
|
|
* | {@linkcode MoveUseMode.INDIRECT} | `true` |
|
|
* | {@linkcode MoveUseMode.FOLLOW_UP} | `true` |
|
|
* | {@linkcode MoveUseMode.REFLECTED} | `true` |
|
|
*/
|
|
export function isIgnorePP(useMode: MoveUseMode): boolean {
|
|
return useMode >= MoveUseMode.IGNORE_PP;
|
|
}
|
|
|
|
/**
|
|
* Check if a given {@linkcode MoveUseMode} is reflected.
|
|
* Reflected moves cannot be reflected, copied, or cancelled by status effects,
|
|
* nor will they trigger {@linkcode PostDancingMoveAbAttr | Dancer}.
|
|
* @param useMode - The {@linkcode MoveUseMode} to check.
|
|
* @returns Whether {@linkcode useMode} is reflected.
|
|
* @remarks
|
|
* This function is equivalent to the following truth table:
|
|
*
|
|
* | Use Type | Returns |
|
|
* |------------------------------------|---------|
|
|
* | {@linkcode MoveUseMode.NORMAL} | `false` |
|
|
* | {@linkcode MoveUseMode.IGNORE_PP} | `false` |
|
|
* | {@linkcode MoveUseMode.INDIRECT} | `false` |
|
|
* | {@linkcode MoveUseMode.FOLLOW_UP} | `false` |
|
|
* | {@linkcode MoveUseMode.REFLECTED} | `true` |
|
|
*/
|
|
export function isReflected(useMode: MoveUseMode): boolean {
|
|
return useMode === MoveUseMode.REFLECTED;
|
|
}
|