mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-09-24 07:23:24 +02:00
Merge branch 'turn-manager-no-queue-phase' of github.com:emdeann/pokerogue into turn-manager-no-queue-phase
This commit is contained in:
commit
f336968019
@ -3557,8 +3557,8 @@ export class GrudgeTag extends SerializableBattlerTag {
|
||||
|
||||
/**
|
||||
* Tag to allow the affected Pokemon's move to go first in its priority bracket.
|
||||
* Used for {@link https://bulbapedia.bulbagarden.net/wiki/Quick_Draw_(Ability) Quick Draw}
|
||||
* and {@link https://bulbapedia.bulbagarden.net/wiki/Quick_Claw Quick Claw}.
|
||||
* Used for {@link https://bulbapedia.bulbagarden.net/wiki/Quick_Draw_(Ability) | Quick Draw}
|
||||
* and {@link https://bulbapedia.bulbagarden.net/wiki/Quick_Claw | Quick Claw}.
|
||||
*/
|
||||
export class BypassSpeedTag extends BattlerTag {
|
||||
public override readonly tagType = BattlerTagType.BYPASS_SPEED;
|
||||
@ -3569,7 +3569,7 @@ export class BypassSpeedTag extends BattlerTag {
|
||||
|
||||
override canAdd(pokemon: Pokemon): boolean {
|
||||
const bypass = new BooleanHolder(true);
|
||||
applyAbAttrs("PreventBypassSpeedChanceAbAttr", { pokemon: pokemon, bypass: bypass });
|
||||
applyAbAttrs("PreventBypassSpeedChanceAbAttr", { pokemon, bypass });
|
||||
return bypass.value;
|
||||
}
|
||||
}
|
||||
|
@ -888,7 +888,7 @@ export abstract class Move implements Localizable {
|
||||
applyMoveAttrs("IncrementMovePriorityAttr", user, null, this, priority);
|
||||
applyAbAttrs("ChangeMovePriorityAbAttr", {pokemon: user, simulated, move: this, priority});
|
||||
|
||||
if (!isNullOrUndefined(user.getTag(BattlerTagType.BYPASS_SPEED))) {
|
||||
if (user.getTag(BattlerTagType.BYPASS_SPEED)) {
|
||||
priority.value += 0.2;
|
||||
}
|
||||
|
||||
|
@ -375,7 +375,7 @@ export class PhaseManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if there is a queued {@linkcode Phase} meeting the conditions
|
||||
* Determine if there is a queued {@linkcode Phase} meeting the specified conditions.
|
||||
* @param type - The {@linkcode PhaseString | type} of phase to search for
|
||||
* @param condition - An optional {@linkcode PhaseConditionFunc} to add conditions to the search
|
||||
* @returns `true` if a matching phase exists, `false` otherwise
|
||||
@ -385,7 +385,7 @@ export class PhaseManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds and removes a single queued {@linkcode Phase}
|
||||
* Attempt to find and remove the first queued {@linkcode Phase} matching the given conditions.
|
||||
* @param type - The {@linkcode PhaseString | type} of phase to search for
|
||||
* @param phaseFilter - A {@linkcode PhaseConditionFunc} to specify conditions for the phase
|
||||
* @returns `true` if a removal occurred, `false` otherwise
|
||||
|
@ -34,12 +34,13 @@ export class PhaseTree {
|
||||
/**
|
||||
* Adds a {@linkcode Phase} to the specified level
|
||||
* @param phase - The phase to add
|
||||
* @param level - The numeric level to add the phase. Must be within legal bounds
|
||||
* @param level - The numeric level to add the phase
|
||||
* @throws Error if `level` is out of legal bounds
|
||||
*/
|
||||
private add(phase: Phase, level: number): void {
|
||||
const addLevel = this.levels[level];
|
||||
if (isNullOrUndefined(addLevel)) {
|
||||
throw new Error("Attempted to add a phase to a nonexistent level of the PhaseTree");
|
||||
throw new Error("Attempted to add a phase to a nonexistent level of the PhaseTree!\nLevel: " + level.toString());
|
||||
}
|
||||
this.levels[level].push(phase);
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ export class CheckSwitchPhase extends BattlePhase {
|
||||
);
|
||||
}
|
||||
|
||||
public end(queuePostSummon = false) {
|
||||
public override end(queuePostSummon = false): void {
|
||||
if (queuePostSummon) {
|
||||
globalScene.phaseManager.unshiftNew("PostSummonPhase", this.fieldIndex);
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ import { sortInSpeedOrder } from "#app/utils/speed-order";
|
||||
*
|
||||
* Orders phases first by ability priority, then by the {@linkcode Pokemon}'s effective speed
|
||||
*/
|
||||
|
||||
export class PostSummonPhasePriorityQueue extends PokemonPhasePriorityQueue<PostSummonPhase> {
|
||||
protected override reorder(): void {
|
||||
this.queue = sortInSpeedOrder(this.queue, false);
|
||||
|
@ -4,12 +4,17 @@ import { BooleanHolder, randSeedShuffle } from "#app/utils/common";
|
||||
import { ArenaTagType } from "#enums/arena-tag-type";
|
||||
import { Stat } from "#enums/stat";
|
||||
|
||||
/** Interface representing a generic type which has a `getPokemon` method */
|
||||
/** Interface representing an object associated with a specific Pokemon */
|
||||
interface hasPokemon {
|
||||
getPokemon(): Pokemon;
|
||||
}
|
||||
|
||||
export function applyInSpeedOrder<T extends Pokemon>(pokemonList: T[], callback: (pokemon: Pokemon) => any): void {
|
||||
/**
|
||||
* Execute a callback on an array of Pokemon in speed order.
|
||||
* @param pokemonList - An array of {@linkcode Pokemon} with which the callback will be executed
|
||||
* @param callback - The lambda function to use. Should not return a value (will be ignored)
|
||||
*/
|
||||
export function applyInSpeedOrder<T extends Pokemon>(pokemonList: T[], callback: (pokemon: T) => void): void {
|
||||
sortInSpeedOrder(pokemonList).forEach(pokemon => {
|
||||
callback(pokemon);
|
||||
});
|
||||
|
@ -34,8 +34,7 @@ describe("Abilities - Dancer", () => {
|
||||
game.override.enemyAbility(AbilityId.DANCER).enemySpecies(SpeciesId.MAGIKARP).enemyMoveset(MoveId.VICTORY_DANCE);
|
||||
await game.classicMode.startBattle([SpeciesId.ORICORIO, SpeciesId.FEEBAS]);
|
||||
|
||||
const [oricorio, feebas] = game.scene.getPlayerField();
|
||||
const [magikarp1] = game.scene.getEnemyField();
|
||||
const [oricorio, feebas, magikarp1] = game.scene.getField();
|
||||
game.move.changeMoveset(oricorio, [MoveId.SWORDS_DANCE, MoveId.VICTORY_DANCE, MoveId.SPLASH]);
|
||||
game.move.changeMoveset(feebas, [MoveId.SWORDS_DANCE, MoveId.SPLASH]);
|
||||
|
||||
|
@ -46,7 +46,7 @@ describe("Abilities - Stall", () => {
|
||||
await game.phaseInterceptor.to("MoveEndPhase", false);
|
||||
// The player Pokemon (without Stall) goes first despite having lower speed than the opponent.
|
||||
// The opponent Pokemon (with Stall) goes last despite having higher speed than the player Pokemon.
|
||||
expect(player.hp).toEqual(player.getMaxHp());
|
||||
expect(player).toHaveFullHp();
|
||||
});
|
||||
|
||||
it("Pokemon with Stall will go first if a move that is in a higher priority bracket than the opponent's move is used", async () => {
|
||||
@ -59,7 +59,7 @@ describe("Abilities - Stall", () => {
|
||||
await game.phaseInterceptor.to("MoveEndPhase", false);
|
||||
// The opponent Pokemon (with Stall) goes first because its move is still within a higher priority bracket than its opponent.
|
||||
// The player Pokemon goes second because its move is in a lower priority bracket.
|
||||
expect(player.hp).not.toEqual(player.getMaxHp());
|
||||
expect(player).not.toHaveFullHp();
|
||||
});
|
||||
|
||||
it("If both Pokemon have stall and use the same move, speed is used to determine who goes first.", async () => {
|
||||
@ -74,6 +74,6 @@ describe("Abilities - Stall", () => {
|
||||
|
||||
// The opponent Pokemon (with Stall) goes first because it has a higher speed.
|
||||
// The player Pokemon (with Stall) goes second because its speed is lower.
|
||||
expect(player.hp).not.toEqual(player.getMaxHp());
|
||||
expect(player).not.toHaveFullHp();
|
||||
});
|
||||
});
|
||||
|
@ -76,7 +76,7 @@ describe("Moves - Baton Pass", () => {
|
||||
expect(game.field.getEnemyPokemon().getStatStage(Stat.SPATK)).toEqual(2);
|
||||
// confirm that a switch actually happened. can't use species because I
|
||||
// can't find a way to override trainer parties with more than 1 pokemon species
|
||||
expect(game.scene.getEnemyPokemon()?.summonData.moveHistory.length).toEqual(0);
|
||||
expect(game.field.getEnemyPokemon().summonData.moveHistory).toHaveLength(0);
|
||||
});
|
||||
|
||||
it("doesn't transfer effects that aren't transferrable", async () => {
|
||||
|
@ -115,7 +115,7 @@ describe("Moves - Focus Punch", () => {
|
||||
await game.phaseInterceptor.to(TurnStartPhase);
|
||||
|
||||
expect(game.scene.phaseManager.getCurrentPhase() instanceof SwitchSummonPhase).toBeTruthy();
|
||||
expect(game.scene.phaseManager.hasPhaseOfType("MoveHeaderPhase")).toBeTruthy();
|
||||
expect(game.scene.phaseManager.hasPhaseOfType("MoveHeaderPhase")).toBe(true);
|
||||
});
|
||||
it("should replace the 'but it failed' text when the user gets hit", async () => {
|
||||
game.override.enemyMoveset([MoveId.TACKLE]);
|
||||
|
@ -126,7 +126,7 @@ describe("Moves - Revival Blessing", () => {
|
||||
|
||||
const enemyFainting = game.scene.getEnemyField()[0];
|
||||
|
||||
game.move.select(MoveId.JUDGMENT, 0, enemyFainting.getBattlerIndex());
|
||||
game.move.use(MoveId.JUDGMENT, 0, BattlerIndex.ENEMY);
|
||||
game.move.select(MoveId.SPLASH, 1);
|
||||
|
||||
await game.toNextTurn();
|
||||
|
@ -464,7 +464,9 @@ export class GameManager {
|
||||
* Faint a player or enemy pokemon instantly by setting their HP to 0.
|
||||
* @param pokemon - The player/enemy pokemon being fainted
|
||||
* @returns A Promise that resolves once the fainted pokemon's FaintPhase finishes running.
|
||||
* @remarks This method *pushes* a FaintPhase and runs until it's finished. This may cause a turn to play out unexpectedly
|
||||
* @remarks
|
||||
* This method *pushes* a FaintPhase and runs until it's finished. This may cause a turn to play out unexpectedly
|
||||
* @todo Consider whether running the faint phase immediately can be done
|
||||
*/
|
||||
async killPokemon(pokemon: PlayerPokemon | EnemyPokemon) {
|
||||
pokemon.hp = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user