Compare commits

...

9 Commits

Author SHA1 Message Date
iTunesko
91d4592756
Merge cbeea82219 into 43aa772603 2025-06-20 01:06:34 +01: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
NightKev
cbeea82219
Fix remaining merge issues 2025-06-08 04:44:21 -07:00
NightKev
07e14ac67c
Fix missed merge conflicts 2025-06-08 04:38:15 -07:00
NightKev
4a4fe185f4
Merge branch 'beta' into ability_check_fail_clowning_encounter 2025-06-08 04:33:58 -07:00
NightKev
04bb1c4c09
Fix merge issues 2025-06-08 04:33:10 -07:00
iTunesko
da1aa0d985
Merge branch 'beta' into ability_check_fail_clowning_encounter 2025-06-07 19:04:31 +01:00
Inês Antunes
b82d4af75f [Fix]: Updated applyAbilityOverrideToPokemon in other files and 'repeated ability message' with a new i18n key 2025-06-07 18:49:27 +01:00
Inês Antunes
b072f91649 [BUG] Fixes #5288 Clowning Around doesn’t check if Pokemon
already  has the ability

When offering the same ability a Pokemon
already has, a menu should
now appear informing the user. The user can then choose a different
Pokemon or proceed to give the same ability anyway.
2025-05-11 21:47:55 +01:00
7 changed files with 132 additions and 14 deletions

View File

@ -468,14 +468,52 @@ function displayYesNoOptions(resolve) {
globalScene.ui.setModeWithoutClear(UiMode.OPTION_SELECT, config, null, true); globalScene.ui.setModeWithoutClear(UiMode.OPTION_SELECT, config, null, true);
} }
function handleRepeatedAbility(resolve, pokemon: PlayerPokemon, ability: AbilityId) {
showEncounterText(`${namespace}:option.1.repeated_ability`);
const fullOptions = [
{
label: i18next.t("menu:yes"),
handler: () => {
applyAbilityOverrideToPokemon(pokemon, ability, true);
globalScene.ui.setMode(UiMode.MESSAGE).then(() => resolve(true));
return true;
},
},
{
label: i18next.t("menu:no"),
handler: () => {
onYesAbilitySwap(resolve);
return true;
},
},
];
const config: OptionSelectConfig = {
options: fullOptions,
maxOptions: 7,
yOffset: 0,
};
globalScene.ui.setModeWithoutClear(UiMode.OPTION_SELECT, config, null, true);
}
function onYesAbilitySwap(resolve) { function onYesAbilitySwap(resolve) {
const onPokemonSelected = (pokemon: PlayerPokemon) => { const onPokemonSelected = (pokemon: PlayerPokemon) => {
// Do ability swap // Do ability swap
const encounter = globalScene.currentBattle.mysteryEncounter!; const encounter = globalScene.currentBattle.mysteryEncounter!;
applyAbilityOverrideToPokemon(pokemon, encounter.misc.ability); // Choose a random ability, to give a pokemon on the end of a battle
const randomAbility = encounter.misc.ability;
const newAbility = applyAbilityOverrideToPokemon(pokemon, randomAbility, false);
encounter.setDialogueToken("chosenPokemon", pokemon.getNameToRender()); encounter.setDialogueToken("chosenPokemon", pokemon.getNameToRender());
globalScene.ui.setMode(UiMode.MESSAGE).then(() => resolve(true));
globalScene.ui.setMode(UiMode.MESSAGE).then(() => {
// if Pokemon already has the same Ability
if (!newAbility) {
handleRepeatedAbility(resolve, pokemon, randomAbility);
} else {
resolve(true);
}
});
}; };
const onPokemonNotSelected = () => { const onPokemonNotSelected = () => {

View File

@ -250,7 +250,7 @@ export const FieryFalloutEncounter: MysteryEncounter = MysteryEncounterBuilder.w
queueEncounterMessage(`${namespace}:option.2.target_burned`); queueEncounterMessage(`${namespace}:option.2.target_burned`);
// Also permanently change the burned Pokemon's ability to Heatproof // Also permanently change the burned Pokemon's ability to Heatproof
applyAbilityOverrideToPokemon(chosenPokemon, AbilityId.HEATPROOF); applyAbilityOverrideToPokemon(chosenPokemon, AbilityId.HEATPROOF, false);
} }
} }

View File

@ -1022,14 +1022,23 @@ export function isPokemonValidForEncounterOptionSelection(
/** /**
* Permanently overrides the ability (not passive) of a pokemon. * Permanently overrides the ability (not passive) of a pokemon.
* If the pokemon is a fusion, instead overrides the fused pokemon's ability. * If the pokemon is a fusion, instead overrides the fused pokemon's ability.
* @param ability
* @param pokemon
* @param flagAcceptAbility
*/ */
export function applyAbilityOverrideToPokemon(pokemon: Pokemon, ability: AbilityId) {
if (pokemon.isFusion()) { export function applyAbilityOverrideToPokemon(pokemon: Pokemon, ability: AbilityId, flagAcceptAbility: boolean) {
if (!pokemon.fusionCustomPokemonData) { const isFusion = pokemon.isFusion();
pokemon.fusionCustomPokemonData = new CustomPokemonData(); const data = isFusion
} ? (pokemon.fusionCustomPokemonData ??= new CustomPokemonData())
pokemon.fusionCustomPokemonData.ability = ability; : (pokemon.customPokemonData ??= new CustomPokemonData());
} else {
pokemon.customPokemonData.ability = ability; const shouldOverride = data.ability !== ability || flagAcceptAbility;
if (shouldOverride) {
data.ability = ability;
return true;
} }
return false;
} }

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

@ -37,6 +37,7 @@ import { CommandPhase } from "#app/phases/command-phase";
import { MovePhase } from "#app/phases/move-phase"; import { MovePhase } from "#app/phases/move-phase";
import { SelectModifierPhase } from "#app/phases/select-modifier-phase"; import { SelectModifierPhase } from "#app/phases/select-modifier-phase";
import { NewBattlePhase } from "#app/phases/new-battle-phase"; import { NewBattlePhase } from "#app/phases/new-battle-phase";
import { allAbilities } from "#app/data/data-lists";
const namespace = "mysteryEncounters/clowningAround"; const namespace = "mysteryEncounters/clowningAround";
const defaultParty = [SpeciesId.LAPRAS, SpeciesId.GENGAR, SpeciesId.ABRA]; const defaultParty = [SpeciesId.LAPRAS, SpeciesId.GENGAR, SpeciesId.ABRA];
@ -233,6 +234,58 @@ describe("Clowning Around - Mystery Encounter", () => {
const leadPokemon = scene.getPlayerParty()[0]; const leadPokemon = scene.getPlayerParty()[0];
expect(leadPokemon.customPokemonData?.ability).toBe(abilityToTrain); expect(leadPokemon.customPokemonData?.ability).toBe(abilityToTrain);
}); });
it("should let the player know their pokemon already has the ability and accept it", async () => {
await game.runToMysteryEncounter(MysteryEncounterType.CLOWNING_AROUND, defaultParty);
await runMysteryEncounterToEnd(game, 1, undefined, true);
await skipBattleRunMysteryEncounterRewardsPhase(game);
await game.phaseInterceptor.to(SelectModifierPhase, false);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(SelectModifierPhase.name);
await game.phaseInterceptor.run(SelectModifierPhase);
const leadPokemon = scene.getPlayerParty()[0];
// offer Prankster abiliy for winning the battle
const abilityToTrain = AbilityId.PRANKSTER;
game.onNextPrompt("PostMysteryEncounterPhase", UiMode.MESSAGE, () => {
game.scene.ui.getHandler().processInput(Button.ACTION);
});
// Give fto the first Pokemon the Prankster ability
vi.spyOn(leadPokemon, "getAbility").mockReturnValue(allAbilities[AbilityId.PRANKSTER]);
// Run to ability train option selection
const optionSelectUiHandler = game.scene.ui.handlers[UiMode.OPTION_SELECT] as OptionSelectUiHandler;
vi.spyOn(optionSelectUiHandler, "show");
const partyUiHandler = game.scene.ui.handlers[UiMode.PARTY] as PartyUiHandler;
vi.spyOn(partyUiHandler, "show");
const optionSelectUiHandlerRepeatedAbility = game.scene.ui.handlers[
UiMode.OPTION_SELECT
] as OptionSelectUiHandler;
vi.spyOn(optionSelectUiHandlerRepeatedAbility, "show");
game.endPhase();
await game.phaseInterceptor.to(PostMysteryEncounterPhase);
expect(scene.phaseManager.getCurrentPhase()?.constructor.name).toBe(PostMysteryEncounterPhase.name);
// Wait for Yes/No confirmation to appear -> accepting the Ability
await vi.waitFor(() => expect(optionSelectUiHandler.show).toHaveBeenCalled());
// Select "Yes" on train ability
optionSelectUiHandler.processInput(Button.ACTION);
// Select first pokemon in party to train
await vi.waitFor(() => expect(partyUiHandler.show).toHaveBeenCalled());
partyUiHandler.processInput(Button.ACTION);
// Click "Select" on Pokemon
partyUiHandler.processInput(Button.ACTION);
// Wait for Yes/No confirmation to appear -> Accepting the Ability, besides being repeated
await vi.waitFor(() => expect(optionSelectUiHandlerRepeatedAbility.show).toHaveBeenCalled());
// Select "Yes" on train the same ability as before
optionSelectUiHandlerRepeatedAbility.processInput(Button.ACTION);
// Stop next battle before it runs
await game.phaseInterceptor.to(NewBattlePhase, false);
expect(leadPokemon.getAbility().id).toBe(abilityToTrain);
});
}); });
describe("Option 2 - Remain Unprovoked", () => { describe("Option 2 - Remain Unprovoked", () => {