Fixed a few more bugs and such

This commit is contained in:
Bertie690 2025-08-08 17:46:02 -04:00
parent e61a0d4326
commit 68a9d785aa
4 changed files with 25 additions and 12 deletions

View File

@ -2040,7 +2040,7 @@ export class VariableHealAttr extends HealAttr {
selfTarget = true,
failOnFullHp = true,
) {
super(1, showAnim, selfTarget, selfTarget);
super(1, showAnim, selfTarget, failOnFullHp);
this.healFunc = healFunc;
}
@ -8091,16 +8091,16 @@ const shoreUpHealRatioFunc = (): number => {
}
const swallowHealFunc = (user: Pokemon): number => {
const tag = user.getTag(StockpilingTag);
const tag = user.getTag(BattlerTagType.STOCKPILING);
if (!tag || tag.stockpiledCount <= 0) {
return 0;
}
switch (tag.stockpiledCount) {
case 1:
return 0.25
return 0.25;
case 2:
return 0.5
return 0.5;
case 3:
default: // in case we ever get more stacks
return 1;
@ -9307,7 +9307,7 @@ export function initMoves() {
.condition(hasStockpileStacksCondition)
.attr(RemoveBattlerTagAttr, [ BattlerTagType.STOCKPILING ], true),
new SelfStatusMove(MoveId.SWALLOW, PokemonType.NORMAL, -1, 10, -1, 0, 3)
.attr(VariableHealAttr, swallowHealFunc, false, true, true)
.attr(VariableHealAttr, swallowHealFunc, false, true, false)
.condition(hasStockpileStacksCondition)
.attr(RemoveBattlerTagAttr, [ BattlerTagType.STOCKPILING ], true)
.triageMove(),

View File

@ -1,4 +1,5 @@
import type { TerrainType } from "#app/data/terrain";
import type Overrides from "#app/overrides";
import type { AbilityId } from "#enums/ability-id";
import type { BattlerTagType } from "#enums/battler-tag-type";
import type { MoveId } from "#enums/move-id";
@ -7,14 +8,14 @@ import type { BattleStat, EffectiveStat, Stat } from "#enums/stat";
import type { StatusEffect } from "#enums/status-effect";
import type { WeatherType } from "#enums/weather-type";
import type { Pokemon } from "#field/pokemon";
import type { PokemonMove } from "#moves/pokemon-move";
import type { ToHaveEffectiveStatMatcherOptions } from "#test/test-utils/matchers/to-have-effective-stat";
import type { expectedStatusType } from "#test/test-utils/matchers/to-have-status-effect";
import type { toHaveTypesOptions } from "#test/test-utils/matchers/to-have-types";
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 Overrides from "#app/overrides";
import type { PokemonMove } from "#moves/pokemon-move";
declare module "vitest" {
interface Assertion {
@ -113,8 +114,9 @@ declare module "vitest" {
/**
* 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
* @param roundDown - Whether to round down {@linkcode expectedDamageTaken} with {@linkcode toDmgValue}; default `true`
*/
toHaveHp(expectedHp: number): void;
toHaveHp(expectedHp: number, roundDown?: boolean): void;
/**
* Check whether a {@linkcode Pokemon} is currently fainted (as determined by {@linkcode Pokemon.isFainted}).

View File

@ -63,7 +63,7 @@ describe("Moves - Swallow & Spit Up - ", () => {
game.move.use(MoveId.SWALLOW);
await game.toEndOfTurn();
expect(swalot).toHaveHp((swalot.getMaxHp() * healPercent) / 100 + 1);
expect(swalot).toHaveHp(Math.min(swalot.getMaxHp(), Math.round((swalot.getMaxHp() * healPercent) / 100) + 1));
expect(swalot).not.toHaveBattlerTag(BattlerTagType.STOCKPILING);
},
);
@ -137,7 +137,7 @@ describe("Moves - Swallow & Spit Up - ", () => {
await game.toEndOfTurn();
expect(spitUpSpy).toHaveReturnedWith(power);
expect(swalot.getTag(StockpilingTag)).toBeUndefined();
expect(swalot).not.toHaveBattlerTag(BattlerTagType.STOCKPILING);
});
it("should fail without Stockpile stacks", async () => {
@ -207,6 +207,7 @@ describe("Moves - Swallow & Spit Up - ", () => {
});
it("should invert stat drops when gaining Contrary", async () => {
game.override.enemyAbility(AbilityId.CONTRARY);
await game.classicMode.startBattle([SpeciesId.ABOMASNOW]);
const player = game.field.getPlayerPokemon();
@ -218,7 +219,7 @@ describe("Moves - Swallow & Spit Up - ", () => {
expect(player).toHaveStatStage(Stat.DEF, 1);
expect(player).toHaveStatStage(Stat.SPDEF, 1);
expect(player).toHaveAbilityApplied(AbilityId.CONTRARY);
expect(player.hasAbility(AbilityId.CONTRARY)).toBe(true);
game.move.use(MoveId.SPIT_UP);
await game.move.forceEnemyMove(MoveId.SPLASH);

View File

@ -2,15 +2,22 @@ import { getPokemonNameWithAffix } from "#app/messages";
// biome-ignore lint/correctness/noUnusedImports: TSDoc
import type { Pokemon } from "#field/pokemon";
import { isPokemonInstance, receivedStr } from "#test/test-utils/test-utils";
import { toDmgValue } from "#utils/common";
import type { MatcherState, SyncExpectationResult } from "@vitest/expect";
/**
* Matcher that checks if a Pokemon has a specific amount of HP.
* @param received - The object to check. Should be a {@linkcode Pokemon}.
* @param expectedHp - The expected amount of HP the {@linkcode Pokemon} has
* @param roundDown - Whether to round down {@linkcode expectedDamageTaken} with {@linkcode toDmgValue}; default `true`
* @returns Whether the matcher passed
*/
export function toHaveHp(this: MatcherState, received: unknown, expectedHp: number): SyncExpectationResult {
export function toHaveHp(
this: MatcherState,
received: unknown,
expectedHp: number,
roundDown = true,
): SyncExpectationResult {
if (!isPokemonInstance(received)) {
return {
pass: false,
@ -18,6 +25,9 @@ export function toHaveHp(this: MatcherState, received: unknown, expectedHp: numb
};
}
if (roundDown) {
expectedHp = toDmgValue(expectedHp);
}
const actualHp = received.hp;
const pass = actualHp === expectedHp;