mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-09-23 06:53:27 +02:00
Merge branch 'beta' into todo-test-enable
This commit is contained in:
commit
102de41155
@ -48,7 +48,7 @@
|
||||
"lefthook": "^1.12.2",
|
||||
"msw": "^2.10.4",
|
||||
"phaser3spectorjs": "^0.0.8",
|
||||
"typedoc": "0.28.7",
|
||||
"typedoc": "^0.28.13",
|
||||
"typedoc-github-theme": "^0.3.1",
|
||||
"typedoc-plugin-coverage": "^4.0.1",
|
||||
"typedoc-plugin-mdn-links": "^5.0.9",
|
||||
|
@ -88,17 +88,17 @@ importers:
|
||||
specifier: ^0.0.8
|
||||
version: 0.0.8
|
||||
typedoc:
|
||||
specifier: 0.28.7
|
||||
version: 0.28.7(typescript@5.9.2)
|
||||
specifier: ^0.28.13
|
||||
version: 0.28.13(typescript@5.9.2)
|
||||
typedoc-github-theme:
|
||||
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:
|
||||
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:
|
||||
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:
|
||||
specifier: ^5.9.2
|
||||
version: 5.9.2
|
||||
@ -717,17 +717,17 @@ packages:
|
||||
cpu: [x64]
|
||||
os: [win32]
|
||||
|
||||
'@shikijs/engine-oniguruma@3.12.2':
|
||||
resolution: {integrity: sha512-hozwnFHsLvujK4/CPVHNo3Bcg2EsnG8krI/ZQ2FlBlCRpPZW4XAEQmEwqegJsypsTAN9ehu2tEYe30lYKSZW/w==}
|
||||
'@shikijs/engine-oniguruma@3.13.0':
|
||||
resolution: {integrity: sha512-O42rBGr4UDSlhT2ZFMxqM7QzIU+IcpoTMzb3W7AlziI1ZF7R8eS2M0yt5Ry35nnnTX/LTLXFPUjRFCIW+Operg==}
|
||||
|
||||
'@shikijs/langs@3.12.2':
|
||||
resolution: {integrity: sha512-bVx5PfuZHDSHoBal+KzJZGheFuyH4qwwcwG/n+MsWno5cTlKmaNtTsGzJpHYQ8YPbB5BdEdKU1rga5/6JGY8ww==}
|
||||
'@shikijs/langs@3.13.0':
|
||||
resolution: {integrity: sha512-672c3WAETDYHwrRP0yLy3W1QYB89Hbpj+pO4KhxK6FzIrDI2FoEXNiNCut6BQmEApYLfuYfpgOZaqbY+E9b8wQ==}
|
||||
|
||||
'@shikijs/themes@3.12.2':
|
||||
resolution: {integrity: sha512-fTR3QAgnwYpfGczpIbzPjlRnxyONJOerguQv1iwpyQZ9QXX4qy/XFQqXlf17XTsorxnHoJGbH/LXBvwtqDsF5A==}
|
||||
'@shikijs/themes@3.13.0':
|
||||
resolution: {integrity: sha512-Vxw1Nm1/Od8jyA7QuAenaV78BG2nSr3/gCGdBkLpfLscddCkzkL36Q5b67SrLLfvAJTOUzW39x4FHVCFriPVgg==}
|
||||
|
||||
'@shikijs/types@3.12.2':
|
||||
resolution: {integrity: sha512-K5UIBzxCyv0YoxN3LMrKB9zuhp1bV+LgewxuVwHdl4Gz5oePoUFrr9EfgJlGlDeXCU1b/yhdnXeuRvAnz8HN8Q==}
|
||||
'@shikijs/types@3.13.0':
|
||||
resolution: {integrity: sha512-oM9P+NCFri/mmQ8LoFGVfVyemm5Hi27330zuOBp0annwJdKH1kOLndw3zCtAVDehPLg9fKqoEx3Ht/wNZxolfw==}
|
||||
|
||||
'@shikijs/vscode-textmate@10.0.2':
|
||||
resolution: {integrity: sha512-83yeghZ2xxin3Nj8z1NMd/NCuca+gsYXswywDy5bHvwlWL8tpTQmzGeUuHd9FC3E/SBEMvzJRwWEOz5gGes9Qg==}
|
||||
@ -1828,12 +1828,12 @@ packages:
|
||||
peerDependencies:
|
||||
typedoc: 0.27.x || 0.28.x
|
||||
|
||||
typedoc@0.28.7:
|
||||
resolution: {integrity: sha512-lpz0Oxl6aidFkmS90VQDQjk/Qf2iw0IUvFqirdONBdj7jPSN9mGXhy66BcGNDxx5ZMyKKiBVAREvPEzT6Uxipw==}
|
||||
typedoc@0.28.13:
|
||||
resolution: {integrity: sha512-dNWY8msnYB2a+7Audha+aTF1Pu3euiE7ySp53w8kEsXoYw7dMouV5A1UsTUY345aB152RHnmRMDiovuBi7BD+w==}
|
||||
engines: {node: '>= 18', pnpm: '>= 10'}
|
||||
hasBin: true
|
||||
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:
|
||||
resolution: {integrity: sha512-CWBzXQrc/qOkhidw1OzBTQuYRbfyxDXJMVJ1XNwUHGROVmuaeiEm3OslpZ1RV96d7SKKjZKrSJu3+t/xlw3R9A==}
|
||||
@ -2312,10 +2312,10 @@ snapshots:
|
||||
|
||||
'@gerrit0/mini-shiki@3.12.2':
|
||||
dependencies:
|
||||
'@shikijs/engine-oniguruma': 3.12.2
|
||||
'@shikijs/langs': 3.12.2
|
||||
'@shikijs/themes': 3.12.2
|
||||
'@shikijs/types': 3.12.2
|
||||
'@shikijs/engine-oniguruma': 3.13.0
|
||||
'@shikijs/langs': 3.13.0
|
||||
'@shikijs/themes': 3.13.0
|
||||
'@shikijs/types': 3.13.0
|
||||
'@shikijs/vscode-textmate': 10.0.2
|
||||
|
||||
'@inquirer/checkbox@4.2.0(@types/node@22.16.5)':
|
||||
@ -2547,20 +2547,20 @@ snapshots:
|
||||
'@rollup/rollup-win32-x64-msvc@4.50.1':
|
||||
optional: true
|
||||
|
||||
'@shikijs/engine-oniguruma@3.12.2':
|
||||
'@shikijs/engine-oniguruma@3.13.0':
|
||||
dependencies:
|
||||
'@shikijs/types': 3.12.2
|
||||
'@shikijs/types': 3.13.0
|
||||
'@shikijs/vscode-textmate': 10.0.2
|
||||
|
||||
'@shikijs/langs@3.12.2':
|
||||
'@shikijs/langs@3.13.0':
|
||||
dependencies:
|
||||
'@shikijs/types': 3.12.2
|
||||
'@shikijs/types': 3.13.0
|
||||
|
||||
'@shikijs/themes@3.12.2':
|
||||
'@shikijs/themes@3.13.0':
|
||||
dependencies:
|
||||
'@shikijs/types': 3.12.2
|
||||
'@shikijs/types': 3.13.0
|
||||
|
||||
'@shikijs/types@3.12.2':
|
||||
'@shikijs/types@3.13.0':
|
||||
dependencies:
|
||||
'@shikijs/vscode-textmate': 10.0.2
|
||||
'@types/hast': 3.0.4
|
||||
@ -3682,19 +3682,19 @@ snapshots:
|
||||
|
||||
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:
|
||||
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:
|
||||
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:
|
||||
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:
|
||||
'@gerrit0/mini-shiki': 3.12.2
|
||||
lunr: 2.3.9
|
||||
|
@ -89,7 +89,8 @@ export type AbilityBattlerTagType =
|
||||
| BattlerTagType.QUARK_DRIVE
|
||||
| BattlerTagType.UNBURDEN
|
||||
| BattlerTagType.SLOW_START
|
||||
| BattlerTagType.TRUANT;
|
||||
| BattlerTagType.TRUANT
|
||||
| BattlerTagType.SUPREME_OVERLORD;
|
||||
|
||||
/** Subset of {@linkcode BattlerTagType}s that provide type boosts */
|
||||
export type TypeBoostTagType = BattlerTagType.FIRE_BOOST | BattlerTagType.CHARGED;
|
||||
|
44
src/@types/damage-params.ts
Normal file
44
src/@types/damage-params.ts
Normal 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">;
|
@ -6961,7 +6961,7 @@ export function initAbilities() {
|
||||
.attr(TypeImmunityStatStageChangeAbAttr, PokemonType.ELECTRIC, Stat.SPD, 1)
|
||||
.ignorable(),
|
||||
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),
|
||||
new Ability(AbilityId.STEADFAST, 4)
|
||||
.attr(FlinchStatStageChangeAbAttr, [ Stat.SPD ], 1),
|
||||
@ -7751,8 +7751,8 @@ export function initAbilities() {
|
||||
new Ability(AbilityId.SHARPNESS, 9)
|
||||
.attr(MovePowerBoostAbAttr, (_user, _target, move) => move.hasFlag(MoveFlags.SLICING_MOVE), 1.5),
|
||||
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))
|
||||
.partial(), // Should only boost once, on summon
|
||||
.conditionalAttr((p) => (p.isPlayer() ? globalScene.arena.playerFaints : globalScene.currentBattle.enemyFaints) > 0, PostSummonAddBattlerTagAbAttr, BattlerTagType.SUPREME_OVERLORD, 0, true)
|
||||
.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)
|
||||
.attr(PostSummonCopyAllyStatsAbAttr),
|
||||
new Ability(AbilityId.TOXIC_DEBRIS, 9)
|
||||
|
@ -56,6 +56,7 @@ import { allMoves } from "#data/data-lists";
|
||||
import { AbilityId } from "#enums/ability-id";
|
||||
import { ArenaTagSide } from "#enums/arena-tag-side";
|
||||
import { ArenaTagType } from "#enums/arena-tag-type";
|
||||
import type { BattlerIndex } from "#enums/battler-index";
|
||||
import { BattlerTagType } from "#enums/battler-tag-type";
|
||||
import { HitResult } from "#enums/hit-result";
|
||||
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
|
||||
export function getArenaTag(
|
||||
tagType: ArenaTagType,
|
||||
@ -1660,6 +1800,8 @@ export function getArenaTag(
|
||||
return new FairyLockTag(turnCount, sourceId);
|
||||
case ArenaTagType.NEUTRALIZING_GAS:
|
||||
return new SuppressAbilitiesTag(sourceId);
|
||||
case ArenaTagType.PENDING_HEAL:
|
||||
return new PendingHealTag();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
@ -1708,5 +1850,6 @@ export type ArenaTagTypeMap = {
|
||||
[ArenaTagType.GRASS_WATER_PLEDGE]: GrassWaterPledgeTag;
|
||||
[ArenaTagType.FAIRY_LOCK]: FairyLockTag;
|
||||
[ArenaTagType.NEUTRALIZING_GAS]: SuppressAbilitiesTag;
|
||||
[ArenaTagType.PENDING_HEAL]: PendingHealTag;
|
||||
[ArenaTagType.NONE]: NoneTag;
|
||||
};
|
||||
|
@ -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.
|
||||
* @param sourceId - The ID of the pokemon adding the tag
|
||||
@ -3874,6 +3909,8 @@ export function getBattlerTag(
|
||||
return new PsychoShiftTag();
|
||||
case BattlerTagType.MAGIC_COAT:
|
||||
return new MagicCoatTag();
|
||||
case BattlerTagType.SUPREME_OVERLORD:
|
||||
return new SupremeOverlordTag();
|
||||
}
|
||||
}
|
||||
|
||||
@ -4008,4 +4045,5 @@ export type BattlerTagTypeMap = {
|
||||
[BattlerTagType.GRUDGE]: GrudgeTag;
|
||||
[BattlerTagType.PSYCHO_SHIFT]: PsychoShiftTag;
|
||||
[BattlerTagType.MAGIC_COAT]: MagicCoatTag;
|
||||
[BattlerTagType.SUPREME_OVERLORD]: SupremeOverlordTag;
|
||||
};
|
||||
|
@ -6,7 +6,7 @@ import { loggedInUser } from "#app/account";
|
||||
import type { GameMode } from "#app/game-mode";
|
||||
import { globalScene } from "#app/global-scene";
|
||||
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 { MoveChargeAnim } from "#data/battle-anims";
|
||||
import {
|
||||
@ -19,6 +19,7 @@ import {
|
||||
ShellTrapTag,
|
||||
StockpilingTag,
|
||||
SubstituteTag,
|
||||
SupremeOverlordTag,
|
||||
TrappedTag,
|
||||
TypeBoostTag,
|
||||
} from "#data/battler-tags";
|
||||
@ -869,6 +870,8 @@ export abstract class Move implements Localizable {
|
||||
power.value *= 1.5;
|
||||
}
|
||||
|
||||
power.value *= (source.getTag(BattlerTagType.SUPREME_OVERLORD) as SupremeOverlordTag | undefined)?.getBoost() ?? 1;
|
||||
|
||||
return power.value;
|
||||
}
|
||||
|
||||
@ -2137,24 +2140,15 @@ export class SacrificialFullRestoreAttr extends SacrificialAttr {
|
||||
return false;
|
||||
}
|
||||
|
||||
// We don't know which party member will be chosen, so pick the highest max HP in the party
|
||||
const party = user.isPlayer() ? globalScene.getPlayerParty() : globalScene.getEnemyParty();
|
||||
const maxPartyMemberHp = party.map(p => p.getMaxHp()).reduce((maxHp: number, hp: number) => Math.max(hp, maxHp), 0);
|
||||
|
||||
const pm = globalScene.phaseManager;
|
||||
|
||||
pm.pushPhase(
|
||||
pm.create("PokemonHealPhase",
|
||||
user.getBattlerIndex(),
|
||||
maxPartyMemberHp,
|
||||
i18next.t(this.moveMessage, { pokemonName: getPokemonNameWithAffix(user) }),
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
this.restorePP),
|
||||
true);
|
||||
// Add a tag to the field if it doesn't already exist, then queue a delayed healing effect in the user's current slot.
|
||||
globalScene.arena.addTag(ArenaTagType.PENDING_HEAL, 0, move.id, user.id); // Arguments after first go completely unused
|
||||
const tag = globalScene.arena.getTag(ArenaTagType.PENDING_HEAL) as PendingHealTag;
|
||||
tag.queueHeal(user.getBattlerIndex(), {
|
||||
sourceId: user.id,
|
||||
moveId: move.id,
|
||||
restorePP: this.restorePP,
|
||||
healMessage: i18next.t(this.moveMessage, { pokemonName: getPokemonNameWithAffix(user) }),
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -34,4 +34,5 @@ export enum ArenaTagType {
|
||||
GRASS_WATER_PLEDGE = "GRASS_WATER_PLEDGE",
|
||||
FAIRY_LOCK = "FAIRY_LOCK",
|
||||
NEUTRALIZING_GAS = "NEUTRALIZING_GAS",
|
||||
PENDING_HEAL = "PENDING_HEAL",
|
||||
}
|
||||
|
@ -94,4 +94,5 @@ export enum BattlerTagType {
|
||||
ENDURE_TOKEN = "ENDURE_TOKEN",
|
||||
POWDER = "POWDER",
|
||||
MAGIC_COAT = "MAGIC_COAT",
|
||||
SUPREME_OVERLORD = "SUPREME_OVERLORD",
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -235,7 +235,6 @@ export class PhaseManager {
|
||||
|
||||
/** overrides default of inserting phases to end of phaseQueuePrepend array. Useful for inserting Phases "out of order" */
|
||||
private phaseQueuePrependSpliceIndex = -1;
|
||||
private nextCommandPhaseQueue: Phase[] = [];
|
||||
|
||||
/** Storage for {@linkcode PhasePriorityQueue}s which hold phases whose order dynamically changes */
|
||||
private dynamicPhaseQueues: PhasePriorityQueue[];
|
||||
@ -293,13 +292,12 @@ export class PhaseManager {
|
||||
/**
|
||||
* Adds a phase to nextCommandPhaseQueue, as long as boolean passed in is false
|
||||
* @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) {
|
||||
this.pushDynamicPhase(phase);
|
||||
} 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
|
||||
*/
|
||||
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);
|
||||
}
|
||||
this.dynamicPhaseQueues.forEach(queue => queue.clear());
|
||||
@ -627,10 +625,6 @@ export class PhaseManager {
|
||||
* Moves everything from nextCommandPhaseQueue to phaseQueue (keeping order)
|
||||
*/
|
||||
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());
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,8 @@ export class PokemonHealPhase extends CommonAnimPhase {
|
||||
}
|
||||
|
||||
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;
|
||||
let lastStatusEffect = StatusEffect.NONE;
|
||||
|
||||
|
@ -2,6 +2,7 @@ import { applyAbAttrs } from "#abilities/apply-ab-attrs";
|
||||
import { globalScene } from "#app/global-scene";
|
||||
import { EntryHazardTag } from "#data/arena-tag";
|
||||
import { MysteryEncounterPostSummonTag } from "#data/battler-tags";
|
||||
import { ArenaTagType } from "#enums/arena-tag-type";
|
||||
import { BattlerTagType } from "#enums/battler-tag-type";
|
||||
import { StatusEffect } from "#enums/status-effect";
|
||||
import { PokemonPhase } from "#phases/pokemon-phase";
|
||||
@ -16,6 +17,9 @@ export class PostSummonPhase extends PokemonPhase {
|
||||
if (pokemon.status?.effect === StatusEffect.TOXIC) {
|
||||
pokemon.status.toxicTurnCount = 0;
|
||||
}
|
||||
|
||||
globalScene.arena.applyTags(ArenaTagType.PENDING_HEAL, false, pokemon);
|
||||
|
||||
globalScene.arena.applyTags(EntryHazardTag, false, pokemon);
|
||||
|
||||
// If this is mystery encounter and has post summon phase tag, apply post summon effects
|
||||
|
@ -285,6 +285,12 @@ export class ArenaFlyout extends Phaser.GameObjects.Container {
|
||||
switch (arenaEffectChangedEvent.constructor) {
|
||||
case 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;
|
||||
let arenaEffectType: ArenaEffectType;
|
||||
|
||||
|
381
test/@types/vitest.d.ts
vendored
381
test/@types/vitest.d.ts
vendored
@ -1,7 +1,7 @@
|
||||
import "vitest";
|
||||
|
||||
import type { Phase } from "#app/phase";
|
||||
import type Overrides from "#app/overrides";
|
||||
import type { Phase } from "#app/phase";
|
||||
import type { ArenaTag } from "#data/arena-tag";
|
||||
import type { TerrainType } from "#data/terrain";
|
||||
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 { MoveId } from "#enums/move-id";
|
||||
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 { BattleStat, EffectiveStat } from "#enums/stat";
|
||||
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 { toHaveBattlerTagOptions } from "#test/test-utils/matchers/to-have-battler-tag";
|
||||
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 { expectedStatusType } from "#test/test-utils/matchers/to-have-status-effect";
|
||||
@ -23,175 +27,212 @@ import type { TurnMove } from "#types/turn-move";
|
||||
import type { AtLeastOne } from "#types/type-helpers";
|
||||
import type { toDmgValue } from "#utils/common";
|
||||
import type { expect } from "vitest";
|
||||
import type { toHaveBattlerTagOptions } from "#test/test-utils/matchers/to-have-battler-tag";
|
||||
|
||||
// #region Boilerplate/Helpers
|
||||
declare module "vitest" {
|
||||
interface Assertion<T> {
|
||||
// #region Generic Matchers
|
||||
|
||||
/**
|
||||
* Check whether an array contains EXACTLY the given items (in any order).
|
||||
*
|
||||
* Different from {@linkcode expect.arrayContaining} as the latter only checks for subset equality
|
||||
* (as opposed to full equality).
|
||||
*
|
||||
* @param expected - The expected contents of the array, in any order
|
||||
* @see {@linkcode expect.arrayContaining}
|
||||
*/
|
||||
toEqualArrayUnsorted(expected: T[]): void;
|
||||
|
||||
// #endregion Generic Matchers
|
||||
|
||||
// #region GameManager Matchers
|
||||
|
||||
/**
|
||||
* Check if the {@linkcode GameManager} has shown the given message at least once in the current battle.
|
||||
* @param expectedMessage - The expected message
|
||||
*/
|
||||
toHaveShownMessage(expectedMessage: string): void;
|
||||
/**
|
||||
* @param expectedPhase - The expected {@linkcode PhaseString}
|
||||
*/
|
||||
toBeAtPhase(expectedPhase: PhaseString): void;
|
||||
// #endregion GameManager Matchers
|
||||
|
||||
// #region Arena Matchers
|
||||
|
||||
/**
|
||||
* Check whether the current {@linkcode WeatherType} is as expected.
|
||||
* @param expectedWeatherType - The expected {@linkcode WeatherType}
|
||||
*/
|
||||
toHaveWeather(expectedWeatherType: WeatherType): void;
|
||||
|
||||
/**
|
||||
* Check whether the current {@linkcode TerrainType} is as expected.
|
||||
* @param expectedTerrainType - The expected {@linkcode TerrainType}
|
||||
*/
|
||||
toHaveTerrain(expectedTerrainType: TerrainType): void;
|
||||
|
||||
/**
|
||||
* Check whether the current {@linkcode Arena} contains the given {@linkcode ArenaTag}.
|
||||
* @param expectedTag - A partially-filled {@linkcode ArenaTag} containing the desired properties
|
||||
*/
|
||||
toHaveArenaTag<A extends ArenaTagType>(expectedTag: toHaveArenaTagOptions<A>): void;
|
||||
/**
|
||||
* Check whether the current {@linkcode Arena} contains the given {@linkcode ArenaTag}.
|
||||
* @param expectedType - The {@linkcode ArenaTagType} of the desired tag
|
||||
* @param side - The {@linkcode ArenaTagSide | side(s) of the field} the tag should affect; default {@linkcode ArenaTagSide.BOTH}
|
||||
*/
|
||||
toHaveArenaTag(expectedType: ArenaTagType, side?: ArenaTagSide): void;
|
||||
|
||||
/**
|
||||
* Check whether the current {@linkcode Arena} contains the given {@linkcode PositionalTag}.
|
||||
* @param expectedTag - A partially-filled `PositionalTag` containing the desired properties
|
||||
*/
|
||||
toHavePositionalTag<P extends PositionalTagType>(expectedTag: toHavePositionalTagOptions<P>): void;
|
||||
/**
|
||||
* Check whether the current {@linkcode Arena} contains the given number of {@linkcode PositionalTag}s.
|
||||
* @param expectedType - The {@linkcode PositionalTagType} of the desired tag
|
||||
* @param count - The number of instances of {@linkcode expectedType} that should be active;
|
||||
* defaults to `1` and must be within the range `[0, 4]`
|
||||
*/
|
||||
toHavePositionalTag(expectedType: PositionalTagType, count?: number): void;
|
||||
|
||||
// #endregion Arena Matchers
|
||||
|
||||
// #region Pokemon Matchers
|
||||
|
||||
/**
|
||||
* 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 options - The {@linkcode toHaveTypesOptions | options} passed to the matcher
|
||||
*/
|
||||
toHaveTypes(expectedTypes: PokemonType[], options?: toHaveTypesOptions): void;
|
||||
|
||||
/**
|
||||
* Check whether a {@linkcode Pokemon} has used a move matching the given criteria.
|
||||
* @param expectedMove - The {@linkcode MoveId} the Pokemon is expected to have used,
|
||||
* or a partially filled {@linkcode TurnMove} containing the desired properties to check
|
||||
* @param index - The index of the move history entry to check, in order from most recent to least recent; default `0`
|
||||
* @see {@linkcode Pokemon.getLastXMoves}
|
||||
*/
|
||||
toHaveUsedMove(expectedMove: MoveId | AtLeastOne<TurnMove>, index?: number): void;
|
||||
|
||||
/**
|
||||
* Check whether a {@linkcode Pokemon}'s effective stat is as expected
|
||||
* (checked after all stat value modifications).
|
||||
* @param stat - The {@linkcode EffectiveStat} to check
|
||||
* @param expectedValue - The expected value of {@linkcode stat}
|
||||
* @param options - The {@linkcode toHaveEffectiveStatOptions | options} passed to the matcher
|
||||
* @remarks
|
||||
* If you want to check the stat **before** modifiers are applied, use {@linkcode Pokemon.getStat} instead.
|
||||
*/
|
||||
toHaveEffectiveStat(stat: EffectiveStat, expectedValue: number, options?: toHaveEffectiveStatOptions): void;
|
||||
|
||||
/**
|
||||
* Check whether a {@linkcode Pokemon} has a specific {@linkcode StatusEffect | non-volatile status effect}.
|
||||
* @param expectedStatusEffect - The {@linkcode StatusEffect} the Pokemon is expected to have,
|
||||
* or a partially filled {@linkcode Status} containing the desired properties
|
||||
*/
|
||||
toHaveStatusEffect(expectedStatusEffect: expectedStatusType): void;
|
||||
|
||||
/**
|
||||
* Check whether a {@linkcode Pokemon} has a specific {@linkcode Stat} stage.
|
||||
* @param stat - The {@linkcode BattleStat} to check
|
||||
* @param expectedStage - The expected stat stage value of {@linkcode stat}
|
||||
*/
|
||||
toHaveStatStage(stat: BattleStat, expectedStage: number): void;
|
||||
|
||||
/**
|
||||
* Check whether a {@linkcode Pokemon} has the given {@linkcode BattlerTag}.
|
||||
* @param expectedTag - A partially-filled {@linkcode BattlerTag} containing the desired properties
|
||||
*/
|
||||
toHaveBattlerTag<B extends BattlerTagType>(expectedTag: toHaveBattlerTagOptions<B>): void;
|
||||
/**
|
||||
* Check whether a {@linkcode Pokemon} has the given {@linkcode BattlerTag}.
|
||||
* @param expectedType - The expected {@linkcode BattlerTagType}
|
||||
*/
|
||||
toHaveBattlerTag(expectedType: BattlerTagType): void;
|
||||
|
||||
/**
|
||||
* Check whether a {@linkcode Pokemon} has applied a specific {@linkcode AbilityId}.
|
||||
* @param expectedAbilityId - The `AbilityId` to check for
|
||||
*/
|
||||
toHaveAbilityApplied(expectedAbilityId: AbilityId): void;
|
||||
|
||||
/**
|
||||
* Check whether a {@linkcode Pokemon} has a specific amount of {@linkcode Stat.HP | HP}.
|
||||
* @param expectedHp - The expected amount of {@linkcode Stat.HP | HP} to have
|
||||
*/
|
||||
toHaveHp(expectedHp: number): void;
|
||||
|
||||
/**
|
||||
* Check whether a {@linkcode Pokemon} has taken a specific amount of damage.
|
||||
* @param expectedDamageTaken - The expected amount of damage taken
|
||||
* @param roundDown - Whether to round down `expectedDamageTaken` with {@linkcode toDmgValue}; default `true`
|
||||
*/
|
||||
toHaveTakenDamage(expectedDamageTaken: number, roundDown?: boolean): void;
|
||||
|
||||
/**
|
||||
* Check whether a {@linkcode Pokemon} is currently fainted (as determined by {@linkcode Pokemon.isFainted}).
|
||||
* @remarks
|
||||
* When checking whether an enemy wild Pokemon is fainted, one must store a reference to it in a variable _before_ the fainting effect occurs.
|
||||
* Otherwise, the Pokemon will be removed from the field and garbage collected.
|
||||
*/
|
||||
toHaveFainted(): void;
|
||||
|
||||
/**
|
||||
* Check whether a {@linkcode Pokemon} is at full HP.
|
||||
*/
|
||||
toHaveFullHp(): void;
|
||||
/**
|
||||
* 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 ppUsed - The numerical amount of PP that should have been consumed,
|
||||
* or `all` to indicate the move should be _out_ of PP
|
||||
* @remarks
|
||||
* If the Pokemon's moveset has been set via {@linkcode Overrides.MOVESET_OVERRIDE}/{@linkcode Overrides.ENEMY_MOVESET_OVERRIDE}
|
||||
* or does not contain exactly one copy of `moveId`, this will fail the test.
|
||||
*/
|
||||
toHaveUsedPP(moveId: MoveId, ppUsed: number | "all"): void;
|
||||
|
||||
// #endregion Pokemon Matchers
|
||||
}
|
||||
interface Assertion<T>
|
||||
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).
|
||||
*
|
||||
* Different from {@linkcode expect.arrayContaining} as the latter only checks for subset equality
|
||||
* (as opposed to full equality).
|
||||
*
|
||||
* @param expected - The expected contents of the array, in any order
|
||||
* @see {@linkcode expect.arrayContaining}
|
||||
*/
|
||||
toEqualUnsorted: T extends (infer U)[] ? (expected: U[]) => void : never;
|
||||
|
||||
/**
|
||||
* Check whether a {@linkcode Map} contains the given key, disregarding its value.
|
||||
* @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;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
} // #endregion GameManager Matchers
|
||||
|
||||
// #region Arena Matchers
|
||||
interface ArenaMatchers {
|
||||
/**
|
||||
* Check whether the current {@linkcode WeatherType} is as expected.
|
||||
* @param expectedWeatherType - The expected `WeatherType`
|
||||
*/
|
||||
toHaveWeather(expectedWeatherType: WeatherType): void;
|
||||
|
||||
/**
|
||||
* Check whether the current {@linkcode TerrainType} is as expected.
|
||||
* @param expectedTerrainType - The expected `TerrainType`
|
||||
*/
|
||||
toHaveTerrain(expectedTerrainType: TerrainType): void;
|
||||
|
||||
/**
|
||||
* Check whether the current {@linkcode Arena} contains the given {@linkcode ArenaTag}.
|
||||
* @param expectedTag - A partially-filled `ArenaTag` containing the desired properties
|
||||
*/
|
||||
toHaveArenaTag<A extends ArenaTagType>(expectedTag: toHaveArenaTagOptions<A>): void;
|
||||
/**
|
||||
* Check whether the current {@linkcode Arena} contains the given {@linkcode ArenaTag}.
|
||||
* @param expectedType - The {@linkcode ArenaTagType} of the desired tag
|
||||
* @param side - The {@linkcode ArenaTagSide | side(s) of the field} the tag should affect; default {@linkcode ArenaTagSide.BOTH}
|
||||
*/
|
||||
toHaveArenaTag(expectedType: ArenaTagType, side?: ArenaTagSide): void;
|
||||
|
||||
/**
|
||||
* Check whether the current {@linkcode Arena} contains the given {@linkcode PositionalTag}.
|
||||
* @param expectedTag - A partially-filled `PositionalTag` containing the desired properties
|
||||
*/
|
||||
toHavePositionalTag<P extends PositionalTagType>(expectedTag: toHavePositionalTagOptions<P>): void;
|
||||
/**
|
||||
* Check whether the current {@linkcode Arena} contains the given number of {@linkcode PositionalTag}s.
|
||||
* @param expectedType - The {@linkcode PositionalTagType} of the desired tag
|
||||
* @param count - The number of instances of `expectedType` that should be active;
|
||||
* defaults to `1` and must be within the range `[0, 4]`
|
||||
*/
|
||||
toHavePositionalTag(expectedType: PositionalTagType, count?: number): void;
|
||||
}
|
||||
|
||||
// #endregion Arena Matchers
|
||||
|
||||
// #region Pokemon Matchers
|
||||
interface PokemonMatchers {
|
||||
/**
|
||||
* 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 options - The {@linkcode toHaveTypesOptions | options} passed to the matcher
|
||||
*/
|
||||
toHaveTypes(expectedTypes: PokemonType[], options?: toHaveTypesOptions): void;
|
||||
|
||||
/**
|
||||
* Check whether a {@linkcode Pokemon} has used a move matching the given criteria.
|
||||
* @param expectedMove - The {@linkcode MoveId} the Pokemon is expected to have used,
|
||||
* or a partially filled {@linkcode TurnMove} containing the desired properties to check
|
||||
* @param index - The index of the move history entry to check, in order from most recent to least recent; default `0`
|
||||
* @see {@linkcode Pokemon.getLastXMoves}
|
||||
*/
|
||||
toHaveUsedMove(expectedMove: MoveId | AtLeastOne<TurnMove>, index?: number): void;
|
||||
|
||||
/**
|
||||
* Check whether a {@linkcode Pokemon}'s effective stat is as expected
|
||||
* (checked after all stat value modifications).
|
||||
* @param stat - The {@linkcode EffectiveStat} to check
|
||||
* @param expectedValue - The expected value of {@linkcode stat}
|
||||
* @param options - The {@linkcode toHaveEffectiveStatOptions | options} passed to the matcher
|
||||
* @remarks
|
||||
* If you want to check the stat **before** modifiers are applied, use {@linkcode Pokemon.getStat} instead.
|
||||
*/
|
||||
toHaveEffectiveStat(stat: EffectiveStat, expectedValue: number, options?: toHaveEffectiveStatOptions): void;
|
||||
|
||||
/**
|
||||
* Check whether a {@linkcode Pokemon} has a specific {@linkcode StatusEffect | non-volatile status effect}.
|
||||
* @param expectedStatusEffect - The {@linkcode StatusEffect} the Pokemon is expected to have,
|
||||
* or a partially filled {@linkcode Status} containing the desired properties
|
||||
*/
|
||||
toHaveStatusEffect(expectedStatusEffect: expectedStatusType): void;
|
||||
|
||||
/**
|
||||
* Check whether a {@linkcode Pokemon} has a specific {@linkcode Stat} stage.
|
||||
* @param stat - The {@linkcode BattleStat} to check
|
||||
* @param expectedStage - The expected stat stage value of {@linkcode stat}
|
||||
*/
|
||||
toHaveStatStage(stat: BattleStat, expectedStage: number): void;
|
||||
|
||||
/**
|
||||
* Check whether a {@linkcode Pokemon} has the given {@linkcode BattlerTag}.
|
||||
* @param expectedTag - A partially-filled {@linkcode BattlerTag} containing the desired properties
|
||||
*/
|
||||
toHaveBattlerTag<B extends BattlerTagType>(expectedTag: toHaveBattlerTagOptions<B>): void;
|
||||
/**
|
||||
* Check whether a {@linkcode Pokemon} has the given {@linkcode BattlerTag}.
|
||||
* @param expectedType - The expected {@linkcode BattlerTagType}
|
||||
*/
|
||||
toHaveBattlerTag(expectedType: BattlerTagType): void;
|
||||
|
||||
/**
|
||||
* Check whether a {@linkcode Pokemon} has applied a specific {@linkcode AbilityId}.
|
||||
* @param expectedAbilityId - The `AbilityId` to check for
|
||||
*/
|
||||
toHaveAbilityApplied(expectedAbilityId: AbilityId): void;
|
||||
|
||||
/**
|
||||
* Check whether a {@linkcode Pokemon} has a specific amount of {@linkcode Stat.HP | HP}.
|
||||
* @param expectedHp - The expected amount of {@linkcode Stat.HP | HP} to have
|
||||
*/
|
||||
toHaveHp(expectedHp: number): void;
|
||||
|
||||
/**
|
||||
* Check whether a {@linkcode Pokemon} has taken a specific amount of damage.
|
||||
* @param expectedDamageTaken - The expected amount of damage taken
|
||||
* @param roundDown - Whether to round down `expectedDamageTaken` with {@linkcode toDmgValue}; default `true`
|
||||
*/
|
||||
toHaveTakenDamage(expectedDamageTaken: number, roundDown?: boolean): void;
|
||||
|
||||
/**
|
||||
* Check whether a {@linkcode Pokemon} is currently fainted (as determined by {@linkcode Pokemon.isFainted}).
|
||||
* @remarks
|
||||
* When checking whether an enemy wild Pokemon is fainted, one must store a reference to it in a variable _before_ the fainting effect occurs.
|
||||
* Otherwise, the Pokemon will be removed from the field and garbage collected.
|
||||
*/
|
||||
toHaveFainted(): void;
|
||||
|
||||
/**
|
||||
* Check whether a {@linkcode Pokemon} is at full HP.
|
||||
*/
|
||||
toHaveFullHp(): void;
|
||||
|
||||
/**
|
||||
* 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 ppUsed - The numerical amount of PP that should have been consumed,
|
||||
* or `all` to indicate the move should be _out_ of PP
|
||||
* @remarks
|
||||
* If the Pokemon's moveset has been set via {@linkcode Overrides.MOVESET_OVERRIDE}/{@linkcode Overrides.ENEMY_MOVESET_OVERRIDE}
|
||||
* or does not contain exactly one copy of `moveId`, this will fail the test.
|
||||
*/
|
||||
toHaveUsedPP(moveId: MoveId, ppUsed: number | "all"): void;
|
||||
}
|
||||
// #endregion Pokemon Matchers
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { allMoves } from "#data/data-lists";
|
||||
import { AbilityId } from "#enums/ability-id";
|
||||
import { BattlerIndex } from "#enums/battler-index";
|
||||
import { BattlerTagType } from "#enums/battler-tag-type";
|
||||
import { MoveId } from "#enums/move-id";
|
||||
import { SpeciesId } from "#enums/species-id";
|
||||
import type { Move } from "#moves/move";
|
||||
@ -166,4 +167,41 @@ describe("Abilities - Supreme Overlord", () => {
|
||||
|
||||
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);
|
||||
});
|
||||
});
|
||||
|
245
test/moves/healing-wish-lunar-dance.test.ts
Normal file
245
test/moves/healing-wish-lunar-dance.test.ts
Normal 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();
|
||||
});
|
||||
});
|
@ -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());
|
||||
});
|
||||
});
|
@ -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 { 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 { toHaveArenaTag } from "#test/test-utils/matchers/to-have-arena-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 { toHaveFullHp } from "#test/test-utils/matchers/to-have-full-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 { toHaveShownMessage } from "#test/test-utils/matchers/to-have-shown-message";
|
||||
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 { expect } from "vitest";
|
||||
|
||||
/*
|
||||
* Setup file for custom matchers.
|
||||
* Make sure to define the call signatures in `#test/@types/vitest.d.ts` too!
|
||||
*/
|
||||
|
||||
expect.extend({
|
||||
toEqualArrayUnsorted,
|
||||
toEqualUnsorted,
|
||||
toHaveKey,
|
||||
toHaveShownMessage,
|
||||
toBeAtPhase,
|
||||
toHaveWeather,
|
||||
|
@ -40,10 +40,7 @@ export class ModifierHelper extends GameManagerHelper {
|
||||
* @returns `this`
|
||||
*/
|
||||
testCheck(modifier: ModifierTypeKeys, expectToBePreset: boolean): this {
|
||||
if (expectToBePreset) {
|
||||
expect(itemPoolChecks.get(modifier)).toBeTruthy();
|
||||
}
|
||||
expect(itemPoolChecks.get(modifier)).toBeFalsy();
|
||||
(expectToBePreset ? expect(itemPoolChecks) : expect(itemPoolChecks).not).toHaveKey(modifier);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -8,11 +8,7 @@ import type { MatcherState, SyncExpectationResult } from "@vitest/expect";
|
||||
* @param expected - The array to check equality with
|
||||
* @returns Whether the matcher passed
|
||||
*/
|
||||
export function toEqualArrayUnsorted(
|
||||
this: MatcherState,
|
||||
received: unknown,
|
||||
expected: unknown[],
|
||||
): SyncExpectationResult {
|
||||
export function toEqualUnsorted(this: MatcherState, received: unknown, expected: unknown[]): SyncExpectationResult {
|
||||
if (!Array.isArray(received)) {
|
||||
return {
|
||||
pass: this.isNot,
|
47
test/test-utils/matchers/to-have-key.ts
Normal file
47
test/test-utils/matchers/to-have-key.ts
Normal 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,
|
||||
};
|
||||
}
|
@ -8,8 +8,8 @@ import { isGameManagerInstance, receivedStr } from "#test/test-utils/test-utils"
|
||||
import type { MatcherState, SyncExpectationResult } from "@vitest/expect";
|
||||
|
||||
/**
|
||||
* Matcher that checks if the {@linkcode TerrainType} is as expected
|
||||
* @param received - The object to check. Should be an instance of {@linkcode GameManager}.
|
||||
* Matcher that checks if the current {@linkcode TerrainType} is as expected.
|
||||
* @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
|
||||
* @returns Whether the matcher passed
|
||||
*/
|
||||
|
@ -8,8 +8,8 @@ import { toTitleCase } from "#utils/strings";
|
||||
import type { MatcherState, SyncExpectationResult } from "@vitest/expect";
|
||||
|
||||
/**
|
||||
* Matcher that checks if the {@linkcode WeatherType} is as expected
|
||||
* @param received - The object to check. Expects an instance of {@linkcode GameManager}.
|
||||
* Matcher that checks if the current {@linkcode WeatherType} is as expected.
|
||||
* @param received - The object to check. Should be the current {@linkcode GameManager}
|
||||
* @param expectedWeatherType - The expected {@linkcode WeatherType}
|
||||
* @returns Whether the matcher passed
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user