Merge branch 'beta' into todo-test-enable

This commit is contained in:
Sirz Benjie 2025-09-20 17:37:27 -05:00
commit 102de41155
No known key found for this signature in database
GPG Key ID: 4A524B4D196C759E
25 changed files with 1308 additions and 594 deletions

View File

@ -48,7 +48,7 @@
"lefthook": "^1.12.2", "lefthook": "^1.12.2",
"msw": "^2.10.4", "msw": "^2.10.4",
"phaser3spectorjs": "^0.0.8", "phaser3spectorjs": "^0.0.8",
"typedoc": "0.28.7", "typedoc": "^0.28.13",
"typedoc-github-theme": "^0.3.1", "typedoc-github-theme": "^0.3.1",
"typedoc-plugin-coverage": "^4.0.1", "typedoc-plugin-coverage": "^4.0.1",
"typedoc-plugin-mdn-links": "^5.0.9", "typedoc-plugin-mdn-links": "^5.0.9",

View File

@ -88,17 +88,17 @@ importers:
specifier: ^0.0.8 specifier: ^0.0.8
version: 0.0.8 version: 0.0.8
typedoc: typedoc:
specifier: 0.28.7 specifier: ^0.28.13
version: 0.28.7(typescript@5.9.2) version: 0.28.13(typescript@5.9.2)
typedoc-github-theme: typedoc-github-theme:
specifier: ^0.3.1 specifier: ^0.3.1
version: 0.3.1(typedoc@0.28.7(typescript@5.9.2)) version: 0.3.1(typedoc@0.28.13(typescript@5.9.2))
typedoc-plugin-coverage: typedoc-plugin-coverage:
specifier: ^4.0.1 specifier: ^4.0.1
version: 4.0.1(typedoc@0.28.7(typescript@5.9.2)) version: 4.0.1(typedoc@0.28.13(typescript@5.9.2))
typedoc-plugin-mdn-links: typedoc-plugin-mdn-links:
specifier: ^5.0.9 specifier: ^5.0.9
version: 5.0.9(typedoc@0.28.7(typescript@5.9.2)) version: 5.0.9(typedoc@0.28.13(typescript@5.9.2))
typescript: typescript:
specifier: ^5.9.2 specifier: ^5.9.2
version: 5.9.2 version: 5.9.2
@ -717,17 +717,17 @@ packages:
cpu: [x64] cpu: [x64]
os: [win32] os: [win32]
'@shikijs/engine-oniguruma@3.12.2': '@shikijs/engine-oniguruma@3.13.0':
resolution: {integrity: sha512-hozwnFHsLvujK4/CPVHNo3Bcg2EsnG8krI/ZQ2FlBlCRpPZW4XAEQmEwqegJsypsTAN9ehu2tEYe30lYKSZW/w==} resolution: {integrity: sha512-O42rBGr4UDSlhT2ZFMxqM7QzIU+IcpoTMzb3W7AlziI1ZF7R8eS2M0yt5Ry35nnnTX/LTLXFPUjRFCIW+Operg==}
'@shikijs/langs@3.12.2': '@shikijs/langs@3.13.0':
resolution: {integrity: sha512-bVx5PfuZHDSHoBal+KzJZGheFuyH4qwwcwG/n+MsWno5cTlKmaNtTsGzJpHYQ8YPbB5BdEdKU1rga5/6JGY8ww==} resolution: {integrity: sha512-672c3WAETDYHwrRP0yLy3W1QYB89Hbpj+pO4KhxK6FzIrDI2FoEXNiNCut6BQmEApYLfuYfpgOZaqbY+E9b8wQ==}
'@shikijs/themes@3.12.2': '@shikijs/themes@3.13.0':
resolution: {integrity: sha512-fTR3QAgnwYpfGczpIbzPjlRnxyONJOerguQv1iwpyQZ9QXX4qy/XFQqXlf17XTsorxnHoJGbH/LXBvwtqDsF5A==} resolution: {integrity: sha512-Vxw1Nm1/Od8jyA7QuAenaV78BG2nSr3/gCGdBkLpfLscddCkzkL36Q5b67SrLLfvAJTOUzW39x4FHVCFriPVgg==}
'@shikijs/types@3.12.2': '@shikijs/types@3.13.0':
resolution: {integrity: sha512-K5UIBzxCyv0YoxN3LMrKB9zuhp1bV+LgewxuVwHdl4Gz5oePoUFrr9EfgJlGlDeXCU1b/yhdnXeuRvAnz8HN8Q==} resolution: {integrity: sha512-oM9P+NCFri/mmQ8LoFGVfVyemm5Hi27330zuOBp0annwJdKH1kOLndw3zCtAVDehPLg9fKqoEx3Ht/wNZxolfw==}
'@shikijs/vscode-textmate@10.0.2': '@shikijs/vscode-textmate@10.0.2':
resolution: {integrity: sha512-83yeghZ2xxin3Nj8z1NMd/NCuca+gsYXswywDy5bHvwlWL8tpTQmzGeUuHd9FC3E/SBEMvzJRwWEOz5gGes9Qg==} resolution: {integrity: sha512-83yeghZ2xxin3Nj8z1NMd/NCuca+gsYXswywDy5bHvwlWL8tpTQmzGeUuHd9FC3E/SBEMvzJRwWEOz5gGes9Qg==}
@ -1828,12 +1828,12 @@ packages:
peerDependencies: peerDependencies:
typedoc: 0.27.x || 0.28.x typedoc: 0.27.x || 0.28.x
typedoc@0.28.7: typedoc@0.28.13:
resolution: {integrity: sha512-lpz0Oxl6aidFkmS90VQDQjk/Qf2iw0IUvFqirdONBdj7jPSN9mGXhy66BcGNDxx5ZMyKKiBVAREvPEzT6Uxipw==} resolution: {integrity: sha512-dNWY8msnYB2a+7Audha+aTF1Pu3euiE7ySp53w8kEsXoYw7dMouV5A1UsTUY345aB152RHnmRMDiovuBi7BD+w==}
engines: {node: '>= 18', pnpm: '>= 10'} engines: {node: '>= 18', pnpm: '>= 10'}
hasBin: true hasBin: true
peerDependencies: peerDependencies:
typescript: 5.0.x || 5.1.x || 5.2.x || 5.3.x || 5.4.x || 5.5.x || 5.6.x || 5.7.x || 5.8.x typescript: 5.0.x || 5.1.x || 5.2.x || 5.3.x || 5.4.x || 5.5.x || 5.6.x || 5.7.x || 5.8.x || 5.9.x
typescript@5.9.2: typescript@5.9.2:
resolution: {integrity: sha512-CWBzXQrc/qOkhidw1OzBTQuYRbfyxDXJMVJ1XNwUHGROVmuaeiEm3OslpZ1RV96d7SKKjZKrSJu3+t/xlw3R9A==} resolution: {integrity: sha512-CWBzXQrc/qOkhidw1OzBTQuYRbfyxDXJMVJ1XNwUHGROVmuaeiEm3OslpZ1RV96d7SKKjZKrSJu3+t/xlw3R9A==}
@ -2312,10 +2312,10 @@ snapshots:
'@gerrit0/mini-shiki@3.12.2': '@gerrit0/mini-shiki@3.12.2':
dependencies: dependencies:
'@shikijs/engine-oniguruma': 3.12.2 '@shikijs/engine-oniguruma': 3.13.0
'@shikijs/langs': 3.12.2 '@shikijs/langs': 3.13.0
'@shikijs/themes': 3.12.2 '@shikijs/themes': 3.13.0
'@shikijs/types': 3.12.2 '@shikijs/types': 3.13.0
'@shikijs/vscode-textmate': 10.0.2 '@shikijs/vscode-textmate': 10.0.2
'@inquirer/checkbox@4.2.0(@types/node@22.16.5)': '@inquirer/checkbox@4.2.0(@types/node@22.16.5)':
@ -2547,20 +2547,20 @@ snapshots:
'@rollup/rollup-win32-x64-msvc@4.50.1': '@rollup/rollup-win32-x64-msvc@4.50.1':
optional: true optional: true
'@shikijs/engine-oniguruma@3.12.2': '@shikijs/engine-oniguruma@3.13.0':
dependencies: dependencies:
'@shikijs/types': 3.12.2 '@shikijs/types': 3.13.0
'@shikijs/vscode-textmate': 10.0.2 '@shikijs/vscode-textmate': 10.0.2
'@shikijs/langs@3.12.2': '@shikijs/langs@3.13.0':
dependencies: dependencies:
'@shikijs/types': 3.12.2 '@shikijs/types': 3.13.0
'@shikijs/themes@3.12.2': '@shikijs/themes@3.13.0':
dependencies: dependencies:
'@shikijs/types': 3.12.2 '@shikijs/types': 3.13.0
'@shikijs/types@3.12.2': '@shikijs/types@3.13.0':
dependencies: dependencies:
'@shikijs/vscode-textmate': 10.0.2 '@shikijs/vscode-textmate': 10.0.2
'@types/hast': 3.0.4 '@types/hast': 3.0.4
@ -3682,19 +3682,19 @@ snapshots:
type-fest@4.41.0: {} type-fest@4.41.0: {}
typedoc-github-theme@0.3.1(typedoc@0.28.7(typescript@5.9.2)): typedoc-github-theme@0.3.1(typedoc@0.28.13(typescript@5.9.2)):
dependencies: dependencies:
typedoc: 0.28.7(typescript@5.9.2) typedoc: 0.28.13(typescript@5.9.2)
typedoc-plugin-coverage@4.0.1(typedoc@0.28.7(typescript@5.9.2)): typedoc-plugin-coverage@4.0.1(typedoc@0.28.13(typescript@5.9.2)):
dependencies: dependencies:
typedoc: 0.28.7(typescript@5.9.2) typedoc: 0.28.13(typescript@5.9.2)
typedoc-plugin-mdn-links@5.0.9(typedoc@0.28.7(typescript@5.9.2)): typedoc-plugin-mdn-links@5.0.9(typedoc@0.28.13(typescript@5.9.2)):
dependencies: dependencies:
typedoc: 0.28.7(typescript@5.9.2) typedoc: 0.28.13(typescript@5.9.2)
typedoc@0.28.7(typescript@5.9.2): typedoc@0.28.13(typescript@5.9.2):
dependencies: dependencies:
'@gerrit0/mini-shiki': 3.12.2 '@gerrit0/mini-shiki': 3.12.2
lunr: 2.3.9 lunr: 2.3.9

View File

@ -89,7 +89,8 @@ export type AbilityBattlerTagType =
| BattlerTagType.QUARK_DRIVE | BattlerTagType.QUARK_DRIVE
| BattlerTagType.UNBURDEN | BattlerTagType.UNBURDEN
| BattlerTagType.SLOW_START | BattlerTagType.SLOW_START
| BattlerTagType.TRUANT; | BattlerTagType.TRUANT
| BattlerTagType.SUPREME_OVERLORD;
/** Subset of {@linkcode BattlerTagType}s that provide type boosts */ /** Subset of {@linkcode BattlerTagType}s that provide type boosts */
export type TypeBoostTagType = BattlerTagType.FIRE_BOOST | BattlerTagType.CHARGED; export type TypeBoostTagType = BattlerTagType.FIRE_BOOST | BattlerTagType.CHARGED;

View File

@ -0,0 +1,44 @@
import type { MoveCategory } from "#enums/move-category";
import type { Pokemon } from "#field/pokemon";
import type { Move } from "#types/move-types";
/**
* Collection of types for methods like {@linkcode Pokemon#getBaseDamage} and {@linkcode Pokemon#getAttackDamage}.
* @module
*/
/** Base type for damage parameter methods, used for DRY */
export interface damageParams {
/** The attacking {@linkcode Pokemon} */
source: Pokemon;
/** The move used in the attack */
move: Move;
/** The move's {@linkcode MoveCategory} after variable-category effects are applied */
moveCategory: MoveCategory;
/** If `true`, ignores this Pokemon's defensive ability effects */
ignoreAbility?: boolean;
/** If `true`, ignores the attacking Pokemon's ability effects */
ignoreSourceAbility?: boolean;
/** If `true`, ignores the ally Pokemon's ability effects */
ignoreAllyAbility?: boolean;
/** If `true`, ignores the ability effects of the attacking pokemon's ally */
ignoreSourceAllyAbility?: boolean;
/** If `true`, calculates damage for a critical hit */
isCritical?: boolean;
/** If `true`, suppresses changes to game state during the calculation */
simulated?: boolean;
/** If defined, used in place of calculated effectiveness values */
effectiveness?: number;
}
/**
* Type for the parameters of {@linkcode Pokemon#getBaseDamage | getBaseDamage}
* @interface
*/
export type getBaseDamageParams = Omit<damageParams, "effectiveness">;
/**
* Type for the parameters of {@linkcode Pokemon#getAttackDamage | getAttackDamage}
* @interface
*/
export type getAttackDamageParams = Omit<damageParams, "moveCategory">;

View File

@ -6961,7 +6961,7 @@ export function initAbilities() {
.attr(TypeImmunityStatStageChangeAbAttr, PokemonType.ELECTRIC, Stat.SPD, 1) .attr(TypeImmunityStatStageChangeAbAttr, PokemonType.ELECTRIC, Stat.SPD, 1)
.ignorable(), .ignorable(),
new Ability(AbilityId.RIVALRY, 4) new Ability(AbilityId.RIVALRY, 4)
.attr(MovePowerBoostAbAttr, (user, target, _move) => user?.gender !== Gender.GENDERLESS && target?.gender !== Gender.GENDERLESS && user?.gender === target?.gender, 1.25, true) .attr(MovePowerBoostAbAttr, (user, target, _move) => user?.gender !== Gender.GENDERLESS && target?.gender !== Gender.GENDERLESS && user?.gender === target?.gender, 1.25)
.attr(MovePowerBoostAbAttr, (user, target, _move) => user?.gender !== Gender.GENDERLESS && target?.gender !== Gender.GENDERLESS && user?.gender !== target?.gender, 0.75), .attr(MovePowerBoostAbAttr, (user, target, _move) => user?.gender !== Gender.GENDERLESS && target?.gender !== Gender.GENDERLESS && user?.gender !== target?.gender, 0.75),
new Ability(AbilityId.STEADFAST, 4) new Ability(AbilityId.STEADFAST, 4)
.attr(FlinchStatStageChangeAbAttr, [ Stat.SPD ], 1), .attr(FlinchStatStageChangeAbAttr, [ Stat.SPD ], 1),
@ -7751,8 +7751,8 @@ export function initAbilities() {
new Ability(AbilityId.SHARPNESS, 9) new Ability(AbilityId.SHARPNESS, 9)
.attr(MovePowerBoostAbAttr, (_user, _target, move) => move.hasFlag(MoveFlags.SLICING_MOVE), 1.5), .attr(MovePowerBoostAbAttr, (_user, _target, move) => move.hasFlag(MoveFlags.SLICING_MOVE), 1.5),
new Ability(AbilityId.SUPREME_OVERLORD, 9) new Ability(AbilityId.SUPREME_OVERLORD, 9)
.attr(VariableMovePowerBoostAbAttr, (user, _target, _move) => 1 + 0.1 * Math.min(user.isPlayer() ? globalScene.arena.playerFaints : globalScene.currentBattle.enemyFaints, 5)) .conditionalAttr((p) => (p.isPlayer() ? globalScene.arena.playerFaints : globalScene.currentBattle.enemyFaints) > 0, PostSummonAddBattlerTagAbAttr, BattlerTagType.SUPREME_OVERLORD, 0, true)
.partial(), // Should only boost once, on summon .edgeCase(), // Tag is not tied to ability, so suppression/removal etc will not function until a structure to allow this is implemented
new Ability(AbilityId.COSTAR, 9, -2) new Ability(AbilityId.COSTAR, 9, -2)
.attr(PostSummonCopyAllyStatsAbAttr), .attr(PostSummonCopyAllyStatsAbAttr),
new Ability(AbilityId.TOXIC_DEBRIS, 9) new Ability(AbilityId.TOXIC_DEBRIS, 9)

View File

@ -56,6 +56,7 @@ 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 { ArenaTagSide } from "#enums/arena-tag-side";
import { ArenaTagType } from "#enums/arena-tag-type"; import { ArenaTagType } from "#enums/arena-tag-type";
import type { BattlerIndex } from "#enums/battler-index";
import { BattlerTagType } from "#enums/battler-tag-type"; import { BattlerTagType } from "#enums/battler-tag-type";
import { HitResult } from "#enums/hit-result"; import { HitResult } from "#enums/hit-result";
import { CommonAnim } from "#enums/move-anims-common"; import { CommonAnim } from "#enums/move-anims-common";
@ -1597,6 +1598,145 @@ export class SuppressAbilitiesTag extends SerializableArenaTag {
} }
} }
/**
* Interface containing data related to a queued healing effect from
* {@link https://bulbapedia.bulbagarden.net/wiki/Healing_Wish_(move) | Healing Wish}
* or {@link https://bulbapedia.bulbagarden.net/wiki/Lunar_Dance_(move) | Lunar Dance}.
*/
interface PendingHealEffect {
/** The {@linkcode Pokemon.id | PID} of the {@linkcode Pokemon} that created the effect. */
readonly sourceId: number;
/** The {@linkcode MoveId} of the move that created the effect. */
readonly moveId: MoveId;
/** If `true`, also restores the target's PP when the effect activates. */
readonly restorePP: boolean;
/** The message to display when the effect activates */
readonly healMessage: string;
}
/**
* Arena tag to contain stored healing effects, namely from
* {@link https://bulbapedia.bulbagarden.net/wiki/Healing_Wish_(move) | Healing Wish}
* and {@link https://bulbapedia.bulbagarden.net/wiki/Lunar_Dance_(move) | Lunar Dance}.
* When a damaged Pokemon first enters the effect's {@linkcode BattlerIndex | field position},
* their HP is fully restored, and they are cured of any non-volatile status condition.
* If the effect is from Lunar Dance, their PP is also restored.
*/
export class PendingHealTag extends SerializableArenaTag {
public readonly tagType = ArenaTagType.PENDING_HEAL;
/** All pending healing effects, organized by {@linkcode BattlerIndex} */
public readonly pendingHeals: Partial<Record<BattlerIndex, PendingHealEffect[]>> = {};
constructor() {
super(0);
}
/**
* Adds a pending healing effect to the field. Effects under the same move *and*
* target index as an existing effect are ignored.
* @param targetIndex - The {@linkcode BattlerIndex} under which the effect applies
* @param healEffect - The {@linkcode PendingHealEffect | data} for the pending heal effect
*/
public queueHeal(targetIndex: BattlerIndex, healEffect: PendingHealEffect): void {
const existingHealEffects = this.pendingHeals[targetIndex];
if (existingHealEffects) {
if (!existingHealEffects.some(he => he.moveId === healEffect.moveId)) {
existingHealEffects.push(healEffect);
}
} else {
this.pendingHeals[targetIndex] = [healEffect];
}
}
/** Removes default on-remove message */
override onRemove(_arena: Arena): void {}
/** This arena tag is removed at the end of the turn if no pending healing effects are on the field */
override lapse(_arena: Arena): boolean {
for (const key in this.pendingHeals) {
if (this.pendingHeals[key].length > 0) {
return true;
}
}
return false;
}
/**
* Applies a pending healing effect on the given target index. If an effect is found for
* the index, the Pokemon at that index is healed to full HP, is cured of any non-volatile status,
* and has its PP fully restored (if the effect is from Lunar Dance).
* @param arena - The {@linkcode Arena} containing this tag
* @param simulated - If `true`, suppresses changes to game state
* @param pokemon - The {@linkcode Pokemon} receiving the healing effect
* @returns `true` if the target Pokemon was healed by this effect
* @todo This should also be called when a Pokemon moves into a new position via Ally Switch
*/
override apply(arena: Arena, simulated: boolean, pokemon: Pokemon): boolean {
const targetIndex = pokemon.getBattlerIndex();
const targetEffects = this.pendingHeals[targetIndex];
if (targetEffects == null || targetEffects.length === 0) {
return false;
}
const healEffect = targetEffects.find(effect => this.canApply(effect, pokemon));
if (healEffect == null) {
return false;
}
if (simulated) {
return true;
}
const { sourceId, moveId, restorePP, healMessage } = healEffect;
const sourcePokemon = globalScene.getPokemonById(sourceId);
if (!sourcePokemon) {
console.warn(`Source of pending ${allMoves[moveId].name} effect is undefined!`);
targetEffects.splice(targetEffects.indexOf(healEffect), 1);
// Re-evaluate after the invalid heal effect is removed
return this.apply(arena, simulated, pokemon);
}
globalScene.phaseManager.unshiftNew(
"PokemonHealPhase",
targetIndex,
pokemon.getMaxHp(),
healMessage,
true,
false,
false,
true,
false,
restorePP,
);
targetEffects.splice(targetEffects.indexOf(healEffect), 1);
return healEffect != null;
}
/**
* Determines if the given {@linkcode PendingHealEffect} can immediately heal
* the given target {@linkcode Pokemon}.
* @param healEffect - The {@linkcode PendingHealEffect} to evaluate
* @param pokemon - The {@linkcode Pokemon} to evaluate against
* @returns `true` if the Pokemon can be healed by the effect
*/
private canApply(healEffect: PendingHealEffect, pokemon: Pokemon): boolean {
return (
!pokemon.isFullHp()
|| pokemon.status != null
|| (healEffect.restorePP && pokemon.getMoveset().some(mv => mv.ppUsed > 0))
);
}
override loadTag(source: BaseArenaTag & Pick<PendingHealTag, "tagType" | "pendingHeals">): void {
super.loadTag(source);
(this as Mutable<this>).pendingHeals = source.pendingHeals;
}
}
// TODO: swap `sourceMove` and `sourceId` and make `sourceMove` an optional parameter // TODO: swap `sourceMove` and `sourceId` and make `sourceMove` an optional parameter
export function getArenaTag( export function getArenaTag(
tagType: ArenaTagType, tagType: ArenaTagType,
@ -1660,6 +1800,8 @@ export function getArenaTag(
return new FairyLockTag(turnCount, sourceId); return new FairyLockTag(turnCount, sourceId);
case ArenaTagType.NEUTRALIZING_GAS: case ArenaTagType.NEUTRALIZING_GAS:
return new SuppressAbilitiesTag(sourceId); return new SuppressAbilitiesTag(sourceId);
case ArenaTagType.PENDING_HEAL:
return new PendingHealTag();
default: default:
return null; return null;
} }
@ -1708,5 +1850,6 @@ export type ArenaTagTypeMap = {
[ArenaTagType.GRASS_WATER_PLEDGE]: GrassWaterPledgeTag; [ArenaTagType.GRASS_WATER_PLEDGE]: GrassWaterPledgeTag;
[ArenaTagType.FAIRY_LOCK]: FairyLockTag; [ArenaTagType.FAIRY_LOCK]: FairyLockTag;
[ArenaTagType.NEUTRALIZING_GAS]: SuppressAbilitiesTag; [ArenaTagType.NEUTRALIZING_GAS]: SuppressAbilitiesTag;
[ArenaTagType.PENDING_HEAL]: PendingHealTag;
[ArenaTagType.NONE]: NoneTag; [ArenaTagType.NONE]: NoneTag;
}; };

View File

@ -3674,6 +3674,41 @@ export class MagicCoatTag extends BattlerTag {
} }
} }
/**
* Tag associated with {@linkcode AbilityId.SUPREME_OVERLORD}
*/
export class SupremeOverlordTag extends AbilityBattlerTag {
public override readonly tagType = BattlerTagType.SUPREME_OVERLORD;
/** The number of faints at the time the user was sent out */
public readonly faintCount: number;
constructor() {
super(BattlerTagType.SUPREME_OVERLORD, AbilityId.SUPREME_OVERLORD, BattlerTagLapseType.FAINT, 0);
}
public override onAdd(pokemon: Pokemon): boolean {
(this as Mutable<this>).faintCount = Math.min(
pokemon.isPlayer() ? globalScene.arena.playerFaints : globalScene.currentBattle.enemyFaints,
5,
);
globalScene.phaseManager.queueMessage(
i18next.t("battlerTags:supremeOverlordOnAdd", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) }),
);
return true;
}
/**
* @returns The damage multiplier for Supreme Overlord
*/
public getBoost(): number {
return 1 + 0.1 * this.faintCount;
}
public override loadTag(source: BaseBattlerTag & Pick<SupremeOverlordTag, "tagType" | "faintCount">): void {
super.loadTag(source);
(this as Mutable<this>).faintCount = source.faintCount;
}
}
/** /**
* Retrieves a {@linkcode BattlerTag} based on the provided tag type, turn count, source move, and source ID. * Retrieves a {@linkcode BattlerTag} based on the provided tag type, turn count, source move, and source ID.
* @param sourceId - The ID of the pokemon adding the tag * @param sourceId - The ID of the pokemon adding the tag
@ -3874,6 +3909,8 @@ export function getBattlerTag(
return new PsychoShiftTag(); return new PsychoShiftTag();
case BattlerTagType.MAGIC_COAT: case BattlerTagType.MAGIC_COAT:
return new MagicCoatTag(); return new MagicCoatTag();
case BattlerTagType.SUPREME_OVERLORD:
return new SupremeOverlordTag();
} }
} }
@ -4008,4 +4045,5 @@ export type BattlerTagTypeMap = {
[BattlerTagType.GRUDGE]: GrudgeTag; [BattlerTagType.GRUDGE]: GrudgeTag;
[BattlerTagType.PSYCHO_SHIFT]: PsychoShiftTag; [BattlerTagType.PSYCHO_SHIFT]: PsychoShiftTag;
[BattlerTagType.MAGIC_COAT]: MagicCoatTag; [BattlerTagType.MAGIC_COAT]: MagicCoatTag;
[BattlerTagType.SUPREME_OVERLORD]: SupremeOverlordTag;
}; };

View File

@ -6,7 +6,7 @@ import { loggedInUser } from "#app/account";
import type { GameMode } from "#app/game-mode"; import type { GameMode } from "#app/game-mode";
import { globalScene } from "#app/global-scene"; import { globalScene } from "#app/global-scene";
import { getPokemonNameWithAffix } from "#app/messages"; import { getPokemonNameWithAffix } from "#app/messages";
import type { EntryHazardTag } from "#data/arena-tag"; import type { EntryHazardTag, PendingHealTag } from "#data/arena-tag";
import { WeakenMoveTypeTag } from "#data/arena-tag"; import { WeakenMoveTypeTag } from "#data/arena-tag";
import { MoveChargeAnim } from "#data/battle-anims"; import { MoveChargeAnim } from "#data/battle-anims";
import { import {
@ -19,6 +19,7 @@ import {
ShellTrapTag, ShellTrapTag,
StockpilingTag, StockpilingTag,
SubstituteTag, SubstituteTag,
SupremeOverlordTag,
TrappedTag, TrappedTag,
TypeBoostTag, TypeBoostTag,
} from "#data/battler-tags"; } from "#data/battler-tags";
@ -869,6 +870,8 @@ export abstract class Move implements Localizable {
power.value *= 1.5; power.value *= 1.5;
} }
power.value *= (source.getTag(BattlerTagType.SUPREME_OVERLORD) as SupremeOverlordTag | undefined)?.getBoost() ?? 1;
return power.value; return power.value;
} }
@ -2137,24 +2140,15 @@ export class SacrificialFullRestoreAttr extends SacrificialAttr {
return false; return false;
} }
// We don't know which party member will be chosen, so pick the highest max HP in the party // Add a tag to the field if it doesn't already exist, then queue a delayed healing effect in the user's current slot.
const party = user.isPlayer() ? globalScene.getPlayerParty() : globalScene.getEnemyParty(); globalScene.arena.addTag(ArenaTagType.PENDING_HEAL, 0, move.id, user.id); // Arguments after first go completely unused
const maxPartyMemberHp = party.map(p => p.getMaxHp()).reduce((maxHp: number, hp: number) => Math.max(hp, maxHp), 0); const tag = globalScene.arena.getTag(ArenaTagType.PENDING_HEAL) as PendingHealTag;
tag.queueHeal(user.getBattlerIndex(), {
const pm = globalScene.phaseManager; sourceId: user.id,
moveId: move.id,
pm.pushPhase( restorePP: this.restorePP,
pm.create("PokemonHealPhase", healMessage: i18next.t(this.moveMessage, { pokemonName: getPokemonNameWithAffix(user) }),
user.getBattlerIndex(), });
maxPartyMemberHp,
i18next.t(this.moveMessage, { pokemonName: getPokemonNameWithAffix(user) }),
true,
false,
false,
true,
false,
this.restorePP),
true);
return true; return true;
} }

View File

@ -34,4 +34,5 @@ export enum ArenaTagType {
GRASS_WATER_PLEDGE = "GRASS_WATER_PLEDGE", GRASS_WATER_PLEDGE = "GRASS_WATER_PLEDGE",
FAIRY_LOCK = "FAIRY_LOCK", FAIRY_LOCK = "FAIRY_LOCK",
NEUTRALIZING_GAS = "NEUTRALIZING_GAS", NEUTRALIZING_GAS = "NEUTRALIZING_GAS",
PENDING_HEAL = "PENDING_HEAL",
} }

View File

@ -94,4 +94,5 @@ export enum BattlerTagType {
ENDURE_TOKEN = "ENDURE_TOKEN", ENDURE_TOKEN = "ENDURE_TOKEN",
POWDER = "POWDER", POWDER = "POWDER",
MAGIC_COAT = "MAGIC_COAT", MAGIC_COAT = "MAGIC_COAT",
SUPREME_OVERLORD = "SUPREME_OVERLORD",
} }

File diff suppressed because it is too large Load Diff

View File

@ -235,7 +235,6 @@ export class PhaseManager {
/** overrides default of inserting phases to end of phaseQueuePrepend array. Useful for inserting Phases "out of order" */ /** overrides default of inserting phases to end of phaseQueuePrepend array. Useful for inserting Phases "out of order" */
private phaseQueuePrependSpliceIndex = -1; private phaseQueuePrependSpliceIndex = -1;
private nextCommandPhaseQueue: Phase[] = [];
/** Storage for {@linkcode PhasePriorityQueue}s which hold phases whose order dynamically changes */ /** Storage for {@linkcode PhasePriorityQueue}s which hold phases whose order dynamically changes */
private dynamicPhaseQueues: PhasePriorityQueue[]; private dynamicPhaseQueues: PhasePriorityQueue[];
@ -293,13 +292,12 @@ export class PhaseManager {
/** /**
* Adds a phase to nextCommandPhaseQueue, as long as boolean passed in is false * Adds a phase to nextCommandPhaseQueue, as long as boolean passed in is false
* @param phase {@linkcode Phase} the phase to add * @param phase {@linkcode Phase} the phase to add
* @param defer boolean on which queue to add to, defaults to false, and adds to phaseQueue
*/ */
pushPhase(phase: Phase, defer = false): void { pushPhase(phase: Phase): void {
if (this.getDynamicPhaseType(phase) !== undefined) { if (this.getDynamicPhaseType(phase) !== undefined) {
this.pushDynamicPhase(phase); this.pushDynamicPhase(phase);
} else { } else {
(!defer ? this.phaseQueue : this.nextCommandPhaseQueue).push(phase); this.phaseQueue.push(phase);
} }
} }
@ -326,7 +324,7 @@ export class PhaseManager {
* Clears all phase-related stuff, including all phase queues, the current and standby phases, and a splice index * Clears all phase-related stuff, including all phase queues, the current and standby phases, and a splice index
*/ */
clearAllPhases(): void { clearAllPhases(): void {
for (const queue of [this.phaseQueue, this.phaseQueuePrepend, this.conditionalQueue, this.nextCommandPhaseQueue]) { for (const queue of [this.phaseQueue, this.phaseQueuePrepend, this.conditionalQueue]) {
queue.splice(0, queue.length); queue.splice(0, queue.length);
} }
this.dynamicPhaseQueues.forEach(queue => queue.clear()); this.dynamicPhaseQueues.forEach(queue => queue.clear());
@ -627,10 +625,6 @@ export class PhaseManager {
* Moves everything from nextCommandPhaseQueue to phaseQueue (keeping order) * Moves everything from nextCommandPhaseQueue to phaseQueue (keeping order)
*/ */
private populatePhaseQueue(): void { private populatePhaseQueue(): void {
if (this.nextCommandPhaseQueue.length > 0) {
this.phaseQueue.push(...this.nextCommandPhaseQueue);
this.nextCommandPhaseQueue.splice(0, this.nextCommandPhaseQueue.length);
}
this.phaseQueue.push(new TurnInitPhase()); this.phaseQueue.push(new TurnInitPhase());
} }

View File

@ -64,7 +64,8 @@ export class PokemonHealPhase extends CommonAnimPhase {
} }
const hasMessage = !!this.message; const hasMessage = !!this.message;
const healOrDamage = !pokemon.isFullHp() || this.hpHealed < 0; const canRestorePP = this.fullRestorePP && pokemon.getMoveset().some(mv => mv.ppUsed > 0);
const healOrDamage = !pokemon.isFullHp() || this.hpHealed < 0 || canRestorePP;
const healBlock = pokemon.getTag(BattlerTagType.HEAL_BLOCK) as HealBlockTag; const healBlock = pokemon.getTag(BattlerTagType.HEAL_BLOCK) as HealBlockTag;
let lastStatusEffect = StatusEffect.NONE; let lastStatusEffect = StatusEffect.NONE;

View File

@ -2,6 +2,7 @@ import { applyAbAttrs } from "#abilities/apply-ab-attrs";
import { globalScene } from "#app/global-scene"; import { globalScene } from "#app/global-scene";
import { EntryHazardTag } from "#data/arena-tag"; import { EntryHazardTag } from "#data/arena-tag";
import { MysteryEncounterPostSummonTag } from "#data/battler-tags"; import { MysteryEncounterPostSummonTag } from "#data/battler-tags";
import { ArenaTagType } from "#enums/arena-tag-type";
import { BattlerTagType } from "#enums/battler-tag-type"; import { BattlerTagType } from "#enums/battler-tag-type";
import { StatusEffect } from "#enums/status-effect"; import { StatusEffect } from "#enums/status-effect";
import { PokemonPhase } from "#phases/pokemon-phase"; import { PokemonPhase } from "#phases/pokemon-phase";
@ -16,6 +17,9 @@ export class PostSummonPhase extends PokemonPhase {
if (pokemon.status?.effect === StatusEffect.TOXIC) { if (pokemon.status?.effect === StatusEffect.TOXIC) {
pokemon.status.toxicTurnCount = 0; pokemon.status.toxicTurnCount = 0;
} }
globalScene.arena.applyTags(ArenaTagType.PENDING_HEAL, false, pokemon);
globalScene.arena.applyTags(EntryHazardTag, false, pokemon); globalScene.arena.applyTags(EntryHazardTag, false, pokemon);
// If this is mystery encounter and has post summon phase tag, apply post summon effects // If this is mystery encounter and has post summon phase tag, apply post summon effects

View File

@ -285,6 +285,12 @@ export class ArenaFlyout extends Phaser.GameObjects.Container {
switch (arenaEffectChangedEvent.constructor) { switch (arenaEffectChangedEvent.constructor) {
case TagAddedEvent: { case TagAddedEvent: {
const tagAddedEvent = arenaEffectChangedEvent as TagAddedEvent; const tagAddedEvent = arenaEffectChangedEvent as TagAddedEvent;
const excludedTags = [ArenaTagType.PENDING_HEAL];
if (excludedTags.includes(tagAddedEvent.arenaTagType)) {
return;
}
const isArenaTrapTag = globalScene.arena.getTag(tagAddedEvent.arenaTagType) instanceof EntryHazardTag; const isArenaTrapTag = globalScene.arena.getTag(tagAddedEvent.arenaTagType) instanceof EntryHazardTag;
let arenaEffectType: ArenaEffectType; let arenaEffectType: ArenaEffectType;

View File

@ -1,7 +1,7 @@
import "vitest"; import "vitest";
import type { Phase } from "#app/phase";
import type Overrides from "#app/overrides"; import type Overrides from "#app/overrides";
import type { Phase } from "#app/phase";
import type { ArenaTag } from "#data/arena-tag"; import type { ArenaTag } from "#data/arena-tag";
import type { TerrainType } from "#data/terrain"; import type { TerrainType } from "#data/terrain";
import type { AbilityId } from "#enums/ability-id"; import type { AbilityId } from "#enums/ability-id";
@ -10,10 +10,14 @@ import type { ArenaTagType } from "#enums/arena-tag-type";
import type { BattlerTagType } from "#enums/battler-tag-type"; import type { BattlerTagType } from "#enums/battler-tag-type";
import type { MoveId } from "#enums/move-id"; import type { MoveId } from "#enums/move-id";
import type { PokemonType } from "#enums/pokemon-type"; import type { PokemonType } from "#enums/pokemon-type";
import type { PositionalTag } from "#data/positional-tags/positional-tag";
import type { PositionalTagType } from "#enums/positional-tag-type"; import type { PositionalTagType } from "#enums/positional-tag-type";
import type { BattleStat, EffectiveStat } from "#enums/stat"; import type { BattleStat, EffectiveStat } from "#enums/stat";
import type { WeatherType } from "#enums/weather-type"; import type { WeatherType } from "#enums/weather-type";
import type { Pokemon } from "#field/pokemon";
import type { GameManager } from "#test/test-utils/game-manager";
import type { toHaveArenaTagOptions } from "#test/test-utils/matchers/to-have-arena-tag"; import type { toHaveArenaTagOptions } from "#test/test-utils/matchers/to-have-arena-tag";
import type { toHaveBattlerTagOptions } from "#test/test-utils/matchers/to-have-battler-tag";
import type { toHaveEffectiveStatOptions } from "#test/test-utils/matchers/to-have-effective-stat"; import type { toHaveEffectiveStatOptions } from "#test/test-utils/matchers/to-have-effective-stat";
import type { toHavePositionalTagOptions } from "#test/test-utils/matchers/to-have-positional-tag"; import type { toHavePositionalTagOptions } from "#test/test-utils/matchers/to-have-positional-tag";
import type { expectedStatusType } from "#test/test-utils/matchers/to-have-status-effect"; import type { expectedStatusType } from "#test/test-utils/matchers/to-have-status-effect";
@ -23,12 +27,33 @@ import type { TurnMove } from "#types/turn-move";
import type { AtLeastOne } from "#types/type-helpers"; import type { AtLeastOne } from "#types/type-helpers";
import type { toDmgValue } from "#utils/common"; import type { toDmgValue } from "#utils/common";
import type { expect } from "vitest"; import type { expect } from "vitest";
import type { toHaveBattlerTagOptions } from "#test/test-utils/matchers/to-have-battler-tag";
// #region Boilerplate/Helpers
declare module "vitest" { declare module "vitest" {
interface Assertion<T> { interface Assertion<T>
// #region Generic Matchers extends GenericMatchers<T>,
RestrictMatcher<GameManagerMatchers, T, GameManager>,
RestrictMatcher<ArenaMatchers, T, GameManager>,
RestrictMatcher<PokemonMatchers, T, Pokemon> {}
}
/**
* Utility type to restrict matchers' properties based on the type of `T`.
* If it does not extend `R`, all methods inside `M` will have their types resolved to `never`.
* @typeParam M - The type of the matchers object to restrict
* @typeParam T - The type parameter of the assertion
* @typeParam R - The type to restrict T based off of
* @privateRemarks
* We cannot remove incompatible methods outright as Typescript requires that
* interfaces extend solely off of types with statically known members.
*/
type RestrictMatcher<M extends object, T, R> = {
[k in keyof M]: T extends R ? M[k] : never;
};
// #endregion Boilerplate/Helpers
// #region Generic Matchers
interface GenericMatchers<T> {
/** /**
* Check whether an array contains EXACTLY the given items (in any order). * Check whether an array contains EXACTLY the given items (in any order).
* *
@ -38,40 +63,56 @@ declare module "vitest" {
* @param expected - The expected contents of the array, in any order * @param expected - The expected contents of the array, in any order
* @see {@linkcode expect.arrayContaining} * @see {@linkcode expect.arrayContaining}
*/ */
toEqualArrayUnsorted(expected: T[]): void; toEqualUnsorted: T extends (infer U)[] ? (expected: U[]) => void : never;
// #endregion Generic Matchers
// #region GameManager Matchers
/** /**
* Check if the {@linkcode GameManager} has shown the given message at least once in the current battle. * Check whether a {@linkcode Map} contains the given key, disregarding its value.
* @param expectedMessage - The expected message * @param expectedKey - The key whose inclusion is being checked
* @privateRemarks
* While this functionality _could_ be simulated by writing
* `expect(x.get(y)).toBeDefined()` or
* `expect(x).toContain([y, expect.anything()])`,
* this is still preferred due to being more ergonomic and provides better error messsages.
*/
toHaveKey: T extends Map<infer K, unknown> ? (expectedKey: K) => void : never;
}
// #endregion Generic Matchers
// #region GameManager Matchers
interface GameManagerMatchers {
/**
* Check if the {@linkcode GameManager} has shown the given message at least once in the current test case.
* @param expectedMessage - The expected message to be displayed
* @remarks
* Strings consumed by this function should _always_ be produced by a call to `i18next.t`
* to avoid hardcoding text into test files.
*/ */
toHaveShownMessage(expectedMessage: string): void; toHaveShownMessage(expectedMessage: string): void;
/** /**
* @param expectedPhase - The expected {@linkcode PhaseString} * Check if the currently-running {@linkcode Phase} is of the given type.
* @param expectedPhase - The expected {@linkcode PhaseString | name of the phase}
*/ */
toBeAtPhase(expectedPhase: PhaseString): void; toBeAtPhase(expectedPhase: PhaseString): void;
// #endregion GameManager Matchers } // #endregion GameManager Matchers
// #region Arena Matchers
// #region Arena Matchers
interface ArenaMatchers {
/** /**
* Check whether the current {@linkcode WeatherType} is as expected. * Check whether the current {@linkcode WeatherType} is as expected.
* @param expectedWeatherType - The expected {@linkcode WeatherType} * @param expectedWeatherType - The expected `WeatherType`
*/ */
toHaveWeather(expectedWeatherType: WeatherType): void; toHaveWeather(expectedWeatherType: WeatherType): void;
/** /**
* Check whether the current {@linkcode TerrainType} is as expected. * Check whether the current {@linkcode TerrainType} is as expected.
* @param expectedTerrainType - The expected {@linkcode TerrainType} * @param expectedTerrainType - The expected `TerrainType`
*/ */
toHaveTerrain(expectedTerrainType: TerrainType): void; toHaveTerrain(expectedTerrainType: TerrainType): void;
/** /**
* Check whether the current {@linkcode Arena} contains the given {@linkcode ArenaTag}. * Check whether the current {@linkcode Arena} contains the given {@linkcode ArenaTag}.
* @param expectedTag - A partially-filled {@linkcode ArenaTag} containing the desired properties * @param expectedTag - A partially-filled `ArenaTag` containing the desired properties
*/ */
toHaveArenaTag<A extends ArenaTagType>(expectedTag: toHaveArenaTagOptions<A>): void; toHaveArenaTag<A extends ArenaTagType>(expectedTag: toHaveArenaTagOptions<A>): void;
/** /**
@ -89,15 +130,16 @@ declare module "vitest" {
/** /**
* Check whether the current {@linkcode Arena} contains the given number of {@linkcode PositionalTag}s. * Check whether the current {@linkcode Arena} contains the given number of {@linkcode PositionalTag}s.
* @param expectedType - The {@linkcode PositionalTagType} of the desired tag * @param expectedType - The {@linkcode PositionalTagType} of the desired tag
* @param count - The number of instances of {@linkcode expectedType} that should be active; * @param count - The number of instances of `expectedType` that should be active;
* defaults to `1` and must be within the range `[0, 4]` * defaults to `1` and must be within the range `[0, 4]`
*/ */
toHavePositionalTag(expectedType: PositionalTagType, count?: number): void; toHavePositionalTag(expectedType: PositionalTagType, count?: number): void;
}
// #endregion Arena Matchers // #endregion Arena Matchers
// #region Pokemon Matchers
// #region Pokemon Matchers
interface PokemonMatchers {
/** /**
* Check whether a {@linkcode Pokemon}'s current typing includes the given types. * Check whether a {@linkcode Pokemon}'s current typing includes the given types.
* @param expectedTypes - The expected {@linkcode PokemonType}s to check against; must have length `>0` * @param expectedTypes - The expected {@linkcode PokemonType}s to check against; must have length `>0`
@ -181,6 +223,7 @@ declare module "vitest" {
* Check whether a {@linkcode Pokemon} is at full HP. * Check whether a {@linkcode Pokemon} is at full HP.
*/ */
toHaveFullHp(): void; toHaveFullHp(): void;
/** /**
* Check whether a {@linkcode Pokemon} has consumed the given amount of PP for one of its moves. * Check whether a {@linkcode Pokemon} has consumed the given amount of PP for one of its moves.
* @param moveId - The {@linkcode MoveId} corresponding to the {@linkcode PokemonMove} that should have consumed PP * @param moveId - The {@linkcode MoveId} corresponding to the {@linkcode PokemonMove} that should have consumed PP
@ -191,7 +234,5 @@ declare module "vitest" {
* or does not contain exactly one copy of `moveId`, this will fail the test. * or does not contain exactly one copy of `moveId`, this will fail the test.
*/ */
toHaveUsedPP(moveId: MoveId, ppUsed: number | "all"): void; toHaveUsedPP(moveId: MoveId, ppUsed: number | "all"): void;
// #endregion Pokemon Matchers
}
} }
// #endregion Pokemon Matchers

View File

@ -1,6 +1,7 @@
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 { BattlerIndex } from "#enums/battler-index"; import { BattlerIndex } from "#enums/battler-index";
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 type { Move } from "#moves/move"; import type { Move } from "#moves/move";
@ -166,4 +167,41 @@ describe("Abilities - Supreme Overlord", () => {
expect(move.calculateBattlePower).toHaveLastReturnedWith(basePower); expect(move.calculateBattlePower).toHaveLastReturnedWith(basePower);
}); });
it("should not increase in power if ally faints while on the field", async () => {
game.override.battleStyle("double");
await game.classicMode.startBattle([SpeciesId.BULBASAUR, SpeciesId.CHARMANDER, SpeciesId.SQUIRTLE]);
game.move.select(MoveId.TACKLE, BattlerIndex.PLAYER, BattlerIndex.ENEMY);
game.move.select(MoveId.LUNAR_DANCE, BattlerIndex.PLAYER_2);
await game.setTurnOrder([BattlerIndex.PLAYER_2, BattlerIndex.PLAYER, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2]);
await game.toEndOfTurn();
expect(game.field.getPlayerPokemon()).not.toHaveBattlerTag(BattlerTagType.SUPREME_OVERLORD);
expect(move.calculateBattlePower).toHaveLastReturnedWith(basePower);
});
it("should persist fainted count through reload", async () => {
// Avoid learning moves
game.override.startingLevel(1000);
await game.classicMode.startBattle([SpeciesId.BULBASAUR, SpeciesId.CHARMANDER, SpeciesId.SQUIRTLE]);
game.move.select(MoveId.LUNAR_DANCE);
game.doSelectPartyPokemon(1);
await game.toNextTurn();
game.move.select(MoveId.TACKLE);
await game.toEndOfTurn();
expect(move.calculateBattlePower).toHaveLastReturnedWith(basePower * 1.1);
await game.toNextWave();
await game.reload.reloadSession();
expect(game.field.getPlayerPokemon()).toHaveBattlerTag({ tagType: BattlerTagType.SUPREME_OVERLORD, faintCount: 1 });
game.move.select(MoveId.TACKLE);
await game.toEndOfTurn();
expect(move.calculateBattlePower).toHaveLastReturnedWith(basePower * 1.1);
});
}); });

View File

@ -0,0 +1,245 @@
import { AbilityId } from "#enums/ability-id";
import { ArenaTagType } from "#enums/arena-tag-type";
import { Challenges } from "#enums/challenges";
import { MoveId } from "#enums/move-id";
import { MoveResult } from "#enums/move-result";
import { PokemonType } from "#enums/pokemon-type";
import { SpeciesId } from "#enums/species-id";
import { StatusEffect } from "#enums/status-effect";
import { GameManager } from "#test/test-utils/game-manager";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
describe("Moves - Lunar Dance and Healing Wish", () => {
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("double").enemyAbility(AbilityId.BALL_FETCH).enemyMoveset(MoveId.SPLASH);
});
describe.each([
{ moveName: "Healing Wish", moveId: MoveId.HEALING_WISH },
{ moveName: "Lunar Dance", moveId: MoveId.LUNAR_DANCE },
])("$moveName", ({ moveId }) => {
it("should sacrifice the user to restore the switched in Pokemon's HP", async () => {
await game.classicMode.startBattle([SpeciesId.BULBASAUR, SpeciesId.CHARMANDER, SpeciesId.SQUIRTLE]);
const [bulbasaur, charmander, squirtle] = game.scene.getPlayerParty();
squirtle.hp = 1;
game.move.use(MoveId.SPLASH, 0);
game.move.use(moveId, 1);
game.doSelectPartyPokemon(2);
await game.toNextTurn();
expect(bulbasaur.isFullHp()).toBe(true);
expect(charmander.isFainted()).toBe(true);
expect(squirtle.isFullHp()).toBe(true);
});
it("should sacrifice the user to cure the switched in Pokemon's status", async () => {
game.override.statusEffect(StatusEffect.BURN);
await game.classicMode.startBattle([SpeciesId.BULBASAUR, SpeciesId.CHARMANDER, SpeciesId.SQUIRTLE]);
const [bulbasaur, charmander, squirtle] = game.scene.getPlayerParty();
game.move.use(MoveId.SPLASH, 0);
game.move.use(moveId, 1);
game.doSelectPartyPokemon(2);
await game.toNextTurn();
expect(bulbasaur.status?.effect).toBe(StatusEffect.BURN);
expect(charmander.isFainted()).toBe(true);
expect(squirtle.status?.effect).toBeUndefined();
});
it("should fail if the user has no non-fainted allies in their party", async () => {
game.override.battleStyle("single");
await game.classicMode.startBattle([SpeciesId.BULBASAUR, SpeciesId.CHARMANDER]);
const [bulbasaur, charmander] = game.scene.getPlayerParty();
game.move.use(MoveId.MEMENTO);
game.doSelectPartyPokemon(1);
await game.toNextTurn();
expect(bulbasaur.isFainted()).toBe(true);
expect(charmander.isActive(true)).toBe(true);
game.move.use(moveId);
await game.toEndOfTurn();
expect(charmander.isFullHp());
expect(charmander.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
});
it("should fail if the user has no challenge-eligible allies", async () => {
game.override.battleStyle("single");
// Mono normal challenge
game.challengeMode.addChallenge(Challenges.SINGLE_TYPE, PokemonType.NORMAL + 1, 0);
await game.challengeMode.startBattle([SpeciesId.RATICATE, SpeciesId.ODDISH]);
const raticate = game.field.getPlayerPokemon();
game.move.use(moveId);
await game.toNextTurn();
expect(raticate.isFullHp()).toBe(true);
expect(raticate.getLastXMoves()[0].result).toEqual(MoveResult.FAIL);
});
it("should store its effect if the switched-in Pokemon would be unaffected", async () => {
game.override.battleStyle("single");
await game.classicMode.startBattle([SpeciesId.BULBASAUR, SpeciesId.CHARMANDER, SpeciesId.SQUIRTLE]);
const [bulbasaur, charmander, squirtle] = game.scene.getPlayerParty();
squirtle.hp = 1;
game.move.use(moveId);
game.doSelectPartyPokemon(1);
await game.toNextTurn();
// Bulbasaur fainted and stored a healing effect
expect(bulbasaur.isFainted()).toBe(true);
expect(charmander.isFullHp()).toBe(true);
expect(game.phaseInterceptor.log).not.toContain("PokemonHealPhase");
expect(game.scene.arena.getTag(ArenaTagType.PENDING_HEAL)).toBeDefined();
// Switch to damaged Squirtle. HW/LD's effect should activate
game.doSwitchPokemon(2);
await game.toEndOfTurn();
expect(squirtle.isFullHp()).toBe(true);
expect(game.scene.arena.getTag(ArenaTagType.PENDING_HEAL)).toBeUndefined();
// Set Charmander's HP to 1, then switch back to Charmander.
// HW/LD shouldn't activate again
charmander.hp = 1;
game.doSwitchPokemon(2);
await game.toEndOfTurn();
expect(charmander.hp).toBe(1);
});
it("should only store one charge of the effect at a time", async () => {
game.override.battleStyle("single");
await game.classicMode.startBattle([
SpeciesId.BULBASAUR,
SpeciesId.CHARMANDER,
SpeciesId.SQUIRTLE,
SpeciesId.PIKACHU,
]);
const [bulbasaur, charmander, squirtle, pikachu] = game.scene.getPlayerParty();
[squirtle, pikachu].forEach(p => (p.hp = 1));
// Use HW/LD and send in Charmander. HW/LD's effect should be stored
game.move.use(moveId);
game.doSelectPartyPokemon(1);
await game.toNextTurn();
expect(bulbasaur.isFainted()).toBe(true);
expect(charmander.isFullHp()).toBe(true);
expect(charmander.isFullHp());
expect(game.phaseInterceptor.log).not.toContain("PokemonHealPhase");
expect(game.scene.arena.getTag(ArenaTagType.PENDING_HEAL)).toBeDefined();
// Use HW/LD again, sending in Squirtle. HW/LD should activate and heal Squirtle
game.move.use(moveId);
game.doSelectPartyPokemon(2);
await game.toNextTurn();
expect(charmander.isFainted()).toBe(true);
expect(squirtle.isFullHp()).toBe(true);
expect(squirtle.isFullHp());
// Switch again to Pikachu. HW/LD's effect shouldn't be present
game.doSwitchPokemon(3);
expect(pikachu.isFullHp()).toBe(false);
});
});
it("Lunar Dance should sacrifice the user to restore the switched in Pokemon's PP", async () => {
game.override.battleStyle("single");
await game.classicMode.startBattle([SpeciesId.BULBASAUR, SpeciesId.CHARMANDER]);
const [bulbasaur, charmander] = game.scene.getPlayerParty();
game.move.use(MoveId.SPLASH);
await game.toNextTurn();
game.doSwitchPokemon(1);
await game.toNextTurn();
game.move.use(MoveId.LUNAR_DANCE);
game.doSelectPartyPokemon(1);
await game.toNextTurn();
expect(charmander.isFainted()).toBeTruthy();
bulbasaur.getMoveset().forEach(mv => expect(mv.ppUsed).toBe(0));
});
it("should stack with each other", async () => {
game.override.battleStyle("single");
await game.classicMode.startBattle([
SpeciesId.BULBASAUR,
SpeciesId.CHARMANDER,
SpeciesId.SQUIRTLE,
SpeciesId.PIKACHU,
]);
const [bulbasaur, charmander, squirtle, pikachu] = game.scene.getPlayerParty();
[squirtle, pikachu].forEach(p => {
p.hp = 1;
p.getMoveset().forEach(mv => (mv.ppUsed = 1));
});
game.move.use(MoveId.LUNAR_DANCE);
game.doSelectPartyPokemon(1);
await game.toNextTurn();
expect(bulbasaur.isFainted()).toBe(true);
expect(charmander.isFullHp()).toBe(true);
expect(game.phaseInterceptor.log).not.toContain("PokemonHealPhase");
expect(game.scene.arena.getTag(ArenaTagType.PENDING_HEAL)).toBeDefined();
game.move.use(MoveId.HEALING_WISH);
game.doSelectPartyPokemon(2);
// Lunar Dance should apply first since it was used first, restoring Squirtle's HP and PP
await game.toNextTurn();
expect(squirtle.isFullHp()).toBe(true);
squirtle.getMoveset().forEach(mv => expect(mv.ppUsed).toBe(0));
expect(game.scene.arena.getTag(ArenaTagType.PENDING_HEAL)).toBeDefined();
game.doSwitchPokemon(3);
// Healing Wish should apply on the next switch, restoring Pikachu's HP
await game.toEndOfTurn();
expect(pikachu.isFullHp()).toBe(true);
pikachu.getMoveset().forEach(mv => expect(mv.ppUsed).toBe(1));
expect(game.scene.arena.getTag(ArenaTagType.PENDING_HEAL)).toBeUndefined();
});
});

View File

@ -1,73 +0,0 @@
import { AbilityId } from "#enums/ability-id";
import { MoveId } from "#enums/move-id";
import { SpeciesId } from "#enums/species-id";
import { StatusEffect } from "#enums/status-effect";
import { GameManager } from "#test/test-utils/game-manager";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
describe("Moves - Lunar Dance", () => {
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
.statusEffect(StatusEffect.BURN)
.battleStyle("double")
.enemyAbility(AbilityId.BALL_FETCH)
.enemyMoveset(MoveId.SPLASH);
});
it("should full restore HP, PP and status of switched in pokemon, then fail second use because no remaining backup pokemon in party", async () => {
await game.classicMode.startBattle([SpeciesId.BULBASAUR, SpeciesId.ODDISH, SpeciesId.RATTATA]);
const [bulbasaur, oddish, rattata] = game.scene.getPlayerParty();
game.move.changeMoveset(bulbasaur, [MoveId.LUNAR_DANCE, MoveId.SPLASH]);
game.move.changeMoveset(oddish, [MoveId.LUNAR_DANCE, MoveId.SPLASH]);
game.move.changeMoveset(rattata, [MoveId.LUNAR_DANCE, MoveId.SPLASH]);
game.move.select(MoveId.SPLASH, 0);
game.move.select(MoveId.SPLASH, 1);
await game.toNextTurn();
// Bulbasaur should still be burned and have used a PP for splash and not at max hp
expect(bulbasaur.status?.effect).toBe(StatusEffect.BURN);
expect(bulbasaur.moveset[1]?.ppUsed).toBe(1);
expect(bulbasaur.hp).toBeLessThan(bulbasaur.getMaxHp());
// Switch out Bulbasaur for Rattata so we can swtich bulbasaur back in with lunar dance
game.doSwitchPokemon(2);
game.move.select(MoveId.SPLASH, 1);
await game.toNextTurn();
game.move.select(MoveId.SPLASH, 0);
game.move.select(MoveId.LUNAR_DANCE);
game.doSelectPartyPokemon(2);
await game.phaseInterceptor.to("SwitchPhase", false);
await game.toNextTurn();
// Bulbasaur should NOT have any status and have full PP for splash and be at max hp
expect(bulbasaur.status?.effect).toBeUndefined();
expect(bulbasaur.moveset[1]?.ppUsed).toBe(0);
expect(bulbasaur.isFullHp()).toBe(true);
game.move.select(MoveId.SPLASH, 0);
game.move.select(MoveId.LUNAR_DANCE);
await game.toNextTurn();
// Using Lunar dance again should fail because nothing in party and rattata should be alive
expect(rattata.status?.effect).toBe(StatusEffect.BURN);
expect(rattata.hp).toBeLessThan(rattata.getMaxHp());
});
});

View File

@ -1,5 +1,11 @@
/**
* Setup file for custom matchers.
* Make sure to define the call signatures in `#test/@types/vitest.d.ts` too!
* @module
*/
import { toBeAtPhase } from "#test/test-utils/matchers/to-be-at-phase"; import { toBeAtPhase } from "#test/test-utils/matchers/to-be-at-phase";
import { toEqualArrayUnsorted } from "#test/test-utils/matchers/to-equal-array-unsorted"; import { toEqualUnsorted } from "#test/test-utils/matchers/to-equal-unsorted";
import { toHaveAbilityApplied } from "#test/test-utils/matchers/to-have-ability-applied"; import { toHaveAbilityApplied } from "#test/test-utils/matchers/to-have-ability-applied";
import { toHaveArenaTag } from "#test/test-utils/matchers/to-have-arena-tag"; import { toHaveArenaTag } from "#test/test-utils/matchers/to-have-arena-tag";
import { toHaveBattlerTag } from "#test/test-utils/matchers/to-have-battler-tag"; import { toHaveBattlerTag } from "#test/test-utils/matchers/to-have-battler-tag";
@ -7,6 +13,7 @@ import { toHaveEffectiveStat } from "#test/test-utils/matchers/to-have-effective
import { toHaveFainted } from "#test/test-utils/matchers/to-have-fainted"; import { toHaveFainted } from "#test/test-utils/matchers/to-have-fainted";
import { toHaveFullHp } from "#test/test-utils/matchers/to-have-full-hp"; import { toHaveFullHp } from "#test/test-utils/matchers/to-have-full-hp";
import { toHaveHp } from "#test/test-utils/matchers/to-have-hp"; import { toHaveHp } from "#test/test-utils/matchers/to-have-hp";
import { toHaveKey } from "#test/test-utils/matchers/to-have-key";
import { toHavePositionalTag } from "#test/test-utils/matchers/to-have-positional-tag"; import { toHavePositionalTag } from "#test/test-utils/matchers/to-have-positional-tag";
import { toHaveShownMessage } from "#test/test-utils/matchers/to-have-shown-message"; import { toHaveShownMessage } from "#test/test-utils/matchers/to-have-shown-message";
import { toHaveStatStage } from "#test/test-utils/matchers/to-have-stat-stage"; import { toHaveStatStage } from "#test/test-utils/matchers/to-have-stat-stage";
@ -19,13 +26,9 @@ import { toHaveUsedPP } from "#test/test-utils/matchers/to-have-used-pp";
import { toHaveWeather } from "#test/test-utils/matchers/to-have-weather"; import { toHaveWeather } from "#test/test-utils/matchers/to-have-weather";
import { expect } from "vitest"; import { expect } from "vitest";
/*
* Setup file for custom matchers.
* Make sure to define the call signatures in `#test/@types/vitest.d.ts` too!
*/
expect.extend({ expect.extend({
toEqualArrayUnsorted, toEqualUnsorted,
toHaveKey,
toHaveShownMessage, toHaveShownMessage,
toBeAtPhase, toBeAtPhase,
toHaveWeather, toHaveWeather,

View File

@ -40,10 +40,7 @@ export class ModifierHelper extends GameManagerHelper {
* @returns `this` * @returns `this`
*/ */
testCheck(modifier: ModifierTypeKeys, expectToBePreset: boolean): this { testCheck(modifier: ModifierTypeKeys, expectToBePreset: boolean): this {
if (expectToBePreset) { (expectToBePreset ? expect(itemPoolChecks) : expect(itemPoolChecks).not).toHaveKey(modifier);
expect(itemPoolChecks.get(modifier)).toBeTruthy();
}
expect(itemPoolChecks.get(modifier)).toBeFalsy();
return this; return this;
} }

View File

@ -8,11 +8,7 @@ import type { MatcherState, SyncExpectationResult } from "@vitest/expect";
* @param expected - The array to check equality with * @param expected - The array to check equality with
* @returns Whether the matcher passed * @returns Whether the matcher passed
*/ */
export function toEqualArrayUnsorted( export function toEqualUnsorted(this: MatcherState, received: unknown, expected: unknown[]): SyncExpectationResult {
this: MatcherState,
received: unknown,
expected: unknown[],
): SyncExpectationResult {
if (!Array.isArray(received)) { if (!Array.isArray(received)) {
return { return {
pass: this.isNot, pass: this.isNot,

View File

@ -0,0 +1,47 @@
import { getOnelineDiffStr } from "#test/test-utils/string-utils";
import { receivedStr } from "#test/test-utils/test-utils";
import type { MatcherState, SyncExpectationResult } from "@vitest/expect";
/**
* Matcher that checks if a {@linkcode Map} contains the given key, regardless of its value.
* @param received - The received value. Should be a Map
* @param expectedKey - The key whose inclusion in the map is being checked
* @returns Whether the matcher passed
*/
export function toHaveKey(this: MatcherState, received: unknown, expectedKey: unknown): SyncExpectationResult {
if (!(received instanceof Map)) {
return {
pass: this.isNot,
message: () => `Expected to receive a Map, but got ${receivedStr(received)}!`,
};
}
if (received.size === 0) {
return {
pass: this.isNot,
message: () => "Expected to receive a non-empty Map, but received map was empty!",
expected: expectedKey,
actual: received,
};
}
const keys = [...received.keys()];
const pass = this.equals(keys, expectedKey, [
...this.customTesters,
this.utils.iterableEquality,
this.utils.subsetEquality,
]);
const actualStr = getOnelineDiffStr.call(this, received);
const expectedStr = getOnelineDiffStr.call(this, expectedKey);
return {
pass,
message: () =>
pass
? `Expected ${actualStr} to NOT have the key ${expectedStr}, but it did!`
: `Expected ${actualStr} to have the key ${expectedStr}, but it didn't!`,
expected: expectedKey,
actual: keys,
};
}

View File

@ -8,8 +8,8 @@ import { isGameManagerInstance, receivedStr } from "#test/test-utils/test-utils"
import type { MatcherState, SyncExpectationResult } from "@vitest/expect"; import type { MatcherState, SyncExpectationResult } from "@vitest/expect";
/** /**
* Matcher that checks if the {@linkcode TerrainType} is as expected * Matcher that checks if the current {@linkcode TerrainType} is as expected.
* @param received - The object to check. Should be an instance of {@linkcode GameManager}. * @param received - The object to check. Should be the current {@linkcode GameManager}.
* @param expectedTerrainType - The expected {@linkcode TerrainType}, or {@linkcode TerrainType.NONE} if no terrain should be active * @param expectedTerrainType - The expected {@linkcode TerrainType}, or {@linkcode TerrainType.NONE} if no terrain should be active
* @returns Whether the matcher passed * @returns Whether the matcher passed
*/ */

View File

@ -8,8 +8,8 @@ import { toTitleCase } from "#utils/strings";
import type { MatcherState, SyncExpectationResult } from "@vitest/expect"; import type { MatcherState, SyncExpectationResult } from "@vitest/expect";
/** /**
* Matcher that checks if the {@linkcode WeatherType} is as expected * Matcher that checks if the current {@linkcode WeatherType} is as expected.
* @param received - The object to check. Expects an instance of {@linkcode GameManager}. * @param received - The object to check. Should be the current {@linkcode GameManager}
* @param expectedWeatherType - The expected {@linkcode WeatherType} * @param expectedWeatherType - The expected {@linkcode WeatherType}
* @returns Whether the matcher passed * @returns Whether the matcher passed
*/ */