hahahhaha

This commit is contained in:
frutescens 2024-10-20 16:38:50 -07:00 committed by NightKev
parent 8ce48815fc
commit a7c9defcb2
2 changed files with 67 additions and 31 deletions

View File

@ -4693,28 +4693,24 @@ export class TerrainEventTypeChangeAbAttr extends PostSummonAbAttr {
} }
const currentTerrain = pokemon.scene.arena.getTerrainType(); const currentTerrain = pokemon.scene.arena.getTerrainType();
const typeChange: Type[] = []; const typeChange: Type[] = [];
let isRevert: boolean = false; switch (currentTerrain) {
if (currentTerrain !== TerrainType.NONE) { case TerrainType.ELECTRIC:
switch (currentTerrain) { typeChange.push(Type.ELECTRIC);
case TerrainType.ELECTRIC: break;
typeChange.push(Type.ELECTRIC); case TerrainType.MISTY:
break; typeChange.push(Type.FAIRY);
case TerrainType.MISTY: break;
typeChange.push(Type.FAIRY); case TerrainType.GRASSY:
break; typeChange.push(Type.GRASS);
case TerrainType.GRASSY: break;
typeChange.push(Type.GRASS); case TerrainType.PSYCHIC:
break; typeChange.push(Type.PSYCHIC);
case TerrainType.PSYCHIC: break;
typeChange.push(Type.PSYCHIC); default:
break; pokemon.getTypes(false, false, true).forEach(t => {
default: typeChange.push(t);
pokemon.getTypes(false, false, true).forEach(t => { });
typeChange.push(t); break;
});
isRevert = true;
break;
}
} }
if (typeChange.length !== 0) { if (typeChange.length !== 0) {
if (pokemon.summonData.addedType && typeChange.includes(pokemon.summonData.addedType)) { if (pokemon.summonData.addedType && typeChange.includes(pokemon.summonData.addedType)) {
@ -4725,15 +4721,22 @@ export class TerrainEventTypeChangeAbAttr extends PostSummonAbAttr {
} }
let message: string = ""; let message: string = "";
const pokemonName = getPokemonNameWithAffix(pokemon); const pokemonName = getPokemonNameWithAffix(pokemon);
if (isRevert) { if (currentTerrain === TerrainType.NONE) {
message = i18next.t("abilityTriggers:pokemonTypeChangeRevert", { pokemonNameWithAffix: pokemonName }); message = i18next.t("abilityTriggers:pokemonTypeChangeRevert", { pokemonNameWithAffix: pokemonName });
} else { } else {
const typeName = i18next.t(`pokemonInfo:Type.${Type[typeChange[0]]})`); const typeName = i18next.t(`pokemonInfo:Type.${Type[typeChange[0]]})`);
message = i18next.t("abilityTriggers:pokemonTypeChange", { pokemonNameWithAffix: pokemonName, typeName: typeName }); message = i18next.t("abilityTriggers:pokemonTypeChange", { pokemonNameWithAffix: pokemonName, moveType: typeName });
} }
pokemon.scene.queueMessage(message); pokemon.scene.queueMessage(message);
return true; return true;
} }
applyPostSummon(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean | Promise<boolean> {
if (pokemon.scene.arena.getTerrainType() !== TerrainType.NONE) {
return this.apply(pokemon, passive, simulated, new Utils.BooleanHolder(false), []);
}
return false;
}
} }
async function applyAbAttrsInternal<TAttr extends AbAttr>( async function applyAbAttrsInternal<TAttr extends AbAttr>(

View File

@ -1,6 +1,7 @@
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import { Type } from "#app/data/type";
import GameManager from "#test/utils/gameManager"; import GameManager from "#test/utils/gameManager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
@ -23,20 +24,52 @@ describe("Abilities - Mimicry", () => {
game = new GameManager(phaserGame); game = new GameManager(phaserGame);
game.override game.override
.moveset([ Moves.SPLASH ]) .moveset([ Moves.SPLASH ])
.ability(Abilities.BALL_FETCH) .ability(Abilities.MIMICRY)
.battleType("single") .battleType("single")
.disableCrits() .disableCrits()
.enemySpecies(Species.MAGIKARP) .enemySpecies(Species.MAGIKARP)
.enemyAbility(Abilities.BALL_FETCH)
.enemyMoveset(Moves.SPLASH); .enemyMoveset(Moves.SPLASH);
}); });
it("should do X", async () => { // List of Tests (Work in Progress)
await game.classicMode.startBattle([ Species.FEEBAS ]); // Pokemon should return to original root type even when transformed when terrain ends
// The effect of Forest's Curse is removed when Mimicry activates in Grassy Terrain
it("Mimicry activates after the Pokémon with Mimicry is switched in while terrain is present, or whenever there is a change in terrain", async () => {
game.override.enemyAbility(Abilities.MISTY_SURGE);
await game.classicMode.startBattle([ Species.FEEBAS, Species.ABRA ]);
const playerPokemon1 = game.scene.getPlayerPokemon();
game.move.select(Moves.SPLASH);
await game.toNextTurn();
expect(playerPokemon1?.getTypes().includes(Type.FAIRY)).toBe(true);
game.doSwitchPokemon(1);
await game.toNextTurn();
const playerPokemon2 = game.scene.getPlayerPokemon();
expect(playerPokemon2?.getTypes().includes(Type.FAIRY)).toBe(true);
});
it("Pokemon should revert back to its original, root type once terrain ends", async () => {
game.override
.moveset([ Moves.SPLASH, Moves.TRANSFORM ])
.enemyAbility(Abilities.MIMICRY)
.enemyMoveset([ Moves.SPLASH, Moves.PSYCHIC_TERRAIN ]);
await game.classicMode.startBattle([ Species.REGIELEKI ]);
const playerPokemon1 = game.scene.getPlayerPokemon();
game.move.select(Moves.TRANSFORM);
await game.forceEnemyMove(Moves.PSYCHIC_TERRAIN);
await game.toNextTurn();
expect(playerPokemon1?.getTypes().includes(Type.PSYCHIC)).toBe(true);
if (game.scene.arena.terrain) {
game.scene.arena.terrain.turnsLeft = 1;
}
game.move.select(Moves.SPLASH); game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to("BerryPhase"); await game.forceEnemyMove(Moves.SPLASH);
await game.toNextTurn();
expect(true).toBe(true); expect(playerPokemon1?.getTypes().includes(Type.ELECTRIC)).toBe(true);
}); });
}); });