mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-06-30 21:42:20 +02:00
Fixed random issues
This commit is contained in:
parent
7a31c19db2
commit
efda271c48
@ -9,7 +9,7 @@ import type { PostDancingMoveAbAttr } from "#app/data/abilities/ability";
|
|||||||
|
|
||||||
* Callers should refrain from performing non-equality checks on `MoveUseTypes` directly,
|
* Callers should refrain from performing non-equality checks on `MoveUseTypes` directly,
|
||||||
* instead using the available helper functions
|
* instead using the available helper functions
|
||||||
* ({@linkcode isVirtual}, {@linkcode isIgnorePP} and {@linkcode isReflected}).
|
* ({@linkcode isVirtual}, {@linkcode isIgnoreStatus}, {@linkcode isIgnorePP} and {@linkcode isReflected}).
|
||||||
*/
|
*/
|
||||||
export enum MoveUseType {
|
export enum MoveUseType {
|
||||||
/**
|
/**
|
||||||
@ -78,7 +78,7 @@ export enum MoveUseType {
|
|||||||
* @returns Whether {@linkcode useType} is virtual.
|
* @returns Whether {@linkcode useType} is virtual.
|
||||||
* @remarks
|
* @remarks
|
||||||
* This function is equivalent to the following truth table:
|
* This function is equivalent to the following truth table:
|
||||||
|
*
|
||||||
* | Use Type | Returns |
|
* | Use Type | Returns |
|
||||||
* |------------------------------------|---------|
|
* |------------------------------------|---------|
|
||||||
* | {@linkcode MoveUseType.NORMAL} | `false` |
|
* | {@linkcode MoveUseType.NORMAL} | `false` |
|
||||||
@ -91,6 +91,25 @@ export function isVirtual(useType: MoveUseType): boolean {
|
|||||||
return useType >= MoveUseType.INDIRECT
|
return useType >= MoveUseType.INDIRECT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a given {@linkcode MoveUseType} should ignore pre-move cancellation checks.
|
||||||
|
* @param useType - The {@linkcode MoveUseType} to check.
|
||||||
|
* @returns Whether {@linkcode useType} should ignore status checks.
|
||||||
|
* @remarks
|
||||||
|
* This function is equivalent to the following truth table:
|
||||||
|
*
|
||||||
|
* | Use Type | Returns |
|
||||||
|
* |------------------------------------|---------|
|
||||||
|
* | {@linkcode MoveUseType.NORMAL} | `false` |
|
||||||
|
* | {@linkcode MoveUseType.IGNORE_PP} | `false` |
|
||||||
|
* | {@linkcode MoveUseType.INDIRECT} | `false` |
|
||||||
|
* | {@linkcode MoveUseType.FOLLOW_UP} | `true` |
|
||||||
|
* | {@linkcode MoveUseType.REFLECTED} | `true` |
|
||||||
|
*/
|
||||||
|
export function isIgnoreStatus(useType: MoveUseType): boolean {
|
||||||
|
return useType >= MoveUseType.FOLLOW_UP;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a given {@linkcode MoveUseType} should ignore PP.
|
* Check if a given {@linkcode MoveUseType} should ignore PP.
|
||||||
* PP-ignoring moves will ignore normal PP consumption as well as associated failure checks.
|
* PP-ignoring moves will ignore normal PP consumption as well as associated failure checks.
|
||||||
@ -98,7 +117,7 @@ export function isVirtual(useType: MoveUseType): boolean {
|
|||||||
* @returns Whether {@linkcode useType} ignores PP.
|
* @returns Whether {@linkcode useType} ignores PP.
|
||||||
* @remarks
|
* @remarks
|
||||||
* This function is equivalent to the following truth table:
|
* This function is equivalent to the following truth table:
|
||||||
|
*
|
||||||
* | Use Type | Returns |
|
* | Use Type | Returns |
|
||||||
* |------------------------------------|---------|
|
* |------------------------------------|---------|
|
||||||
* | {@linkcode MoveUseType.NORMAL} | `false` |
|
* | {@linkcode MoveUseType.NORMAL} | `false` |
|
||||||
|
@ -162,7 +162,7 @@ export class CommandPhase extends FieldPhase {
|
|||||||
const turnMove: TurnMove | undefined = args.length === 2 ? (args[1] as TurnMove) : undefined;
|
const turnMove: TurnMove | undefined = args.length === 2 ? (args[1] as TurnMove) : undefined;
|
||||||
if (
|
if (
|
||||||
cursor === -1 ||
|
cursor === -1 ||
|
||||||
playerPokemon.trySelectMove(cursor, (args[0] as MoveUseType) >= MoveUseType.IGNORE_PP) ||
|
playerPokemon.trySelectMove(cursor, isIgnorePP(args[0] as MoveUseType)) ||
|
||||||
(useStruggle = cursor > -1 && !playerPokemon.getMoveset().filter(m => m.isUsable(playerPokemon)).length)
|
(useStruggle = cursor > -1 && !playerPokemon.getMoveset().filter(m => m.isUsable(playerPokemon)).length)
|
||||||
) {
|
) {
|
||||||
let moveId: Moves;
|
let moveId: Moves;
|
||||||
|
@ -50,7 +50,7 @@ import { BattlerTagType } from "#enums/battler-tag-type";
|
|||||||
import { Moves } from "#enums/moves";
|
import { Moves } from "#enums/moves";
|
||||||
import { StatusEffect } from "#enums/status-effect";
|
import { StatusEffect } from "#enums/status-effect";
|
||||||
import i18next from "i18next";
|
import i18next from "i18next";
|
||||||
import { isVirtual, isIgnorePP, isReflected, MoveUseType } from "#enums/move-use-type";
|
import { isVirtual, isIgnorePP, isReflected, MoveUseType, isIgnoreStatus } from "#enums/move-use-type";
|
||||||
|
|
||||||
export class MovePhase extends BattlePhase {
|
export class MovePhase extends BattlePhase {
|
||||||
protected _pokemon: Pokemon;
|
protected _pokemon: Pokemon;
|
||||||
@ -234,7 +234,7 @@ export class MovePhase extends BattlePhase {
|
|||||||
*/
|
*/
|
||||||
protected resolvePreMoveStatusEffects(): void {
|
protected resolvePreMoveStatusEffects(): void {
|
||||||
// Skip for follow ups/reflected moves, no status condition or post turn statuses (e.g. Poison/Toxic)
|
// Skip for follow ups/reflected moves, no status condition or post turn statuses (e.g. Poison/Toxic)
|
||||||
if (!this.pokemon.status || this.pokemon.status?.isPostTurn() || this.useType >= MoveUseType.FOLLOW_UP) {
|
if (!this.pokemon.status || this.pokemon.status?.isPostTurn() || isIgnoreStatus(this.useType)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -321,7 +321,7 @@ export class MovePhase extends BattlePhase {
|
|||||||
|
|
||||||
// TODO: does this intentionally happen before the no targets/Moves.NONE on queue cancellation case is checked?
|
// TODO: does this intentionally happen before the no targets/Moves.NONE on queue cancellation case is checked?
|
||||||
// (In other words, check if truant can proc on a move w/o targets)
|
// (In other words, check if truant can proc on a move w/o targets)
|
||||||
if (!isVirtual(this.useType) && this.canMove() && !this.cancelled) {
|
if (!isIgnoreStatus(this.useType) && this.canMove() && !this.cancelled) {
|
||||||
this.pokemon.lapseTags(BattlerTagLapseType.MOVE);
|
this.pokemon.lapseTags(BattlerTagLapseType.MOVE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user