Compare commits

...

6 Commits

Author SHA1 Message Date
Bertie690
c27a7a750f
Merge ca7947c770 into 3b36ab17e4 2025-08-05 00:57:38 -05:00
Jimmybald1
3b36ab17e4
[Bug] Protect now tracks success chance properly (#5869)
* Protect rng now resets on new waves and fixed to look at all turns in the same wave.

* Added per-wave move history object to fix issues

@Jimmybald1 I added a commented out `console.log` in the protect code (L5797) for you to use for testing

* Added many tests

* Wave move history has to be looped in reverse

* Update src/data/moves/move.ts

Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>

* Update src/data/moves/move.ts

Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>

* comments

* Fixed forceEnemyMove references after merge

* Removed console log

Co-authored-by: Amani H. <109637146+xsn34kzx@users.noreply.github.com>

* Fixed test message

Co-authored-by: Bertie690 <136088738+Bertie690@users.noreply.github.com>

* Apply Biome

* Fix merge issues

* Fix Crafty Shield test

* Remove protect chance reset on wave change

* Fix merge issue

---------

Co-authored-by: Jimmybald1 <147992650+IBBCalc@users.noreply.github.com>
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
Co-authored-by: Amani H. <109637146+xsn34kzx@users.noreply.github.com>
Co-authored-by: Bertie690 <136088738+Bertie690@users.noreply.github.com>
2025-08-05 07:35:14 +02:00
Bertie690
ca7947c770 fixed stupid whirlwind tests 2025-08-03 19:13:48 -04:00
Bertie690
6a284b7ab3 Added MessageAttr; cleaned up a lot of other jank move attrs 2025-08-03 18:31:08 -04:00
Bertie690
c2db0ed397 Fixed key for locales text 2025-08-02 17:09:35 -04:00
Bertie690
5f29e4acf2 Added Laser Focus locales 2025-08-02 16:58:23 -04:00
13 changed files with 455 additions and 304 deletions

View File

@ -1,13 +1,24 @@
import type { Pokemon } from "#field/pokemon";
import type { import type {
AttackMove, AttackMove,
ChargingAttackMove, ChargingAttackMove,
ChargingSelfStatusMove, ChargingSelfStatusMove,
Move,
MoveAttr, MoveAttr,
MoveAttrConstructorMap, MoveAttrConstructorMap,
SelfStatusMove, SelfStatusMove,
StatusMove, StatusMove,
} from "#moves/move"; } from "#moves/move";
/**
* A generic function producing a message during a Move's execution.
* @param user - The {@linkcode Pokemon} using the move
* @param target - The {@linkcode Pokemon} targeted by the move
* @param move - The {@linkcode Move} being used
* @returns a string
*/
export type MoveMessageFunc = (user: Pokemon, target: Pokemon, move: Move) => string;
export type MoveAttrFilter = (attr: MoveAttr) => boolean; export type MoveAttrFilter = (attr: MoveAttr) => boolean;
export type * from "#moves/move"; export type * from "#moves/move";

View File

@ -1670,6 +1670,7 @@ export class MoveTypeChangeAbAttr extends PreAttackAbAttr {
constructor( constructor(
private newType: PokemonType, private newType: PokemonType,
private powerMultiplier: number, private powerMultiplier: number,
// TODO: all moves with this attr solely check the move being used...
private condition?: PokemonAttackCondition, private condition?: PokemonAttackCondition,
) { ) {
super(false); super(false);

View File

@ -87,7 +87,7 @@ import { PokemonHealPhase } from "#phases/pokemon-heal-phase";
import { SwitchSummonPhase } from "#phases/switch-summon-phase"; import { SwitchSummonPhase } from "#phases/switch-summon-phase";
import type { AttackMoveResult } from "#types/attack-move-result"; import type { AttackMoveResult } from "#types/attack-move-result";
import type { Localizable } from "#types/locales"; import type { Localizable } from "#types/locales";
import type { ChargingMove, MoveAttrMap, MoveAttrString, MoveClassMap, MoveKindString } from "#types/move-types"; import type { ChargingMove, MoveAttrMap, MoveAttrString, MoveClassMap, MoveKindString, MoveMessageFunc } from "#types/move-types";
import type { TurnMove } from "#types/turn-move"; import type { TurnMove } from "#types/turn-move";
import { BooleanHolder, type Constructor, isNullOrUndefined, NumberHolder, randSeedFloat, randSeedInt, randSeedItem, toDmgValue } from "#utils/common"; import { BooleanHolder, type Constructor, isNullOrUndefined, NumberHolder, randSeedFloat, randSeedInt, randSeedItem, toDmgValue } from "#utils/common";
import { getEnumValues } from "#utils/enums"; import { getEnumValues } from "#utils/enums";
@ -1357,20 +1357,20 @@ export class MoveHeaderAttr extends MoveAttr {
/** /**
* Header attribute to queue a message at the beginning of a turn. * Header attribute to queue a message at the beginning of a turn.
* @see {@link MoveHeaderAttr}
*/ */
export class MessageHeaderAttr extends MoveHeaderAttr { export class MessageHeaderAttr extends MoveHeaderAttr {
private message: string | ((user: Pokemon, move: Move) => string); /** The message to display, or a function producing one. */
private message: string | MoveMessageFunc;
constructor(message: string | ((user: Pokemon, move: Move) => string)) { constructor(message: string | MoveMessageFunc) {
super(); super();
this.message = message; this.message = message;
} }
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { apply(user: Pokemon, target: Pokemon, move: Move): boolean {
const message = typeof this.message === "string" const message = typeof this.message === "string"
? this.message ? this.message
: this.message(user, move); : this.message(user, target, move);
if (message) { if (message) {
globalScene.phaseManager.queueMessage(message); globalScene.phaseManager.queueMessage(message);
@ -1418,21 +1418,21 @@ export class BeakBlastHeaderAttr extends AddBattlerTagHeaderAttr {
*/ */
export class PreMoveMessageAttr extends MoveAttr { export class PreMoveMessageAttr extends MoveAttr {
/** The message to display or a function returning one */ /** The message to display or a function returning one */
private message: string | ((user: Pokemon, target: Pokemon, move: Move) => string | undefined); private message: string | MoveMessageFunc;
/** /**
* Create a new {@linkcode PreMoveMessageAttr} to display a message before move execution. * Create a new {@linkcode PreMoveMessageAttr} to display a message before move execution.
* @param message - The message to display before move use, either as a string or a function producing one. * @param message - The message to display before move use, either` a literal string or a function producing one.
* @remarks * @remarks
* If {@linkcode message} evaluates to an empty string (`''`), no message will be displayed * If {@linkcode message} evaluates to an empty string (`""`), no message will be displayed
* (though the move will still succeed). * (though the move will still succeed).
*/ */
constructor(message: string | ((user: Pokemon, target: Pokemon, move: Move) => string)) { constructor(message: string | MoveMessageFunc) {
super(); super();
this.message = message; this.message = message;
} }
apply(user: Pokemon, target: Pokemon, move: Move, _args: any[]): boolean { apply(user: Pokemon, target: Pokemon, move: Move): boolean {
const message = typeof this.message === "function" const message = typeof this.message === "function"
? this.message(user, target, move) ? this.message(user, target, move)
: this.message; : this.message;
@ -1453,18 +1453,17 @@ export class PreMoveMessageAttr extends MoveAttr {
* @extends MoveAttr * @extends MoveAttr
*/ */
export class PreUseInterruptAttr extends MoveAttr { export class PreUseInterruptAttr extends MoveAttr {
protected message?: string | ((user: Pokemon, target: Pokemon, move: Move) => string); protected message: string | MoveMessageFunc;
protected overridesFailedMessage: boolean;
protected conditionFunc: MoveConditionFunc; protected conditionFunc: MoveConditionFunc;
/** /**
* Create a new MoveInterruptedMessageAttr. * Create a new MoveInterruptedMessageAttr.
* @param message The message to display when the move is interrupted, or a function that formats the message based on the user, target, and move. * @param message The message to display when the move is interrupted, or a function that formats the message based on the user, target, and move.
*/ */
constructor(message?: string | ((user: Pokemon, target: Pokemon, move: Move) => string), conditionFunc?: MoveConditionFunc) { constructor(message: string | MoveMessageFunc, conditionFunc: MoveConditionFunc) {
super(); super();
this.message = message; this.message = message;
this.conditionFunc = conditionFunc ?? (() => true); this.conditionFunc = conditionFunc;
} }
/** /**
@ -1485,11 +1484,9 @@ export class PreUseInterruptAttr extends MoveAttr {
*/ */
override getFailedText(user: Pokemon, target: Pokemon, move: Move): string | undefined { override getFailedText(user: Pokemon, target: Pokemon, move: Move): string | undefined {
if (this.message && this.conditionFunc(user, target, move)) { if (this.message && this.conditionFunc(user, target, move)) {
const message = return typeof this.message === "string"
typeof this.message === "string" ? this.message
? (this.message as string)
: this.message(user, target, move); : this.message(user, target, move);
return message;
} }
} }
} }
@ -1694,19 +1691,33 @@ export class SurviveDamageAttr extends ModifiedDamageAttr {
} }
} }
export class SplashAttr extends MoveEffectAttr { /**
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { * Move attribute to display arbitrary text during a move's execution.
globalScene.phaseManager.queueMessage(i18next.t("moveTriggers:splash")); */
return true; export class MessageAttr extends MoveEffectAttr {
/** The message to display, either as a string or a function returning one. */
private message: string | MoveMessageFunc;
constructor(message: string | MoveMessageFunc, options?: MoveEffectAttrOptions) {
// TODO: Do we need to respect `selfTarget` if we're just displaying text?
super(false, options)
this.message = message;
}
override apply(user: Pokemon, target: Pokemon, move: Move): boolean {
const message = typeof this.message === "function"
? this.message(user, target, move)
: this.message;
// TODO: Consider changing if/when MoveAttr `apply` return values become significant
if (message) {
globalScene.phaseManager.queueMessage(message, 500);
return true;
}
return false;
} }
} }
export class CelebrateAttr extends MoveEffectAttr {
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
globalScene.phaseManager.queueMessage(i18next.t("moveTriggers:celebrate", { playerName: loggedInUser?.username }));
return true;
}
}
export class RecoilAttr extends MoveEffectAttr { export class RecoilAttr extends MoveEffectAttr {
private useHp: boolean; private useHp: boolean;
@ -5912,56 +5923,25 @@ export class ProtectAttr extends AddBattlerTagAttr {
getCondition(): MoveConditionFunc { getCondition(): MoveConditionFunc {
return ((user, target, move): boolean => { return ((user, target, move): boolean => {
let timesUsed = 0; let timesUsed = 0;
const moveHistory = user.getLastXMoves();
let turnMove: TurnMove | undefined;
while (moveHistory.length) { for (const turnMove of user.getLastXMoves(-1).slice()) {
turnMove = moveHistory.shift(); if (
if (!allMoves[turnMove?.move ?? MoveId.NONE].hasAttr("ProtectAttr") || turnMove?.result !== MoveResult.SUCCESS) { // Quick & Wide guard increment the Protect counter without using it for fail chance
!(allMoves[turnMove.move].hasAttr("ProtectAttr") ||
[MoveId.QUICK_GUARD, MoveId.WIDE_GUARD].includes(turnMove.move)) ||
turnMove.result !== MoveResult.SUCCESS
) {
break; break;
} }
timesUsed++;
timesUsed++
} }
if (timesUsed) {
return !user.randBattleSeedInt(Math.pow(3, timesUsed)); return timesUsed === 0 || user.randBattleSeedInt(Math.pow(3, timesUsed)) === 0;
}
return true;
}); });
} }
} }
export class IgnoreAccuracyAttr extends AddBattlerTagAttr {
constructor() {
super(BattlerTagType.IGNORE_ACCURACY, true, false, 2);
}
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
if (!super.apply(user, target, move, args)) {
return false;
}
globalScene.phaseManager.queueMessage(i18next.t("moveTriggers:tookAimAtTarget", { pokemonName: getPokemonNameWithAffix(user), targetName: getPokemonNameWithAffix(target) }));
return true;
}
}
export class FaintCountdownAttr extends AddBattlerTagAttr {
constructor() {
super(BattlerTagType.PERISH_SONG, false, true, 4);
}
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
if (!super.apply(user, target, move, args)) {
return false;
}
globalScene.phaseManager.queueMessage(i18next.t("moveTriggers:faintCountdown", { pokemonName: getPokemonNameWithAffix(target), turnCount: this.turnCountMin - 1 }));
return true;
}
}
/** /**
* Attribute to remove all Substitutes from the field. * Attribute to remove all Substitutes from the field.
* @extends MoveEffectAttr * @extends MoveEffectAttr
@ -6602,8 +6582,10 @@ export class ChillyReceptionAttr extends ForceSwitchOutAttr {
return (user, target, move) => globalScene.arena.weather?.weatherType !== WeatherType.SNOW || super.getSwitchOutCondition()(user, target, move); return (user, target, move) => globalScene.arena.weather?.weatherType !== WeatherType.SNOW || super.getSwitchOutCondition()(user, target, move);
} }
} }
export class RemoveTypeAttr extends MoveEffectAttr { export class RemoveTypeAttr extends MoveEffectAttr {
// TODO: Remove the message callback
private removedType: PokemonType; private removedType: PokemonType;
private messageCallback: ((user: Pokemon) => void) | undefined; private messageCallback: ((user: Pokemon) => void) | undefined;
@ -8292,8 +8274,6 @@ const MoveAttrs = Object.freeze({
RandomLevelDamageAttr, RandomLevelDamageAttr,
ModifiedDamageAttr, ModifiedDamageAttr,
SurviveDamageAttr, SurviveDamageAttr,
SplashAttr,
CelebrateAttr,
RecoilAttr, RecoilAttr,
SacrificialAttr, SacrificialAttr,
SacrificialAttrOnHit, SacrificialAttrOnHit,
@ -8436,8 +8416,7 @@ const MoveAttrs = Object.freeze({
RechargeAttr, RechargeAttr,
TrapAttr, TrapAttr,
ProtectAttr, ProtectAttr,
IgnoreAccuracyAttr, MessageAttr,
FaintCountdownAttr,
RemoveAllSubstitutesAttr, RemoveAllSubstitutesAttr,
HitsTagAttr, HitsTagAttr,
HitsTagForDoubleDamageAttr, HitsTagForDoubleDamageAttr,
@ -8931,7 +8910,7 @@ export function initMoves() {
new AttackMove(MoveId.PSYWAVE, PokemonType.PSYCHIC, MoveCategory.SPECIAL, -1, 100, 15, -1, 0, 1) new AttackMove(MoveId.PSYWAVE, PokemonType.PSYCHIC, MoveCategory.SPECIAL, -1, 100, 15, -1, 0, 1)
.attr(RandomLevelDamageAttr), .attr(RandomLevelDamageAttr),
new SelfStatusMove(MoveId.SPLASH, PokemonType.NORMAL, -1, 40, -1, 0, 1) new SelfStatusMove(MoveId.SPLASH, PokemonType.NORMAL, -1, 40, -1, 0, 1)
.attr(SplashAttr) .attr(MessageAttr, i18next.t("moveTriggers:splash"))
.condition(failOnGravityCondition), .condition(failOnGravityCondition),
new SelfStatusMove(MoveId.ACID_ARMOR, PokemonType.POISON, -1, 20, -1, 0, 1) new SelfStatusMove(MoveId.ACID_ARMOR, PokemonType.POISON, -1, 20, -1, 0, 1)
.attr(StatStageChangeAttr, [ Stat.DEF ], 2, true), .attr(StatStageChangeAttr, [ Stat.DEF ], 2, true),
@ -8993,7 +8972,10 @@ export function initMoves() {
.attr(AddBattlerTagAttr, BattlerTagType.TRAPPED, false, true, 1) .attr(AddBattlerTagAttr, BattlerTagType.TRAPPED, false, true, 1)
.reflectable(), .reflectable(),
new StatusMove(MoveId.MIND_READER, PokemonType.NORMAL, -1, 5, -1, 0, 2) new StatusMove(MoveId.MIND_READER, PokemonType.NORMAL, -1, 5, -1, 0, 2)
.attr(IgnoreAccuracyAttr), .attr(AddBattlerTagAttr, BattlerTagType.IGNORE_ACCURACY, true, false, 2)
.attr(MessageAttr, (user, target) =>
i18next.t("moveTriggers:tookAimAtTarget", { pokemonName: getPokemonNameWithAffix(user), targetName: getPokemonNameWithAffix(target) })
),
new StatusMove(MoveId.NIGHTMARE, PokemonType.GHOST, 100, 15, -1, 0, 2) new StatusMove(MoveId.NIGHTMARE, PokemonType.GHOST, 100, 15, -1, 0, 2)
.attr(AddBattlerTagAttr, BattlerTagType.NIGHTMARE) .attr(AddBattlerTagAttr, BattlerTagType.NIGHTMARE)
.condition(targetSleptOrComatoseCondition), .condition(targetSleptOrComatoseCondition),
@ -9081,7 +9063,9 @@ export function initMoves() {
return lastTurnMove.length === 0 || lastTurnMove[0].move !== move.id || lastTurnMove[0].result !== MoveResult.SUCCESS; return lastTurnMove.length === 0 || lastTurnMove[0].move !== move.id || lastTurnMove[0].result !== MoveResult.SUCCESS;
}), }),
new StatusMove(MoveId.PERISH_SONG, PokemonType.NORMAL, -1, 5, -1, 0, 2) new StatusMove(MoveId.PERISH_SONG, PokemonType.NORMAL, -1, 5, -1, 0, 2)
.attr(FaintCountdownAttr) .attr(AddBattlerTagAttr, BattlerTagType.PERISH_SONG, false, true, 4)
.attr(MessageAttr, (_user, target) =>
i18next.t("moveTriggers:faintCountdown", { pokemonName: getPokemonNameWithAffix(target), turnCount: 3 }))
.ignoresProtect() .ignoresProtect()
.soundBased() .soundBased()
.condition(failOnBossCondition) .condition(failOnBossCondition)
@ -9097,7 +9081,10 @@ export function initMoves() {
.attr(MultiHitAttr) .attr(MultiHitAttr)
.makesContact(false), .makesContact(false),
new StatusMove(MoveId.LOCK_ON, PokemonType.NORMAL, -1, 5, -1, 0, 2) new StatusMove(MoveId.LOCK_ON, PokemonType.NORMAL, -1, 5, -1, 0, 2)
.attr(IgnoreAccuracyAttr), .attr(AddBattlerTagAttr, BattlerTagType.IGNORE_ACCURACY, true, false, 2)
.attr(MessageAttr, (user, target) =>
i18next.t("moveTriggers:tookAimAtTarget", { pokemonName: getPokemonNameWithAffix(user), targetName: getPokemonNameWithAffix(target) })
),
new AttackMove(MoveId.OUTRAGE, PokemonType.DRAGON, MoveCategory.PHYSICAL, 120, 100, 10, -1, 0, 2) new AttackMove(MoveId.OUTRAGE, PokemonType.DRAGON, MoveCategory.PHYSICAL, 120, 100, 10, -1, 0, 2)
.attr(FrenzyAttr) .attr(FrenzyAttr)
.attr(MissEffectAttr, frenzyMissFunc) .attr(MissEffectAttr, frenzyMissFunc)
@ -9324,8 +9311,8 @@ export function initMoves() {
&& (user.status.effect === StatusEffect.BURN || user.status.effect === StatusEffect.POISON || user.status.effect === StatusEffect.TOXIC || user.status.effect === StatusEffect.PARALYSIS) ? 2 : 1) && (user.status.effect === StatusEffect.BURN || user.status.effect === StatusEffect.POISON || user.status.effect === StatusEffect.TOXIC || user.status.effect === StatusEffect.PARALYSIS) ? 2 : 1)
.attr(BypassBurnDamageReductionAttr), .attr(BypassBurnDamageReductionAttr),
new AttackMove(MoveId.FOCUS_PUNCH, PokemonType.FIGHTING, MoveCategory.PHYSICAL, 150, 100, 20, -1, -3, 3) new AttackMove(MoveId.FOCUS_PUNCH, PokemonType.FIGHTING, MoveCategory.PHYSICAL, 150, 100, 20, -1, -3, 3)
.attr(MessageHeaderAttr, (user, move) => i18next.t("moveTriggers:isTighteningFocus", { pokemonName: getPokemonNameWithAffix(user) })) .attr(MessageHeaderAttr, (user) => i18next.t("moveTriggers:isTighteningFocus", { pokemonName: getPokemonNameWithAffix(user) }))
.attr(PreUseInterruptAttr, (user, target, move) => i18next.t("moveTriggers:lostFocus", { pokemonName: getPokemonNameWithAffix(user) }), user => !!user.turnData.attacksReceived.find(r => r.damage)) .attr(PreUseInterruptAttr, (user) => i18next.t("moveTriggers:lostFocus", { pokemonName: getPokemonNameWithAffix(user) }), user => user.turnData.attacksReceived.some(r => r.damage > 0))
.punchingMove(), .punchingMove(),
new AttackMove(MoveId.SMELLING_SALTS, PokemonType.NORMAL, MoveCategory.PHYSICAL, 70, 100, 10, -1, 0, 3) new AttackMove(MoveId.SMELLING_SALTS, PokemonType.NORMAL, MoveCategory.PHYSICAL, 70, 100, 10, -1, 0, 3)
.attr(MovePowerMultiplierAttr, (user, target, move) => target.status?.effect === StatusEffect.PARALYSIS ? 2 : 1) .attr(MovePowerMultiplierAttr, (user, target, move) => target.status?.effect === StatusEffect.PARALYSIS ? 2 : 1)
@ -10426,7 +10413,8 @@ export function initMoves() {
new AttackMove(MoveId.DAZZLING_GLEAM, PokemonType.FAIRY, MoveCategory.SPECIAL, 80, 100, 10, -1, 0, 6) new AttackMove(MoveId.DAZZLING_GLEAM, PokemonType.FAIRY, MoveCategory.SPECIAL, 80, 100, 10, -1, 0, 6)
.target(MoveTarget.ALL_NEAR_ENEMIES), .target(MoveTarget.ALL_NEAR_ENEMIES),
new SelfStatusMove(MoveId.CELEBRATE, PokemonType.NORMAL, -1, 40, -1, 0, 6) new SelfStatusMove(MoveId.CELEBRATE, PokemonType.NORMAL, -1, 40, -1, 0, 6)
.attr(CelebrateAttr), // NB: This needs a lambda function as the user will not be logged in by the time the moves are initialized
.attr(MessageAttr, () => i18next.t("moveTriggers:celebrate", { playerName: loggedInUser?.username })),
new StatusMove(MoveId.HOLD_HANDS, PokemonType.NORMAL, -1, 40, -1, 0, 6) new StatusMove(MoveId.HOLD_HANDS, PokemonType.NORMAL, -1, 40, -1, 0, 6)
.ignoresSubstitute() .ignoresSubstitute()
.target(MoveTarget.NEAR_ALLY), .target(MoveTarget.NEAR_ALLY),
@ -10601,7 +10589,12 @@ export function initMoves() {
.attr(StatStageChangeAttr, [ Stat.SPD ], -1) .attr(StatStageChangeAttr, [ Stat.SPD ], -1)
.reflectable(), .reflectable(),
new SelfStatusMove(MoveId.LASER_FOCUS, PokemonType.NORMAL, -1, 30, -1, 0, 7) new SelfStatusMove(MoveId.LASER_FOCUS, PokemonType.NORMAL, -1, 30, -1, 0, 7)
.attr(AddBattlerTagAttr, BattlerTagType.ALWAYS_CRIT, true, false), .attr(AddBattlerTagAttr, BattlerTagType.ALWAYS_CRIT, true, false)
.attr(MessageAttr, (user) =>
i18next.t("battlerTags:laserFocusOnAdd", {
pokemonNameWithAffix: getPokemonNameWithAffix(user),
}),
),
new StatusMove(MoveId.GEAR_UP, PokemonType.STEEL, -1, 20, -1, 0, 7) new StatusMove(MoveId.GEAR_UP, PokemonType.STEEL, -1, 20, -1, 0, 7)
.attr(StatStageChangeAttr, [ Stat.ATK, Stat.SPATK ], 1, false, { condition: (user, target, move) => !![ AbilityId.PLUS, AbilityId.MINUS ].find(a => target.hasAbility(a, false)) }) .attr(StatStageChangeAttr, [ Stat.ATK, Stat.SPATK ], 1, false, { condition: (user, target, move) => !![ AbilityId.PLUS, AbilityId.MINUS ].find(a => target.hasAbility(a, false)) })
.ignoresSubstitute() .ignoresSubstitute()

View File

@ -253,7 +253,6 @@ export class PokemonTempSummonData {
* Only currently used for positioning the battle cursor. * Only currently used for positioning the battle cursor.
*/ */
turnCount = 1; turnCount = 1;
/** /**
* The number of turns this pokemon has spent in the active position since the start of the wave * The number of turns this pokemon has spent in the active position since the start of the wave
* without switching out. * without switching out.

View File

@ -5094,6 +5094,7 @@ export abstract class Pokemon extends Phaser.GameObjects.Container {
*/ */
resetWaveData(): void { resetWaveData(): void {
this.waveData = new PokemonWaveData(); this.waveData = new PokemonWaveData();
this.tempSummonData.waveTurnCount = 1;
} }
resetTera(): void { resetTera(): void {

View File

@ -58,12 +58,6 @@ export class BattleEndPhase extends BattlePhase {
globalScene.phaseManager.unshiftNew("GameOverPhase", true); globalScene.phaseManager.unshiftNew("GameOverPhase", true);
} }
for (const pokemon of globalScene.getField()) {
if (pokemon) {
pokemon.tempSummonData.waveTurnCount = 1;
}
}
for (const pokemon of globalScene.getPokemonAllowedInBattle()) { for (const pokemon of globalScene.getPokemonAllowedInBattle()) {
applyAbAttrs("PostBattleAbAttr", { pokemon, victory: this.isVictory }); applyAbAttrs("PostBattleAbAttr", { pokemon, victory: this.isVictory });
} }

View File

@ -5,7 +5,7 @@ import { SpeciesId } from "#enums/species-id";
import { StatusEffect } from "#enums/status-effect"; import { StatusEffect } from "#enums/status-effect";
import { GameManager } from "#test/test-utils/game-manager"; import { GameManager } from "#test/test-utils/game-manager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
describe("Moves - Baneful Bunker", () => { describe("Moves - Baneful Bunker", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -26,55 +26,51 @@ describe("Moves - Baneful Bunker", () => {
game.override game.override
.battleStyle("single") .battleStyle("single")
.moveset(MoveId.SLASH) .moveset([MoveId.SLASH, MoveId.FLASH_CANNON])
.enemySpecies(SpeciesId.SNORLAX) .enemySpecies(SpeciesId.TOXAPEX)
.enemyAbility(AbilityId.INSOMNIA) .enemyAbility(AbilityId.INSOMNIA)
.enemyMoveset(MoveId.BANEFUL_BUNKER) .enemyMoveset(MoveId.BANEFUL_BUNKER)
.startingLevel(100) .startingLevel(100)
.enemyLevel(100); .enemyLevel(100);
}); });
test("should protect the user and poison attackers that make contact", async () => {
await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
const leadPokemon = game.field.getPlayerPokemon(); function expectProtected() {
const enemyPokemon = game.field.getEnemyPokemon(); expect(game.scene.getEnemyPokemon()?.hp).toBe(game.scene.getEnemyPokemon()?.getMaxHp());
expect(game.scene.getPlayerPokemon()?.status?.effect).toBe(StatusEffect.POISON);
}
it("should protect the user and poison attackers that make contact", async () => {
await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
game.move.select(MoveId.SLASH); game.move.select(MoveId.SLASH);
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
await game.phaseInterceptor.to("BerryPhase", false); await game.phaseInterceptor.to("BerryPhase", false);
expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp());
expect(leadPokemon.status?.effect === StatusEffect.POISON).toBeTruthy(); expectProtected();
}); });
test("should protect the user and poison attackers that make contact, regardless of accuracy checks", async () => {
it("should ignore accuracy checks", async () => {
await game.classicMode.startBattle([SpeciesId.CHARIZARD]); await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
const leadPokemon = game.field.getPlayerPokemon();
const enemyPokemon = game.field.getEnemyPokemon();
game.move.select(MoveId.SLASH); game.move.select(MoveId.SLASH);
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.phaseInterceptor.to("MoveEndPhase"); // baneful bunker
await game.phaseInterceptor.to("MoveEffectPhase");
await game.move.forceMiss(); await game.move.forceMiss();
await game.phaseInterceptor.to("BerryPhase", false); await game.phaseInterceptor.to("BerryPhase", false);
expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp());
expect(leadPokemon.status?.effect === StatusEffect.POISON).toBeTruthy(); expectProtected();
}); });
test("should not poison attackers that don't make contact", async () => { it("should block non-contact moves without poisoning attackers", async () => {
game.override.moveset(MoveId.FLASH_CANNON);
await game.classicMode.startBattle([SpeciesId.CHARIZARD]); await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
const leadPokemon = game.field.getPlayerPokemon(); const charizard = game.field.getPlayerPokemon();
const enemyPokemon = game.field.getEnemyPokemon(); const toxapex = game.field.getEnemyPokemon();
game.move.select(MoveId.FLASH_CANNON); game.move.select(MoveId.FLASH_CANNON);
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
await game.phaseInterceptor.to("MoveEffectPhase");
await game.move.forceMiss();
await game.phaseInterceptor.to("BerryPhase", false); await game.phaseInterceptor.to("BerryPhase", false);
expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp());
expect(leadPokemon.status?.effect === StatusEffect.POISON).toBeFalsy(); expect(toxapex.hp).toBe(toxapex.getMaxHp());
expect(charizard.status?.effect).toBeUndefined();
}); });
}); });

View File

@ -1,12 +1,14 @@
import { AbilityId } from "#enums/ability-id"; import { AbilityId } from "#enums/ability-id";
import { ArenaTagSide } from "#enums/arena-tag-side";
import { ArenaTagType } from "#enums/arena-tag-type";
import { BattlerIndex } from "#enums/battler-index";
import { BattlerTagType } from "#enums/battler-tag-type"; import { BattlerTagType } from "#enums/battler-tag-type";
import { MoveId } from "#enums/move-id"; import { MoveId } from "#enums/move-id";
import { SpeciesId } from "#enums/species-id"; import { SpeciesId } from "#enums/species-id";
import { Stat } from "#enums/stat"; import { Stat } from "#enums/stat";
import { BerryPhase } from "#phases/berry-phase";
import { GameManager } from "#test/test-utils/game-manager"; import { GameManager } from "#test/test-utils/game-manager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
describe("Moves - Crafty Shield", () => { describe("Moves - Crafty Shield", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -27,68 +29,100 @@ describe("Moves - Crafty Shield", () => {
game.override game.override
.battleStyle("double") .battleStyle("double")
.moveset([MoveId.CRAFTY_SHIELD, MoveId.SPLASH, MoveId.SWORDS_DANCE]) .enemySpecies(SpeciesId.DUSKNOIR)
.enemySpecies(SpeciesId.SNORLAX) .enemyMoveset(MoveId.GROWL)
.enemyMoveset([MoveId.GROWL])
.enemyAbility(AbilityId.INSOMNIA) .enemyAbility(AbilityId.INSOMNIA)
.startingLevel(100) .startingLevel(100)
.enemyLevel(100); .enemyLevel(100);
}); });
test("should protect the user and allies from status moves", async () => { it("should protect the user and allies from status moves", async () => {
await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]); await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]);
const leadPokemon = game.scene.getPlayerField(); const [charizard, blastoise] = game.scene.getPlayerField();
game.move.use(MoveId.CRAFTY_SHIELD, BattlerIndex.PLAYER);
game.move.use(MoveId.SPLASH, BattlerIndex.PLAYER_2);
await game.move.forceEnemyMove(MoveId.GROWL);
await game.move.forceEnemyMove(MoveId.GROWL);
game.move.select(MoveId.CRAFTY_SHIELD); await game.phaseInterceptor.to("TurnEndPhase");
game.move.select(MoveId.SPLASH, 1);
await game.phaseInterceptor.to(BerryPhase, false); expect(charizard.getStatStage(Stat.ATK)).toBe(0);
expect(blastoise.getStatStage(Stat.ATK)).toBe(0);
leadPokemon.forEach(p => expect(p.getStatStage(Stat.ATK)).toBe(0));
}); });
test("should not protect the user and allies from attack moves", async () => { it("should not protect the user and allies from attack moves", async () => {
game.override.enemyMoveset([MoveId.TACKLE]); game.override.enemyMoveset(MoveId.TACKLE);
await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]); await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]);
const leadPokemon = game.scene.getPlayerField(); const [charizard, blastoise] = game.scene.getPlayerField();
game.move.select(MoveId.CRAFTY_SHIELD); game.move.use(MoveId.CRAFTY_SHIELD, BattlerIndex.PLAYER);
game.move.select(MoveId.SPLASH, 1); game.move.use(MoveId.SPLASH, BattlerIndex.PLAYER_2);
await game.move.forceEnemyMove(MoveId.TACKLE, BattlerIndex.PLAYER);
await game.move.forceEnemyMove(MoveId.TACKLE, BattlerIndex.PLAYER_2);
await game.phaseInterceptor.to("TurnEndPhase");
await game.phaseInterceptor.to(BerryPhase, false); expect(charizard.isFullHp()).toBe(false);
expect(blastoise.isFullHp()).toBe(false);
expect(leadPokemon.some(p => p.hp < p.getMaxHp())).toBeTruthy();
}); });
test("should protect the user and allies from moves that ignore other protection", async () => { it("should not block entry hazards and field-targeted moves", async () => {
game.override.enemySpecies(SpeciesId.DUSCLOPS).enemyMoveset([MoveId.CURSE]); game.override.enemyMoveset([MoveId.PERISH_SONG, MoveId.TOXIC_SPIKES]);
await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]); await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]);
const leadPokemon = game.scene.getPlayerField(); const [charizard, blastoise] = game.scene.getPlayerField();
game.move.select(MoveId.CRAFTY_SHIELD); game.move.use(MoveId.CRAFTY_SHIELD, BattlerIndex.PLAYER);
game.move.select(MoveId.SPLASH, 1); game.move.use(MoveId.SPLASH, BattlerIndex.PLAYER_2);
await game.move.forceEnemyMove(MoveId.PERISH_SONG);
await game.move.forceEnemyMove(MoveId.TOXIC_SPIKES);
await game.phaseInterceptor.to("TurnEndPhase");
await game.phaseInterceptor.to(BerryPhase, false); expect(game.scene.arena.getTagOnSide(ArenaTagType.TOXIC_SPIKES, ArenaTagSide.PLAYER)).toBeDefined();
expect(charizard.getTag(BattlerTagType.PERISH_SONG)).toBeDefined();
leadPokemon.forEach(p => expect(p.getTag(BattlerTagType.CURSED)).toBeUndefined()); expect(blastoise.getTag(BattlerTagType.PERISH_SONG)).toBeDefined();
}); });
test("should not block allies' self-targeted moves", async () => { it("should protect the user and allies from moves that ignore other protection", async () => {
game.override.moveset(MoveId.CURSE);
await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]); await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]);
const leadPokemon = game.scene.getPlayerField(); const [charizard, blastoise] = game.scene.getPlayerField();
game.move.select(MoveId.CRAFTY_SHIELD); game.move.use(MoveId.CRAFTY_SHIELD, BattlerIndex.PLAYER);
game.move.select(MoveId.SWORDS_DANCE, 1); game.move.use(MoveId.SPLASH, BattlerIndex.PLAYER_2);
await game.move.forceEnemyMove(MoveId.CURSE, BattlerIndex.PLAYER);
await game.move.forceEnemyMove(MoveId.CURSE, BattlerIndex.PLAYER_2);
await game.phaseInterceptor.to(BerryPhase, false); await game.toEndOfTurn();
expect(leadPokemon[0].getStatStage(Stat.ATK)).toBe(0); expect(charizard.getTag(BattlerTagType.CURSED)).toBeUndefined();
expect(leadPokemon[1].getStatStage(Stat.ATK)).toBe(2); expect(blastoise.getTag(BattlerTagType.CURSED)).toBeUndefined();
const [dusknoir1, dusknoir2] = game.scene.getEnemyField();
expect(dusknoir1).toHaveFullHp();
expect(dusknoir2).toHaveFullHp();
});
it("should not block allies' self or ally-targeted moves", async () => {
await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]);
const [charizard, blastoise] = game.scene.getPlayerField();
game.move.use(MoveId.CRAFTY_SHIELD, BattlerIndex.PLAYER);
game.move.use(MoveId.SWORDS_DANCE, BattlerIndex.PLAYER_2);
await game.phaseInterceptor.to("TurnEndPhase");
expect(charizard.getStatStage(Stat.ATK)).toBe(0);
expect(blastoise.getStatStage(Stat.ATK)).toBe(2);
game.move.use(MoveId.HOWL, BattlerIndex.PLAYER);
game.move.use(MoveId.CRAFTY_SHIELD, BattlerIndex.PLAYER_2);
await game.phaseInterceptor.to("TurnEndPhase");
expect(charizard.getStatStage(Stat.ATK)).toBe(1);
expect(blastoise.getStatStage(Stat.ATK)).toBe(3);
}); });
}); });

View File

@ -1,9 +1,10 @@
import { AbilityId } from "#enums/ability-id"; import { AbilityId } from "#enums/ability-id";
import { HitResult } from "#enums/hit-result";
import { MoveId } from "#enums/move-id"; import { MoveId } from "#enums/move-id";
import { SpeciesId } from "#enums/species-id"; import { SpeciesId } from "#enums/species-id";
import { GameManager } from "#test/test-utils/game-manager"; import { GameManager } from "#test/test-utils/game-manager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
describe("Moves - Endure", () => { describe("Moves - Endure", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -22,7 +23,7 @@ describe("Moves - Endure", () => {
beforeEach(() => { beforeEach(() => {
game = new GameManager(phaserGame); game = new GameManager(phaserGame);
game.override game.override
.moveset([MoveId.THUNDER, MoveId.BULLET_SEED, MoveId.TOXIC, MoveId.SHEER_COLD]) .moveset([MoveId.THUNDER, MoveId.BULLET_SEED, MoveId.SHEER_COLD])
.ability(AbilityId.SKILL_LINK) .ability(AbilityId.SKILL_LINK)
.startingLevel(100) .startingLevel(100)
.battleStyle("single") .battleStyle("single")
@ -32,7 +33,7 @@ describe("Moves - Endure", () => {
.enemyMoveset(MoveId.ENDURE); .enemyMoveset(MoveId.ENDURE);
}); });
it("should let the pokemon survive with 1 HP", async () => { it("should let the pokemon survive with 1 HP from attacks", async () => {
await game.classicMode.startBattle([SpeciesId.ARCEUS]); await game.classicMode.startBattle([SpeciesId.ARCEUS]);
game.move.select(MoveId.THUNDER); game.move.select(MoveId.THUNDER);
@ -41,7 +42,7 @@ describe("Moves - Endure", () => {
expect(game.field.getEnemyPokemon().hp).toBe(1); expect(game.field.getEnemyPokemon().hp).toBe(1);
}); });
it("should let the pokemon survive with 1 HP when hit with a multihit move", async () => { it("should let the pokemon survive with 1 HP from multi-strike moves", async () => {
await game.classicMode.startBattle([SpeciesId.ARCEUS]); await game.classicMode.startBattle([SpeciesId.ARCEUS]);
game.move.select(MoveId.BULLET_SEED); game.move.select(MoveId.BULLET_SEED);
@ -57,30 +58,27 @@ describe("Moves - Endure", () => {
game.move.select(MoveId.SHEER_COLD); game.move.select(MoveId.SHEER_COLD);
await game.phaseInterceptor.to("TurnEndPhase"); await game.phaseInterceptor.to("TurnEndPhase");
expect(enemy.isFainted()).toBeFalsy(); expect(enemy.hp).toBe(1);
}); });
// comprehensive indirect damage test copied from Reviver Seed test // comprehensive indirect damage test copied from Reviver Seed test
it.each([ it.each([
{ moveType: "Damaging Move Chip Damage", move: MoveId.SALT_CURE }, { moveType: "Damaging Move Chip", move: MoveId.SALT_CURE },
{ moveType: "Chip Damage", move: MoveId.LEECH_SEED }, { moveType: "Status Move Chip", move: MoveId.LEECH_SEED },
{ moveType: "Trapping Chip Damage", move: MoveId.WHIRLPOOL }, { moveType: "Partial Trapping move", move: MoveId.WHIRLPOOL },
{ moveType: "Status Effect Damage", move: MoveId.TOXIC }, { moveType: "Status Effect", move: MoveId.TOXIC },
{ moveType: "Weather", move: MoveId.SANDSTORM }, { moveType: "Weather", move: MoveId.SANDSTORM },
])("should not prevent fainting from $moveType", async ({ move }) => { ])("should not prevent fainting from $moveType Damage", async ({ move }) => {
game.override game.override.moveset(move).enemyLevel(100);
.enemyLevel(1)
.startingLevel(100)
.enemySpecies(SpeciesId.MAGIKARP)
.moveset(move)
.enemyMoveset(MoveId.ENDURE);
await game.classicMode.startBattle([SpeciesId.MAGIKARP, SpeciesId.FEEBAS]); await game.classicMode.startBattle([SpeciesId.MAGIKARP, SpeciesId.FEEBAS]);
const enemy = game.field.getEnemyPokemon(); const enemy = game.field.getEnemyPokemon();
enemy.damageAndUpdate(enemy.hp - 1); enemy.hp = 2;
// force attack to do 1 dmg (for salt cure)
vi.spyOn(enemy, "getAttackDamage").mockReturnValue({ cancelled: false, result: HitResult.EFFECTIVE, damage: 1 });
game.move.select(move); game.move.select(move);
await game.phaseInterceptor.to("TurnEndPhase"); await game.phaseInterceptor.to("TurnEndPhase");
expect(enemy.isFainted()).toBeTruthy(); expect(enemy.isFainted()).toBe(true);
}); });
}); });

View File

@ -1,15 +1,14 @@
import { ArenaTrapTag } from "#data/arena-tag";
import { allMoves } from "#data/data-lists"; import { allMoves } from "#data/data-lists";
import { AbilityId } from "#enums/ability-id"; import { AbilityId } from "#enums/ability-id";
import { ArenaTagSide } from "#enums/arena-tag-side";
import { BattlerIndex } from "#enums/battler-index"; import { BattlerIndex } from "#enums/battler-index";
import { MoveId } from "#enums/move-id"; import { MoveId } from "#enums/move-id";
import { MoveResult } from "#enums/move-result"; import { MoveResult } from "#enums/move-result";
import { MoveUseMode } from "#enums/move-use-mode";
import { SpeciesId } from "#enums/species-id"; import { SpeciesId } from "#enums/species-id";
import { Stat } from "#enums/stat"; import { Stat } from "#enums/stat";
import { GameManager } from "#test/test-utils/game-manager"; import { GameManager } from "#test/test-utils/game-manager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, test, vi } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
describe("Moves - Protect", () => { describe("Moves - Protect", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -27,90 +26,210 @@ describe("Moves - Protect", () => {
beforeEach(() => { beforeEach(() => {
game = new GameManager(phaserGame); game = new GameManager(phaserGame);
game.override game.override
.battleStyle("single") .battleStyle("single")
.moveset([MoveId.PROTECT]) .moveset([MoveId.PROTECT, MoveId.SPIKY_SHIELD, MoveId.ENDURE, MoveId.SPLASH])
.enemySpecies(SpeciesId.SNORLAX) .enemySpecies(SpeciesId.SNORLAX)
.enemyAbility(AbilityId.INSOMNIA) .enemyAbility(AbilityId.INSOMNIA)
.enemyMoveset([MoveId.TACKLE]) .enemyMoveset(MoveId.LUMINA_CRASH)
.startingLevel(100) .startingLevel(100)
.enemyLevel(100); .enemyLevel(100);
}); });
test("should protect the user from attacks", async () => { it("should protect the user from attacks and their secondary effects", async () => {
await game.classicMode.startBattle([SpeciesId.CHARIZARD]); await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
const leadPokemon = game.field.getPlayerPokemon(); const charizard = game.field.getPlayerPokemon();
game.move.select(MoveId.PROTECT); game.move.select(MoveId.PROTECT);
await game.phaseInterceptor.to("BerryPhase", false); await game.phaseInterceptor.to("BerryPhase", false);
expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp()); expect(charizard.hp).toBe(charizard.getMaxHp());
expect(charizard.getStatStage(Stat.SPDEF)).toBe(0);
expect(charizard);
}); });
test("should prevent secondary effects from the opponent's attack", async () => { it.each<{ numTurns: number; chance: number }>([
game.override.enemyMoveset([MoveId.CEASELESS_EDGE]); { numTurns: 1, chance: 3 },
vi.spyOn(allMoves[MoveId.CEASELESS_EDGE], "accuracy", "get").mockReturnValue(100); { numTurns: 2, chance: 9 },
{ numTurns: 3, chance: 27 },
{ numTurns: 4, chance: 81 },
])("should have a 1/$chance success rate after $numTurns successful uses", async ({ numTurns, chance }) => {
await game.classicMode.startBattle([SpeciesId.CHARIZARD]); await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
const leadPokemon = game.field.getPlayerPokemon(); const charizard = game.scene.getPlayerPokemon()!;
// mock RNG roll to suceed unless exactly the desired chance is hit
vi.spyOn(charizard, "randBattleSeedInt").mockImplementation(range => (range !== chance ? 0 : 1));
const conditionSpy = vi.spyOn(allMoves[MoveId.PROTECT]["conditions"][0], "apply");
// click protect many times
for (let x = 0; x < numTurns; x++) {
game.move.select(MoveId.PROTECT);
await game.toNextTurn();
expect(charizard.hp).toBe(charizard.getMaxHp());
expect(charizard.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
expect(conditionSpy).toHaveLastReturnedWith(true);
}
game.move.select(MoveId.PROTECT); game.move.select(MoveId.PROTECT);
await game.toNextTurn();
await game.phaseInterceptor.to("BerryPhase", false); expect(charizard.hp).toBeLessThan(charizard.getMaxHp());
expect(charizard.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp()); expect(conditionSpy).toHaveLastReturnedWith(false);
expect(game.scene.arena.getTagOnSide(ArenaTrapTag, ArenaTagSide.ENEMY)).toBeUndefined();
}); });
test("should protect the user from status moves", async () => { it("should share fail chance with all move variants", async () => {
game.override.enemyMoveset([MoveId.CHARM]);
await game.classicMode.startBattle([SpeciesId.CHARIZARD]); await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
const leadPokemon = game.field.getPlayerPokemon(); const charizard = game.field.getPlayerPokemon();
charizard.summonData.moveHistory = [
{ move: MoveId.ENDURE, result: MoveResult.SUCCESS, targets: [BattlerIndex.PLAYER], useMode: MoveUseMode.NORMAL },
{
move: MoveId.SPIKY_SHIELD,
result: MoveResult.SUCCESS,
targets: [BattlerIndex.PLAYER],
useMode: MoveUseMode.NORMAL,
},
];
// force protect to fail on anything >=2 uses (1/9 chance)
vi.spyOn(charizard, "randBattleSeedInt").mockImplementation(range => (range >= 9 ? 1 : 0));
game.move.select(MoveId.PROTECT); game.move.select(MoveId.PROTECT);
await game.toNextTurn();
await game.phaseInterceptor.to("BerryPhase", false); expect(charizard.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
expect(leadPokemon.getStatStage(Stat.ATK)).toBe(0);
}); });
test("should stop subsequent hits of a multi-hit move", async () => { it("should reset fail chance on move failure", async () => {
await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
const charizard = game.scene.getPlayerPokemon()!;
// force protect to always fail if RNG roll attempt is made
vi.spyOn(charizard, "randBattleSeedInt").mockReturnValue(1);
game.move.select(MoveId.PROTECT);
await game.toNextTurn();
expect(charizard.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
game.move.select(MoveId.SPIKY_SHIELD);
await game.toNextTurn();
expect(charizard.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
game.move.select(MoveId.SPIKY_SHIELD);
await game.toNextTurn();
expect(charizard.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
});
it("should reset fail chance on using another move", async () => {
await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
const charizard = game.scene.getPlayerPokemon()!;
// force protect to always fail if RNG roll attempt is made
vi.spyOn(charizard, "randBattleSeedInt").mockReturnValue(1);
game.move.select(MoveId.PROTECT);
await game.toNextTurn();
expect(charizard.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
game.move.select(MoveId.SPLASH);
await game.toNextTurn();
game.move.select(MoveId.PROTECT);
await game.toNextTurn();
expect(charizard.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
});
it("should reset fail chance on starting a new wave", async () => {
await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
const charizard = game.field.getPlayerPokemon();
// force protect to always fail if RNG roll attempt is made
vi.spyOn(charizard, "randBattleSeedInt").mockReturnValue(1);
game.move.select(MoveId.PROTECT);
// Wait until move end phase to kill opponent to ensure protect doesn't fail due to going last
await game.phaseInterceptor.to("MoveEndPhase");
await game.doKillOpponents();
await game.toNextWave();
expect(charizard.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
game.move.select(MoveId.SPIKY_SHIELD);
expect(charizard.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
});
it("should not be blocked by Psychic Terrain", async () => {
game.override.ability(AbilityId.PSYCHIC_SURGE);
await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
const charizard = game.scene.getPlayerPokemon()!;
game.move.select(MoveId.PROTECT);
await game.toNextTurn();
expect(charizard.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
});
it("should stop subsequent hits of multi-hit moves", async () => {
game.override.enemyMoveset([MoveId.TACHYON_CUTTER]); game.override.enemyMoveset([MoveId.TACHYON_CUTTER]);
await game.classicMode.startBattle([SpeciesId.CHARIZARD]); await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
const leadPokemon = game.field.getPlayerPokemon(); const charizard = game.field.getPlayerPokemon();
const enemyPokemon = game.field.getEnemyPokemon(); const enemyPokemon = game.field.getEnemyPokemon();
game.move.select(MoveId.PROTECT); game.move.select(MoveId.PROTECT);
await game.phaseInterceptor.to("BerryPhase", false); await game.phaseInterceptor.to("BerryPhase", false);
expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp()); expect(charizard.hp).toBe(charizard.getMaxHp());
expect(enemyPokemon.turnData.hitCount).toBe(1); expect(enemyPokemon.turnData.hitCount).toBe(1);
}); });
test("should fail if the user is the last to move in the turn", async () => { it("should fail if the user moves last in the turn", async () => {
game.override.enemyMoveset([MoveId.PROTECT]); game.override.enemyMoveset(MoveId.PROTECT);
await game.classicMode.startBattle([SpeciesId.CHARIZARD]); await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
const leadPokemon = game.field.getPlayerPokemon(); const charizard = game.field.getPlayerPokemon();
const enemyPokemon = game.field.getEnemyPokemon(); const enemyPokemon = game.field.getEnemyPokemon();
game.move.select(MoveId.PROTECT); game.move.select(MoveId.PROTECT);
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
await game.phaseInterceptor.to("BerryPhase", false); await game.phaseInterceptor.to("BerryPhase", false);
expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS); expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
expect(leadPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL); expect(charizard.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
}); });
it("should not block Protection-bypassing moves or Future Sight", async () => {
game.override.enemyMoveset([MoveId.FUTURE_SIGHT, MoveId.MIGHTY_CLEAVE, MoveId.SPORE]);
await game.classicMode.startBattle([SpeciesId.AGGRON]);
const aggron = game.scene.getPlayerPokemon()!;
vi.spyOn(aggron, "randBattleSeedInt").mockReturnValue(0);
// Turn 1: setup future sight
game.move.select(MoveId.PROTECT);
await game.move.forceEnemyMove(MoveId.FUTURE_SIGHT);
await game.toNextTurn();
// Turn 2: mighty cleave
game.move.select(MoveId.PROTECT);
await game.move.forceEnemyMove(MoveId.MIGHTY_CLEAVE);
await game.toNextTurn();
expect(aggron.hp).toBeLessThan(aggron.getMaxHp());
aggron.hp = aggron.getMaxHp();
// turn 3: Future Sight hits
game.move.select(MoveId.PROTECT);
await game.move.forceEnemyMove(MoveId.SPORE);
await game.toNextTurn();
expect(aggron.hp).toBeLessThan(aggron.getMaxHp());
expect(aggron.status?.effect).toBeUndefined(); // check that protect actually worked
});
// TODO: Add test
it.todo("should not reset counter when throwing balls");
}); });

View File

@ -3,10 +3,9 @@ import { BattlerIndex } from "#enums/battler-index";
import { MoveId } from "#enums/move-id"; import { MoveId } from "#enums/move-id";
import { MoveResult } from "#enums/move-result"; import { MoveResult } from "#enums/move-result";
import { SpeciesId } from "#enums/species-id"; import { SpeciesId } from "#enums/species-id";
import { Stat } from "#enums/stat";
import { GameManager } from "#test/test-utils/game-manager"; import { GameManager } from "#test/test-utils/game-manager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
describe("Moves - Quick Guard", () => { describe("Moves - Quick Guard", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -27,74 +26,72 @@ describe("Moves - Quick Guard", () => {
game.override game.override
.battleStyle("double") .battleStyle("double")
.moveset([MoveId.QUICK_GUARD, MoveId.SPLASH, MoveId.FOLLOW_ME]) .moveset([MoveId.QUICK_GUARD, MoveId.SPLASH, MoveId.SPIKY_SHIELD])
.enemySpecies(SpeciesId.SNORLAX) .enemySpecies(SpeciesId.SNORLAX)
.enemyMoveset([MoveId.QUICK_ATTACK]) .enemyMoveset(MoveId.QUICK_ATTACK)
.enemyAbility(AbilityId.INSOMNIA) .enemyAbility(AbilityId.BALL_FETCH)
.startingLevel(100) .startingLevel(100)
.enemyLevel(100); .enemyLevel(100);
}); });
test("should protect the user and allies from priority moves", async () => { it("should protect the user and allies from priority moves", async () => {
await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]); await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]);
const playerPokemon = game.scene.getPlayerField(); const [charizard, blastoise] = game.scene.getPlayerField();
game.move.select(MoveId.QUICK_GUARD);
game.move.select(MoveId.SPLASH, 1);
game.move.select(MoveId.QUICK_GUARD, BattlerIndex.PLAYER);
game.move.select(MoveId.SPLASH, BattlerIndex.PLAYER_2);
await game.move.forceEnemyMove(MoveId.QUICK_ATTACK, BattlerIndex.PLAYER);
await game.move.forceEnemyMove(MoveId.QUICK_ATTACK, BattlerIndex.PLAYER_2);
await game.phaseInterceptor.to("BerryPhase", false); await game.phaseInterceptor.to("BerryPhase", false);
playerPokemon.forEach(p => expect(p.hp).toBe(p.getMaxHp())); expect(charizard.hp).toBe(charizard.getMaxHp());
expect(blastoise.hp).toBe(blastoise.getMaxHp());
}); });
test("should protect the user and allies from Prankster-boosted moves", async () => { it.each<{ name: string; move: MoveId; ability: AbilityId }>([
game.override.enemyAbility(AbilityId.PRANKSTER).enemyMoveset([MoveId.GROWL]); { name: "Prankster", move: MoveId.SPORE, ability: AbilityId.PRANKSTER },
{ name: "Gale Wings", move: MoveId.BRAVE_BIRD, ability: AbilityId.GALE_WINGS },
])("should protect the user and allies from $name-boosted moves", async ({ move, ability }) => {
game.override.enemyMoveset(move).enemyAbility(ability);
await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]); await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]);
const playerPokemon = game.scene.getPlayerField(); const [charizard, blastoise] = game.scene.getPlayerField();
game.move.select(MoveId.QUICK_GUARD);
game.move.select(MoveId.SPLASH, 1);
game.move.select(MoveId.QUICK_GUARD, BattlerIndex.PLAYER);
game.move.select(MoveId.SPLASH, BattlerIndex.PLAYER_2);
await game.move.forceEnemyMove(move, BattlerIndex.PLAYER);
await game.move.forceEnemyMove(move, BattlerIndex.PLAYER_2);
await game.phaseInterceptor.to("BerryPhase", false); await game.phaseInterceptor.to("BerryPhase", false);
playerPokemon.forEach(p => expect(p.getStatStage(Stat.ATK)).toBe(0)); expect(charizard.hp).toBe(charizard.getMaxHp());
expect(blastoise.hp).toBe(blastoise.getMaxHp());
expect(charizard.status?.effect).toBeUndefined();
expect(blastoise.status?.effect).toBeUndefined();
}); });
test("should stop subsequent hits of a multi-hit priority move", async () => { it("should increment (but not respect) other protection moves' fail counters", async () => {
game.override.enemyMoveset([MoveId.WATER_SHURIKEN]); game.override.battleStyle("single");
await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]);
const playerPokemon = game.scene.getPlayerField();
const enemyPokemon = game.scene.getEnemyField();
game.move.select(MoveId.QUICK_GUARD);
game.move.select(MoveId.FOLLOW_ME, 1);
await game.phaseInterceptor.to("BerryPhase", false);
playerPokemon.forEach(p => expect(p.hp).toBe(p.getMaxHp()));
enemyPokemon.forEach(p => expect(p.turnData.hitCount).toBe(1));
});
test("should fail if the user is the last to move in the turn", async () => {
game.override.battleStyle("single").enemyMoveset([MoveId.QUICK_GUARD]);
await game.classicMode.startBattle([SpeciesId.CHARIZARD]); await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
const playerPokemon = game.field.getPlayerPokemon(); const charizard = game.scene.getPlayerPokemon()!;
const enemyPokemon = game.field.getEnemyPokemon(); // force protect to fail on anything >0 uses
vi.spyOn(charizard, "randBattleSeedInt").mockReturnValue(1);
game.move.select(MoveId.QUICK_GUARD); game.move.select(MoveId.QUICK_GUARD);
await game.toNextTurn();
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); expect(charizard.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
await game.phaseInterceptor.to("BerryPhase", false); game.move.select(MoveId.QUICK_GUARD);
await game.toNextTurn();
expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS); // ignored fail chance
expect(playerPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL); expect(charizard.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
game.move.select(MoveId.SPIKY_SHIELD);
await game.toNextTurn();
expect(charizard.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
}); });
}); });

View File

@ -1,4 +1,3 @@
import { globalScene } from "#app/global-scene";
import { Status } from "#data/status-effect"; import { Status } from "#data/status-effect";
import { AbilityId } from "#enums/ability-id"; import { AbilityId } from "#enums/ability-id";
import { BattleType } from "#enums/battle-type"; import { BattleType } from "#enums/battle-type";
@ -179,18 +178,13 @@ describe("Moves - Whirlwind", () => {
const eligibleEnemy = enemyParty.filter(p => p.hp > 0 && p.isAllowedInBattle()); const eligibleEnemy = enemyParty.filter(p => p.hp > 0 && p.isAllowedInBattle());
expect(eligibleEnemy.length).toBe(1); expect(eligibleEnemy.length).toBe(1);
// Spy on the queueMessage function
const queueSpy = vi.spyOn(globalScene.phaseManager, "queueMessage");
// Player uses Whirlwind; opponent uses Splash // Player uses Whirlwind; opponent uses Splash
game.move.select(MoveId.WHIRLWIND); game.move.select(MoveId.WHIRLWIND);
await game.move.selectEnemyMove(MoveId.SPLASH); await game.move.selectEnemyMove(MoveId.SPLASH);
await game.toNextTurn(); await game.toNextTurn();
// Verify that the failure message is displayed for Whirlwind const player = game.field.getPlayerPokemon();
expect(queueSpy).toHaveBeenCalledWith(expect.stringContaining("But it failed")); expect(player).toHaveUsedMove({ move: MoveId.WHIRLWIND, result: MoveResult.FAIL });
// Verify the opponent's Splash message
expect(queueSpy).toHaveBeenCalledWith(expect.stringContaining("But nothing happened!"));
}); });
it("should not pull in the other trainer's pokemon in a partner trainer battle", async () => { it("should not pull in the other trainer's pokemon in a partner trainer battle", async () => {

View File

@ -1,11 +1,12 @@
import { AbilityId } from "#enums/ability-id"; import { AbilityId } from "#enums/ability-id";
import { BattlerIndex } from "#enums/battler-index";
import { MoveId } from "#enums/move-id"; import { MoveId } from "#enums/move-id";
import { MoveResult } from "#enums/move-result";
import { SpeciesId } from "#enums/species-id"; import { SpeciesId } from "#enums/species-id";
import { Stat } from "#enums/stat"; import { Stat } from "#enums/stat";
import { BerryPhase } from "#phases/berry-phase";
import { GameManager } from "#test/test-utils/game-manager"; import { GameManager } from "#test/test-utils/game-manager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
describe("Moves - Wide Guard", () => { describe("Moves - Wide Guard", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -26,71 +27,84 @@ describe("Moves - Wide Guard", () => {
game.override game.override
.battleStyle("double") .battleStyle("double")
.moveset([MoveId.WIDE_GUARD, MoveId.SPLASH, MoveId.SURF]) .moveset([MoveId.WIDE_GUARD, MoveId.SPLASH, MoveId.SURF, MoveId.SPIKY_SHIELD])
.enemySpecies(SpeciesId.SNORLAX) .enemySpecies(SpeciesId.SNORLAX)
.enemyMoveset(MoveId.SWIFT) .enemyMoveset([MoveId.SWIFT, MoveId.GROWL, MoveId.TACKLE])
.enemyAbility(AbilityId.INSOMNIA) .enemyAbility(AbilityId.INSOMNIA)
.startingLevel(100) .startingLevel(100)
.enemyLevel(100); .enemyLevel(100);
}); });
test("should protect the user and allies from multi-target attack moves", async () => { it("should protect the user and allies from multi-target attack and status moves", async () => {
await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]); await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]);
const [charizard, blastoise] = game.scene.getPlayerField();
const leadPokemon = game.scene.getPlayerField(); game.move.select(MoveId.WIDE_GUARD, BattlerIndex.PLAYER);
game.move.select(MoveId.SPLASH, BattlerIndex.PLAYER_2);
await game.move.forceEnemyMove(MoveId.SWIFT);
await game.move.forceEnemyMove(MoveId.GROWL);
await game.phaseInterceptor.to("TurnEndPhase");
game.move.select(MoveId.WIDE_GUARD); expect(charizard.hp).toBe(charizard.getMaxHp());
game.move.select(MoveId.SPLASH, 1); expect(blastoise.hp).toBe(blastoise.getMaxHp());
expect(charizard.getStatStage(Stat.ATK)).toBe(0);
await game.phaseInterceptor.to(BerryPhase, false); expect(blastoise.getStatStage(Stat.ATK)).toBe(0);
leadPokemon.forEach(p => expect(p.hp).toBe(p.getMaxHp()));
}); });
test("should protect the user and allies from multi-target status moves", async () => { it("should not protect the user and allies from single-target moves", async () => {
game.override.enemyMoveset([MoveId.GROWL]);
await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]); await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]);
const leadPokemon = game.scene.getPlayerField(); const [charizard, blastoise] = game.scene.getPlayerField();
game.move.select(MoveId.WIDE_GUARD, BattlerIndex.PLAYER);
game.move.select(MoveId.SPLASH, BattlerIndex.PLAYER_2);
await game.move.forceEnemyMove(MoveId.TACKLE, BattlerIndex.PLAYER);
await game.move.forceEnemyMove(MoveId.TACKLE, BattlerIndex.PLAYER_2);
await game.phaseInterceptor.to("TurnEndPhase");
game.move.select(MoveId.WIDE_GUARD); expect(charizard.hp).toBeLessThan(charizard.getMaxHp());
game.move.select(MoveId.SPLASH, 1); expect(blastoise.hp).toBeLessThan(blastoise.getMaxHp());
await game.phaseInterceptor.to(BerryPhase, false);
leadPokemon.forEach(p => expect(p.getStatStage(Stat.ATK)).toBe(0));
}); });
test("should not protect the user and allies from single-target moves", async () => { it("should protect the user from its ally's multi-target move", async () => {
game.override.enemyMoveset([MoveId.TACKLE]); game.override.enemyMoveset(MoveId.SPLASH);
await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]); await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]);
const leadPokemon = game.scene.getPlayerField(); const charizard = game.scene.getPlayerPokemon()!;
const [snorlax1, snorlax2] = game.scene.getEnemyField();
game.move.select(MoveId.WIDE_GUARD); game.move.select(MoveId.WIDE_GUARD, BattlerIndex.PLAYER);
game.move.select(MoveId.SPLASH, 1); game.move.select(MoveId.SURF, BattlerIndex.PLAYER_2);
await game.phaseInterceptor.to("TurnEndPhase");
await game.phaseInterceptor.to(BerryPhase, false); expect(charizard.hp).toBe(charizard.getMaxHp());
expect(snorlax1.hp).toBeLessThan(snorlax1.getMaxHp());
expect(leadPokemon.some(p => p.hp < p.getMaxHp())).toBeTruthy(); expect(snorlax2.hp).toBeLessThan(snorlax2.getMaxHp());
}); });
test("should protect the user from its ally's multi-target move", async () => { it("should increment (but not respect) other protection moves' fail counters", async () => {
game.override.enemyMoveset([MoveId.SPLASH]); game.override.battleStyle("single");
await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]); const charizard = game.scene.getPlayerPokemon()!;
// force protect to fail on anything other than a guaranteed success
const leadPokemon = game.scene.getPlayerField(); vi.spyOn(charizard, "randBattleSeedInt").mockReturnValue(1);
const enemyPokemon = game.scene.getEnemyField();
game.move.select(MoveId.WIDE_GUARD); game.move.select(MoveId.WIDE_GUARD);
game.move.select(MoveId.SURF, 1); await game.toNextTurn();
await game.phaseInterceptor.to(BerryPhase, false); expect(charizard.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
expect(leadPokemon[0].hp).toBe(leadPokemon[0].getMaxHp()); // ignored fail chance
enemyPokemon.forEach(p => expect(p.hp).toBeLessThan(p.getMaxHp())); game.move.select(MoveId.WIDE_GUARD);
await game.toNextTurn();
expect(charizard.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
game.move.select(MoveId.SPIKY_SHIELD);
await game.toNextTurn();
// ignored fail chance
expect(charizard.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
}); });
}); });