mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-03 23:12:20 +02:00
Compare commits
9 Commits
6ca868d0b9
...
91d4592756
Author | SHA1 | Date | |
---|---|---|---|
|
91d4592756 | ||
|
43aa772603 | ||
|
cbeea82219 | ||
|
07e14ac67c | ||
|
4a4fe185f4 | ||
|
04bb1c4c09 | ||
|
da1aa0d985 | ||
|
b82d4af75f | ||
|
b072f91649 |
@ -468,14 +468,52 @@ function displayYesNoOptions(resolve) {
|
||||
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) {
|
||||
const onPokemonSelected = (pokemon: PlayerPokemon) => {
|
||||
// Do ability swap
|
||||
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());
|
||||
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 = () => {
|
||||
|
@ -250,7 +250,7 @@ export const FieryFalloutEncounter: MysteryEncounter = MysteryEncounterBuilder.w
|
||||
queueEncounterMessage(`${namespace}:option.2.target_burned`);
|
||||
|
||||
// Also permanently change the burned Pokemon's ability to Heatproof
|
||||
applyAbilityOverrideToPokemon(chosenPokemon, AbilityId.HEATPROOF);
|
||||
applyAbilityOverrideToPokemon(chosenPokemon, AbilityId.HEATPROOF, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1022,14 +1022,23 @@ export function isPokemonValidForEncounterOptionSelection(
|
||||
/**
|
||||
* Permanently overrides the ability (not passive) of a pokemon.
|
||||
* 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()) {
|
||||
if (!pokemon.fusionCustomPokemonData) {
|
||||
pokemon.fusionCustomPokemonData = new CustomPokemonData();
|
||||
}
|
||||
pokemon.fusionCustomPokemonData.ability = ability;
|
||||
} else {
|
||||
pokemon.customPokemonData.ability = ability;
|
||||
|
||||
export function applyAbilityOverrideToPokemon(pokemon: Pokemon, ability: AbilityId, flagAcceptAbility: boolean) {
|
||||
const isFusion = pokemon.isFusion();
|
||||
const data = isFusion
|
||||
? (pokemon.fusionCustomPokemonData ??= new CustomPokemonData())
|
||||
: (pokemon.customPokemonData ??= new CustomPokemonData());
|
||||
|
||||
const shouldOverride = data.ability !== ability || flagAcceptAbility;
|
||||
|
||||
if (shouldOverride) {
|
||||
data.ability = ability;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -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(() => {
|
||||
|
@ -37,6 +37,7 @@ import { CommandPhase } from "#app/phases/command-phase";
|
||||
import { MovePhase } from "#app/phases/move-phase";
|
||||
import { SelectModifierPhase } from "#app/phases/select-modifier-phase";
|
||||
import { NewBattlePhase } from "#app/phases/new-battle-phase";
|
||||
import { allAbilities } from "#app/data/data-lists";
|
||||
|
||||
const namespace = "mysteryEncounters/clowningAround";
|
||||
const defaultParty = [SpeciesId.LAPRAS, SpeciesId.GENGAR, SpeciesId.ABRA];
|
||||
@ -233,6 +234,58 @@ describe("Clowning Around - Mystery Encounter", () => {
|
||||
const leadPokemon = scene.getPlayerParty()[0];
|
||||
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", () => {
|
||||
|
Loading…
Reference in New Issue
Block a user