mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-20 06:19:29 +02:00
[ME] Fix GTS Wonder Trade shiny not giving luck
This commit is contained in:
parent
1f6dab069d
commit
9eed724b4c
@ -12,8 +12,7 @@ import PokemonSpecies, { allSpecies, getPokemonSpecies } from "#app/data/pokemon
|
||||
import { getTypeRgb } from "#app/data/type";
|
||||
import { MysteryEncounterOptionBuilder } from "#app/data/mystery-encounters/mystery-encounter-option";
|
||||
import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode";
|
||||
import * as Utils from "#app/utils";
|
||||
import { IntegerHolder, isNullOrUndefined, randInt, randSeedInt, randSeedShuffle } from "#app/utils";
|
||||
import { NumberHolder, isNullOrUndefined, randInt, randSeedInt, randSeedShuffle } from "#app/utils";
|
||||
import Pokemon, { EnemyPokemon, PlayerPokemon, PokemonMove } from "#app/field/pokemon";
|
||||
import { HiddenAbilityRateBoosterModifier, PokemonFormChangeItemModifier, PokemonHeldItemModifier, ShinyRateBoosterModifier, SpeciesStatBoosterModifier } from "#app/modifier/modifier";
|
||||
import { OptionSelectItem } from "#app/ui/abstact-option-select-ui-handler";
|
||||
@ -229,7 +228,7 @@ export const GlobalTradeSystemEncounter: MysteryEncounter =
|
||||
const tradePokemon = new EnemyPokemon(scene, randomTradeOption, pokemon.level, TrainerSlot.NONE, false);
|
||||
// Extra shiny roll at 1/128 odds (boosted by events and charms)
|
||||
if (!tradePokemon.shiny) {
|
||||
const shinyThreshold = new Utils.IntegerHolder(WONDER_TRADE_SHINY_CHANCE);
|
||||
const shinyThreshold = new NumberHolder(WONDER_TRADE_SHINY_CHANCE);
|
||||
if (scene.eventManager.isEventActive()) {
|
||||
shinyThreshold.value *= scene.eventManager.getShinyMultiplier();
|
||||
}
|
||||
@ -246,7 +245,7 @@ export const GlobalTradeSystemEncounter: MysteryEncounter =
|
||||
const hiddenIndex = tradePokemon.species.ability2 ? 2 : 1;
|
||||
if (tradePokemon.species.abilityHidden) {
|
||||
if (tradePokemon.abilityIndex < hiddenIndex) {
|
||||
const hiddenAbilityChance = new IntegerHolder(64);
|
||||
const hiddenAbilityChance = new NumberHolder(64);
|
||||
scene.applyModifiers(HiddenAbilityRateBoosterModifier, true, hiddenAbilityChance);
|
||||
|
||||
const hasHiddenAbility = !randSeedInt(hiddenAbilityChance.value);
|
||||
|
@ -1979,6 +1979,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
this.shiny = randSeedInt(65536) < shinyThreshold.value;
|
||||
|
||||
if (this.shiny) {
|
||||
this.variant = this.generateShinyVariant();
|
||||
this.luck = this.variant + 1 + (this.fusionShiny ? this.fusionVariant + 1 : 0);
|
||||
this.initShinySparkle();
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@ import { SelectModifierPhase } from "#app/phases/select-modifier-phase";
|
||||
import { Mode } from "#app/ui/ui";
|
||||
import ModifierSelectUiHandler from "#app/ui/modifier-select-ui-handler";
|
||||
import { ModifierTier } from "#app/modifier/modifier-tier";
|
||||
import * as Utils from "#app/utils";
|
||||
|
||||
const namespace = "mysteryEncounters/globalTradeSystem";
|
||||
const defaultParty = [ Species.LAPRAS, Species.GENGAR, Species.ABRA ];
|
||||
@ -176,6 +177,23 @@ describe("Global Trade System - Mystery Encounter", () => {
|
||||
expect(defaultParty.includes(speciesAfter!)).toBeFalsy();
|
||||
});
|
||||
|
||||
it("Should roll for shiny twice, with random variant and associated luck", async () => {
|
||||
// This ensures that the first shiny roll gets ignored, to test the ME rerolling for shiny
|
||||
game.override.enemyShiny(false);
|
||||
|
||||
await game.runToMysteryEncounter(MysteryEncounterType.GLOBAL_TRADE_SYSTEM, defaultParty);
|
||||
|
||||
vi.spyOn(Utils, "randSeedInt").mockReturnValue(1); // force shiny on reroll
|
||||
|
||||
await runMysteryEncounterToEnd(game, 2, { pokemonNo: 1 });
|
||||
|
||||
const receivedPokemon = scene.getPlayerParty().at(-1)!;
|
||||
|
||||
expect(receivedPokemon.shiny).toBeTruthy();
|
||||
expect(receivedPokemon.variant).toBeDefined();
|
||||
expect(receivedPokemon.luck).toBe(receivedPokemon.variant + 1);
|
||||
});
|
||||
|
||||
it("should leave encounter without battle", async () => {
|
||||
const leaveEncounterWithoutBattleSpy = vi.spyOn(EncounterPhaseUtils, "leaveEncounterWithoutBattle");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user