Berry juice uses a number parameter again, allowing to convert from old saves without a migrator

This commit is contained in:
Wlowscha 2025-06-21 11:55:06 +02:00
parent f955a55493
commit 421f9588d5
No known key found for this signature in database
GPG Key ID: 3C8F1AD330565D04
3 changed files with 20 additions and 21 deletions

View File

@ -378,7 +378,7 @@ export function applyHealToPokemon(pokemon: PlayerPokemon, heal: number) {
export async function modifyPlayerPokemonBST(pokemon: PlayerPokemon, good: boolean) {
const modType = modifierTypes
.MYSTERY_ENCOUNTER_SHUCKLE_JUICE()
.generateType(globalScene.getPlayerParty(), [good])
.generateType(globalScene.getPlayerParty(), [good ? 10 : -15])
?.withIdFromFunc(modifierTypes.MYSTERY_ENCOUNTER_SHUCKLE_JUICE);
const modifier = modType?.newModifier(pokemon);
if (modifier) {

View File

@ -967,27 +967,27 @@ export class PokemonBaseStatTotalModifierType
extends PokemonHeldItemModifierType
implements GeneratedPersistentModifierType
{
private readonly good: boolean;
private readonly statModifier: 10 | -15;
constructor(good: boolean) {
constructor(statModifier: 10 | -15) {
super(
good
? "modifierType:ModifierType.MYSTERY_ENCOUNTER_SHUCKLE_JUICE_GOOD.name"
: "modifierType:ModifierType.MYSTERY_ENCOUNTER_SHUCKLE_JUICE_BAD.name",
good ? "berry_juice_good" : "berry_juice_bad",
(_type, args) => new PokemonBaseStatTotalModifier(this, (args[0] as Pokemon).id, this.good),
statModifier > 0
? "modifierType:ModifierType.MYSTERY_ENCOUNTER_SHUCKLE_JUICE_GOOD"
: "modifierType:ModifierType.MYSTERY_ENCOUNTER_SHUCKLE_JUICE_BAD",
statModifier > 0 ? "berry_juice_good" : "berry_juice_bad",
(_type, args) => new PokemonBaseStatTotalModifier(this, (args[0] as Pokemon).id, statModifier),
);
this.good = good;
this.statModifier = statModifier;
}
override getDescription(): string {
return this.good
return this.statModifier > 0
? i18next.t("modifierType:ModifierType.MYSTERY_ENCOUNTER_SHUCKLE_JUICE_GOOD.description")
: i18next.t("modifierType:ModifierType.MYSTERY_ENCOUNTER_SHUCKLE_JUICE_BAD.description");
}
public getPregenArgs(): any[] {
return [this.good];
return [this.statModifier];
}
}
@ -2291,9 +2291,9 @@ const modifierTypeInitObj = Object.freeze({
MYSTERY_ENCOUNTER_SHUCKLE_JUICE: () =>
new ModifierTypeGenerator((_party: Pokemon[], pregenArgs?: any[]) => {
if (pregenArgs) {
return new PokemonBaseStatTotalModifierType(pregenArgs[0] as boolean);
return new PokemonBaseStatTotalModifierType(pregenArgs[0] as 10 | -15);
}
return new PokemonBaseStatTotalModifierType(true);
return new PokemonBaseStatTotalModifierType(10);
}),
MYSTERY_ENCOUNTER_OLD_GATEAU: () =>
new PokemonHeldItemModifierType(

View File

@ -952,23 +952,23 @@ export class EvoTrackerModifier extends PokemonHeldItemModifier {
export class PokemonBaseStatTotalModifier extends PokemonHeldItemModifier {
public override type: PokemonBaseStatTotalModifierType;
public isTransferable = false;
public good: boolean;
public statModifier: 10 | -15;
constructor(type: PokemonBaseStatTotalModifierType, pokemonId: number, good: boolean, stackCount?: number) {
constructor(type: PokemonBaseStatTotalModifierType, pokemonId: number, statModifier: 10 | -15, stackCount?: number) {
super(type, pokemonId, stackCount);
this.good = good;
this.statModifier = statModifier;
}
override matchType(modifier: Modifier): boolean {
return modifier instanceof PokemonBaseStatTotalModifier && this.good === modifier.good;
return modifier instanceof PokemonBaseStatTotalModifier && this.statModifier === modifier.statModifier;
}
override clone(): PersistentModifier {
return new PokemonBaseStatTotalModifier(this.type, this.pokemonId, this.good, this.stackCount);
return new PokemonBaseStatTotalModifier(this.type, this.pokemonId, this.statModifier, this.stackCount);
}
override getArgs(): any[] {
return super.getArgs().concat(this.good);
return super.getArgs().concat(this.statModifier);
}
/**
@ -988,11 +988,10 @@ export class PokemonBaseStatTotalModifier extends PokemonHeldItemModifier {
* @returns always `true`
*/
override apply(_pokemon: Pokemon, baseStats: number[]): boolean {
const statModifier = this.good ? 10 : -15;
// Modifies the passed in baseStats[] array
baseStats.forEach((v, i) => {
// HP is affected by half as much as other stats
const newVal = i === 0 ? Math.floor(v + statModifier / 2) : Math.floor(v + statModifier);
const newVal = i === 0 ? Math.floor(v + this.statModifier / 2) : Math.floor(v + this.statModifier);
baseStats[i] = Math.min(Math.max(newVal, 1), 999999);
});