Fixed the tests

This commit is contained in:
Bertie690 2025-06-14 12:27:01 -04:00
parent 455f3b6be1
commit a179fdeac6
3 changed files with 32 additions and 18 deletions

View File

@ -8640,8 +8640,7 @@ export function initAbilities() {
.unsuppressable() .unsuppressable()
.bypassFaint(), .bypassFaint(),
new Ability(AbilityId.CORROSION, 7) new Ability(AbilityId.CORROSION, 7)
.attr(IgnoreTypeStatusEffectImmunityAbAttr, [ StatusEffect.POISON, StatusEffect.TOXIC ], [ PokemonType.STEEL, PokemonType.POISON ]) .attr(IgnoreTypeStatusEffectImmunityAbAttr, [ StatusEffect.POISON, StatusEffect.TOXIC ], [ PokemonType.STEEL, PokemonType.POISON ]),
.edgeCase(), // Should poison itself with toxic orb.
new Ability(AbilityId.COMATOSE, 7) new Ability(AbilityId.COMATOSE, 7)
.attr(StatusEffectImmunityAbAttr, ...getNonVolatileStatusEffects()) .attr(StatusEffectImmunityAbAttr, ...getNonVolatileStatusEffects())
.attr(BattlerTagImmunityAbAttr, BattlerTagType.DROWSY) .attr(BattlerTagImmunityAbAttr, BattlerTagType.DROWSY)

View File

@ -1165,8 +1165,9 @@ export abstract class MoveAttr {
} }
/** /**
* @virtual * Return this `MoveAttr`'s associated {@linkcode MoveCondition} or {@linkcode MoveConditionFunc}.
* @returns the {@linkcode MoveCondition} or {@linkcode MoveConditionFunc} for this {@linkcode Move} * The specified condition will be added to all {@linkcode Move}s with this attribute,
* and moves **will fail upon use** if _at least 1_ of their attached conditions returns `false`.
*/ */
getCondition(): MoveCondition | MoveConditionFunc | null { getCondition(): MoveCondition | MoveConditionFunc | null {
return null; return null;
@ -1279,15 +1280,21 @@ export class MoveEffectAttr extends MoveAttr {
} }
/** /**
* Determines whether the {@linkcode Move}'s effects are valid to {@linkcode apply} * Determine whether this {@linkcode MoveAttr}'s effects are able to {@linkcode apply | be applied} to the target.
* @virtual *
* @param user {@linkcode Pokemon} using the move * Will **NOT** cause the move to fail upon returning `false` (unlike {@linkcode getCondition};
* @param target {@linkcode Pokemon} target of the move * merely that the effect for this attribute will be nullified.
* @param move {@linkcode Move} with this attribute * @param user - The {@linkcode Pokemon} using the move
* @param args Set of unique arguments needed by this attribute * @param target - The {@linkcode Pokemon} being targeted by the move, or {@linkcode user} if the move is
* @returns true if basic application of the ability attribute should be possible * {@linkcode selfTarget | self-targeting}
* @param move - The {@linkcode Move} being used
* @param _args - Set of unique arguments needed by this attribute
* @returns `true` if basic application of this `MoveAttr`s effects should be possible
*/ */
canApply(user: Pokemon, target: Pokemon, move: Move, args?: any[]) { // TODO: Decouple this check from the `apply` step
// TODO: Make non-damaging moves fail by default if none of their attributes can apply
canApply(user: Pokemon, target: Pokemon, move: Move, _args?: any[]) {
// TODO: These checks seem redundant
return !! (this.selfTarget ? user.hp && !user.getTag(BattlerTagType.FRENZY) : target.hp) return !! (this.selfTarget ? user.hp && !user.getTag(BattlerTagType.FRENZY) : target.hp)
&& (this.selfTarget || !target.getTag(BattlerTagType.PROTECTED) || && (this.selfTarget || !target.getTag(BattlerTagType.PROTECTED) ||
move.doesFlagEffectApply({ flag: MoveFlags.IGNORE_PROTECT, user, target })); move.doesFlagEffectApply({ flag: MoveFlags.IGNORE_PROTECT, user, target }));
@ -1941,8 +1948,13 @@ export class HealAttr extends MoveEffectAttr {
return Math.round(score / (1 - this.healRatio / 2)); return Math.round(score / (1 - this.healRatio / 2));
} }
// TODO: Remove once `canApply` is made to make status moves fail if no attributes apply
override getCondition(): MoveConditionFunc {
return (user, target, move) => this.canApply(user, target, move, [])
}
override canApply(user: Pokemon, target: Pokemon, _move: Move, _args?: any[]): boolean { override canApply(user: Pokemon, target: Pokemon, _move: Move, _args?: any[]): boolean {
return !(this.selfTarget ? user : target).isFullHp(); return super.canApply(user, target, _move, _args) && !(this.selfTarget ? user : target).isFullHp();
} }
override getFailedText(user: Pokemon, target: Pokemon, _move: Move): string | undefined { override getFailedText(user: Pokemon, target: Pokemon, _move: Move): string | undefined {
@ -1975,14 +1987,17 @@ export class RestAttr extends HealAttr {
return wasSet && super.apply(user, target, move, args); return wasSet && super.apply(user, target, move, args);
} }
override addHealPhase(user: Pokemon, healRatio: number): void { override addHealPhase(user: Pokemon): void {
globalScene.phaseManager.unshiftNew("PokemonHealPhase", user.getBattlerIndex(), healRatio, null) globalScene.phaseManager.unshiftNew("PokemonHealPhase", user.getBattlerIndex(), user.getMaxHp(), null)
} }
override canApply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { override canApply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
// Intentionally suppress messages here as we display generic fail msg // Intentionally suppress messages here as we display generic fail msg
// TODO: This might have order-of-operation jank // TODO: This might have order-of-operation jank
return super.canApply(user, target, move, args) && user.canSetStatus(StatusEffect.SLEEP, true, true, user) return (
super.canApply(user, target, move, args)
&& user.canSetStatus(StatusEffect.SLEEP, true, true, user)
);
} }
} }

View File

@ -45,7 +45,7 @@ describe("Move - Rest", () => {
game.move.use(MoveId.REST); game.move.use(MoveId.REST);
await game.toEndOfTurn(); await game.toEndOfTurn();
expect(snorlax.isFullHp()).toBe(true); expect(snorlax.hp).toBe(snorlax.getMaxHp());
expect(snorlax.status?.effect).toBe(StatusEffect.SLEEP); expect(snorlax.status?.effect).toBe(StatusEffect.SLEEP);
}); });