mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-06-21 09:02:47 +02:00
Merge 458faf90eb
into 4b70fab608
This commit is contained in:
commit
83ddfaaa9a
@ -1165,43 +1165,45 @@ export class MoveImmunityStatStageChangeAbAttr extends MoveImmunityAbAttr {
|
|||||||
* @see {@linkcode applyPostDefend}
|
* @see {@linkcode applyPostDefend}
|
||||||
*/
|
*/
|
||||||
export class ReverseDrainAbAttr extends PostDefendAbAttr {
|
export class ReverseDrainAbAttr extends PostDefendAbAttr {
|
||||||
|
private attacker: Pokemon;
|
||||||
override canApplyPostDefend(
|
override canApplyPostDefend(
|
||||||
_pokemon: Pokemon,
|
|
||||||
_passive: boolean,
|
|
||||||
_simulated: boolean,
|
|
||||||
_attacker: Pokemon,
|
|
||||||
move: Move,
|
|
||||||
_hitResult: HitResult | null,
|
|
||||||
_args: any[],
|
|
||||||
): boolean {
|
|
||||||
return move.hasAttr("HitHealAttr");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determines if a damage and draining move was used to check if this ability should stop the healing.
|
|
||||||
* Examples include: Absorb, Draining Kiss, Bitter Blade, etc.
|
|
||||||
* Also displays a message to show this ability was activated.
|
|
||||||
* @param _pokemon {@linkcode Pokemon} with this ability
|
|
||||||
* @param _passive N/A
|
|
||||||
* @param attacker {@linkcode Pokemon} that is attacking this Pokemon
|
|
||||||
* @param _move {@linkcode PokemonMove} that is being used
|
|
||||||
* @param _hitResult N/A
|
|
||||||
* @param _args N/A
|
|
||||||
*/
|
|
||||||
override applyPostDefend(
|
|
||||||
_pokemon: Pokemon,
|
_pokemon: Pokemon,
|
||||||
_passive: boolean,
|
_passive: boolean,
|
||||||
simulated: boolean,
|
simulated: boolean,
|
||||||
attacker: Pokemon,
|
attacker: Pokemon,
|
||||||
_move: Move,
|
move: Move,
|
||||||
_hitResult: HitResult,
|
_hitResult: HitResult | null,
|
||||||
|
_args: any[],
|
||||||
|
): boolean {
|
||||||
|
const cancelled = new BooleanHolder(false);
|
||||||
|
applyAbAttrs("BlockNonDirectDamageAbAttr", attacker, cancelled, simulated);
|
||||||
|
this.attacker = attacker;
|
||||||
|
return !cancelled.value && move.hasAttr("HitHealAttr");
|
||||||
|
}
|
||||||
|
|
||||||
|
override applyPostDefend(
|
||||||
|
pokemon: Pokemon,
|
||||||
|
_passive: boolean,
|
||||||
|
_simulated: boolean,
|
||||||
|
attacker: Pokemon,
|
||||||
|
move: Move,
|
||||||
|
_hitResult: HitResult | null,
|
||||||
_args: any[],
|
_args: any[],
|
||||||
): void {
|
): void {
|
||||||
if (!simulated) {
|
const damageAmount = move.getAttrs<"HitHealAttr">("HitHealAttr")[0].getHealAmount(attacker, pokemon);
|
||||||
globalScene.phaseManager.queueMessage(
|
pokemon.turnData.damageTaken += damageAmount;
|
||||||
i18next.t("abilityTriggers:reverseDrain", { pokemonNameWithAffix: getPokemonNameWithAffix(attacker) }),
|
globalScene.phaseManager.unshiftNew(
|
||||||
|
"PokemonHealPhase",
|
||||||
|
attacker.getBattlerIndex(),
|
||||||
|
-damageAmount,
|
||||||
|
null,
|
||||||
|
false,
|
||||||
|
true,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override getTriggerMessage(_pokemon: Pokemon, _abilityName: string, ..._args: any[]): string | null {
|
||||||
|
return i18next.t("abilityTriggers:reverseDrain", { pokemonNameWithAffix: getPokemonNameWithAffix(this.attacker) });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2271,28 +2271,18 @@ export class HitHealAttr extends MoveEffectAttr {
|
|||||||
* @returns true if the function succeeds
|
* @returns true if the function succeeds
|
||||||
*/
|
*/
|
||||||
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
||||||
let healAmount = 0;
|
if (target.hasAbilityWithAttr("ReverseDrainAbAttr")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const healAmount = this.getHealAmount(user, target);
|
||||||
let message = "";
|
let message = "";
|
||||||
const reverseDrain = target.hasAbilityWithAttr("ReverseDrainAbAttr", false);
|
|
||||||
if (this.healStat !== null) {
|
if (this.healStat !== null) {
|
||||||
// Strength Sap formula
|
|
||||||
healAmount = target.getEffectiveStat(this.healStat);
|
|
||||||
message = i18next.t("battle:drainMessage", { pokemonName: getPokemonNameWithAffix(target) });
|
message = i18next.t("battle:drainMessage", { pokemonName: getPokemonNameWithAffix(target) });
|
||||||
} else {
|
} else {
|
||||||
// Default healing formula used by draining moves like Absorb, Draining Kiss, Bitter Blade, etc.
|
|
||||||
healAmount = toDmgValue(user.turnData.singleHitDamageDealt * this.healRatio);
|
|
||||||
message = i18next.t("battle:regainHealth", { pokemonName: getPokemonNameWithAffix(user) });
|
message = i18next.t("battle:regainHealth", { pokemonName: getPokemonNameWithAffix(user) });
|
||||||
}
|
}
|
||||||
if (reverseDrain) {
|
|
||||||
if (user.hasAbilityWithAttr("BlockNonDirectDamageAbAttr")) {
|
|
||||||
healAmount = 0;
|
|
||||||
message = "";
|
|
||||||
} else {
|
|
||||||
user.turnData.damageTaken += healAmount;
|
|
||||||
healAmount = healAmount * -1;
|
|
||||||
message = "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
globalScene.phaseManager.unshiftNew("PokemonHealPhase", user.getBattlerIndex(), healAmount, message, false, true);
|
globalScene.phaseManager.unshiftNew("PokemonHealPhase", user.getBattlerIndex(), healAmount, message, false, true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -2311,6 +2301,10 @@ export class HitHealAttr extends MoveEffectAttr {
|
|||||||
}
|
}
|
||||||
return Math.floor(Math.max((1 - user.getHpRatio()) - 0.33, 0) * (move.power / 4));
|
return Math.floor(Math.max((1 - user.getHpRatio()) - 0.33, 0) * (move.power / 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getHealAmount(user: Pokemon, target: Pokemon): number {
|
||||||
|
return (this.healStat) ? target.getEffectiveStat(this.healStat) : toDmgValue(user.turnData.singleHitDamageDealt * this.healRatio);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
62
test/abilities/liquid_ooze.test.ts
Normal file
62
test/abilities/liquid_ooze.test.ts
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
import { AbilityId } from "#enums/ability-id";
|
||||||
|
import { MoveId } from "#enums/move-id";
|
||||||
|
import { SpeciesId } from "#enums/species-id";
|
||||||
|
import GameManager from "#test/testUtils/gameManager";
|
||||||
|
import Phaser from "phaser";
|
||||||
|
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
||||||
|
|
||||||
|
describe("Abilities - Liquid Ooze", () => {
|
||||||
|
let phaserGame: Phaser.Game;
|
||||||
|
let game: GameManager;
|
||||||
|
|
||||||
|
beforeAll(() => {
|
||||||
|
phaserGame = new Phaser.Game({
|
||||||
|
type: Phaser.HEADLESS,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
game.phaseInterceptor.restoreOg();
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
game = new GameManager(phaserGame);
|
||||||
|
game.override
|
||||||
|
.moveset([MoveId.SPLASH, MoveId.GIGA_DRAIN])
|
||||||
|
.ability(AbilityId.BALL_FETCH)
|
||||||
|
.battleStyle("single")
|
||||||
|
.enemyLevel(20)
|
||||||
|
.enemySpecies(SpeciesId.MAGIKARP)
|
||||||
|
.enemyAbility(AbilityId.LIQUID_OOZE)
|
||||||
|
.enemyMoveset(MoveId.SPLASH);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should drain the attacker's HP after a draining move", async () => {
|
||||||
|
await game.classicMode.startBattle([SpeciesId.FEEBAS]);
|
||||||
|
|
||||||
|
game.move.select(MoveId.GIGA_DRAIN);
|
||||||
|
await game.phaseInterceptor.to("BerryPhase");
|
||||||
|
|
||||||
|
expect(game.scene.getPlayerPokemon()?.isFullHp()).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should not drain the attacker's HP if it ignores indirect damage", async () => {
|
||||||
|
game.override.ability(AbilityId.MAGIC_GUARD);
|
||||||
|
await game.classicMode.startBattle([SpeciesId.FEEBAS]);
|
||||||
|
|
||||||
|
game.move.select(MoveId.GIGA_DRAIN);
|
||||||
|
await game.phaseInterceptor.to("BerryPhase");
|
||||||
|
|
||||||
|
expect(game.scene.getPlayerPokemon()?.isFullHp()).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should not apply if suppressed", async () => {
|
||||||
|
game.override.ability(AbilityId.NEUTRALIZING_GAS);
|
||||||
|
await game.classicMode.startBattle([SpeciesId.FEEBAS]);
|
||||||
|
|
||||||
|
game.move.select(MoveId.GIGA_DRAIN);
|
||||||
|
await game.phaseInterceptor.to("BerryPhase");
|
||||||
|
|
||||||
|
expect(game.scene.getPlayerPokemon()?.isFullHp()).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user