From bdd0850e6f64f6875abec52a599eb2636ac5cd72 Mon Sep 17 00:00:00 2001 From: Temps Ray Date: Tue, 17 Sep 2024 23:21:55 -0400 Subject: [PATCH] Another linting --- src/data/battler-tags.ts | 2 ++ src/field/pokemon.ts | 2 +- src/phases/form-change-phase.ts | 2 ++ src/phases/quiet-form-change-phase.ts | 2 ++ src/test/moves/autotomize.test.ts | 31 +++++++++++++++++++++++++-- 5 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/data/battler-tags.ts b/src/data/battler-tags.ts index cf1a60ae868..f5b80a06c18 100644 --- a/src/data/battler-tags.ts +++ b/src/data/battler-tags.ts @@ -2518,6 +2518,8 @@ export function getBattlerTag(tagType: BattlerTagType, turnCount: number, source return new GorillaTacticsTag(); case BattlerTagType.SUBSTITUTE: return new SubstituteTag(sourceMove, sourceId); + case BattlerTagType.AUTOTOMIZED: + return new AutotomizedTag(); case BattlerTagType.MYSTERY_ENCOUNTER_POST_SUMMON: return new MysteryEncounterPostSummonTag(); case BattlerTagType.NONE: diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index aa9f47b8001..4eeab536bc5 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -1401,7 +1401,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { getWeight(): number { const autotomizedTag = this.getTag(AutotomizedTag); let weightRemoved = 0; - if (autotomizedTag !== null) { + if (autotomizedTag !== null && autotomizedTag !== undefined) { weightRemoved = 100 * autotomizedTag.autotomizeCount; } const minWeight = 0.1; diff --git a/src/phases/form-change-phase.ts b/src/phases/form-change-phase.ts index 33c1f8e8cef..1f18457146d 100644 --- a/src/phases/form-change-phase.ts +++ b/src/phases/form-change-phase.ts @@ -9,6 +9,7 @@ import PartyUiHandler from "../ui/party-ui-handler"; import { getPokemonNameWithAffix } from "../messages"; import { EndEvolutionPhase } from "./end-evolution-phase"; import { EvolutionPhase } from "./evolution-phase"; +import { BattlerTagType } from "#app/enums/battler-tag-type"; export class FormChangePhase extends EvolutionPhase { private formChange: SpeciesFormChange; @@ -157,6 +158,7 @@ export class FormChangePhase extends EvolutionPhase { } end(): void { + this.pokemon.findAndRemoveTags(t => t.tagType === BattlerTagType.AUTOTOMIZED); if (this.modal) { this.scene.ui.revertMode().then(() => { if (this.scene.ui.getMode() === Mode.PARTY) { diff --git a/src/phases/quiet-form-change-phase.ts b/src/phases/quiet-form-change-phase.ts index dde500e156a..c28cc28b592 100644 --- a/src/phases/quiet-form-change-phase.ts +++ b/src/phases/quiet-form-change-phase.ts @@ -3,6 +3,7 @@ import { SemiInvulnerableTag } from "#app/data/battler-tags"; import { SpeciesFormChange, getSpeciesFormChangeMessage } from "#app/data/pokemon-forms"; import { getTypeRgb } from "#app/data/type"; import { BattleSpec } from "#app/enums/battle-spec"; +import { BattlerTagType } from "#app/enums/battler-tag-type"; import Pokemon, { EnemyPokemon } from "#app/field/pokemon"; import { getPokemonNameWithAffix } from "#app/messages"; import { BattlePhase } from "./battle-phase"; @@ -113,6 +114,7 @@ export class QuietFormChangePhase extends BattlePhase { } end(): void { + this.pokemon.findAndRemoveTags(t => t.tagType === BattlerTagType.AUTOTOMIZED); if (this.pokemon.scene?.currentBattle.battleSpec === BattleSpec.FINAL_BOSS && this.pokemon instanceof EnemyPokemon) { this.scene.playBgm(); this.scene.unshiftPhase(new PokemonHealPhase(this.scene, this.pokemon.getBattlerIndex(), this.pokemon.getMaxHp(), null, false, false, false, true)); diff --git a/src/test/moves/autotomize.test.ts b/src/test/moves/autotomize.test.ts index c3439e4228a..36f90216a0a 100644 --- a/src/test/moves/autotomize.test.ts +++ b/src/test/moves/autotomize.test.ts @@ -23,7 +23,7 @@ describe("Moves - Autotomize", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([Moves.AUTOTOMIZE]) + .moveset([Moves.AUTOTOMIZE, Moves.KINGS_SHIELD, Moves.FALSE_SWIPE]) .battleType("single") .enemyAbility(Abilities.BALL_FETCH) .enemyMoveset(Moves.SPLASH); @@ -34,9 +34,9 @@ describe("Moves - Autotomize", () => { const oneAutotomizeDracozoltWeight = 90; const twoAutotomizeDracozoltWeight = 0.1; const threeAutotomizeDracozoltWeight = 0.1; - const playerPokemon = game.scene.getPlayerPokemon()!; await game.classicMode.startBattle([Species.DRACOZOLT]); + const playerPokemon = game.scene.getPlayerPokemon()!; expect(playerPokemon.getWeight()).toBe(baseDracozoltWeight); game.move.select(Moves.AUTOTOMIZE); // expect a queued message here @@ -52,4 +52,31 @@ describe("Moves - Autotomize", () => { // expect no queued message here expect(playerPokemon.getWeight()).toBe(threeAutotomizeDracozoltWeight); }, TIMEOUT); + + it("Changing forms should revert weight", async () => { + const baseAegislashWeight = 53; + const autotomizeAegislashWeight = 0.1; + + await game.classicMode.startBattle([Species.AEGISLASH]); + const playerPokemon = game.scene.getPlayerPokemon()!; + + expect(playerPokemon.getWeight()).toBe(baseAegislashWeight); + game.move.select(Moves.AUTOTOMIZE); + expect(playerPokemon.getWeight()).toBe(autotomizeAegislashWeight); + await game.toNextTurn(); + + game.move.select(Moves.KINGS_SHIELD); + expect(playerPokemon.getWeight()).toBe(baseAegislashWeight); + await game.toNextTurn(); + + game.move.select(Moves.AUTOTOMIZE); + expect(playerPokemon.getWeight()).toBe(autotomizeAegislashWeight); + + game.move.select(Moves.FALSE_SWIPE); + expect(playerPokemon.getWeight()).toBe(baseAegislashWeight); + await game.toNextTurn(); + + game.move.select(Moves.AUTOTOMIZE); + expect(playerPokemon.getWeight()).toBe(autotomizeAegislashWeight); + }, TIMEOUT); });