Fix unit tests

This commit is contained in:
Temps Ray 2024-09-17 23:40:03 -04:00
parent bdd0850e6f
commit 17e5ef789d
3 changed files with 26 additions and 10 deletions

View File

@ -2207,12 +2207,12 @@ export class TarShotTag extends BattlerTag {
*/ */
export class AutotomizedTag extends BattlerTag { export class AutotomizedTag extends BattlerTag {
public autotomizeCount: number = 0; public autotomizeCount: number = 0;
constructor(sourceMove: Moves = Moves.NONE) { constructor(sourceMove: Moves = Moves.AUTOTOMIZE) {
super(BattlerTagType.AUTOTOMIZED, BattlerTagLapseType.CUSTOM, 1, sourceMove); super(BattlerTagType.AUTOTOMIZED, BattlerTagLapseType.CUSTOM, 1, sourceMove);
} }
/** /**
* Adds an autotmize count to the Pokemon. Each stack reduces weight by 100kg * Adds an autotomize count to the Pokemon. Each stack reduces weight by 100kg
* If the Pokemon is over 0.1kg it also displays a message. * If the Pokemon is over 0.1kg it also displays a message.
* @param pokemon The Pokemon that is being autotomized * @param pokemon The Pokemon that is being autotomized
*/ */

View File

@ -1401,7 +1401,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
getWeight(): number { getWeight(): number {
const autotomizedTag = this.getTag(AutotomizedTag); const autotomizedTag = this.getTag(AutotomizedTag);
let weightRemoved = 0; let weightRemoved = 0;
if (autotomizedTag !== null && autotomizedTag !== undefined) { if (!Utils.isNullOrUndefined(autotomizedTag)) {
weightRemoved = 100 * autotomizedTag.autotomizeCount; weightRemoved = 100 * autotomizedTag.autotomizeCount;
} }
const minWeight = 0.1; const minWeight = 0.1;

View File

@ -39,17 +39,16 @@ describe("Moves - Autotomize", () => {
const playerPokemon = game.scene.getPlayerPokemon()!; const playerPokemon = game.scene.getPlayerPokemon()!;
expect(playerPokemon.getWeight()).toBe(baseDracozoltWeight); expect(playerPokemon.getWeight()).toBe(baseDracozoltWeight);
game.move.select(Moves.AUTOTOMIZE); game.move.select(Moves.AUTOTOMIZE);
// expect a queued message here await game.toNextTurn();
expect(playerPokemon.getWeight()).toBe(oneAutotomizeDracozoltWeight); expect(playerPokemon.getWeight()).toBe(oneAutotomizeDracozoltWeight);
await game.toNextTurn();
game.move.select(Moves.AUTOTOMIZE); game.move.select(Moves.AUTOTOMIZE);
//expect a queued message here await game.toNextTurn();
expect(playerPokemon.getWeight()).toBe(twoAutotomizeDracozoltWeight); expect(playerPokemon.getWeight()).toBe(twoAutotomizeDracozoltWeight);
await game.toNextTurn();
game.move.select(Moves.AUTOTOMIZE); game.move.select(Moves.AUTOTOMIZE);
// expect no queued message here await game.toNextTurn();
expect(playerPokemon.getWeight()).toBe(threeAutotomizeDracozoltWeight); expect(playerPokemon.getWeight()).toBe(threeAutotomizeDracozoltWeight);
}, TIMEOUT); }, TIMEOUT);
@ -62,21 +61,38 @@ describe("Moves - Autotomize", () => {
expect(playerPokemon.getWeight()).toBe(baseAegislashWeight); expect(playerPokemon.getWeight()).toBe(baseAegislashWeight);
game.move.select(Moves.AUTOTOMIZE); game.move.select(Moves.AUTOTOMIZE);
await game.toNextTurn();
expect(playerPokemon.getWeight()).toBe(autotomizeAegislashWeight); expect(playerPokemon.getWeight()).toBe(autotomizeAegislashWeight);
game.move.select(Moves.FALSE_SWIPE);
await game.toNextTurn(); await game.toNextTurn();
game.move.select(Moves.KINGS_SHIELD); game.move.select(Moves.KINGS_SHIELD);
expect(playerPokemon.getWeight()).toBe(baseAegislashWeight);
await game.toNextTurn(); await game.toNextTurn();
expect(playerPokemon.getWeight()).toBe(baseAegislashWeight);
game.move.select(Moves.AUTOTOMIZE); game.move.select(Moves.AUTOTOMIZE);
await game.toNextTurn();
expect(playerPokemon.getWeight()).toBe(autotomizeAegislashWeight); expect(playerPokemon.getWeight()).toBe(autotomizeAegislashWeight);
game.move.select(Moves.FALSE_SWIPE); game.move.select(Moves.FALSE_SWIPE);
expect(playerPokemon.getWeight()).toBe(baseAegislashWeight);
await game.toNextTurn(); await game.toNextTurn();
expect(playerPokemon.getWeight()).toBe(baseAegislashWeight);
game.move.select(Moves.AUTOTOMIZE); game.move.select(Moves.AUTOTOMIZE);
await game.toNextTurn();
expect(playerPokemon.getWeight()).toBe(autotomizeAegislashWeight); expect(playerPokemon.getWeight()).toBe(autotomizeAegislashWeight);
}, TIMEOUT); }, TIMEOUT);
it("Autotomize should interact with light metal correctly", async () => {
const baseLightGroudonWeight = 475;
const autotomizeLightGroudonWeight = 425;
game.override.ability(Abilities.LIGHT_METAL);
await game.classicMode.startBattle([Species.GROUDON]);
const playerPokemon = game.scene.getPlayerPokemon()!;
expect(playerPokemon.getWeight()).toBe(baseLightGroudonWeight);
game.move.select(Moves.AUTOTOMIZE);
await game.toNextTurn();
expect(playerPokemon.getWeight()).toBe(autotomizeLightGroudonWeight);
}, TIMEOUT);
}); });