mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-06 00:12:16 +02:00
Compare commits
16 Commits
f9493dec63
...
828083a74e
Author | SHA1 | Date | |
---|---|---|---|
|
828083a74e | ||
|
43aa772603 | ||
|
458faf90eb | ||
|
151c308d63 | ||
|
3551f69b0e | ||
|
6c0d6dbe57 | ||
|
cc4e2244ed | ||
|
20dc23cded | ||
|
0d6f45092c | ||
|
8aa61ddfa2 | ||
|
9db818d539 | ||
|
3a37f301c5 | ||
|
3363078bb4 | ||
|
e7e7ec97bc | ||
|
bcdeb8a36a | ||
|
2b24d5cd09 |
@ -1172,43 +1172,45 @@ export class MoveImmunityStatStageChangeAbAttr extends MoveImmunityAbAttr {
|
||||
* @see {@linkcode applyPostDefend}
|
||||
*/
|
||||
export class ReverseDrainAbAttr extends PostDefendAbAttr {
|
||||
private attacker: Pokemon;
|
||||
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,
|
||||
_passive: boolean,
|
||||
simulated: boolean,
|
||||
attacker: Pokemon,
|
||||
_move: Move,
|
||||
_hitResult: HitResult,
|
||||
move: Move,
|
||||
_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[],
|
||||
): void {
|
||||
if (!simulated) {
|
||||
globalScene.phaseManager.queueMessage(
|
||||
i18next.t("abilityTriggers:reverseDrain", { pokemonNameWithAffix: getPokemonNameWithAffix(attacker) }),
|
||||
const damageAmount = move.getAttrs<"HitHealAttr">("HitHealAttr")[0].getHealAmount(attacker, pokemon);
|
||||
pokemon.turnData.damageTaken += damageAmount;
|
||||
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) });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2254,28 +2254,18 @@ export class HitHealAttr extends MoveEffectAttr {
|
||||
* @returns true if the function succeeds
|
||||
*/
|
||||
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 = "";
|
||||
const reverseDrain = target.hasAbilityWithAttr("ReverseDrainAbAttr", false);
|
||||
if (this.healStat !== null) {
|
||||
// Strength Sap formula
|
||||
healAmount = target.getEffectiveStat(this.healStat);
|
||||
message = i18next.t("battle:drainMessage", { pokemonName: getPokemonNameWithAffix(target) });
|
||||
} 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) });
|
||||
}
|
||||
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);
|
||||
return true;
|
||||
}
|
||||
@ -2294,6 +2284,10 @@ export class HitHealAttr extends MoveEffectAttr {
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -764,7 +764,7 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali
|
||||
readonly subLegendary: boolean;
|
||||
readonly legendary: boolean;
|
||||
readonly mythical: boolean;
|
||||
readonly species: string;
|
||||
public category: string;
|
||||
readonly growthRate: GrowthRate;
|
||||
/** The chance (as a decimal) for this Species to be male, or `null` for genderless species */
|
||||
readonly malePercent: number | null;
|
||||
@ -778,7 +778,7 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali
|
||||
subLegendary: boolean,
|
||||
legendary: boolean,
|
||||
mythical: boolean,
|
||||
species: string,
|
||||
category: string,
|
||||
type1: PokemonType,
|
||||
type2: PokemonType | null,
|
||||
height: number,
|
||||
@ -829,7 +829,7 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali
|
||||
this.subLegendary = subLegendary;
|
||||
this.legendary = legendary;
|
||||
this.mythical = mythical;
|
||||
this.species = species;
|
||||
this.category = category;
|
||||
this.growthRate = growthRate;
|
||||
this.malePercent = malePercent;
|
||||
this.genderDiffs = genderDiffs;
|
||||
@ -968,6 +968,7 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali
|
||||
|
||||
localize(): void {
|
||||
this.name = i18next.t(`pokemon:${SpeciesId[this.speciesId].toLowerCase()}`);
|
||||
this.category = i18next.t(`pokemonCategory:${SpeciesId[this.speciesId].toLowerCase()}_category`);
|
||||
}
|
||||
|
||||
getWildSpeciesForLevel(level: number, allowEvolving: boolean, isBoss: boolean, gameMode: GameMode): SpeciesId {
|
||||
|
@ -245,6 +245,7 @@ export async function initI18n(): Promise<void> {
|
||||
"pokeball",
|
||||
"pokedexUiHandler",
|
||||
"pokemon",
|
||||
"pokemonCategory",
|
||||
"pokemonEvolutions",
|
||||
"pokemonForm",
|
||||
"pokemonInfo",
|
||||
|
@ -174,6 +174,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
||||
private pokemonCaughtHatchedContainer: Phaser.GameObjects.Container;
|
||||
private pokemonCaughtCountText: Phaser.GameObjects.Text;
|
||||
private pokemonFormText: Phaser.GameObjects.Text;
|
||||
private pokemonCategoryText: Phaser.GameObjects.Text;
|
||||
private pokemonHatchedIcon: Phaser.GameObjects.Sprite;
|
||||
private pokemonHatchedCountText: Phaser.GameObjects.Text;
|
||||
private pokemonShinyIcons: Phaser.GameObjects.Sprite[];
|
||||
@ -409,6 +410,12 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
||||
this.pokemonFormText.setOrigin(0, 0);
|
||||
this.starterSelectContainer.add(this.pokemonFormText);
|
||||
|
||||
this.pokemonCategoryText = addTextObject(100, 18, "Category", TextStyle.WINDOW_ALT, {
|
||||
fontSize: "42px",
|
||||
});
|
||||
this.pokemonCategoryText.setOrigin(1, 0);
|
||||
this.starterSelectContainer.add(this.pokemonCategoryText);
|
||||
|
||||
this.pokemonCaughtHatchedContainer = globalScene.add.container(2, 25);
|
||||
this.pokemonCaughtHatchedContainer.setScale(0.5);
|
||||
this.starterSelectContainer.add(this.pokemonCaughtHatchedContainer);
|
||||
@ -2354,6 +2361,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
||||
this.pokemonCaughtHatchedContainer.setVisible(true);
|
||||
this.pokemonCandyContainer.setVisible(false);
|
||||
this.pokemonFormText.setVisible(false);
|
||||
this.pokemonCategoryText.setVisible(false);
|
||||
|
||||
const defaultDexAttr = globalScene.gameData.getSpeciesDefaultDexAttr(species, true, true);
|
||||
const props = globalScene.gameData.getSpeciesDexAttrProps(species, defaultDexAttr);
|
||||
@ -2382,6 +2390,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
||||
this.pokemonCaughtHatchedContainer.setVisible(false);
|
||||
this.pokemonCandyContainer.setVisible(false);
|
||||
this.pokemonFormText.setVisible(false);
|
||||
this.pokemonCategoryText.setVisible(false);
|
||||
|
||||
this.setSpeciesDetails(species!, {
|
||||
// TODO: is this bang correct?
|
||||
@ -2534,6 +2543,13 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
||||
this.pokemonNameText.setText(species ? "???" : "");
|
||||
}
|
||||
|
||||
// Setting the category
|
||||
if (isFormCaught) {
|
||||
this.pokemonCategoryText.setText(species.category);
|
||||
} else {
|
||||
this.pokemonCategoryText.setText("");
|
||||
}
|
||||
|
||||
// Setting tint of the sprite
|
||||
if (isFormCaught) {
|
||||
this.species.loadAssets(female!, formIndex, shiny, variant as Variant, true).then(() => {
|
||||
|
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