mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-06-20 16:42:45 +02:00
Compare commits
10 Commits
f3a0a2baf5
...
f22d4ed032
Author | SHA1 | Date | |
---|---|---|---|
|
f22d4ed032 | ||
|
1ff2701964 | ||
|
1e306e25b5 | ||
|
43aa772603 | ||
|
3d20235fa5 | ||
|
33a639c18e | ||
|
07eb03f981 | ||
|
501fb0b594 | ||
|
5449209f2f | ||
|
e7b8326bb7 |
@ -93,6 +93,10 @@ import { ChargingMove, MoveAttrMap, MoveAttrString, MoveKindString, MoveClassMap
|
||||
import { applyMoveAttrs } from "./apply-attrs";
|
||||
import { frenzyMissFunc, getMoveTargets } from "./move-utils";
|
||||
|
||||
/**
|
||||
* A function used to conditionally determine execution of a given {@linkcode MoveAttr}.
|
||||
* Conventionally returns `true` for success and `false` for failure.
|
||||
*/
|
||||
type MoveConditionFunc = (user: Pokemon, target: Pokemon, move: Move) => boolean;
|
||||
export type UserMoveConditionFunc = (user: Pokemon, move: Move) => boolean;
|
||||
|
||||
@ -1390,18 +1394,31 @@ export class BeakBlastHeaderAttr extends AddBattlerTagHeaderAttr {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attribute to display a message before a move is executed.
|
||||
*/
|
||||
export class PreMoveMessageAttr extends MoveAttr {
|
||||
private message: string | ((user: Pokemon, target: Pokemon, move: Move) => string);
|
||||
/** The message to display or a function returning one */
|
||||
private message: string | ((user: Pokemon, target: Pokemon, move: Move) => string | undefined);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @remarks
|
||||
* If {@linkcode message} evaluates to an empty string (`''`), no message will be displayed
|
||||
* (though the move will still succeed).
|
||||
*/
|
||||
constructor(message: string | ((user: Pokemon, target: Pokemon, move: Move) => string)) {
|
||||
super();
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
||||
const message = typeof this.message === "string"
|
||||
? this.message as string
|
||||
: this.message(user, target, move);
|
||||
apply(user: Pokemon, target: Pokemon, move: Move, _args: any[]): 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;
|
||||
@ -1929,15 +1946,74 @@ export class HealAttr extends MoveEffectAttr {
|
||||
* Creates a new {@linkcode PokemonHealPhase}.
|
||||
* This heals the target and shows the appropriate message.
|
||||
*/
|
||||
addHealPhase(target: Pokemon, healRatio: number) {
|
||||
protected addHealPhase(target: Pokemon, healRatio: number) {
|
||||
globalScene.phaseManager.unshiftNew("PokemonHealPhase", target.getBattlerIndex(),
|
||||
toDmgValue(target.getMaxHp() * healRatio), i18next.t("moveTriggers:healHp", { pokemonName: getPokemonNameWithAffix(target) }), true, !this.showAnim);
|
||||
}
|
||||
|
||||
getTargetBenefitScore(user: Pokemon, target: Pokemon, move: Move): number {
|
||||
override getTargetBenefitScore(user: Pokemon, target: Pokemon, _move: Move): number {
|
||||
const score = ((1 - (this.selfTarget ? user : target).getHpRatio()) * 20) - this.healRatio * 10;
|
||||
return Math.round(score / (1 - this.healRatio / 2));
|
||||
}
|
||||
|
||||
// TODO: Change post move failure rework
|
||||
override canApply(user: Pokemon, target: Pokemon, _move: Move, _args?: any[]): boolean {
|
||||
if (!super.canApply(user, target, _move, _args)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const healedPokemon = this.selfTarget ? user : target;
|
||||
if (healedPokemon.isFullHp()) {
|
||||
globalScene.phaseManager.queueMessage(i18next.t("battle:hpIsFull", {
|
||||
pokemonName: getPokemonNameWithAffix(healedPokemon),
|
||||
}))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attribute for moves with variable healing amounts.
|
||||
* Heals the target by an amount depending on the return value of {@linkcode healFunc}.
|
||||
*
|
||||
* Used for {@linkcode MoveId.MOONLIGHT}, {@linkcode MoveId.SHORE_UP}, {@linkcode MoveId.JUNGLE_HEALING}, {@linkcode MoveId.SWALLOW}
|
||||
*/
|
||||
export class VariableHealAttr extends HealAttr {
|
||||
constructor(
|
||||
/** A function yielding the amount of HP to heal. */
|
||||
private healFunc: (user: Pokemon, target: Pokemon, _move: Move) => number,
|
||||
showAnim = false,
|
||||
selfTarget = true,
|
||||
) {
|
||||
super(1, showAnim, selfTarget);
|
||||
this.healFunc = healFunc;
|
||||
}
|
||||
|
||||
apply(user: Pokemon, target: Pokemon, move: Move, _args: any[]): boolean {
|
||||
const healRatio = this.healFunc(user, target, move)
|
||||
this.addHealPhase(target, healRatio);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Heals the target only if it is an ally.
|
||||
* Used for {@linkcode MoveId.POLLEN_PUFF}.
|
||||
*/
|
||||
export class HealOnAllyAttr extends HealAttr {
|
||||
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
||||
if (user.getAlly() === target) {
|
||||
super.apply(user, target, move, args);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
override canApply(user: Pokemon, target: Pokemon, _move: Move, _args?: any[]): boolean {
|
||||
return user.getAlly() !== target || super.canApply(user, target, _move, _args);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2120,112 +2196,6 @@ export class IgnoreWeatherTypeDebuffAttr extends MoveAttr {
|
||||
}
|
||||
}
|
||||
|
||||
export abstract class WeatherHealAttr extends HealAttr {
|
||||
constructor() {
|
||||
super(0.5);
|
||||
}
|
||||
|
||||
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
||||
let healRatio = 0.5;
|
||||
if (!globalScene.arena.weather?.isEffectSuppressed()) {
|
||||
const weatherType = globalScene.arena.weather?.weatherType || WeatherType.NONE;
|
||||
healRatio = this.getWeatherHealRatio(weatherType);
|
||||
}
|
||||
this.addHealPhase(user, healRatio);
|
||||
return true;
|
||||
}
|
||||
|
||||
abstract getWeatherHealRatio(weatherType: WeatherType): number;
|
||||
}
|
||||
|
||||
export class PlantHealAttr extends WeatherHealAttr {
|
||||
getWeatherHealRatio(weatherType: WeatherType): number {
|
||||
switch (weatherType) {
|
||||
case WeatherType.SUNNY:
|
||||
case WeatherType.HARSH_SUN:
|
||||
return 2 / 3;
|
||||
case WeatherType.RAIN:
|
||||
case WeatherType.SANDSTORM:
|
||||
case WeatherType.HAIL:
|
||||
case WeatherType.SNOW:
|
||||
case WeatherType.FOG:
|
||||
case WeatherType.HEAVY_RAIN:
|
||||
return 0.25;
|
||||
default:
|
||||
return 0.5;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class SandHealAttr extends WeatherHealAttr {
|
||||
getWeatherHealRatio(weatherType: WeatherType): number {
|
||||
switch (weatherType) {
|
||||
case WeatherType.SANDSTORM:
|
||||
return 2 / 3;
|
||||
default:
|
||||
return 0.5;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Heals the target or the user by either {@linkcode normalHealRatio} or {@linkcode boostedHealRatio}
|
||||
* depending on the evaluation of {@linkcode condition}
|
||||
* @extends HealAttr
|
||||
* @see {@linkcode apply}
|
||||
*/
|
||||
export class BoostHealAttr extends HealAttr {
|
||||
/** Healing received when {@linkcode condition} is false */
|
||||
private normalHealRatio: number;
|
||||
/** Healing received when {@linkcode condition} is true */
|
||||
private boostedHealRatio: number;
|
||||
/** The lambda expression to check against when boosting the healing value */
|
||||
private condition?: MoveConditionFunc;
|
||||
|
||||
constructor(normalHealRatio: number = 0.5, boostedHealRatio: number = 2 / 3, showAnim?: boolean, selfTarget?: boolean, condition?: MoveConditionFunc) {
|
||||
super(normalHealRatio, showAnim, selfTarget);
|
||||
this.normalHealRatio = normalHealRatio;
|
||||
this.boostedHealRatio = boostedHealRatio;
|
||||
this.condition = condition;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param user {@linkcode Pokemon} using the move
|
||||
* @param target {@linkcode Pokemon} target of the move
|
||||
* @param move {@linkcode Move} with this attribute
|
||||
* @param args N/A
|
||||
* @returns true if the move was successful
|
||||
*/
|
||||
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
||||
const healRatio: number = (this.condition ? this.condition(user, target, move) : false) ? this.boostedHealRatio : this.normalHealRatio;
|
||||
this.addHealPhase(target, healRatio);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Heals the target only if it is the ally
|
||||
* @extends HealAttr
|
||||
* @see {@linkcode apply}
|
||||
*/
|
||||
export class HealOnAllyAttr extends HealAttr {
|
||||
/**
|
||||
* @param user {@linkcode Pokemon} using the move
|
||||
* @param target {@linkcode Pokemon} target of the move
|
||||
* @param move {@linkcode Move} with this attribute
|
||||
* @param args N/A
|
||||
* @returns true if the function succeeds
|
||||
*/
|
||||
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
||||
if (user.getAlly() === target) {
|
||||
super.apply(user, target, move, args);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Heals user as a side effect of a move that hits a target.
|
||||
* Healing is based on {@linkcode healRatio} * the amount of damage dealt or a stat of the target.
|
||||
@ -4328,36 +4298,6 @@ export class SpitUpPowerAttr extends VariablePowerAttr {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attribute used to apply Swallow's healing, which scales with Stockpile stacks.
|
||||
* Does NOT remove stockpiled stacks.
|
||||
*/
|
||||
export class SwallowHealAttr extends HealAttr {
|
||||
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
||||
const stockpilingTag = user.getTag(StockpilingTag);
|
||||
|
||||
if (stockpilingTag && stockpilingTag.stockpiledCount > 0) {
|
||||
const stockpiled = stockpilingTag.stockpiledCount;
|
||||
let healRatio: number;
|
||||
|
||||
if (stockpiled === 1) {
|
||||
healRatio = 0.25;
|
||||
} else if (stockpiled === 2) {
|
||||
healRatio = 0.50;
|
||||
} else { // stockpiled >= 3
|
||||
healRatio = 1.00;
|
||||
}
|
||||
|
||||
if (healRatio) {
|
||||
this.addHealPhase(user, healRatio);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
const hasStockpileStacksCondition: MoveConditionFunc = (user) => {
|
||||
const hasStockpilingTag = user.getTag(StockpilingTag);
|
||||
return !!hasStockpilingTag && hasStockpilingTag.stockpiledCount > 0;
|
||||
@ -8003,6 +7943,53 @@ const attackedByItemMessageFunc = (user: Pokemon, target: Pokemon, move: Move) =
|
||||
return message;
|
||||
};
|
||||
|
||||
const sunnyHealRatioFunc = (): number => {
|
||||
if (globalScene.arena.weather?.isEffectSuppressed()) {
|
||||
return 1 / 2;
|
||||
}
|
||||
|
||||
switch (globalScene.arena.getWeatherType()) {
|
||||
case WeatherType.SUNNY:
|
||||
case WeatherType.HARSH_SUN:
|
||||
return 2 / 3;
|
||||
case WeatherType.RAIN:
|
||||
case WeatherType.SANDSTORM:
|
||||
case WeatherType.HAIL:
|
||||
case WeatherType.SNOW:
|
||||
case WeatherType.HEAVY_RAIN:
|
||||
case WeatherType.FOG:
|
||||
return 1 / 4;
|
||||
case WeatherType.STRONG_WINDS:
|
||||
default:
|
||||
return 1 / 2;
|
||||
}
|
||||
}
|
||||
|
||||
const shoreUpHealRatioFunc = (): number => {
|
||||
if (globalScene.arena.weather?.isEffectSuppressed()) {
|
||||
return 1 / 2;
|
||||
}
|
||||
|
||||
return globalScene.arena.getWeatherType() === WeatherType.SANDSTORM ? 2 / 3 : 1 / 2;
|
||||
}
|
||||
|
||||
const swallowHealFunc = (user: Pokemon): number => {
|
||||
const tag = user.getTag(StockpilingTag);
|
||||
if (!tag || tag.stockpiledCount <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (tag.stockpiledCount) {
|
||||
case 1:
|
||||
return 0.25
|
||||
case 2:
|
||||
return 0.5
|
||||
case 3:
|
||||
default: // in case we ever get more stacks
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
export class MoveCondition {
|
||||
protected func: MoveConditionFunc;
|
||||
|
||||
@ -8214,15 +8201,12 @@ const MoveAttrs = Object.freeze({
|
||||
SacrificialAttrOnHit,
|
||||
HalfSacrificialAttr,
|
||||
AddSubstituteAttr,
|
||||
HealAttr,
|
||||
PartyStatusCureAttr,
|
||||
FlameBurstAttr,
|
||||
SacrificialFullRestoreAttr,
|
||||
IgnoreWeatherTypeDebuffAttr,
|
||||
WeatherHealAttr,
|
||||
PlantHealAttr,
|
||||
SandHealAttr,
|
||||
BoostHealAttr,
|
||||
HealAttr,
|
||||
VariableHealAttr,
|
||||
HealOnAllyAttr,
|
||||
HitHealAttr,
|
||||
IncrementMovePriorityAttr,
|
||||
@ -8287,7 +8271,6 @@ const MoveAttrs = Object.freeze({
|
||||
PresentPowerAttr,
|
||||
WaterShurikenPowerAttr,
|
||||
SpitUpPowerAttr,
|
||||
SwallowHealAttr,
|
||||
MultiHitPowerIncrementAttr,
|
||||
LastMoveDoublePowerAttr,
|
||||
CombinedPledgePowerAttr,
|
||||
@ -9138,13 +9121,13 @@ export function initMoves() {
|
||||
.attr(StatStageChangeAttr, [ Stat.ATK ], 1, true),
|
||||
new AttackMove(MoveId.VITAL_THROW, PokemonType.FIGHTING, MoveCategory.PHYSICAL, 70, -1, 10, -1, -1, 2),
|
||||
new SelfStatusMove(MoveId.MORNING_SUN, PokemonType.NORMAL, -1, 5, -1, 0, 2)
|
||||
.attr(PlantHealAttr)
|
||||
.attr(VariableHealAttr, sunnyHealRatioFunc)
|
||||
.triageMove(),
|
||||
new SelfStatusMove(MoveId.SYNTHESIS, PokemonType.GRASS, -1, 5, -1, 0, 2)
|
||||
.attr(PlantHealAttr)
|
||||
.attr(VariableHealAttr, sunnyHealRatioFunc)
|
||||
.triageMove(),
|
||||
new SelfStatusMove(MoveId.MOONLIGHT, PokemonType.FAIRY, -1, 5, -1, 0, 2)
|
||||
.attr(PlantHealAttr)
|
||||
.attr(VariableHealAttr, sunnyHealRatioFunc)
|
||||
.triageMove(),
|
||||
new AttackMove(MoveId.HIDDEN_POWER, PokemonType.NORMAL, MoveCategory.SPECIAL, 60, 100, 15, -1, 0, 2)
|
||||
.attr(HiddenPowerTypeAttr),
|
||||
@ -9201,12 +9184,12 @@ export function initMoves() {
|
||||
.condition(user => (user.getTag(StockpilingTag)?.stockpiledCount ?? 0) < 3)
|
||||
.attr(AddBattlerTagAttr, BattlerTagType.STOCKPILING, true),
|
||||
new AttackMove(MoveId.SPIT_UP, PokemonType.NORMAL, MoveCategory.SPECIAL, -1, -1, 10, -1, 0, 3)
|
||||
.condition(hasStockpileStacksCondition)
|
||||
.attr(SpitUpPowerAttr, 100)
|
||||
.condition(hasStockpileStacksCondition)
|
||||
.attr(RemoveBattlerTagAttr, [ BattlerTagType.STOCKPILING ], true),
|
||||
new SelfStatusMove(MoveId.SWALLOW, PokemonType.NORMAL, -1, 10, -1, 0, 3)
|
||||
.attr(VariableHealAttr, swallowHealFunc)
|
||||
.condition(hasStockpileStacksCondition)
|
||||
.attr(SwallowHealAttr)
|
||||
.attr(RemoveBattlerTagAttr, [ BattlerTagType.STOCKPILING ], true)
|
||||
.triageMove(),
|
||||
new AttackMove(MoveId.HEAT_WAVE, PokemonType.FIRE, MoveCategory.SPECIAL, 95, 90, 10, 10, 0, 3)
|
||||
@ -10464,7 +10447,7 @@ export function initMoves() {
|
||||
.unimplemented(),
|
||||
/* End Unused */
|
||||
new SelfStatusMove(MoveId.SHORE_UP, PokemonType.GROUND, -1, 5, -1, 0, 7)
|
||||
.attr(SandHealAttr)
|
||||
.attr(VariableHealAttr, shoreUpHealRatioFunc)
|
||||
.triageMove(),
|
||||
new AttackMove(MoveId.FIRST_IMPRESSION, PokemonType.BUG, MoveCategory.PHYSICAL, 90, 100, 10, -1, 2, 7)
|
||||
.condition(new FirstMoveCondition()),
|
||||
@ -10484,7 +10467,7 @@ export function initMoves() {
|
||||
.attr(StatStageChangeAttr, [ Stat.SPD ], -1, true)
|
||||
.punchingMove(),
|
||||
new StatusMove(MoveId.FLORAL_HEALING, PokemonType.FAIRY, -1, 10, -1, 0, 7)
|
||||
.attr(BoostHealAttr, 0.5, 2 / 3, true, false, (user, target, move) => globalScene.arena.terrain?.terrainType === TerrainType.GRASSY)
|
||||
.attr(VariableHealAttr, () => globalScene.arena.terrain?.terrainType === TerrainType.GRASSY ? 2 / 3 : 1 / 2, true, false)
|
||||
.triageMove()
|
||||
.reflectable(),
|
||||
new AttackMove(MoveId.HIGH_HORSEPOWER, PokemonType.GROUND, MoveCategory.PHYSICAL, 95, 95, 10, -1, 0, 7),
|
||||
@ -11299,7 +11282,11 @@ export function initMoves() {
|
||||
.attr(ForceSwitchOutAttr, true, SwitchType.SHED_TAIL)
|
||||
.condition(failIfLastInPartyCondition),
|
||||
new SelfStatusMove(MoveId.CHILLY_RECEPTION, PokemonType.ICE, -1, 10, -1, 0, 9)
|
||||
.attr(PreMoveMessageAttr, (user, move) => i18next.t("moveTriggers:chillyReception", { pokemonName: getPokemonNameWithAffix(user) }))
|
||||
.attr(PreMoveMessageAttr, (user, _target, _move) =>
|
||||
// Don't display text if current move phase is follow up (ie move called indirectly)
|
||||
isVirtual((globalScene.phaseManager.getCurrentPhase() as MovePhase).useMode)
|
||||
? ""
|
||||
: i18next.t("moveTriggers:chillyReception", { pokemonName: getPokemonNameWithAffix(user) }))
|
||||
.attr(ChillyReceptionAttr, true),
|
||||
new SelfStatusMove(MoveId.TIDY_UP, PokemonType.NORMAL, -1, 10, -1, 0, 9)
|
||||
.attr(StatStageChangeAttr, [ Stat.ATK, Stat.SPD ], 1, true)
|
||||
|
@ -751,7 +751,7 @@ export async function catchPokemon(
|
||||
UiMode.POKEDEX_PAGE,
|
||||
pokemon.species,
|
||||
pokemon.formIndex,
|
||||
attributes,
|
||||
[attributes],
|
||||
null,
|
||||
() => {
|
||||
globalScene.ui.setMode(UiMode.MESSAGE).then(() => {
|
||||
|
@ -764,7 +764,7 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali
|
||||
readonly subLegendary: boolean;
|
||||
readonly legendary: boolean;
|
||||
readonly mythical: boolean;
|
||||
readonly species: string;
|
||||
public category: string;
|
||||
readonly growthRate: GrowthRate;
|
||||
/** The chance (as a decimal) for this Species to be male, or `null` for genderless species */
|
||||
readonly malePercent: number | null;
|
||||
@ -778,7 +778,7 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali
|
||||
subLegendary: boolean,
|
||||
legendary: boolean,
|
||||
mythical: boolean,
|
||||
species: string,
|
||||
category: string,
|
||||
type1: PokemonType,
|
||||
type2: PokemonType | null,
|
||||
height: number,
|
||||
@ -829,7 +829,7 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali
|
||||
this.subLegendary = subLegendary;
|
||||
this.legendary = legendary;
|
||||
this.mythical = mythical;
|
||||
this.species = species;
|
||||
this.category = category;
|
||||
this.growthRate = growthRate;
|
||||
this.malePercent = malePercent;
|
||||
this.genderDiffs = genderDiffs;
|
||||
@ -968,6 +968,7 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali
|
||||
|
||||
localize(): void {
|
||||
this.name = i18next.t(`pokemon:${SpeciesId[this.speciesId].toLowerCase()}`);
|
||||
this.category = i18next.t(`pokemonCategory:${SpeciesId[this.speciesId].toLowerCase()}_category`);
|
||||
}
|
||||
|
||||
getWildSpeciesForLevel(level: number, allowEvolving: boolean, isBoss: boolean, gameMode: GameMode): SpeciesId {
|
||||
|
@ -668,6 +668,9 @@ export class MovePhase extends BattlePhase {
|
||||
}),
|
||||
500,
|
||||
);
|
||||
|
||||
// Moves with pre-use messages (Magnitude, Chilly Reception, Fickle Beam, etc.) always display their messages even on failure
|
||||
// TODO: This assumes single target for message funcs - is this sustainable?
|
||||
applyMoveAttrs("PreMoveMessageAttr", this.pokemon, this.pokemon.getOpponents(false)[0], this.move.getMove());
|
||||
}
|
||||
|
||||
|
@ -245,6 +245,7 @@ export async function initI18n(): Promise<void> {
|
||||
"pokeball",
|
||||
"pokedexUiHandler",
|
||||
"pokemon",
|
||||
"pokemonCategory",
|
||||
"pokemonEvolutions",
|
||||
"pokemonForm",
|
||||
"pokemonInfo",
|
||||
|
@ -174,6 +174,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
||||
private pokemonCaughtHatchedContainer: Phaser.GameObjects.Container;
|
||||
private pokemonCaughtCountText: Phaser.GameObjects.Text;
|
||||
private pokemonFormText: Phaser.GameObjects.Text;
|
||||
private pokemonCategoryText: Phaser.GameObjects.Text;
|
||||
private pokemonHatchedIcon: Phaser.GameObjects.Sprite;
|
||||
private pokemonHatchedCountText: Phaser.GameObjects.Text;
|
||||
private pokemonShinyIcons: Phaser.GameObjects.Sprite[];
|
||||
@ -409,6 +410,12 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
||||
this.pokemonFormText.setOrigin(0, 0);
|
||||
this.starterSelectContainer.add(this.pokemonFormText);
|
||||
|
||||
this.pokemonCategoryText = addTextObject(100, 18, "Category", TextStyle.WINDOW_ALT, {
|
||||
fontSize: "42px",
|
||||
});
|
||||
this.pokemonCategoryText.setOrigin(1, 0);
|
||||
this.starterSelectContainer.add(this.pokemonCategoryText);
|
||||
|
||||
this.pokemonCaughtHatchedContainer = globalScene.add.container(2, 25);
|
||||
this.pokemonCaughtHatchedContainer.setScale(0.5);
|
||||
this.starterSelectContainer.add(this.pokemonCaughtHatchedContainer);
|
||||
@ -2354,6 +2361,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
||||
this.pokemonCaughtHatchedContainer.setVisible(true);
|
||||
this.pokemonCandyContainer.setVisible(false);
|
||||
this.pokemonFormText.setVisible(false);
|
||||
this.pokemonCategoryText.setVisible(false);
|
||||
|
||||
const defaultDexAttr = globalScene.gameData.getSpeciesDefaultDexAttr(species, true, true);
|
||||
const props = globalScene.gameData.getSpeciesDexAttrProps(species, defaultDexAttr);
|
||||
@ -2382,6 +2390,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
||||
this.pokemonCaughtHatchedContainer.setVisible(false);
|
||||
this.pokemonCandyContainer.setVisible(false);
|
||||
this.pokemonFormText.setVisible(false);
|
||||
this.pokemonCategoryText.setVisible(false);
|
||||
|
||||
this.setSpeciesDetails(species!, {
|
||||
// TODO: is this bang correct?
|
||||
@ -2534,6 +2543,13 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
||||
this.pokemonNameText.setText(species ? "???" : "");
|
||||
}
|
||||
|
||||
// Setting the category
|
||||
if (isFormCaught) {
|
||||
this.pokemonCategoryText.setText(species.category);
|
||||
} else {
|
||||
this.pokemonCategoryText.setText("");
|
||||
}
|
||||
|
||||
// Setting tint of the sprite
|
||||
if (isFormCaught) {
|
||||
this.species.loadAssets(female!, formIndex, shiny, variant as Variant, true).then(() => {
|
||||
|
@ -1,11 +1,14 @@
|
||||
import { AbilityId } from "#enums/ability-id";
|
||||
import { RandomMoveAttr } from "#app/data/moves/move";
|
||||
import { MoveResult } from "#enums/move-result";
|
||||
import { getPokemonNameWithAffix } from "#app/messages";
|
||||
import { MoveId } from "#enums/move-id";
|
||||
import { SpeciesId } from "#enums/species-id";
|
||||
import { AbilityId } from "#app/enums/ability-id";
|
||||
import { WeatherType } from "#enums/weather-type";
|
||||
import GameManager from "#test/testUtils/gameManager";
|
||||
import i18next from "i18next";
|
||||
import Phaser from "phaser";
|
||||
//import { TurnInitPhase } from "#app/phases/turn-init-phase";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
describe("Moves - Chilly Reception", () => {
|
||||
let phaserGame: Phaser.Game;
|
||||
@ -25,95 +28,121 @@ describe("Moves - Chilly Reception", () => {
|
||||
game = new GameManager(phaserGame);
|
||||
game.override
|
||||
.battleStyle("single")
|
||||
.moveset([MoveId.CHILLY_RECEPTION, MoveId.SNOWSCAPE])
|
||||
.moveset([MoveId.CHILLY_RECEPTION, MoveId.SNOWSCAPE, MoveId.SPLASH, MoveId.METRONOME])
|
||||
.enemyMoveset(MoveId.SPLASH)
|
||||
.enemyAbility(AbilityId.BALL_FETCH)
|
||||
.ability(AbilityId.BALL_FETCH);
|
||||
});
|
||||
|
||||
it("should still change the weather if user can't switch out", async () => {
|
||||
it("should display message before use, switch the user out and change the weather to snow", async () => {
|
||||
await game.classicMode.startBattle([SpeciesId.SLOWKING, SpeciesId.MEOWTH]);
|
||||
|
||||
const [slowking, meowth] = game.scene.getPlayerParty();
|
||||
|
||||
game.move.select(MoveId.CHILLY_RECEPTION);
|
||||
game.doSelectPartyPokemon(1);
|
||||
await game.toEndOfTurn();
|
||||
|
||||
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
||||
expect(game.scene.getPlayerPokemon()).toBe(meowth);
|
||||
expect(slowking.isOnField()).toBe(false);
|
||||
expect(game.phaseInterceptor.log).toContain("SwitchSummonPhase");
|
||||
expect(game.textInterceptor.logs).toContain(
|
||||
i18next.t("moveTriggers:chillyReception", { pokemonName: getPokemonNameWithAffix(slowking) }),
|
||||
);
|
||||
});
|
||||
|
||||
it("should still change weather if user can't switch out", async () => {
|
||||
await game.classicMode.startBattle([SpeciesId.SLOWKING]);
|
||||
|
||||
game.move.select(MoveId.CHILLY_RECEPTION);
|
||||
await game.toEndOfTurn();
|
||||
|
||||
await game.phaseInterceptor.to("BerryPhase", false);
|
||||
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
||||
expect(game.phaseInterceptor.log).not.toContain("SwitchSummonPhase");
|
||||
expect(game.scene.getPlayerPokemon()?.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
|
||||
});
|
||||
|
||||
it("should switch out even if it's snowing", async () => {
|
||||
it("should still switch out even if weather cannot be changed", async () => {
|
||||
await game.classicMode.startBattle([SpeciesId.SLOWKING, SpeciesId.MEOWTH]);
|
||||
// first turn set up snow with snowscape, try chilly reception on second turn
|
||||
|
||||
expect(game.scene.arena.weather?.weatherType).not.toBe(WeatherType.SNOW);
|
||||
|
||||
const [slowking, meowth] = game.scene.getPlayerParty();
|
||||
|
||||
game.move.select(MoveId.SNOWSCAPE);
|
||||
await game.phaseInterceptor.to("BerryPhase", false);
|
||||
await game.toNextTurn();
|
||||
|
||||
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
||||
|
||||
await game.phaseInterceptor.to("TurnInitPhase", false);
|
||||
game.move.select(MoveId.CHILLY_RECEPTION);
|
||||
game.doSelectPartyPokemon(1);
|
||||
// TODO: Uncomment lines once wimp out PR fixes force switches to not reset summon data immediately
|
||||
// await game.phaseInterceptor.to("SwitchSummonPhase", false);
|
||||
// expect(slowking.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
|
||||
|
||||
await game.toEndOfTurn();
|
||||
|
||||
await game.phaseInterceptor.to("BerryPhase", false);
|
||||
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
||||
expect(game.scene.getPlayerField()[0].species.speciesId).toBe(SpeciesId.MEOWTH);
|
||||
expect(game.phaseInterceptor.log).toContain("SwitchSummonPhase");
|
||||
expect(game.scene.getPlayerPokemon()).toBe(meowth);
|
||||
expect(slowking.isOnField()).toBe(false);
|
||||
});
|
||||
|
||||
it("happy case - switch out and weather changes", async () => {
|
||||
// Source: https://replay.pokemonshowdown.com/gen9ou-2367532550
|
||||
it("should fail (while still displaying message) if neither weather change nor switch out succeeds", async () => {
|
||||
await game.classicMode.startBattle([SpeciesId.SLOWKING]);
|
||||
|
||||
expect(game.scene.arena.weather?.weatherType).not.toBe(WeatherType.SNOW);
|
||||
|
||||
const slowking = game.scene.getPlayerPokemon()!;
|
||||
|
||||
game.move.select(MoveId.SNOWSCAPE);
|
||||
await game.toNextTurn();
|
||||
|
||||
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
||||
|
||||
game.move.select(MoveId.CHILLY_RECEPTION);
|
||||
game.doSelectPartyPokemon(1);
|
||||
await game.toEndOfTurn();
|
||||
|
||||
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
||||
expect(game.phaseInterceptor.log).not.toContain("SwitchSummonPhase");
|
||||
expect(game.scene.getPlayerPokemon()).toBe(slowking);
|
||||
expect(slowking.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
|
||||
expect(game.textInterceptor.logs).toContain(
|
||||
i18next.t("moveTriggers:chillyReception", { pokemonName: getPokemonNameWithAffix(slowking) }),
|
||||
);
|
||||
});
|
||||
|
||||
it("should succeed without message if called indirectly", async () => {
|
||||
vi.spyOn(RandomMoveAttr.prototype, "getMoveOverride").mockReturnValue(MoveId.CHILLY_RECEPTION);
|
||||
await game.classicMode.startBattle([SpeciesId.SLOWKING, SpeciesId.MEOWTH]);
|
||||
|
||||
game.move.select(MoveId.CHILLY_RECEPTION);
|
||||
game.doSelectPartyPokemon(1);
|
||||
const [slowking, meowth] = game.scene.getPlayerParty();
|
||||
|
||||
game.move.select(MoveId.METRONOME);
|
||||
game.doSelectPartyPokemon(1);
|
||||
await game.toEndOfTurn();
|
||||
|
||||
await game.phaseInterceptor.to("BerryPhase", false);
|
||||
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
||||
expect(game.scene.getPlayerField()[0].species.speciesId).toBe(SpeciesId.MEOWTH);
|
||||
expect(game.scene.getPlayerPokemon()).toBe(meowth);
|
||||
expect(slowking.isOnField()).toBe(false);
|
||||
expect(game.phaseInterceptor.log).toContain("SwitchSummonPhase");
|
||||
expect(game.textInterceptor.logs).not.toContain(
|
||||
i18next.t("moveTriggers:chillyReception", { pokemonName: getPokemonNameWithAffix(slowking) }),
|
||||
);
|
||||
});
|
||||
|
||||
// enemy uses another move and weather doesn't change
|
||||
it("check case - enemy not selecting chilly reception doesn't change weather ", async () => {
|
||||
game.override.battleStyle("single").enemyMoveset([MoveId.CHILLY_RECEPTION, MoveId.TACKLE]).moveset(MoveId.SPLASH);
|
||||
|
||||
// Bugcheck test for enemy AI bug
|
||||
it("check case - enemy not selecting chilly reception doesn't change weather", async () => {
|
||||
game.override.enemyMoveset([MoveId.CHILLY_RECEPTION, MoveId.TACKLE]);
|
||||
await game.classicMode.startBattle([SpeciesId.SLOWKING, SpeciesId.MEOWTH]);
|
||||
|
||||
game.move.select(MoveId.SPLASH);
|
||||
await game.move.selectEnemyMove(MoveId.TACKLE);
|
||||
await game.toEndOfTurn();
|
||||
|
||||
await game.phaseInterceptor.to("BerryPhase", false);
|
||||
expect(game.scene.arena.weather?.weatherType).toBe(undefined);
|
||||
});
|
||||
|
||||
it("enemy trainer - expected behavior ", async () => {
|
||||
game.override
|
||||
.battleStyle("single")
|
||||
.startingWave(8)
|
||||
.enemyMoveset(MoveId.CHILLY_RECEPTION)
|
||||
.enemySpecies(SpeciesId.MAGIKARP)
|
||||
.moveset([MoveId.SPLASH, MoveId.THUNDERBOLT]);
|
||||
|
||||
await game.classicMode.startBattle([SpeciesId.JOLTEON]);
|
||||
const RIVAL_MAGIKARP1 = game.scene.getEnemyPokemon()?.id;
|
||||
|
||||
game.move.select(MoveId.SPLASH);
|
||||
await game.phaseInterceptor.to("BerryPhase", false);
|
||||
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
||||
expect(game.scene.getEnemyPokemon()?.id !== RIVAL_MAGIKARP1);
|
||||
|
||||
await game.phaseInterceptor.to("TurnInitPhase", false);
|
||||
game.move.select(MoveId.SPLASH);
|
||||
|
||||
// second chilly reception should still switch out
|
||||
await game.phaseInterceptor.to("BerryPhase", false);
|
||||
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
||||
await game.phaseInterceptor.to("TurnInitPhase", false);
|
||||
expect(game.scene.getEnemyPokemon()?.id === RIVAL_MAGIKARP1);
|
||||
game.move.select(MoveId.THUNDERBOLT);
|
||||
|
||||
// enemy chilly recep move should fail: it's snowing and no option to switch out
|
||||
// no crashing
|
||||
await game.phaseInterceptor.to("BerryPhase", false);
|
||||
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
||||
await game.phaseInterceptor.to("TurnInitPhase", false);
|
||||
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
||||
game.move.select(MoveId.SPLASH);
|
||||
await game.phaseInterceptor.to("BerryPhase", false);
|
||||
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SNOW);
|
||||
expect(game.scene.arena.weather?.weatherType).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
175
test/moves/recovery-moves.test.ts
Normal file
175
test/moves/recovery-moves.test.ts
Normal file
@ -0,0 +1,175 @@
|
||||
import { getPokemonNameWithAffix } from "#app/messages";
|
||||
import { getEnumValues, toReadableString } from "#app/utils/common";
|
||||
import { AbilityId } from "#enums/ability-id";
|
||||
import { MoveId } from "#enums/move-id";
|
||||
import { SpeciesId } from "#enums/species-id";
|
||||
import { WeatherType } from "#enums/weather-type";
|
||||
import GameManager from "#test/testUtils/gameManager";
|
||||
import i18next from "i18next";
|
||||
import Phaser from "phaser";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
||||
|
||||
describe("Moves - Recovery Moves", () => {
|
||||
let phaserGame: Phaser.Game;
|
||||
let game: GameManager;
|
||||
|
||||
beforeAll(() => {
|
||||
phaserGame = new Phaser.Game({
|
||||
type: Phaser.HEADLESS,
|
||||
});
|
||||
});
|
||||
|
||||
describe.each<{ name: string; move: MoveId }>([
|
||||
{ name: "Recover", move: MoveId.RECOVER },
|
||||
{ name: "Soft-Boiled", move: MoveId.SOFT_BOILED },
|
||||
{ name: "Milk Drink", move: MoveId.MILK_DRINK },
|
||||
{ name: "Slack Off", move: MoveId.SLACK_OFF },
|
||||
{ name: "Roost", move: MoveId.ROOST },
|
||||
])("Normal Recovery Moves - $name", ({ move }) => {
|
||||
afterEach(() => {
|
||||
game.phaseInterceptor.restoreOg();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
game = new GameManager(phaserGame);
|
||||
game.override
|
||||
.ability(AbilityId.BALL_FETCH)
|
||||
.battleStyle("single")
|
||||
.disableCrits()
|
||||
.enemySpecies(SpeciesId.MAGIKARP)
|
||||
.enemyAbility(AbilityId.BALL_FETCH)
|
||||
.enemyMoveset(MoveId.SPLASH)
|
||||
.startingLevel(100)
|
||||
.enemyLevel(100);
|
||||
});
|
||||
|
||||
it("should heal 50% of the user's maximum HP", async () => {
|
||||
await game.classicMode.startBattle([SpeciesId.BLISSEY]);
|
||||
|
||||
const blissey = game.field.getPlayerPokemon();
|
||||
blissey.hp = 1;
|
||||
|
||||
game.move.use(move);
|
||||
await game.toEndOfTurn();
|
||||
|
||||
expect(blissey.getHpRatio()).toBeCloseTo(0.5, 1);
|
||||
expect(game.phaseInterceptor.log).toContain("PokemonHealPhase");
|
||||
});
|
||||
|
||||
it("should display message and fail if used at full HP", async () => {
|
||||
await game.classicMode.startBattle([SpeciesId.BLISSEY]);
|
||||
|
||||
game.move.use(move);
|
||||
await game.toEndOfTurn();
|
||||
|
||||
const blissey = game.field.getPlayerPokemon();
|
||||
expect(blissey.hp).toBe(blissey.getMaxHp());
|
||||
expect(game.textInterceptor.logs).toContain(
|
||||
i18next.t("battle:hpIsFull", {
|
||||
pokemonName: getPokemonNameWithAffix(blissey),
|
||||
}),
|
||||
);
|
||||
expect(game.phaseInterceptor.log).not.toContain("PokemonHealPhase");
|
||||
});
|
||||
});
|
||||
|
||||
describe("Weather-based Healing moves", () => {
|
||||
afterEach(() => {
|
||||
game.phaseInterceptor.restoreOg();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
game = new GameManager(phaserGame);
|
||||
game.override
|
||||
.ability(AbilityId.BALL_FETCH)
|
||||
.battleStyle("single")
|
||||
.disableCrits()
|
||||
.enemySpecies(SpeciesId.MAGIKARP)
|
||||
.enemyAbility(AbilityId.BALL_FETCH)
|
||||
.enemyMoveset(MoveId.SPLASH)
|
||||
.startingLevel(100)
|
||||
.enemyLevel(100);
|
||||
});
|
||||
|
||||
it.each([
|
||||
{ name: "Harsh Sunlight", ability: AbilityId.DROUGHT },
|
||||
{ name: "Extremely Harsh Sunlight", ability: AbilityId.DESOLATE_LAND },
|
||||
])("should heal 66% of the user's maximum HP under $name", async ({ ability }) => {
|
||||
game.override.passiveAbility(ability);
|
||||
await game.classicMode.startBattle([SpeciesId.BLISSEY]);
|
||||
|
||||
const blissey = game.field.getPlayerPokemon();
|
||||
blissey.hp = 1;
|
||||
|
||||
game.move.use(MoveId.MOONLIGHT);
|
||||
await game.toEndOfTurn();
|
||||
|
||||
expect(blissey.getHpRatio()).toBeCloseTo(0.66, 1);
|
||||
});
|
||||
|
||||
const nonSunWTs = getEnumValues(WeatherType)
|
||||
.filter(wt => ![WeatherType.NONE, WeatherType.STRONG_WINDS].includes(wt))
|
||||
.map(wt => ({
|
||||
name: toReadableString(WeatherType[wt]),
|
||||
weather: wt,
|
||||
}));
|
||||
|
||||
it.each(nonSunWTs)("should heal 25% of the user's maximum HP under $name", async ({ weather }) => {
|
||||
game.override.weather(weather);
|
||||
await game.classicMode.startBattle([SpeciesId.BLISSEY]);
|
||||
|
||||
const blissey = game.field.getPlayerPokemon();
|
||||
blissey.hp = 1;
|
||||
|
||||
game.move.use(MoveId.MOONLIGHT);
|
||||
await game.toEndOfTurn();
|
||||
|
||||
expect(blissey.getHpRatio()).toBeCloseTo(0.25, 1);
|
||||
});
|
||||
|
||||
it("should heal 50% of the user's maximum HP under strong winds", async () => {
|
||||
game.override.ability(AbilityId.DELTA_STREAM);
|
||||
await game.classicMode.startBattle([SpeciesId.BLISSEY]);
|
||||
|
||||
const blissey = game.field.getPlayerPokemon();
|
||||
blissey.hp = 1;
|
||||
|
||||
game.move.use(MoveId.MOONLIGHT);
|
||||
await game.toEndOfTurn();
|
||||
|
||||
expect(blissey.getHpRatio()).toBeCloseTo(0.5, 1);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Shore Up", () => {
|
||||
afterEach(() => {
|
||||
game.phaseInterceptor.restoreOg();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
game = new GameManager(phaserGame);
|
||||
game.override
|
||||
.ability(AbilityId.BALL_FETCH)
|
||||
.battleStyle("single")
|
||||
.disableCrits()
|
||||
.enemySpecies(SpeciesId.MAGIKARP)
|
||||
.enemyAbility(AbilityId.BALL_FETCH)
|
||||
.enemyMoveset(MoveId.SPLASH)
|
||||
.startingLevel(100)
|
||||
.enemyLevel(100);
|
||||
});
|
||||
|
||||
it("should heal 66% of the user's maximum HP under sandstorm", async () => {
|
||||
game.override.ability(AbilityId.SAND_STREAM);
|
||||
await game.classicMode.startBattle([SpeciesId.BLISSEY]);
|
||||
|
||||
const blissey = game.field.getPlayerPokemon();
|
||||
blissey.hp = 1;
|
||||
|
||||
game.move.use(MoveId.SHORE_UP);
|
||||
await game.toEndOfTurn();
|
||||
|
||||
expect(blissey.getHpRatio()).toBeCloseTo(0.66, 1);
|
||||
});
|
||||
});
|
||||
});
|
@ -1,201 +0,0 @@
|
||||
import { Stat } from "#enums/stat";
|
||||
import { StockpilingTag } from "#app/data/battler-tags";
|
||||
import { allMoves } from "#app/data/data-lists";
|
||||
import { BattlerTagType } from "#app/enums/battler-tag-type";
|
||||
import { MoveResult } from "#enums/move-result";
|
||||
import GameManager from "#test/testUtils/gameManager";
|
||||
import { AbilityId } from "#enums/ability-id";
|
||||
import { MoveId } from "#enums/move-id";
|
||||
import type Move from "#app/data/moves/move";
|
||||
import { SpeciesId } from "#enums/species-id";
|
||||
import Phaser from "phaser";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { MovePhase } from "#app/phases/move-phase";
|
||||
import { TurnInitPhase } from "#app/phases/turn-init-phase";
|
||||
|
||||
describe("Moves - Spit Up", () => {
|
||||
let phaserGame: Phaser.Game;
|
||||
let game: GameManager;
|
||||
|
||||
let spitUp: Move;
|
||||
|
||||
beforeAll(() => {
|
||||
phaserGame = new Phaser.Game({ type: Phaser.HEADLESS });
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
game.phaseInterceptor.restoreOg();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
spitUp = allMoves[MoveId.SPIT_UP];
|
||||
game = new GameManager(phaserGame);
|
||||
|
||||
game.override
|
||||
.battleStyle("single")
|
||||
.enemySpecies(SpeciesId.RATTATA)
|
||||
.enemyMoveset(MoveId.SPLASH)
|
||||
.enemyAbility(AbilityId.NONE)
|
||||
.enemyLevel(2000)
|
||||
.moveset(MoveId.SPIT_UP)
|
||||
.ability(AbilityId.NONE);
|
||||
|
||||
vi.spyOn(spitUp, "calculateBattlePower");
|
||||
});
|
||||
|
||||
describe("consumes all stockpile stacks to deal damage (scaling with stacks)", () => {
|
||||
it("1 stack -> 100 power", async () => {
|
||||
const stacksToSetup = 1;
|
||||
const expectedPower = 100;
|
||||
|
||||
await game.classicMode.startBattle([SpeciesId.ABOMASNOW]);
|
||||
|
||||
const pokemon = game.scene.getPlayerPokemon()!;
|
||||
pokemon.addTag(BattlerTagType.STOCKPILING);
|
||||
|
||||
const stockpilingTag = pokemon.getTag(StockpilingTag)!;
|
||||
expect(stockpilingTag).toBeDefined();
|
||||
expect(stockpilingTag.stockpiledCount).toBe(stacksToSetup);
|
||||
|
||||
game.move.select(MoveId.SPIT_UP);
|
||||
await game.phaseInterceptor.to(TurnInitPhase);
|
||||
|
||||
expect(spitUp.calculateBattlePower).toHaveBeenCalledOnce();
|
||||
expect(spitUp.calculateBattlePower).toHaveReturnedWith(expectedPower);
|
||||
|
||||
expect(pokemon.getTag(StockpilingTag)).toBeUndefined();
|
||||
});
|
||||
|
||||
it("2 stacks -> 200 power", async () => {
|
||||
const stacksToSetup = 2;
|
||||
const expectedPower = 200;
|
||||
|
||||
await game.classicMode.startBattle([SpeciesId.ABOMASNOW]);
|
||||
|
||||
const pokemon = game.scene.getPlayerPokemon()!;
|
||||
pokemon.addTag(BattlerTagType.STOCKPILING);
|
||||
pokemon.addTag(BattlerTagType.STOCKPILING);
|
||||
|
||||
const stockpilingTag = pokemon.getTag(StockpilingTag)!;
|
||||
expect(stockpilingTag).toBeDefined();
|
||||
expect(stockpilingTag.stockpiledCount).toBe(stacksToSetup);
|
||||
|
||||
game.move.select(MoveId.SPIT_UP);
|
||||
await game.phaseInterceptor.to(TurnInitPhase);
|
||||
|
||||
expect(spitUp.calculateBattlePower).toHaveBeenCalledOnce();
|
||||
expect(spitUp.calculateBattlePower).toHaveReturnedWith(expectedPower);
|
||||
|
||||
expect(pokemon.getTag(StockpilingTag)).toBeUndefined();
|
||||
});
|
||||
|
||||
it("3 stacks -> 300 power", async () => {
|
||||
const stacksToSetup = 3;
|
||||
const expectedPower = 300;
|
||||
|
||||
await game.classicMode.startBattle([SpeciesId.ABOMASNOW]);
|
||||
|
||||
const pokemon = game.scene.getPlayerPokemon()!;
|
||||
pokemon.addTag(BattlerTagType.STOCKPILING);
|
||||
pokemon.addTag(BattlerTagType.STOCKPILING);
|
||||
pokemon.addTag(BattlerTagType.STOCKPILING);
|
||||
|
||||
const stockpilingTag = pokemon.getTag(StockpilingTag)!;
|
||||
expect(stockpilingTag).toBeDefined();
|
||||
expect(stockpilingTag.stockpiledCount).toBe(stacksToSetup);
|
||||
|
||||
game.move.select(MoveId.SPIT_UP);
|
||||
await game.phaseInterceptor.to(TurnInitPhase);
|
||||
|
||||
expect(spitUp.calculateBattlePower).toHaveBeenCalledOnce();
|
||||
expect(spitUp.calculateBattlePower).toHaveReturnedWith(expectedPower);
|
||||
|
||||
expect(pokemon.getTag(StockpilingTag)).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
it("fails without stacks", async () => {
|
||||
await game.classicMode.startBattle([SpeciesId.ABOMASNOW]);
|
||||
|
||||
const pokemon = game.scene.getPlayerPokemon()!;
|
||||
|
||||
const stockpilingTag = pokemon.getTag(StockpilingTag)!;
|
||||
expect(stockpilingTag).toBeUndefined();
|
||||
|
||||
game.move.select(MoveId.SPIT_UP);
|
||||
await game.phaseInterceptor.to(TurnInitPhase);
|
||||
|
||||
expect(pokemon.getMoveHistory().at(-1)).toMatchObject({
|
||||
move: MoveId.SPIT_UP,
|
||||
result: MoveResult.FAIL,
|
||||
targets: [game.scene.getEnemyPokemon()!.getBattlerIndex()],
|
||||
});
|
||||
|
||||
expect(spitUp.calculateBattlePower).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
describe("restores stat boosts granted by stacks", () => {
|
||||
it("decreases stats based on stored values (both boosts equal)", async () => {
|
||||
await game.classicMode.startBattle([SpeciesId.ABOMASNOW]);
|
||||
|
||||
const pokemon = game.scene.getPlayerPokemon()!;
|
||||
pokemon.addTag(BattlerTagType.STOCKPILING);
|
||||
|
||||
const stockpilingTag = pokemon.getTag(StockpilingTag)!;
|
||||
expect(stockpilingTag).toBeDefined();
|
||||
|
||||
game.move.select(MoveId.SPIT_UP);
|
||||
await game.phaseInterceptor.to(MovePhase);
|
||||
|
||||
expect(pokemon.getStatStage(Stat.DEF)).toBe(1);
|
||||
expect(pokemon.getStatStage(Stat.SPDEF)).toBe(1);
|
||||
|
||||
await game.phaseInterceptor.to(TurnInitPhase);
|
||||
|
||||
expect(pokemon.getMoveHistory().at(-1)).toMatchObject({
|
||||
move: MoveId.SPIT_UP,
|
||||
result: MoveResult.SUCCESS,
|
||||
targets: [game.scene.getEnemyPokemon()!.getBattlerIndex()],
|
||||
});
|
||||
|
||||
expect(spitUp.calculateBattlePower).toHaveBeenCalledOnce();
|
||||
|
||||
expect(pokemon.getStatStage(Stat.DEF)).toBe(0);
|
||||
expect(pokemon.getStatStage(Stat.SPDEF)).toBe(0);
|
||||
|
||||
expect(pokemon.getTag(StockpilingTag)).toBeUndefined();
|
||||
});
|
||||
|
||||
it("decreases stats based on stored values (different boosts)", async () => {
|
||||
await game.classicMode.startBattle([SpeciesId.ABOMASNOW]);
|
||||
|
||||
const pokemon = game.scene.getPlayerPokemon()!;
|
||||
pokemon.addTag(BattlerTagType.STOCKPILING);
|
||||
|
||||
const stockpilingTag = pokemon.getTag(StockpilingTag)!;
|
||||
expect(stockpilingTag).toBeDefined();
|
||||
|
||||
// for the sake of simplicity (and because other tests cover the setup), set boost amounts directly
|
||||
stockpilingTag.statChangeCounts = {
|
||||
[Stat.DEF]: -1,
|
||||
[Stat.SPDEF]: 2,
|
||||
};
|
||||
|
||||
game.move.select(MoveId.SPIT_UP);
|
||||
await game.phaseInterceptor.to(TurnInitPhase);
|
||||
|
||||
expect(pokemon.getMoveHistory().at(-1)).toMatchObject({
|
||||
move: MoveId.SPIT_UP,
|
||||
result: MoveResult.SUCCESS,
|
||||
targets: [game.scene.getEnemyPokemon()!.getBattlerIndex()],
|
||||
});
|
||||
|
||||
expect(spitUp.calculateBattlePower).toHaveBeenCalledOnce();
|
||||
|
||||
expect(pokemon.getStatStage(Stat.DEF)).toBe(1);
|
||||
expect(pokemon.getStatStage(Stat.SPDEF)).toBe(-2);
|
||||
|
||||
expect(pokemon.getTag(StockpilingTag)).toBeUndefined();
|
||||
});
|
||||
});
|
||||
});
|
264
test/moves/swallow-spit-up.test.ts
Normal file
264
test/moves/swallow-spit-up.test.ts
Normal file
@ -0,0 +1,264 @@
|
||||
import { Stat } from "#enums/stat";
|
||||
import { StockpilingTag } from "#app/data/battler-tags";
|
||||
import { BattlerTagType } from "#app/enums/battler-tag-type";
|
||||
import { MoveResult } from "#enums/move-result";
|
||||
import { AbilityId } from "#enums/ability-id";
|
||||
import { MoveId } from "#enums/move-id";
|
||||
import { SpeciesId } from "#enums/species-id";
|
||||
import GameManager from "#test/testUtils/gameManager";
|
||||
import Phaser from "phaser";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi, type MockInstance } from "vitest";
|
||||
import { BattlerIndex } from "#enums/battler-index";
|
||||
import { allMoves } from "#app/data/data-lists";
|
||||
import { getPokemonNameWithAffix } from "#app/messages";
|
||||
import i18next from "i18next";
|
||||
|
||||
describe("Swallow & Spit Up", () => {
|
||||
let phaserGame: Phaser.Game;
|
||||
let game: GameManager;
|
||||
|
||||
beforeAll(() => {
|
||||
phaserGame = new Phaser.Game({ type: Phaser.HEADLESS });
|
||||
});
|
||||
|
||||
describe("Moves - Swallow", () => {
|
||||
afterEach(() => {
|
||||
game.phaseInterceptor.restoreOg();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
game = new GameManager(phaserGame);
|
||||
game.override
|
||||
.battleStyle("single")
|
||||
.enemySpecies(SpeciesId.RATTATA)
|
||||
.enemyMoveset(MoveId.SPLASH)
|
||||
.enemyAbility(AbilityId.BALL_FETCH)
|
||||
.enemyLevel(100)
|
||||
.startingLevel(100)
|
||||
.ability(AbilityId.BALL_FETCH);
|
||||
});
|
||||
|
||||
it.each<{ stackCount: number; healPercent: number }>([
|
||||
{ stackCount: 1, healPercent: 25 },
|
||||
{ stackCount: 2, healPercent: 50 },
|
||||
{ stackCount: 3, healPercent: 100 },
|
||||
])(
|
||||
"should heal the user by $healPercent% max HP when consuming $stackCount stockpile stacks",
|
||||
async ({ stackCount, healPercent }) => {
|
||||
await game.classicMode.startBattle([SpeciesId.SWALOT]);
|
||||
|
||||
const swalot = game.field.getPlayerPokemon();
|
||||
swalot.hp = 1;
|
||||
|
||||
for (let i = 0; i < stackCount; i++) {
|
||||
swalot.addTag(BattlerTagType.STOCKPILING);
|
||||
}
|
||||
|
||||
const stockpilingTag = swalot.getTag(StockpilingTag)!;
|
||||
expect(stockpilingTag).toBeDefined();
|
||||
expect(stockpilingTag.stockpiledCount).toBe(stackCount);
|
||||
|
||||
game.move.use(MoveId.SWALLOW);
|
||||
await game.toEndOfTurn();
|
||||
|
||||
expect(swalot.getHpRatio()).toBeCloseTo(healPercent / 100, 1);
|
||||
expect(swalot.getTag(StockpilingTag)).toBeUndefined();
|
||||
},
|
||||
);
|
||||
|
||||
it("should fail without Stockpile stacks", async () => {
|
||||
await game.classicMode.startBattle([SpeciesId.ABOMASNOW]);
|
||||
|
||||
const player = game.field.getPlayerPokemon();
|
||||
player.hp = 1;
|
||||
|
||||
const stockpilingTag = player.getTag(StockpilingTag)!;
|
||||
expect(stockpilingTag).toBeUndefined();
|
||||
|
||||
game.move.use(MoveId.SWALLOW);
|
||||
await game.toEndOfTurn();
|
||||
|
||||
expect(player.getLastXMoves()[0]).toMatchObject({
|
||||
move: MoveId.SWALLOW,
|
||||
result: MoveResult.FAIL,
|
||||
});
|
||||
});
|
||||
|
||||
// TODO: Does this consume stacks or not?
|
||||
it.todo("should fail and display message at full HP, consuming stacks", async () => {
|
||||
await game.classicMode.startBattle([SpeciesId.SWALOT]);
|
||||
|
||||
const swalot = game.field.getPlayerPokemon();
|
||||
swalot.addTag(BattlerTagType.STOCKPILING);
|
||||
const stockpilingTag = swalot.getTag(StockpilingTag)!;
|
||||
expect(stockpilingTag).toBeDefined();
|
||||
|
||||
game.move.use(MoveId.SWALLOW);
|
||||
await game.toEndOfTurn();
|
||||
|
||||
expect(swalot.getLastXMoves()[0]).toMatchObject({
|
||||
move: MoveId.SWALLOW,
|
||||
result: MoveResult.FAIL,
|
||||
});
|
||||
expect(game.textInterceptor.logs).toContain(
|
||||
i18next.t("battle:hpIsFull", {
|
||||
pokemonName: getPokemonNameWithAffix(swalot),
|
||||
}),
|
||||
);
|
||||
expect(stockpilingTag).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe("Moves - Spit Up", () => {
|
||||
let spitUpSpy: MockInstance;
|
||||
|
||||
afterEach(() => {
|
||||
game.phaseInterceptor.restoreOg();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
game = new GameManager(phaserGame);
|
||||
|
||||
game.override
|
||||
.battleStyle("single")
|
||||
.enemySpecies(SpeciesId.RATTATA)
|
||||
.enemyAbility(AbilityId.BALL_FETCH)
|
||||
.enemyLevel(2000)
|
||||
.enemyMoveset(MoveId.SPLASH)
|
||||
.ability(AbilityId.BALL_FETCH);
|
||||
|
||||
spitUpSpy = vi.spyOn(allMoves[MoveId.SPIT_UP], "calculateBattlePower");
|
||||
});
|
||||
|
||||
it.each<{ stackCount: number; power: number }>([
|
||||
{ stackCount: 1, power: 100 },
|
||||
{ stackCount: 2, power: 200 },
|
||||
{ stackCount: 3, power: 300 },
|
||||
])("should have $power base power when consuming $stackCount stockpile stacks", async ({ stackCount, power }) => {
|
||||
await game.classicMode.startBattle([SpeciesId.SWALOT]);
|
||||
|
||||
const swalot = game.field.getPlayerPokemon();
|
||||
|
||||
for (let i = 0; i < stackCount; i++) {
|
||||
swalot.addTag(BattlerTagType.STOCKPILING);
|
||||
}
|
||||
|
||||
const stockpilingTag = swalot.getTag(StockpilingTag)!;
|
||||
expect(stockpilingTag).toBeDefined();
|
||||
expect(stockpilingTag.stockpiledCount).toBe(stackCount);
|
||||
|
||||
game.move.use(MoveId.SPIT_UP);
|
||||
await game.toEndOfTurn();
|
||||
|
||||
expect(spitUpSpy).toHaveReturnedWith(power);
|
||||
expect(swalot.getTag(StockpilingTag)).toBeUndefined();
|
||||
});
|
||||
|
||||
it("should fail without Stockpile stacks", async () => {
|
||||
await game.classicMode.startBattle([SpeciesId.ABOMASNOW]);
|
||||
|
||||
const player = game.field.getPlayerPokemon();
|
||||
|
||||
const stockpilingTag = player.getTag(StockpilingTag)!;
|
||||
expect(stockpilingTag).toBeUndefined();
|
||||
|
||||
game.move.use(MoveId.SPIT_UP);
|
||||
await game.toEndOfTurn();
|
||||
|
||||
expect(player.getLastXMoves()[0]).toMatchObject({
|
||||
move: MoveId.SPIT_UP,
|
||||
result: MoveResult.FAIL,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("Stockpile stack removal", () => {
|
||||
afterEach(() => {
|
||||
game.phaseInterceptor.restoreOg();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
game = new GameManager(phaserGame);
|
||||
|
||||
game.override
|
||||
.battleStyle("single")
|
||||
.enemySpecies(SpeciesId.RATTATA)
|
||||
.enemyMoveset(MoveId.SPLASH)
|
||||
.enemyAbility(AbilityId.BALL_FETCH)
|
||||
.enemyLevel(100)
|
||||
.startingLevel(100)
|
||||
.ability(AbilityId.BALL_FETCH);
|
||||
});
|
||||
|
||||
it("should undo stat boosts when losing stacks", async () => {
|
||||
await game.classicMode.startBattle([SpeciesId.ABOMASNOW]);
|
||||
|
||||
const player = game.field.getPlayerPokemon();
|
||||
player.hp = 1;
|
||||
|
||||
player.addTag(BattlerTagType.STOCKPILING);
|
||||
const stockpilingTag = player.getTag(StockpilingTag)!;
|
||||
expect(stockpilingTag).toBeDefined();
|
||||
expect(player.getStatStage(Stat.DEF)).toBe(1);
|
||||
expect(player.getStatStage(Stat.SPDEF)).toBe(1);
|
||||
|
||||
// remove the prior stat boosts from the log
|
||||
game.phaseInterceptor.clearLogs();
|
||||
game.move.use(MoveId.SWALLOW);
|
||||
await game.move.forceEnemyMove(MoveId.ACID_SPRAY);
|
||||
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
|
||||
await game.toEndOfTurn();
|
||||
|
||||
expect(player.getStatStage(Stat.DEF)).toBe(0);
|
||||
expect(player.getStatStage(Stat.SPDEF)).toBe(-2); // +1 --> -1 --> -2
|
||||
expect(game.phaseInterceptor.log.filter(l => l === "StatStageChangePhase")).toHaveLength(3);
|
||||
});
|
||||
|
||||
it("should double stat drops when gaining Simple", async () => {
|
||||
await game.classicMode.startBattle([SpeciesId.ABOMASNOW]);
|
||||
|
||||
const player = game.field.getPlayerPokemon();
|
||||
|
||||
game.move.use(MoveId.STOCKPILE);
|
||||
await game.move.forceEnemyMove(MoveId.SIMPLE_BEAM);
|
||||
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
||||
await game.toNextTurn();
|
||||
|
||||
expect(player.getStatStage(Stat.DEF)).toBe(1);
|
||||
expect(player.getStatStage(Stat.SPDEF)).toBe(1);
|
||||
expect(player.hasAbility(AbilityId.SIMPLE)).toBe(true);
|
||||
|
||||
game.move.use(MoveId.SPIT_UP);
|
||||
await game.move.forceEnemyMove(MoveId.SPLASH);
|
||||
await game.toEndOfTurn();
|
||||
|
||||
// should have fallen by 2 stages from Simple
|
||||
expect(player.getStatStage(Stat.DEF)).toBe(-1);
|
||||
expect(player.getStatStage(Stat.SPDEF)).toBe(-1);
|
||||
});
|
||||
|
||||
it("should invert stat drops when gaining Contrary", async () => {
|
||||
game.override.enemyAbility(AbilityId.CONTRARY);
|
||||
await game.classicMode.startBattle([SpeciesId.ABOMASNOW]);
|
||||
|
||||
const player = game.field.getPlayerPokemon();
|
||||
|
||||
game.move.use(MoveId.STOCKPILE);
|
||||
await game.move.forceEnemyMove(MoveId.ENTRAINMENT);
|
||||
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
||||
await game.toEndOfTurn();
|
||||
|
||||
expect(player.getStatStage(Stat.DEF)).toBe(1);
|
||||
expect(player.getStatStage(Stat.SPDEF)).toBe(1);
|
||||
expect(player.hasAbility(AbilityId.CONTRARY)).toBe(true);
|
||||
|
||||
game.move.use(MoveId.SPIT_UP);
|
||||
await game.move.forceEnemyMove(MoveId.SPLASH);
|
||||
await game.toEndOfTurn();
|
||||
|
||||
// should have risen 1 stage from Contrary
|
||||
expect(player.getStatStage(Stat.DEF)).toBe(2);
|
||||
expect(player.getStatStage(Stat.SPDEF)).toBe(2);
|
||||
});
|
||||
});
|
||||
});
|
@ -1,204 +0,0 @@
|
||||
import { Stat } from "#enums/stat";
|
||||
import { StockpilingTag } from "#app/data/battler-tags";
|
||||
import { BattlerTagType } from "#app/enums/battler-tag-type";
|
||||
import { MoveResult } from "#enums/move-result";
|
||||
import { MovePhase } from "#app/phases/move-phase";
|
||||
import { TurnInitPhase } from "#app/phases/turn-init-phase";
|
||||
import { AbilityId } from "#enums/ability-id";
|
||||
import { MoveId } from "#enums/move-id";
|
||||
import { SpeciesId } from "#enums/species-id";
|
||||
import GameManager from "#test/testUtils/gameManager";
|
||||
import Phaser from "phaser";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
describe("Moves - Swallow", () => {
|
||||
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
|
||||
.battleStyle("single")
|
||||
.enemySpecies(SpeciesId.RATTATA)
|
||||
.enemyMoveset(MoveId.SPLASH)
|
||||
.enemyAbility(AbilityId.NONE)
|
||||
.enemyLevel(2000)
|
||||
.moveset(MoveId.SWALLOW)
|
||||
.ability(AbilityId.NONE);
|
||||
});
|
||||
|
||||
describe("consumes all stockpile stacks to heal (scaling with stacks)", () => {
|
||||
it("1 stack -> 25% heal", async () => {
|
||||
const stacksToSetup = 1;
|
||||
const expectedHeal = 25;
|
||||
|
||||
await game.classicMode.startBattle([SpeciesId.ABOMASNOW]);
|
||||
|
||||
const pokemon = game.scene.getPlayerPokemon()!;
|
||||
vi.spyOn(pokemon, "getMaxHp").mockReturnValue(100);
|
||||
pokemon["hp"] = 1;
|
||||
|
||||
pokemon.addTag(BattlerTagType.STOCKPILING);
|
||||
|
||||
const stockpilingTag = pokemon.getTag(StockpilingTag)!;
|
||||
expect(stockpilingTag).toBeDefined();
|
||||
expect(stockpilingTag.stockpiledCount).toBe(stacksToSetup);
|
||||
|
||||
vi.spyOn(pokemon, "heal");
|
||||
|
||||
game.move.select(MoveId.SWALLOW);
|
||||
await game.phaseInterceptor.to(TurnInitPhase);
|
||||
|
||||
expect(pokemon.heal).toHaveBeenCalledOnce();
|
||||
expect(pokemon.heal).toHaveReturnedWith(expectedHeal);
|
||||
|
||||
expect(pokemon.getTag(StockpilingTag)).toBeUndefined();
|
||||
});
|
||||
|
||||
it("2 stacks -> 50% heal", async () => {
|
||||
const stacksToSetup = 2;
|
||||
const expectedHeal = 50;
|
||||
|
||||
await game.classicMode.startBattle([SpeciesId.ABOMASNOW]);
|
||||
|
||||
const pokemon = game.scene.getPlayerPokemon()!;
|
||||
vi.spyOn(pokemon, "getMaxHp").mockReturnValue(100);
|
||||
pokemon["hp"] = 1;
|
||||
|
||||
pokemon.addTag(BattlerTagType.STOCKPILING);
|
||||
pokemon.addTag(BattlerTagType.STOCKPILING);
|
||||
|
||||
const stockpilingTag = pokemon.getTag(StockpilingTag)!;
|
||||
expect(stockpilingTag).toBeDefined();
|
||||
expect(stockpilingTag.stockpiledCount).toBe(stacksToSetup);
|
||||
|
||||
vi.spyOn(pokemon, "heal");
|
||||
|
||||
game.move.select(MoveId.SWALLOW);
|
||||
await game.phaseInterceptor.to(TurnInitPhase);
|
||||
|
||||
expect(pokemon.heal).toHaveBeenCalledOnce();
|
||||
expect(pokemon.heal).toHaveReturnedWith(expectedHeal);
|
||||
|
||||
expect(pokemon.getTag(StockpilingTag)).toBeUndefined();
|
||||
});
|
||||
|
||||
it("3 stacks -> 100% heal", async () => {
|
||||
const stacksToSetup = 3;
|
||||
const expectedHeal = 100;
|
||||
|
||||
await game.classicMode.startBattle([SpeciesId.ABOMASNOW]);
|
||||
|
||||
const pokemon = game.scene.getPlayerPokemon()!;
|
||||
vi.spyOn(pokemon, "getMaxHp").mockReturnValue(100);
|
||||
pokemon["hp"] = 0.0001;
|
||||
|
||||
pokemon.addTag(BattlerTagType.STOCKPILING);
|
||||
pokemon.addTag(BattlerTagType.STOCKPILING);
|
||||
pokemon.addTag(BattlerTagType.STOCKPILING);
|
||||
|
||||
const stockpilingTag = pokemon.getTag(StockpilingTag)!;
|
||||
expect(stockpilingTag).toBeDefined();
|
||||
expect(stockpilingTag.stockpiledCount).toBe(stacksToSetup);
|
||||
|
||||
vi.spyOn(pokemon, "heal");
|
||||
|
||||
game.move.select(MoveId.SWALLOW);
|
||||
await game.phaseInterceptor.to(TurnInitPhase);
|
||||
|
||||
expect(pokemon.heal).toHaveBeenCalledOnce();
|
||||
expect(pokemon.heal).toHaveReturnedWith(expect.closeTo(expectedHeal));
|
||||
|
||||
expect(pokemon.getTag(StockpilingTag)).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
it("fails without stacks", async () => {
|
||||
await game.classicMode.startBattle([SpeciesId.ABOMASNOW]);
|
||||
|
||||
const pokemon = game.scene.getPlayerPokemon()!;
|
||||
|
||||
const stockpilingTag = pokemon.getTag(StockpilingTag)!;
|
||||
expect(stockpilingTag).toBeUndefined();
|
||||
|
||||
game.move.select(MoveId.SWALLOW);
|
||||
await game.phaseInterceptor.to(TurnInitPhase);
|
||||
|
||||
expect(pokemon.getMoveHistory().at(-1)).toMatchObject({
|
||||
move: MoveId.SWALLOW,
|
||||
result: MoveResult.FAIL,
|
||||
targets: [pokemon.getBattlerIndex()],
|
||||
});
|
||||
});
|
||||
|
||||
describe("restores stat stage boosts granted by stacks", () => {
|
||||
it("decreases stats based on stored values (both boosts equal)", async () => {
|
||||
await game.classicMode.startBattle([SpeciesId.ABOMASNOW]);
|
||||
|
||||
const pokemon = game.scene.getPlayerPokemon()!;
|
||||
pokemon.addTag(BattlerTagType.STOCKPILING);
|
||||
|
||||
const stockpilingTag = pokemon.getTag(StockpilingTag)!;
|
||||
expect(stockpilingTag).toBeDefined();
|
||||
|
||||
game.move.select(MoveId.SWALLOW);
|
||||
await game.phaseInterceptor.to(MovePhase);
|
||||
|
||||
expect(pokemon.getStatStage(Stat.DEF)).toBe(1);
|
||||
expect(pokemon.getStatStage(Stat.SPDEF)).toBe(1);
|
||||
|
||||
await game.phaseInterceptor.to(TurnInitPhase);
|
||||
|
||||
expect(pokemon.getMoveHistory().at(-1)).toMatchObject({
|
||||
move: MoveId.SWALLOW,
|
||||
result: MoveResult.SUCCESS,
|
||||
targets: [pokemon.getBattlerIndex()],
|
||||
});
|
||||
|
||||
expect(pokemon.getStatStage(Stat.DEF)).toBe(0);
|
||||
expect(pokemon.getStatStage(Stat.SPDEF)).toBe(0);
|
||||
|
||||
expect(pokemon.getTag(StockpilingTag)).toBeUndefined();
|
||||
});
|
||||
|
||||
it("lower stat stages based on stored values (different boosts)", async () => {
|
||||
await game.classicMode.startBattle([SpeciesId.ABOMASNOW]);
|
||||
|
||||
const pokemon = game.scene.getPlayerPokemon()!;
|
||||
pokemon.addTag(BattlerTagType.STOCKPILING);
|
||||
|
||||
const stockpilingTag = pokemon.getTag(StockpilingTag)!;
|
||||
expect(stockpilingTag).toBeDefined();
|
||||
|
||||
// for the sake of simplicity (and because other tests cover the setup), set boost amounts directly
|
||||
stockpilingTag.statChangeCounts = {
|
||||
[Stat.DEF]: -1,
|
||||
[Stat.SPDEF]: 2,
|
||||
};
|
||||
|
||||
game.move.select(MoveId.SWALLOW);
|
||||
|
||||
await game.phaseInterceptor.to(TurnInitPhase);
|
||||
|
||||
expect(pokemon.getMoveHistory().at(-1)).toMatchObject({
|
||||
move: MoveId.SWALLOW,
|
||||
result: MoveResult.SUCCESS,
|
||||
targets: [pokemon.getBattlerIndex()],
|
||||
});
|
||||
|
||||
expect(pokemon.getStatStage(Stat.DEF)).toBe(1);
|
||||
expect(pokemon.getStatStage(Stat.SPDEF)).toBe(-2);
|
||||
|
||||
expect(pokemon.getTag(StockpilingTag)).toBeUndefined();
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user