nit corrections

This commit is contained in:
Lylian 2024-08-05 01:17:25 +02:00
parent 699de179e6
commit 41ca2cd9ef
3 changed files with 46 additions and 33 deletions

View File

@ -1896,11 +1896,14 @@ export class PostSummonMessageAbAttr extends PostSummonAbAttr {
applyPostSummon(pokemon: Pokemon, passive: boolean, args: any[]): boolean { applyPostSummon(pokemon: Pokemon, passive: boolean, args: any[]): boolean {
pokemon.scene.queueMessage(this.messageFunc(pokemon)); pokemon.scene.queueMessage(this.messageFunc(pokemon));
return true;
}
}
export class PostSummonRemoveIllusionAbAttr extends PostSummonAbAttr {
applyPostSummon(pokemon: Pokemon, passive: boolean, args: any[]): boolean {
pokemon.scene.getField(true).map(pokemon => { pokemon.scene.getField(true).map(pokemon => {
if (pokemon.breakIllusion()) { pokemon.breakIllusion();
pokemon.scene.queueMessage(i18next.t("abilityTriggers:illusionBreak", { pokemonName: getPokemonNameWithAffix(pokemon) }));
}
}); });
return true; return true;
} }
@ -4049,6 +4052,11 @@ export class IceFaceBlockPhysicalAbAttr extends ReceivedMoveDamageMultiplierAbAt
} }
} }
/**
* Base class for defining {@linkcode Ability} attributes before summon
* (should use {@linkcode PostSummonAbAttr} for most ability)
* @see {@linkcode applyPreSummon()}
*/
export class PreSummonAbAttr extends AbAttr { export class PreSummonAbAttr extends AbAttr {
applyPreSummon(pokemon: Pokemon, passive: boolean, args: any[]): boolean { applyPreSummon(pokemon: Pokemon, passive: boolean, args: any[]): boolean {
return false; return false;
@ -4097,17 +4105,16 @@ export class IllusionBreakAbAttr extends PostDefendAbAttr {
*/ */
applyPostDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): boolean { applyPostDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): boolean {
const breakIllusion: HitResult[] = [HitResult.EFFECTIVE, HitResult.SUPER_EFFECTIVE, HitResult.NOT_VERY_EFFECTIVE, HitResult.ONE_HIT_KO]; const breakIllusion: HitResult[] = [ HitResult.EFFECTIVE, HitResult.SUPER_EFFECTIVE, HitResult.NOT_VERY_EFFECTIVE, HitResult.ONE_HIT_KO ];
if (!breakIllusion.includes(hitResult)) { if (!breakIllusion.includes(hitResult)) {
return false; return false;
} }
pokemon.breakIllusion(); pokemon.breakIllusion();
pokemon.scene.queueMessage(i18next.t("abilityTriggers:illusionBreak", { pokemonName: getPokemonNameWithAffix(pokemon) }));
return true; return true;
} }
} }
export class IllusionAfterBattle extends PostBattleAbAttr { export class IllusionPostBattleAbAttr extends PostBattleAbAttr {
/** /**
* Illusion will be available again after a battle and apply the illusion of the pokemon is already on field * Illusion will be available again after a battle and apply the illusion of the pokemon is already on field
* *
@ -4868,7 +4875,7 @@ export function initAbilities() {
//The pokemon loses his illusion when he is damaged by a move //The pokemon loses his illusion when he is damaged by a move
.conditionalAttr((pokemon) => pokemon.illusion.active, IllusionBreakAbAttr, true) .conditionalAttr((pokemon) => pokemon.illusion.active, IllusionBreakAbAttr, true)
//Illusion is available again after a battle //Illusion is available again after a battle
.conditionalAttr((pokemon) => pokemon.isAllowedInBattle(), IllusionAfterBattle, false) .conditionalAttr((pokemon) => pokemon.isAllowedInBattle(), IllusionPostBattleAbAttr, false)
//Illusion is not available after summon //Illusion is not available after summon
.attr(IllusionDisableAbAttr, false) .attr(IllusionDisableAbAttr, false)
.bypassFaint(), .bypassFaint(),
@ -5246,6 +5253,7 @@ export function initAbilities() {
.attr(UnswappableAbilityAbAttr) .attr(UnswappableAbilityAbAttr)
.attr(NoTransformAbilityAbAttr) .attr(NoTransformAbilityAbAttr)
.attr(PostSummonMessageAbAttr, (pokemon: Pokemon) => i18next.t("abilityTriggers:postSummonNeutralizingGas", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })) .attr(PostSummonMessageAbAttr, (pokemon: Pokemon) => i18next.t("abilityTriggers:postSummonNeutralizingGas", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) }))
.attr(PostSummonRemoveIllusionAbAttr)
.partial(), .partial(),
new Ability(Abilities.PASTEL_VEIL, 8) new Ability(Abilities.PASTEL_VEIL, 8)
.attr(PostSummonUserFieldRemoveStatusEffectAbAttr, StatusEffect.POISON, StatusEffect.TOXIC) .attr(PostSummonUserFieldRemoveStatusEffectAbAttr, StatusEffect.POISON, StatusEffect.TOXIC)

View File

@ -1,6 +1,5 @@
import { ability } from "./ability"; import { ability } from "./ability";
import { abilityTriggers } from "./ability-trigger"; import { abilityTriggers } from "./ability-trigger";
import { arenaFlyout } from "./arena-flyout";
import { PGFachv, PGMachv } from "./achv"; import { PGFachv, PGMachv } from "./achv";
import { arenaFlyout } from "./arena-flyout"; import { arenaFlyout } from "./arena-flyout";
import { arenaTag } from "./arena-tag"; import { arenaTag } from "./arena-tag";

View File

@ -28,17 +28,17 @@ describe("Abilities - Illusion", () => {
beforeEach(() => { beforeEach(() => {
game = new GameManager(phaserGame); game = new GameManager(phaserGame);
vi.spyOn(overrides, "BATTLE_TYPE_OVERRIDE", "get").mockReturnValue("single"); game.override.battleType("single");
vi.spyOn(overrides, "OPP_SPECIES_OVERRIDE", "get").mockReturnValue(Species.ZORUA); game.override.enemySpecies(Species.ZORUA);
vi.spyOn(overrides, "OPP_ABILITY_OVERRIDE", "get").mockReturnValue(Abilities.ILLUSION); game.override.enemyAbility(Abilities.ILLUSION);
vi.spyOn(overrides, "OPP_MOVESET_OVERRIDE", "get").mockReturnValue([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]); game.override.enemyMoveset([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]);
vi.spyOn(overrides, "OPP_HELD_ITEMS_OVERRIDE", "get").mockReturnValue([{name: "WIDE_LENS", count: 3}]); game.override.enemyHeldItems([{name: "WIDE_LENS", count: 3}]);
vi.spyOn(overrides, "MOVESET_OVERRIDE", "get").mockReturnValue([Moves.WORRY_SEED, Moves.SOAK, Moves.TACKLE, Moves.TACKLE]); game.override.moveset([Moves.WORRY_SEED, Moves.SOAK, Moves.TACKLE, Moves.TACKLE]);
vi.spyOn(overrides, "STARTING_HELD_ITEMS_OVERRIDE", "get").mockReturnValue([{name: "WIDE_LENS", count: 3}]); game.override.startingHeldItems([{name: "WIDE_LENS", count: 3}]);
}); });
it("create illusion at the start", async () => { it("creates illusion at the start", async () => {
await game.startBattle([Species.ZOROARK, Species.AXEW]); await game.startBattle([Species.ZOROARK, Species.AXEW]);
const zoroark = game.scene.getPlayerPokemon(); const zoroark = game.scene.getPlayerPokemon();
@ -47,24 +47,30 @@ describe("Abilities - Illusion", () => {
expect(zoroark.illusion.active).equals(true); expect(zoroark.illusion.active).equals(true);
expect(zorua.illusion.active).equals(true); expect(zorua.illusion.active).equals(true);
expect(zoroark.illusion.available).equals(false); expect(zoroark.illusion.available).equals(false);
}); });
it("disappear after receiving damaging move and changing ability move", async () => { it("break after receiving damaging move", async () => {
await game.startBattle([Species.ZOROARK, Species.AXEW]); await game.startBattle([Species.AXEW]);
game.doAttack(getMovePosition(game.scene, 0, Moves.WORRY_SEED)); game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE));
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
const zoroark = game.scene.getPlayerPokemon();
const zorua = game.scene.getEnemyPokemon(); const zorua = game.scene.getEnemyPokemon();
expect(zorua.illusion.active).equals(false); expect(zorua.illusion.active).equals(false);
expect(zoroark.illusion.active).equals(false);
}); });
it("disappear if the ability is suppressed", async () => { it("break after getting ability changed", async () => {
vi.spyOn(overrides, "ABILITY_OVERRIDE", "get").mockReturnValue(Abilities.NEUTRALIZING_GAS); await game.startBattle([Species.AXEW]);
game.doAttack(getMovePosition(game.scene, 0, Moves.WORRY_SEED));
const zorua = game.scene.getEnemyPokemon();
expect(zorua.illusion.active).equals(false);
});
it("break if the ability is suppressed", async () => {
game.override.enemyAbility(Abilities.NEUTRALIZING_GAS);
await game.startBattle([Species.KOFFING]); await game.startBattle([Species.KOFFING]);
const zorua = game.scene.getEnemyPokemon(); const zorua = game.scene.getEnemyPokemon();
@ -72,24 +78,24 @@ describe("Abilities - Illusion", () => {
expect(zorua.illusion.active).equals(false); expect(zorua.illusion.active).equals(false);
}); });
it("trick the enemy AI", async () => { it("trick the enemy AI for moves effectiveness using ILLUSION type instead of actual type", async () => {
vi.spyOn(overrides, "OPP_MOVESET_OVERRIDE", "get").mockReturnValue([Moves.FLAMETHROWER, Moves.PSYCHIC, Moves.TACKLE, Moves.TACKLE]); game.override.enemyMoveset([Moves.FLAMETHROWER, Moves.PSYCHIC, Moves.TACKLE, Moves.TACKLE]);
await game.startBattle([Species.ZOROARK, Species.AXEW]); await game.startBattle([Species.ZOROARK, Species.AXEW]);
const enemy = game.scene.getEnemyPokemon(); const enemy = game.scene.getEnemyPokemon();
const zoroark = game.scene.getPlayerPokemon(); const zoroark = game.scene.getPlayerPokemon();
const flameThwowerEffectiveness = zoroark.getAttackMoveEffectiveness(enemy, enemy.getMoveset()[0], false, true); const flameThrowerEffectiveness = zoroark.getAttackMoveEffectiveness(enemy, enemy.getMoveset()[0], false, true);
const psychicEffectiveness = zoroark.getAttackMoveEffectiveness(enemy, enemy.getMoveset()[1], false, true); const psychicEffectiveness = zoroark.getAttackMoveEffectiveness(enemy, enemy.getMoveset()[1], false, true);
expect(psychicEffectiveness).above(flameThwowerEffectiveness); expect(psychicEffectiveness).above(flameThrowerEffectiveness);
}); });
it("do not disappear if the pokemon takes indirect damages", async () => { it("do not breaks if the pokemon takes indirect damages", async () => {
vi.spyOn(overrides, "OPP_SPECIES_OVERRIDE", "get").mockReturnValue(Species.GIGALITH); game.override.enemySpecies(Species.GIGALITH);
vi.spyOn(overrides, "OPP_ABILITY_OVERRIDE", "get").mockReturnValue(Abilities.SAND_STREAM); game.override.enemyAbility(Abilities.SAND_STREAM);
vi.spyOn(overrides, "OPP_MOVESET_OVERRIDE", "get").mockReturnValue([Moves.WILL_O_WISP, Moves.WILL_O_WISP, Moves.WILL_O_WISP, Moves.WILL_O_WISP]); game.override.enemyMoveset([Moves.WILL_O_WISP, Moves.WILL_O_WISP, Moves.WILL_O_WISP, Moves.WILL_O_WISP]);
vi.spyOn(overrides, "MOVESET_OVERRIDE", "get").mockReturnValue([Moves.FLARE_BLITZ]); game.override.moveset([Moves.FLARE_BLITZ]);
await game.startBattle([Species.ZOROARK, Species.AZUMARILL]); await game.startBattle([Species.ZOROARK, Species.AZUMARILL]);