mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-20 06:19:29 +02:00
Merge branch 'beta' into fix-pokeballtype-import
This commit is contained in:
commit
b2828f26da
@ -7,7 +7,7 @@ import { Weather } from "#app/data/weather";
|
||||
import { BattlerTag, BattlerTagLapseType, GroundedTag } from "./battler-tags";
|
||||
import { getNonVolatileStatusEffects, getStatusEffectDescriptor, getStatusEffectHealText } from "#app/data/status-effect";
|
||||
import { Gender } from "./gender";
|
||||
import Move, { AttackMove, MoveCategory, MoveFlags, MoveTarget, FlinchAttr, OneHitKOAttr, HitHealAttr, allMoves, StatusMove, SelfStatusMove, VariablePowerAttr, applyMoveAttrs, IncrementMovePriorityAttr, VariableMoveTypeAttr, RandomMovesetMoveAttr, RandomMoveAttr, NaturePowerAttr, CopyMoveAttr, MoveAttr, MultiHitAttr, SacrificialAttr, SacrificialAttrOnHit, NeutralDamageAgainstFlyingTypeMultiplierAttr, FixedDamageAttr } from "./move";
|
||||
import Move, { AttackMove, MoveCategory, MoveFlags, MoveTarget, FlinchAttr, OneHitKOAttr, HitHealAttr, allMoves, StatusMove, SelfStatusMove, VariablePowerAttr, applyMoveAttrs, VariableMoveTypeAttr, RandomMovesetMoveAttr, RandomMoveAttr, NaturePowerAttr, CopyMoveAttr, MoveAttr, MultiHitAttr, SacrificialAttr, SacrificialAttrOnHit, NeutralDamageAgainstFlyingTypeMultiplierAttr, FixedDamageAttr } from "./move";
|
||||
import { ArenaTagSide, ArenaTrapTag } from "./arena-tag";
|
||||
import { BerryModifier, HitHealModifier, PokemonHeldItemModifier } from "../modifier/modifier";
|
||||
import { TerrainType } from "./terrain";
|
||||
@ -585,15 +585,11 @@ export class PostDefendAbAttr extends AbAttr {
|
||||
|
||||
export class FieldPriorityMoveImmunityAbAttr extends PreDefendAbAttr {
|
||||
applyPreDefend(pokemon: Pokemon, passive: boolean, simulated: boolean, attacker: Pokemon, move: Move, cancelled: Utils.BooleanHolder, args: any[]): boolean {
|
||||
const attackPriority = new Utils.IntegerHolder(move.priority);
|
||||
applyMoveAttrs(IncrementMovePriorityAttr, attacker, null, move, attackPriority);
|
||||
applyAbAttrs(ChangeMovePriorityAbAttr, attacker, null, simulated, move, attackPriority);
|
||||
|
||||
if (move.moveTarget === MoveTarget.USER || move.moveTarget === MoveTarget.NEAR_ALLY) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (attackPriority.value > 0 && !move.isMultiTarget()) {
|
||||
if (move.getPriority(attacker) > 0 && !move.isMultiTarget()) {
|
||||
cancelled.value = true;
|
||||
return true;
|
||||
}
|
||||
|
@ -2,12 +2,12 @@ import { Arena } from "#app/field/arena";
|
||||
import BattleScene from "#app/battle-scene";
|
||||
import { Type } from "#enums/type";
|
||||
import { BooleanHolder, NumberHolder, toDmgValue } from "#app/utils";
|
||||
import { MoveCategory, allMoves, MoveTarget, IncrementMovePriorityAttr, applyMoveAttrs } from "#app/data/move";
|
||||
import { MoveCategory, allMoves, MoveTarget } from "#app/data/move";
|
||||
import { getPokemonNameWithAffix } from "#app/messages";
|
||||
import Pokemon, { HitResult, PokemonMove } from "#app/field/pokemon";
|
||||
import { StatusEffect } from "#enums/status-effect";
|
||||
import { BattlerIndex } from "#app/battle";
|
||||
import { BlockNonDirectDamageAbAttr, ChangeMovePriorityAbAttr, InfiltratorAbAttr, ProtectStatAbAttr, applyAbAttrs } from "#app/data/ability";
|
||||
import { BlockNonDirectDamageAbAttr, InfiltratorAbAttr, ProtectStatAbAttr, applyAbAttrs } from "#app/data/ability";
|
||||
import { Stat } from "#enums/stat";
|
||||
import { CommonAnim, CommonBattleAnim } from "#app/data/battle-anims";
|
||||
import i18next from "i18next";
|
||||
@ -318,17 +318,15 @@ export class ConditionalProtectTag extends ArenaTag {
|
||||
*/
|
||||
const QuickGuardConditionFunc: ProtectConditionFunc = (arena, moveId) => {
|
||||
const move = allMoves[moveId];
|
||||
const priority = new NumberHolder(move.priority);
|
||||
const effectPhase = arena.scene.getCurrentPhase();
|
||||
|
||||
if (effectPhase instanceof MoveEffectPhase) {
|
||||
const attacker = effectPhase.getUserPokemon();
|
||||
applyMoveAttrs(IncrementMovePriorityAttr, attacker, null, move, priority);
|
||||
if (attacker) {
|
||||
applyAbAttrs(ChangeMovePriorityAbAttr, attacker, null, false, move, priority);
|
||||
return move.getPriority(attacker) > 0;
|
||||
}
|
||||
}
|
||||
return priority.value > 0;
|
||||
return move.priority > 0;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -910,11 +910,15 @@ export class FrenzyTag extends BattlerTag {
|
||||
}
|
||||
}
|
||||
|
||||
export class EncoreTag extends BattlerTag {
|
||||
/**
|
||||
* Applies the effects of the move Encore onto the target Pokemon
|
||||
* Encore forces the target Pokemon to use its most-recent move for 3 turns
|
||||
*/
|
||||
export class EncoreTag extends MoveRestrictionBattlerTag {
|
||||
public moveId: Moves;
|
||||
|
||||
constructor(sourceId: number) {
|
||||
super(BattlerTagType.ENCORE, BattlerTagLapseType.AFTER_MOVE, 3, Moves.ENCORE, sourceId);
|
||||
super(BattlerTagType.ENCORE, [ BattlerTagLapseType.CUSTOM, BattlerTagLapseType.AFTER_MOVE ], 3, Moves.ENCORE, sourceId);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -970,6 +974,39 @@ export class EncoreTag extends BattlerTag {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If the encored move has run out of PP, Encore ends early. Otherwise, Encore lapses based on the AFTER_MOVE battler tag lapse type.
|
||||
* @returns `true` to persist | `false` to end and be removed
|
||||
*/
|
||||
override lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean {
|
||||
if (lapseType === BattlerTagLapseType.CUSTOM) {
|
||||
const encoredMove = pokemon.getMoveset().find(m => m?.moveId === this.moveId);
|
||||
if (encoredMove && encoredMove?.getPpRatio() > 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
return super.lapse(pokemon, lapseType);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the move matches the moveId stored within the tag and returns a boolean value
|
||||
* @param move {@linkcode Moves} the move selected
|
||||
* @param user N/A
|
||||
* @returns `true` if the move does not match with the moveId stored and as a result, restricted
|
||||
*/
|
||||
override isMoveRestricted(move: Moves, _user?: Pokemon): boolean {
|
||||
if (move !== this.moveId) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
override selectionDeniedText(_pokemon: Pokemon, move: Moves): string {
|
||||
return i18next.t("battle:moveDisabled", { moveName: allMoves[move].name });
|
||||
}
|
||||
|
||||
onRemove(pokemon: Pokemon): void {
|
||||
super.onRemove(pokemon);
|
||||
|
||||
@ -2361,7 +2398,7 @@ export class HealBlockTag extends MoveRestrictionBattlerTag {
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses DisabledTag's selectionDeniedText() message
|
||||
* Uses its own unique selectionDeniedText() message
|
||||
*/
|
||||
override selectionDeniedText(pokemon: Pokemon, move: Moves): string {
|
||||
return i18next.t("battle:moveDisabledHealBlock", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), moveName: allMoves[move].name, healBlockName: allMoves[Moves.HEAL_BLOCK].name });
|
||||
|
@ -9,7 +9,7 @@ import { Constructor, NumberHolder } from "#app/utils";
|
||||
import * as Utils from "../utils";
|
||||
import { WeatherType } from "#enums/weather-type";
|
||||
import { ArenaTagSide, ArenaTrapTag, WeakenMoveTypeTag } from "./arena-tag";
|
||||
import { allAbilities, AllyMoveCategoryPowerBoostAbAttr, applyAbAttrs, applyPostAttackAbAttrs, applyPostItemLostAbAttrs, applyPreAttackAbAttrs, applyPreDefendAbAttrs, BlockItemTheftAbAttr, BlockNonDirectDamageAbAttr, BlockOneHitKOAbAttr, BlockRecoilDamageAttr, ConfusionOnStatusEffectAbAttr, FieldMoveTypePowerBoostAbAttr, FieldPreventExplosiveMovesAbAttr, ForceSwitchOutImmunityAbAttr, HealFromBerryUseAbAttr, IgnoreContactAbAttr, IgnoreMoveEffectsAbAttr, IgnoreProtectOnContactAbAttr, InfiltratorAbAttr, MaxMultiHitAbAttr, MoveAbilityBypassAbAttr, MoveEffectChanceMultiplierAbAttr, MoveTypeChangeAbAttr, PostDamageForceSwitchAbAttr, PostItemLostAbAttr, ReverseDrainAbAttr, UncopiableAbilityAbAttr, UnsuppressableAbilityAbAttr, UnswappableAbilityAbAttr, UserFieldMoveTypePowerBoostAbAttr, VariableMovePowerAbAttr, WonderSkinAbAttr } from "./ability";
|
||||
import { allAbilities, AllyMoveCategoryPowerBoostAbAttr, applyAbAttrs, applyPostAttackAbAttrs, applyPostItemLostAbAttrs, applyPreAttackAbAttrs, applyPreDefendAbAttrs, BlockItemTheftAbAttr, BlockNonDirectDamageAbAttr, BlockOneHitKOAbAttr, BlockRecoilDamageAttr, ChangeMovePriorityAbAttr, ConfusionOnStatusEffectAbAttr, FieldMoveTypePowerBoostAbAttr, FieldPreventExplosiveMovesAbAttr, ForceSwitchOutImmunityAbAttr, HealFromBerryUseAbAttr, IgnoreContactAbAttr, IgnoreMoveEffectsAbAttr, IgnoreProtectOnContactAbAttr, InfiltratorAbAttr, MaxMultiHitAbAttr, MoveAbilityBypassAbAttr, MoveEffectChanceMultiplierAbAttr, MoveTypeChangeAbAttr, PostDamageForceSwitchAbAttr, PostItemLostAbAttr, ReverseDrainAbAttr, UncopiableAbilityAbAttr, UnsuppressableAbilityAbAttr, UnswappableAbilityAbAttr, UserFieldMoveTypePowerBoostAbAttr, VariableMovePowerAbAttr, WonderSkinAbAttr } from "./ability";
|
||||
import { AttackTypeBoosterModifier, BerryModifier, PokemonHeldItemModifier, PokemonMoveAccuracyBoosterModifier, PokemonMultiHitModifier, PreserveBerryModifier } from "../modifier/modifier";
|
||||
import { BattlerIndex, BattleType } from "../battle";
|
||||
import { TerrainType } from "./terrain";
|
||||
@ -831,6 +831,15 @@ export default class Move implements Localizable {
|
||||
|
||||
return power.value;
|
||||
}
|
||||
|
||||
getPriority(user: Pokemon, simulated: boolean = true) {
|
||||
const priority = new Utils.NumberHolder(this.priority);
|
||||
|
||||
applyMoveAttrs(IncrementMovePriorityAttr, user, null, this, priority);
|
||||
applyAbAttrs(ChangeMovePriorityAbAttr, user, null, simulated, this, priority);
|
||||
|
||||
return priority.value;
|
||||
}
|
||||
}
|
||||
|
||||
export class AttackMove extends Move {
|
||||
@ -6750,7 +6759,8 @@ export class SketchAttr extends MoveEffectAttr {
|
||||
return false;
|
||||
}
|
||||
|
||||
const targetMove = target.getMoveHistory().filter(m => !m.virtual).at(-1);
|
||||
const targetMove = target.getLastXMoves(target.battleSummonData.turnCount)
|
||||
.find(m => m.move !== Moves.NONE && m.move !== Moves.STRUGGLE && !m.virtual);
|
||||
if (!targetMove) {
|
||||
return false;
|
||||
}
|
||||
@ -7453,6 +7463,27 @@ export class FirstMoveCondition extends MoveCondition {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Condition used by the move {@link https://bulbapedia.bulbagarden.net/wiki/Upper_Hand_(move) | Upper Hand}.
|
||||
* Moves with this condition are only successful when the target has selected
|
||||
* a high-priority attack (after factoring in priority-boosting effects) and
|
||||
* hasn't moved yet this turn.
|
||||
*/
|
||||
export class UpperHandCondition extends MoveCondition {
|
||||
constructor() {
|
||||
super((user, target, move) => {
|
||||
const targetCommand = user.scene.currentBattle.turnCommands[target.getBattlerIndex()];
|
||||
|
||||
return !!targetCommand
|
||||
&& targetCommand.command === Command.FIGHT
|
||||
&& !target.turnData.acted
|
||||
&& !!targetCommand.move?.move
|
||||
&& allMoves[targetCommand.move.move].category !== MoveCategory.STATUS
|
||||
&& allMoves[targetCommand.move.move].getPriority(target) > 0;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export class hitsSameTypeAttr extends VariableMoveTypeMultiplierAttr {
|
||||
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
||||
const multiplier = args[0] as Utils.NumberHolder;
|
||||
@ -10570,8 +10601,7 @@ export function initMoves() {
|
||||
.attr(AddBattlerTagAttr, BattlerTagType.HEAL_BLOCK, false, false, 2),
|
||||
new AttackMove(Moves.UPPER_HAND, Type.FIGHTING, MoveCategory.PHYSICAL, 65, 100, 15, 100, 3, 9)
|
||||
.attr(FlinchAttr)
|
||||
.condition((user, target, move) => user.scene.currentBattle.turnCommands[target.getBattlerIndex()]?.command === Command.FIGHT && !target.turnData.acted && allMoves[user.scene.currentBattle.turnCommands[target.getBattlerIndex()]?.move?.move!].category !== MoveCategory.STATUS && allMoves[user.scene.currentBattle.turnCommands[target.getBattlerIndex()]?.move?.move!].priority > 0 ) // TODO: is this bang correct?
|
||||
.partial(), // Should also apply when target move priority increased by ability ex. gale wings
|
||||
.condition(new UpperHandCondition()),
|
||||
new AttackMove(Moves.MALIGNANT_CHAIN, Type.POISON, MoveCategory.SPECIAL, 100, 100, 5, 50, 0, 9)
|
||||
.attr(StatusEffectAttr, StatusEffect.TOXIC)
|
||||
);
|
||||
|
@ -1,8 +1,6 @@
|
||||
import Pokemon from "../field/pokemon";
|
||||
import Move from "./move";
|
||||
import { Type } from "#enums/type";
|
||||
import * as Utils from "../utils";
|
||||
import { ChangeMovePriorityAbAttr, applyAbAttrs } from "./ability";
|
||||
import { ProtectAttr } from "./move";
|
||||
import { BattlerIndex } from "#app/battle";
|
||||
import i18next from "i18next";
|
||||
@ -58,10 +56,8 @@ export class Terrain {
|
||||
switch (this.terrainType) {
|
||||
case TerrainType.PSYCHIC:
|
||||
if (!move.hasAttr(ProtectAttr)) {
|
||||
const priority = new Utils.IntegerHolder(move.priority);
|
||||
applyAbAttrs(ChangeMovePriorityAbAttr, user, null, false, move, priority);
|
||||
// Cancels move if the move has positive priority and targets a Pokemon grounded on the Psychic Terrain
|
||||
return priority.value > 0 && user.getOpponents().some(o => targets.includes(o.getBattlerIndex()) && o.isGrounded());
|
||||
return move.getPriority(user) > 0 && user.getOpponents().some(o => targets.includes(o.getBattlerIndex()) && o.isGrounded());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5082,26 +5082,6 @@ export class EnemyPokemon extends Pokemon {
|
||||
}
|
||||
}
|
||||
|
||||
heal(amount: integer): integer {
|
||||
if (this.isBoss()) {
|
||||
const amountRatio = amount / this.getMaxHp();
|
||||
const segmentBypassCount = Math.floor(amountRatio / (1 / this.bossSegments));
|
||||
const segmentSize = this.getMaxHp() / this.bossSegments;
|
||||
for (let s = 1; s < this.bossSegments; s++) {
|
||||
const hpThreshold = segmentSize * s;
|
||||
if (this.hp <= Math.round(hpThreshold)) {
|
||||
const healAmount = Math.min(amount, this.getMaxHp() - this.hp, Math.round(hpThreshold + (segmentSize * segmentBypassCount) - this.hp));
|
||||
this.hp += healAmount;
|
||||
return healAmount;
|
||||
} else if (s >= this.bossSegmentIndex) {
|
||||
return super.heal(amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return super.heal(amount);
|
||||
}
|
||||
|
||||
getFieldIndex(): integer {
|
||||
return this.scene.getEnemyField().indexOf(this);
|
||||
}
|
||||
|
@ -61,6 +61,12 @@ export class CommandPhase extends FieldPhase {
|
||||
this.scene.currentBattle.turnCommands[this.fieldIndex] = { command: Command.FIGHT, move: { move: Moves.NONE, targets: []}, skip: true };
|
||||
}
|
||||
|
||||
// Checks if the Pokemon is under the effects of Encore. If so, Encore can end early if the encored move has no more PP.
|
||||
const encoreTag = this.getPokemon().getTag(BattlerTagType.ENCORE) as EncoreTag;
|
||||
if (encoreTag) {
|
||||
this.getPokemon().lapseTag(BattlerTagType.ENCORE);
|
||||
}
|
||||
|
||||
if (this.scene.currentBattle.turnCommands[this.fieldIndex]?.skip) {
|
||||
return this.end();
|
||||
}
|
||||
@ -291,26 +297,6 @@ export class CommandPhase extends FieldPhase {
|
||||
}
|
||||
}
|
||||
|
||||
checkFightOverride(): boolean {
|
||||
const pokemon = this.getPokemon();
|
||||
|
||||
const encoreTag = pokemon.getTag(EncoreTag) as EncoreTag;
|
||||
|
||||
if (!encoreTag) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const moveIndex = pokemon.getMoveset().findIndex(m => m?.moveId === encoreTag.moveId);
|
||||
|
||||
if (moveIndex === -1 || !pokemon.getMoveset()[moveIndex]!.isUsable(pokemon)) { // TODO: is this bang correct?
|
||||
return false;
|
||||
}
|
||||
|
||||
this.handleCommand(Command.FIGHT, moveIndex, false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
getFieldIndex(): integer {
|
||||
return this.fieldIndex;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import BattleScene from "#app/battle-scene";
|
||||
import { applyAbAttrs, BypassSpeedChanceAbAttr, PreventBypassSpeedChanceAbAttr, ChangeMovePriorityAbAttr } from "#app/data/ability";
|
||||
import { allMoves, applyMoveAttrs, IncrementMovePriorityAttr, MoveHeaderAttr } from "#app/data/move";
|
||||
import { applyAbAttrs, BypassSpeedChanceAbAttr, PreventBypassSpeedChanceAbAttr } from "#app/data/ability";
|
||||
import { allMoves, MoveHeaderAttr } from "#app/data/move";
|
||||
import { Abilities } from "#app/enums/abilities";
|
||||
import { Stat } from "#app/enums/stat";
|
||||
import Pokemon, { PokemonMove } from "#app/field/pokemon";
|
||||
@ -98,26 +98,22 @@ export class TurnStartPhase extends FieldPhase {
|
||||
const aMove = allMoves[aCommand.move!.move];
|
||||
const bMove = allMoves[bCommand!.move!.move];
|
||||
|
||||
// The game now considers priority and applies the relevant move and ability attributes
|
||||
const aPriority = new Utils.IntegerHolder(aMove.priority);
|
||||
const bPriority = new Utils.IntegerHolder(bMove.priority);
|
||||
const aUser = this.scene.getField(true).find(p => p.getBattlerIndex() === a)!;
|
||||
const bUser = this.scene.getField(true).find(p => p.getBattlerIndex() === b)!;
|
||||
|
||||
applyMoveAttrs(IncrementMovePriorityAttr, this.scene.getField().find(p => p?.isActive() && p.getBattlerIndex() === a)!, null, aMove, aPriority);
|
||||
applyMoveAttrs(IncrementMovePriorityAttr, this.scene.getField().find(p => p?.isActive() && p.getBattlerIndex() === b)!, null, bMove, bPriority);
|
||||
|
||||
applyAbAttrs(ChangeMovePriorityAbAttr, this.scene.getField().find(p => p?.isActive() && p.getBattlerIndex() === a)!, null, false, aMove, aPriority);
|
||||
applyAbAttrs(ChangeMovePriorityAbAttr, this.scene.getField().find(p => p?.isActive() && p.getBattlerIndex() === b)!, null, false, bMove, bPriority);
|
||||
const aPriority = aMove.getPriority(aUser, false);
|
||||
const bPriority = bMove.getPriority(bUser, false);
|
||||
|
||||
// The game now checks for differences in priority levels.
|
||||
// If the moves share the same original priority bracket, it can check for differences in battlerBypassSpeed and return the result.
|
||||
// This conditional is used to ensure that Quick Claw can still activate with abilities like Stall and Mycelium Might (attack moves only)
|
||||
// Otherwise, the game returns the user of the move with the highest priority.
|
||||
const isSameBracket = Math.ceil(aPriority.value) - Math.ceil(bPriority.value) === 0;
|
||||
if (aPriority.value !== bPriority.value) {
|
||||
const isSameBracket = Math.ceil(aPriority) - Math.ceil(bPriority) === 0;
|
||||
if (aPriority !== bPriority) {
|
||||
if (isSameBracket && battlerBypassSpeed[a].value !== battlerBypassSpeed[b].value) {
|
||||
return battlerBypassSpeed[a].value ? -1 : 1;
|
||||
}
|
||||
return aPriority.value < bPriority.value ? 1 : -1;
|
||||
return (aPriority < bPriority) ? 1 : -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
116
src/test/moves/encore.test.ts
Normal file
116
src/test/moves/encore.test.ts
Normal file
@ -0,0 +1,116 @@
|
||||
import { BattlerTagType } from "#enums/battler-tag-type";
|
||||
import { BattlerIndex } from "#app/battle";
|
||||
import { MoveResult } from "#app/field/pokemon";
|
||||
import { Abilities } from "#enums/abilities";
|
||||
import { Moves } from "#enums/moves";
|
||||
import { Species } from "#enums/species";
|
||||
import GameManager from "#test/utils/gameManager";
|
||||
import Phaser from "phaser";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
||||
|
||||
describe("Moves - Encore", () => {
|
||||
let phaserGame: Phaser.Game;
|
||||
let game: GameManager;
|
||||
|
||||
beforeAll(() => {
|
||||
phaserGame = new Phaser.Game({
|
||||
type: Phaser.HEADLESS,
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
game.phaseInterceptor.restoreOg();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
game = new GameManager(phaserGame);
|
||||
game.override
|
||||
.moveset([ Moves.SPLASH, Moves.ENCORE ])
|
||||
.ability(Abilities.BALL_FETCH)
|
||||
.battleType("single")
|
||||
.disableCrits()
|
||||
.enemySpecies(Species.MAGIKARP)
|
||||
.enemyAbility(Abilities.BALL_FETCH)
|
||||
.enemyMoveset([ Moves.SPLASH, Moves.TACKLE ])
|
||||
.startingLevel(100)
|
||||
.enemyLevel(100);
|
||||
});
|
||||
|
||||
it("should prevent the target from using any move except the last used move", async () => {
|
||||
await game.classicMode.startBattle([ Species.SNORLAX ]);
|
||||
|
||||
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
||||
|
||||
game.move.select(Moves.ENCORE);
|
||||
await game.forceEnemyMove(Moves.SPLASH);
|
||||
|
||||
await game.toNextTurn();
|
||||
expect(enemyPokemon.getTag(BattlerTagType.ENCORE)).toBeDefined();
|
||||
|
||||
game.move.select(Moves.SPLASH);
|
||||
// The enemy AI would normally be inclined to use Tackle, but should be
|
||||
// forced into using Splash.
|
||||
await game.phaseInterceptor.to("BerryPhase", false);
|
||||
|
||||
expect(enemyPokemon.getLastXMoves().every(turnMove => turnMove.move === Moves.SPLASH)).toBeTruthy();
|
||||
});
|
||||
|
||||
describe("should fail against the following moves:", () => {
|
||||
it.each([
|
||||
{ moveId: Moves.TRANSFORM, name: "Transform", delay: false },
|
||||
{ moveId: Moves.MIMIC, name: "Mimic", delay: true },
|
||||
{ moveId: Moves.SKETCH, name: "Sketch", delay: true },
|
||||
{ moveId: Moves.ENCORE, name: "Encore", delay: false },
|
||||
{ moveId: Moves.STRUGGLE, name: "Struggle", delay: false }
|
||||
])("$name", async ({ moveId, delay }) => {
|
||||
game.override.enemyMoveset(moveId);
|
||||
|
||||
await game.classicMode.startBattle([ Species.SNORLAX ]);
|
||||
|
||||
const playerPokemon = game.scene.getPlayerPokemon()!;
|
||||
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
||||
|
||||
if (delay) {
|
||||
game.move.select(Moves.SPLASH);
|
||||
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
|
||||
await game.toNextTurn();
|
||||
}
|
||||
|
||||
game.move.select(Moves.ENCORE);
|
||||
|
||||
const turnOrder = delay
|
||||
? [ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]
|
||||
: [ BattlerIndex.ENEMY, BattlerIndex.PLAYER ];
|
||||
await game.setTurnOrder(turnOrder);
|
||||
|
||||
await game.phaseInterceptor.to("BerryPhase", false);
|
||||
expect(playerPokemon.getLastXMoves(1)[0].result).toBe(MoveResult.FAIL);
|
||||
expect(enemyPokemon.getTag(BattlerTagType.ENCORE)).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
it("Pokemon under both Encore and Torment should alternate between Struggle and restricted move", async () => {
|
||||
const turnOrder = [ BattlerIndex.ENEMY, BattlerIndex.PLAYER ];
|
||||
game.override.moveset([ Moves.ENCORE, Moves.TORMENT, Moves.SPLASH ]);
|
||||
await game.classicMode.startBattle([ Species.FEEBAS ]);
|
||||
|
||||
const enemyPokemon = game.scene.getEnemyPokemon();
|
||||
game.move.select(Moves.ENCORE);
|
||||
await game.setTurnOrder(turnOrder);
|
||||
await game.phaseInterceptor.to("BerryPhase");
|
||||
expect(enemyPokemon?.getTag(BattlerTagType.ENCORE)).toBeDefined();
|
||||
|
||||
await game.toNextTurn();
|
||||
game.move.select(Moves.TORMENT);
|
||||
await game.setTurnOrder(turnOrder);
|
||||
await game.phaseInterceptor.to("BerryPhase");
|
||||
expect(enemyPokemon?.getTag(BattlerTagType.TORMENT)).toBeDefined();
|
||||
|
||||
await game.toNextTurn();
|
||||
game.move.select(Moves.SPLASH);
|
||||
await game.setTurnOrder(turnOrder);
|
||||
await game.phaseInterceptor.to("BerryPhase");
|
||||
const lastMove = enemyPokemon?.getLastXMoves()[0];
|
||||
expect(lastMove?.move).toBe(Moves.STRUGGLE);
|
||||
});
|
||||
});
|
@ -1,10 +1,12 @@
|
||||
import { Abilities } from "#enums/abilities";
|
||||
import { Moves } from "#enums/moves";
|
||||
import { Species } from "#enums/species";
|
||||
import { MoveResult } from "#app/field/pokemon";
|
||||
import { MoveResult, PokemonMove } from "#app/field/pokemon";
|
||||
import GameManager from "#test/utils/gameManager";
|
||||
import Phaser from "phaser";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
||||
import { StatusEffect } from "#app/enums/status-effect";
|
||||
import { BattlerIndex } from "#app/battle";
|
||||
|
||||
describe("Moves - Sketch", () => {
|
||||
let phaserGame: Phaser.Game;
|
||||
@ -32,22 +34,46 @@ describe("Moves - Sketch", () => {
|
||||
});
|
||||
|
||||
it("Sketch should not fail even if a previous Sketch failed to retrieve a valid move and ran out of PP", async () => {
|
||||
game.override.moveset([ Moves.SKETCH, Moves.SKETCH ]);
|
||||
|
||||
await game.classicMode.startBattle([ Species.REGIELEKI ]);
|
||||
const playerPokemon = game.scene.getPlayerPokemon();
|
||||
const playerPokemon = game.scene.getPlayerPokemon()!;
|
||||
// can't use normal moveset override because we need to check moveset changes
|
||||
playerPokemon.moveset = [ new PokemonMove(Moves.SKETCH), new PokemonMove(Moves.SKETCH) ];
|
||||
|
||||
game.move.select(Moves.SKETCH);
|
||||
await game.phaseInterceptor.to("TurnEndPhase");
|
||||
expect(playerPokemon?.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
|
||||
const moveSlot0 = playerPokemon?.getMoveset()[0];
|
||||
expect(moveSlot0?.moveId).toBe(Moves.SKETCH);
|
||||
expect(moveSlot0?.getPpRatio()).toBe(0);
|
||||
expect(playerPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
|
||||
const moveSlot0 = playerPokemon.getMoveset()[0]!;
|
||||
expect(moveSlot0.moveId).toBe(Moves.SKETCH);
|
||||
expect(moveSlot0.getPpRatio()).toBe(0);
|
||||
|
||||
await game.toNextTurn();
|
||||
game.move.select(Moves.SKETCH);
|
||||
await game.phaseInterceptor.to("TurnEndPhase");
|
||||
expect(playerPokemon?.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
|
||||
// Can't verify if the player Pokemon's moveset was successfully changed because of overrides.
|
||||
expect(playerPokemon.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
|
||||
expect(playerPokemon.moveset[0]?.moveId).toBe(Moves.SPLASH);
|
||||
expect(playerPokemon.moveset[1]?.moveId).toBe(Moves.SKETCH);
|
||||
});
|
||||
|
||||
it("Sketch should retrieve the most recent valid move from its target history", async () => {
|
||||
game.override.enemyStatusEffect(StatusEffect.PARALYSIS);
|
||||
await game.classicMode.startBattle([ Species.REGIELEKI ]);
|
||||
const playerPokemon = game.scene.getPlayerPokemon()!;
|
||||
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
||||
playerPokemon.moveset = [ new PokemonMove(Moves.SKETCH), new PokemonMove(Moves.GROWL) ];
|
||||
|
||||
game.move.select(Moves.GROWL);
|
||||
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
|
||||
await game.move.forceStatusActivation(false);
|
||||
await game.phaseInterceptor.to("TurnEndPhase");
|
||||
expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
|
||||
|
||||
await game.toNextTurn();
|
||||
game.move.select(Moves.SKETCH);
|
||||
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
|
||||
await game.move.forceStatusActivation(true);
|
||||
await game.phaseInterceptor.to("TurnEndPhase");
|
||||
expect(playerPokemon.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
|
||||
expect(playerPokemon.moveset[0]?.moveId).toBe(Moves.SPLASH);
|
||||
expect(playerPokemon.moveset[1]?.moveId).toBe(Moves.GROWL);
|
||||
});
|
||||
});
|
||||
|
103
src/test/moves/upper_hand.test.ts
Normal file
103
src/test/moves/upper_hand.test.ts
Normal file
@ -0,0 +1,103 @@
|
||||
import { BattlerIndex } from "#app/battle";
|
||||
import { MoveResult } from "#app/field/pokemon";
|
||||
import { Abilities } from "#enums/abilities";
|
||||
import { Moves } from "#enums/moves";
|
||||
import { Species } from "#enums/species";
|
||||
import GameManager from "#test/utils/gameManager";
|
||||
import Phaser from "phaser";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
||||
|
||||
describe("Moves - Upper Hand", () => {
|
||||
let phaserGame: Phaser.Game;
|
||||
let game: GameManager;
|
||||
|
||||
beforeAll(() => {
|
||||
phaserGame = new Phaser.Game({
|
||||
type: Phaser.HEADLESS,
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
game.phaseInterceptor.restoreOg();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
game = new GameManager(phaserGame);
|
||||
game.override
|
||||
.moveset(Moves.UPPER_HAND)
|
||||
.ability(Abilities.BALL_FETCH)
|
||||
.battleType("single")
|
||||
.disableCrits()
|
||||
.enemySpecies(Species.MAGIKARP)
|
||||
.enemyAbility(Abilities.BALL_FETCH)
|
||||
.enemyMoveset(Moves.QUICK_ATTACK)
|
||||
.startingLevel(100)
|
||||
.enemyLevel(100);
|
||||
});
|
||||
|
||||
it("should flinch the opponent before they use a priority attack", async () => {
|
||||
await game.classicMode.startBattle([ Species.FEEBAS ]);
|
||||
|
||||
const feebas = game.scene.getPlayerPokemon()!;
|
||||
const magikarp = game.scene.getEnemyPokemon()!;
|
||||
|
||||
game.move.select(Moves.UPPER_HAND);
|
||||
await game.phaseInterceptor.to("BerryPhase");
|
||||
|
||||
expect(feebas.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
|
||||
expect(magikarp.isFullHp()).toBeFalsy();
|
||||
expect(feebas.isFullHp()).toBeTruthy();
|
||||
});
|
||||
|
||||
it.each([
|
||||
{ descriptor: "non-priority attack", move: Moves.TACKLE },
|
||||
{ descriptor: "status move", move: Moves.BABY_DOLL_EYES }
|
||||
])("should fail when the opponent selects a $descriptor", async ({ move }) => {
|
||||
game.override.enemyMoveset(move);
|
||||
|
||||
await game.classicMode.startBattle([ Species.FEEBAS ]);
|
||||
|
||||
const feebas = game.scene.getPlayerPokemon()!;
|
||||
|
||||
game.move.select(Moves.UPPER_HAND);
|
||||
await game.phaseInterceptor.to("BerryPhase");
|
||||
|
||||
expect(feebas.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
|
||||
});
|
||||
|
||||
it("should flinch the opponent before they use an attack boosted by Gale Wings", async () => {
|
||||
game.override
|
||||
.enemyAbility(Abilities.GALE_WINGS)
|
||||
.enemyMoveset(Moves.GUST);
|
||||
|
||||
await game.classicMode.startBattle([ Species.FEEBAS ]);
|
||||
|
||||
const feebas = game.scene.getPlayerPokemon()!;
|
||||
const magikarp = game.scene.getEnemyPokemon()!;
|
||||
|
||||
game.move.select(Moves.UPPER_HAND);
|
||||
await game.phaseInterceptor.to("BerryPhase");
|
||||
|
||||
expect(feebas.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
|
||||
expect(magikarp.isFullHp()).toBeFalsy();
|
||||
expect(feebas.isFullHp()).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should fail if the target has already moved", async () => {
|
||||
game.override
|
||||
.enemyMoveset(Moves.FAKE_OUT)
|
||||
.enemyAbility(Abilities.SHEER_FORCE);
|
||||
|
||||
await game.classicMode.startBattle([ Species.FEEBAS ]);
|
||||
|
||||
const feebas = game.scene.getPlayerPokemon()!;
|
||||
|
||||
game.move.select(Moves.UPPER_HAND);
|
||||
|
||||
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
|
||||
await game.phaseInterceptor.to("BerryPhase");
|
||||
|
||||
expect(feebas.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
|
||||
expect(feebas.isFullHp()).toBeFalsy();
|
||||
});
|
||||
});
|
@ -90,9 +90,6 @@ export default class CommandUiHandler extends UiHandler {
|
||||
switch (cursor) {
|
||||
// Fight
|
||||
case Command.FIGHT:
|
||||
if ((this.scene.getCurrentPhase() as CommandPhase).checkFightOverride()) {
|
||||
return true;
|
||||
}
|
||||
ui.setMode(Mode.FIGHT, (this.scene.getCurrentPhase() as CommandPhase).getFieldIndex());
|
||||
success = true;
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user