Compare commits

...

16 Commits

Author SHA1 Message Date
Dean
828083a74e
Merge 458faf90eb into 43aa772603 2025-06-19 18:13:00 -06:00
Madmadness65
43aa772603
[UI/UX] Add Pokémon category flavor text to Pokédex (#5957)
* Add Pokémon category flavor text to Pokédex

* Append `_category` to locale entry
2025-06-20 00:04:57 +00:00
Dean
458faf90eb Move checks to canApply 2025-06-17 19:21:46 -07:00
Dean
151c308d63 Fix test 2025-06-17 11:18:01 -07:00
Dean
3551f69b0e Fix hithealattr apply method 2025-06-17 10:50:34 -07:00
Dean
6c0d6dbe57 Merge branch 'beta' into suppress-ooze 2025-06-17 10:50:03 -07:00
Dean
cc4e2244ed Fix liquid ooze test 2025-04-23 14:45:52 -07:00
Dean
20dc23cded Merge branch 'beta' into suppress-ooze 2025-04-23 14:41:03 -07:00
Dean
0d6f45092c
Kev fixes
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
2025-04-08 00:42:57 -07:00
Sirz Benjie
8aa61ddfa2
Merge branch 'beta' into suppress-ooze 2025-04-04 17:09:46 -05:00
Dean
9db818d539
Merge branch 'beta' into suppress-ooze 2025-03-29 14:24:09 -07:00
Dean
3a37f301c5 Unchange move effect phase 2025-03-18 12:51:42 -07:00
Dean
3363078bb4 Add test 2025-03-18 12:43:10 -07:00
Dean
e7e7ec97bc Fix using defender instead of attacker when applying magic guard 2025-03-18 12:41:33 -07:00
Dean
bcdeb8a36a Rewrite move/ability effects 2025-03-18 12:33:46 -07:00
Dean
2b24d5cd09 Fix applying even when suppressed 2025-03-18 11:45:53 -07:00
6 changed files with 125 additions and 49 deletions

View File

@ -1172,43 +1172,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) });
} }
} }

View File

@ -2254,28 +2254,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;
} }
@ -2294,6 +2284,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);
}
} }
/** /**

View File

@ -764,7 +764,7 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali
readonly subLegendary: boolean; readonly subLegendary: boolean;
readonly legendary: boolean; readonly legendary: boolean;
readonly mythical: boolean; readonly mythical: boolean;
readonly species: string; public category: string;
readonly growthRate: GrowthRate; readonly growthRate: GrowthRate;
/** The chance (as a decimal) for this Species to be male, or `null` for genderless species */ /** The chance (as a decimal) for this Species to be male, or `null` for genderless species */
readonly malePercent: number | null; readonly malePercent: number | null;
@ -778,7 +778,7 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali
subLegendary: boolean, subLegendary: boolean,
legendary: boolean, legendary: boolean,
mythical: boolean, mythical: boolean,
species: string, category: string,
type1: PokemonType, type1: PokemonType,
type2: PokemonType | null, type2: PokemonType | null,
height: number, height: number,
@ -829,7 +829,7 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali
this.subLegendary = subLegendary; this.subLegendary = subLegendary;
this.legendary = legendary; this.legendary = legendary;
this.mythical = mythical; this.mythical = mythical;
this.species = species; this.category = category;
this.growthRate = growthRate; this.growthRate = growthRate;
this.malePercent = malePercent; this.malePercent = malePercent;
this.genderDiffs = genderDiffs; this.genderDiffs = genderDiffs;
@ -968,6 +968,7 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali
localize(): void { localize(): void {
this.name = i18next.t(`pokemon:${SpeciesId[this.speciesId].toLowerCase()}`); 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 { getWildSpeciesForLevel(level: number, allowEvolving: boolean, isBoss: boolean, gameMode: GameMode): SpeciesId {

View File

@ -245,6 +245,7 @@ export async function initI18n(): Promise<void> {
"pokeball", "pokeball",
"pokedexUiHandler", "pokedexUiHandler",
"pokemon", "pokemon",
"pokemonCategory",
"pokemonEvolutions", "pokemonEvolutions",
"pokemonForm", "pokemonForm",
"pokemonInfo", "pokemonInfo",

View File

@ -174,6 +174,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
private pokemonCaughtHatchedContainer: Phaser.GameObjects.Container; private pokemonCaughtHatchedContainer: Phaser.GameObjects.Container;
private pokemonCaughtCountText: Phaser.GameObjects.Text; private pokemonCaughtCountText: Phaser.GameObjects.Text;
private pokemonFormText: Phaser.GameObjects.Text; private pokemonFormText: Phaser.GameObjects.Text;
private pokemonCategoryText: Phaser.GameObjects.Text;
private pokemonHatchedIcon: Phaser.GameObjects.Sprite; private pokemonHatchedIcon: Phaser.GameObjects.Sprite;
private pokemonHatchedCountText: Phaser.GameObjects.Text; private pokemonHatchedCountText: Phaser.GameObjects.Text;
private pokemonShinyIcons: Phaser.GameObjects.Sprite[]; private pokemonShinyIcons: Phaser.GameObjects.Sprite[];
@ -409,6 +410,12 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
this.pokemonFormText.setOrigin(0, 0); this.pokemonFormText.setOrigin(0, 0);
this.starterSelectContainer.add(this.pokemonFormText); 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 = globalScene.add.container(2, 25);
this.pokemonCaughtHatchedContainer.setScale(0.5); this.pokemonCaughtHatchedContainer.setScale(0.5);
this.starterSelectContainer.add(this.pokemonCaughtHatchedContainer); this.starterSelectContainer.add(this.pokemonCaughtHatchedContainer);
@ -2354,6 +2361,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
this.pokemonCaughtHatchedContainer.setVisible(true); this.pokemonCaughtHatchedContainer.setVisible(true);
this.pokemonCandyContainer.setVisible(false); this.pokemonCandyContainer.setVisible(false);
this.pokemonFormText.setVisible(false); this.pokemonFormText.setVisible(false);
this.pokemonCategoryText.setVisible(false);
const defaultDexAttr = globalScene.gameData.getSpeciesDefaultDexAttr(species, true, true); const defaultDexAttr = globalScene.gameData.getSpeciesDefaultDexAttr(species, true, true);
const props = globalScene.gameData.getSpeciesDexAttrProps(species, defaultDexAttr); const props = globalScene.gameData.getSpeciesDexAttrProps(species, defaultDexAttr);
@ -2382,6 +2390,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
this.pokemonCaughtHatchedContainer.setVisible(false); this.pokemonCaughtHatchedContainer.setVisible(false);
this.pokemonCandyContainer.setVisible(false); this.pokemonCandyContainer.setVisible(false);
this.pokemonFormText.setVisible(false); this.pokemonFormText.setVisible(false);
this.pokemonCategoryText.setVisible(false);
this.setSpeciesDetails(species!, { this.setSpeciesDetails(species!, {
// TODO: is this bang correct? // TODO: is this bang correct?
@ -2534,6 +2543,13 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
this.pokemonNameText.setText(species ? "???" : ""); this.pokemonNameText.setText(species ? "???" : "");
} }
// Setting the category
if (isFormCaught) {
this.pokemonCategoryText.setText(species.category);
} else {
this.pokemonCategoryText.setText("");
}
// Setting tint of the sprite // Setting tint of the sprite
if (isFormCaught) { if (isFormCaught) {
this.species.loadAssets(female!, formIndex, shiny, variant as Variant, true).then(() => { this.species.loadAssets(female!, formIndex, shiny, variant as Variant, true).then(() => {

View 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);
});
});