From 4ddd4ceb97daa9c2ab4f213c6cda164e9e6828db Mon Sep 17 00:00:00 2001 From: PrabbyDD Date: Tue, 10 Sep 2024 11:43:59 -0700 Subject: [PATCH] roost test update --- src/test/moves/roost.test.ts | 124 ++++++++++++++++++++++++++++++----- 1 file changed, 108 insertions(+), 16 deletions(-) diff --git a/src/test/moves/roost.test.ts b/src/test/moves/roost.test.ts index cf07a3485e7..6fe001a4b2c 100644 --- a/src/test/moves/roost.test.ts +++ b/src/test/moves/roost.test.ts @@ -1,4 +1,4 @@ -import { Abilities } from "#app/enums/abilities"; +import { Type } from "#app/data/type.js"; import { BattlerTagType } from "#app/enums/battler-tag-type"; import { Moves } from "#app/enums/moves"; import { Species } from "#app/enums/species"; @@ -27,33 +27,125 @@ describe("Moves - Roost", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override.battleType("single"); - game.override.enemySpecies(Species.STARAPTOR); - game.override.enemyAbility(Abilities.INSOMNIA); + game.override.enemySpecies(Species.MAGIKARP); game.override.startingLevel(100); game.override.enemyLevel(100); - game.override.moveset([Moves.STOMPING_TANTRUM]); - game.override.enemyMoveset([Moves.ROOST, Moves.ROOST, Moves.ROOST, Moves.ROOST]); }); + /** + * Roost's behavior should be defined as: + * The pokemon loses its flying type for a turn. If the pokemon was ungroundd solely due to being a flying type, it will be grounded until end of turn. + * + * 1. Pure Flying type pokemon -> become normal type until end of turn + * 2. Dual Flying/X type pokemon -> become type X until end of turn + * 3. Pokemon that use burn up into roost (ex. Moltres) -> become flying due to burn up, then typeless until end of turn after using roost + * 4. If a pokemon is afflicted with Forest's Curse or Trick or treat, dual type pokemon will become 3 type pokemon after the flying type is regained + * Pure flying types become (Grass or Ghost) and then back to flying/ (Grass or Ghost), + * and pokemon post Burn up become () + * 5. If a pokemon is also ungrounded due to other reasons (such as levitate), it will stay ungrounded post roost, despite not being flying type. + * 6. Non flying types using roost (such as dunsparce) are already grounded, so this move will only heal and have no other effects. + */ + test( - "move should ground the user until the end of turn", + "Pure flying type -> becomes normal after roost and takes damage from ground moves -> regains flying", async () => { - await game.startBattle([Species.MAGIKARP]); - - const enemyPokemon = game.scene.getEnemyPokemon()!; - - const enemyStartingHp = enemyPokemon.hp; - - game.move.select(Moves.STOMPING_TANTRUM); + await game.startBattle([Species.TORNADUS]); + game.override.moveset([Moves.ROOST]); + game.move.select(Moves.ROOST); + const playerPokemon = game.scene.getPlayerPokemon()!; + game.override.enemyMoveset([Moves.EARTHQUAKE, Moves.EARTHQUAKE, Moves.EARTHQUAKE, Moves.EARTHQUAKE]); + const playerPokemonStartingHP = playerPokemon.hp; await game.phaseInterceptor.to(MoveEffectPhase); - expect(enemyPokemon.getTag(BattlerTagType.ROOSTED)).toBeDefined(); + // Should only be normal type, and NOT flying type + let playerPokemonTypes = playerPokemon.summonData.types; + expect(playerPokemon.getTag(BattlerTagType.ROOSTED)).toBeDefined(); + expect(playerPokemonTypes[0] === Type.NORMAL).toBeTruthy(); + expect(playerPokemonTypes[0] === Type.FLYING).toBeFalsy(); + expect(playerPokemon.isGrounded()).toBeTruthy(); await game.phaseInterceptor.to(TurnEndPhase); - expect(enemyPokemon.hp).toBeLessThan(enemyStartingHp); - expect(enemyPokemon.getTag(BattlerTagType.ROOSTED)).toBeUndefined(); + // Should have lost HP and is now back to being pure flying + playerPokemonTypes = playerPokemon.summonData.types; + expect(playerPokemon.hp).toBeLessThan(playerPokemonStartingHP); + expect(playerPokemonTypes[0] === Type.NORMAL).toBeFalsy(); + expect(playerPokemonTypes[0] === Type.FLYING).toBeTruthy(); + expect(playerPokemon.getTag(BattlerTagType.ROOSTED)).toBeUndefined(); + expect(playerPokemon.isGrounded()).toBeFalsy(); + + }, TIMEOUT + ); + + test( + "Dual X/flying type -> becomes type X after roost and takes damage from ground moves -> regains flying", + async () => { + await game.startBattle([Species.HAWLUCHA]); + game.override.moveset([Moves.ROOST]); + game.move.select(Moves.ROOST); + + const playerPokemon = game.scene.getPlayerPokemon()!; + game.override.enemyMoveset([Moves.EARTHQUAKE, Moves.EARTHQUAKE, Moves.EARTHQUAKE, Moves.EARTHQUAKE]); + const playerPokemonStartingHP = playerPokemon.hp; + await game.phaseInterceptor.to(MoveEffectPhase); + + // Should only be pure fighting type and grounded + let playerPokemonTypes = playerPokemon.summonData.types; + expect(playerPokemon.getTag(BattlerTagType.ROOSTED)).toBeDefined(); + expect(playerPokemonTypes[0] === Type.FIGHTING).toBeTruthy(); + expect(playerPokemonTypes.length === 1).toBeTruthy(); + expect(playerPokemon.isGrounded()).toBeTruthy(); + + await game.phaseInterceptor.to(TurnEndPhase); + + // Should have lost HP and is now back to being fighting/flying + playerPokemonTypes = playerPokemon.summonData.types; + expect(playerPokemon.hp).toBeLessThan(playerPokemonStartingHP); + expect(playerPokemonTypes[0] === Type.FIGHTING).toBeTruthy(); + expect(playerPokemonTypes[1] === Type.FLYING).toBeTruthy(); + expect(playerPokemon.getTag(BattlerTagType.ROOSTED)).toBeUndefined(); + expect(playerPokemon.isGrounded()).toBeFalsy(); + + }, TIMEOUT + ); + + test( + "Dual X/flying type with levitate -> becomes type X after roost and does NOT takes damage from ground moves -> regains flying, is always grounded", + async () => { + await game.startBattle([Species.ROTOM]); + //game.override.starterForms({ [Species.ROTOM]: 4 }) + game.override.moveset([Moves.ROOST]); + game.move.select(Moves.ROOST); + + + const playerPokemon = game.scene.getPlayerPokemon()!; + game.override.enemyMoveset([Moves.EARTHQUAKE, Moves.EARTHQUAKE, Moves.EARTHQUAKE, Moves.EARTHQUAKE]); + const playerPokemonStartingHP = playerPokemon.hp; + + expect(playerPokemon.summonData.types.length === 0).toBeTruthy(); + + await game.phaseInterceptor.to(MoveEffectPhase); + + // Should only be pure electric type and not grounded + let playerPokemonTypes = playerPokemon.summonData.types; + console.log("TYPES OF POKEMONZZZ", playerPokemonTypes); + + expect(playerPokemon.getTag(BattlerTagType.ROOSTED)).toBeDefined(); + expect(playerPokemonTypes[0] === Type.ELECTRIC).toBeTruthy(); + expect(playerPokemonTypes.length === 1).toBeTruthy(); + expect(playerPokemon.isGrounded()).toBeFalsy(); + + await game.phaseInterceptor.to(TurnEndPhase); + + // Should have same HP and is now back to being electric/flying + playerPokemonTypes = playerPokemon.summonData.types; + expect(playerPokemon.hp).toBe(playerPokemonStartingHP); + expect(playerPokemonTypes[0] === Type.ELECTRIC).toBeTruthy(); + expect(playerPokemonTypes[1] === Type.FLYING).toBeTruthy(); + expect(playerPokemon.getTag(BattlerTagType.ROOSTED)).toBeUndefined(); + expect(playerPokemon.isGrounded()).toBeFalsy(); + }, TIMEOUT ); });