Refactored items and respective MEs

This commit is contained in:
Wlowscha 2025-06-20 23:58:02 +02:00
parent 9f67e06279
commit 23932b1bd9
No known key found for this signature in database
GPG Key ID: 3C8F1AD330565D04
5 changed files with 57 additions and 122 deletions

View File

@ -171,11 +171,11 @@ export const TheStrongStuffEncounter: MysteryEncounter = MysteryEncounterBuilder
sortedParty.forEach((pokemon, index) => {
if (index < 2) {
// -15 to the two highest BST mons
modifyPlayerPokemonBST(pokemon, -HIGH_BST_REDUCTION_VALUE);
modifyPlayerPokemonBST(pokemon, false);
encounter.setDialogueToken("highBstPokemon" + (index + 1), pokemon.getNameToRender());
} else {
// +10 for the rest
modifyPlayerPokemonBST(pokemon, BST_INCREASE_VALUE);
modifyPlayerPokemonBST(pokemon, true);
}
});

View File

@ -33,7 +33,6 @@ import {
TransformationScreenPosition,
} from "#app/data/mystery-encounters/utils/encounter-transformation-sequence";
import { getLevelTotalExp } from "#app/data/exp";
import { Stat } from "#enums/stat";
import { Challenges } from "#enums/challenges";
import { ModifierTier } from "#enums/modifier-tier";
import { PlayerGender } from "#enums/player-gender";
@ -104,7 +103,7 @@ const EXCLUDED_TRANSFORMATION_SPECIES = [
const SUPER_LEGENDARY_BST_THRESHOLD = 600;
const NON_LEGENDARY_BST_THRESHOLD = 570;
const OLD_GATEAU_STATS_UP = 20;
//const OLD_GATEAU_STATS_UP = 20;
/** 0-100 */
const PERCENT_LEVEL_LOSS_ON_REFUSE = 10;
@ -275,12 +274,8 @@ export const WeirdDreamEncounter: MysteryEncounter = MysteryEncounterBuilder.wit
}
// Any pokemon that is below 570 BST gets +20 permanent BST to 3 stats
if (shouldGetOldGateau(newPokemon)) {
const stats = getOldGateauBoostedStats(newPokemon);
newPokemonHeldItemConfigs.push({
modifier: generateModifierType(modifierTypes.MYSTERY_ENCOUNTER_OLD_GATEAU, [
OLD_GATEAU_STATS_UP,
stats,
]) as PokemonHeldItemModifierType,
modifier: generateModifierType(modifierTypes.MYSTERY_ENCOUNTER_OLD_GATEAU) as PokemonHeldItemModifierType,
stackCount: 1,
isTransferable: false,
});
@ -461,11 +456,7 @@ async function doNewTeamPostProcess(transformations: PokemonTransformation[]) {
}
// Any pokemon that is below 570 BST gets +20 permanent BST to 3 stats
if (shouldGetOldGateau(newPokemon)) {
const stats = getOldGateauBoostedStats(newPokemon);
const modType = modifierTypes
.MYSTERY_ENCOUNTER_OLD_GATEAU()
.generateType(globalScene.getPlayerParty(), [OLD_GATEAU_STATS_UP, stats])
?.withIdFromFunc(modifierTypes.MYSTERY_ENCOUNTER_OLD_GATEAU);
const modType = modifierTypes.MYSTERY_ENCOUNTER_OLD_GATEAU();
const modifier = modType?.newModifier(newPokemon);
if (modifier) {
globalScene.addModifier(modifier, false, false, false, true);
@ -616,22 +607,6 @@ function shouldGetOldGateau(pokemon: Pokemon): boolean {
return pokemon.getSpeciesForm().getBaseStatTotal() < NON_LEGENDARY_BST_THRESHOLD;
}
/**
* Get the lowest of HP/Spd, lowest of Atk/SpAtk, and lowest of Def/SpDef
* @returns Array of 3 {@linkcode Stat}s to boost
*/
function getOldGateauBoostedStats(pokemon: Pokemon): Stat[] {
const stats: Stat[] = [];
const baseStats = pokemon.getSpeciesForm().baseStats.slice(0);
// HP or Speed
stats.push(baseStats[Stat.HP] < baseStats[Stat.SPD] ? Stat.HP : Stat.SPD);
// Attack or SpAtk
stats.push(baseStats[Stat.ATK] < baseStats[Stat.SPATK] ? Stat.ATK : Stat.SPATK);
// Def or SpDef
stats.push(baseStats[Stat.DEF] < baseStats[Stat.SPDEF] ? Stat.DEF : Stat.SPDEF);
return stats;
}
function getTransformedSpecies(
originalBst: number,
bstSearchRange: [number, number],

View File

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

View File

@ -967,67 +967,27 @@ export class PokemonBaseStatTotalModifierType
extends PokemonHeldItemModifierType
implements GeneratedPersistentModifierType
{
private readonly statModifier: number;
private readonly good: boolean;
constructor(statModifier: number) {
constructor(good: boolean) {
super(
"modifierType:ModifierType.MYSTERY_ENCOUNTER_SHUCKLE_JUICE",
"berry_juice",
(_type, args) => new PokemonBaseStatTotalModifier(this, (args[0] as Pokemon).id, this.statModifier),
good
? "modifierType:ModifierType.MYSTERY_ENCOUNTER_SHUCKLE_JUICE_GOOD"
: "modifierType:ModifierType.MYSTERY_ENCOUNTER_SHUCKLE_JUICE_BAD",
good ? "good_berry_juice" : "bad_berry_juice",
(_type, args) => new PokemonBaseStatTotalModifier(this, (args[0] as Pokemon).id, this.good),
);
this.statModifier = statModifier;
this.good = good;
}
override getDescription(): string {
return i18next.t("modifierType:ModifierType.PokemonBaseStatTotalModifierType.description", {
increaseDecrease: i18next.t(
this.statModifier >= 0
? "modifierType:ModifierType.PokemonBaseStatTotalModifierType.extra.increase"
: "modifierType:ModifierType.PokemonBaseStatTotalModifierType.extra.decrease",
),
blessCurse: i18next.t(
this.statModifier >= 0
? "modifierType:ModifierType.PokemonBaseStatTotalModifierType.extra.blessed"
: "modifierType:ModifierType.PokemonBaseStatTotalModifierType.extra.cursed",
),
statValue: this.statModifier,
});
return this.good
? i18next.t("modifierType:ModifierType.PokemonBaseStatTotalModifierType.description.good")
: i18next.t("modifierType:ModifierType.PokemonBaseStatTotalModifierType.description.bad");
}
public getPregenArgs(): any[] {
return [this.statModifier];
}
}
/**
* Old Gateau item
*/
export class PokemonBaseStatFlatModifierType
extends PokemonHeldItemModifierType
implements GeneratedPersistentModifierType
{
private readonly statModifier: number;
private readonly stats: Stat[];
constructor(statModifier: number, stats: Stat[]) {
super(
"modifierType:ModifierType.MYSTERY_ENCOUNTER_OLD_GATEAU",
"old_gateau",
(_type, args) => new PokemonBaseStatFlatModifier(this, (args[0] as Pokemon).id, this.statModifier, this.stats),
);
this.statModifier = statModifier;
this.stats = stats;
}
override getDescription(): string {
return i18next.t("modifierType:ModifierType.PokemonBaseStatFlatModifierType.description", {
stats: this.stats.map(stat => i18next.t(getStatKey(stat))).join("/"),
statValue: this.statModifier,
});
}
public getPregenArgs(): any[] {
return [this.statModifier, this.stats];
return [this.good];
}
}
@ -2331,17 +2291,16 @@ const modifierTypeInitObj = Object.freeze({
MYSTERY_ENCOUNTER_SHUCKLE_JUICE: () =>
new ModifierTypeGenerator((_party: Pokemon[], pregenArgs?: any[]) => {
if (pregenArgs) {
return new PokemonBaseStatTotalModifierType(pregenArgs[0] as number);
return new PokemonBaseStatTotalModifierType(pregenArgs[0] as boolean);
}
return new PokemonBaseStatTotalModifierType(randSeedInt(20, 1));
return new PokemonBaseStatTotalModifierType(true);
}),
MYSTERY_ENCOUNTER_OLD_GATEAU: () =>
new ModifierTypeGenerator((_party: Pokemon[], pregenArgs?: any[]) => {
if (pregenArgs) {
return new PokemonBaseStatFlatModifierType(pregenArgs[0] as number, pregenArgs[1] as Stat[]);
}
return new PokemonBaseStatFlatModifierType(randSeedInt(20, 1), [Stat.HP, Stat.ATK, Stat.DEF]);
}),
new PokemonHeldItemModifierType(
"modifierType:ModifierType.MYSTERY_ENCOUNTER_OLD_GATEAU",
"old_gateau",
(type, args) => new PokemonBaseStatFlatModifier(type, (args[0] as Pokemon).id),
),
MYSTERY_ENCOUNTER_BLACK_SLUDGE: () =>
new ModifierTypeGenerator((_party: Pokemon[], pregenArgs?: any[]) => {
if (pregenArgs) {

View File

@ -952,24 +952,23 @@ export class EvoTrackerModifier extends PokemonHeldItemModifier {
export class PokemonBaseStatTotalModifier extends PokemonHeldItemModifier {
public override type: PokemonBaseStatTotalModifierType;
public isTransferable = false;
public good: boolean;
private statModifier: number;
constructor(type: PokemonBaseStatTotalModifierType, pokemonId: number, statModifier: number, stackCount?: number) {
constructor(type: PokemonBaseStatTotalModifierType, pokemonId: number, good: boolean, stackCount?: number) {
super(type, pokemonId, stackCount);
this.statModifier = statModifier;
this.good = good;
}
override matchType(modifier: Modifier): boolean {
return modifier instanceof PokemonBaseStatTotalModifier && this.statModifier === modifier.statModifier;
return modifier instanceof PokemonBaseStatTotalModifier && this.good === modifier.good;
}
override clone(): PersistentModifier {
return new PokemonBaseStatTotalModifier(this.type, this.pokemonId, this.statModifier, this.stackCount);
return new PokemonBaseStatTotalModifier(this.type, this.pokemonId, this.good, this.stackCount);
}
override getArgs(): any[] {
return super.getArgs().concat(this.statModifier);
return super.getArgs().concat(this.good);
}
/**
@ -989,10 +988,11 @@ 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 + this.statModifier / 2) : Math.floor(v + this.statModifier);
const newVal = i === 0 ? Math.floor(v + statModifier / 2) : Math.floor(v + statModifier);
baseStats[i] = Math.min(Math.max(newVal, 1), 999999);
});
@ -1012,31 +1012,14 @@ export class PokemonBaseStatTotalModifier extends PokemonHeldItemModifier {
* Currently used by Old Gateau item
*/
export class PokemonBaseStatFlatModifier extends PokemonHeldItemModifier {
private statModifier: number;
private stats: Stat[];
public isTransferable = false;
constructor(type: ModifierType, pokemonId: number, statModifier: number, stats: Stat[], stackCount?: number) {
super(type, pokemonId, stackCount);
this.statModifier = statModifier;
this.stats = stats;
}
override matchType(modifier: Modifier): boolean {
return (
modifier instanceof PokemonBaseStatFlatModifier &&
modifier.statModifier === this.statModifier &&
this.stats.every(s => modifier.stats.some(stat => s === stat))
);
return modifier instanceof PokemonBaseStatFlatModifier;
}
override clone(): PersistentModifier {
return new PokemonBaseStatFlatModifier(this.type, this.pokemonId, this.statModifier, this.stats, this.stackCount);
}
override getArgs(): any[] {
return [...super.getArgs(), this.statModifier, this.stats];
return new PokemonBaseStatFlatModifier(this.type, this.pokemonId, this.stackCount);
}
/**
@ -1055,11 +1038,13 @@ export class PokemonBaseStatFlatModifier extends PokemonHeldItemModifier {
* @param baseStats The base stats of the {@linkcode Pokemon}
* @returns always `true`
*/
override apply(_pokemon: Pokemon, baseStats: number[]): boolean {
override apply(pokemon: Pokemon, baseStats: number[]): boolean {
// Modifies the passed in baseStats[] array by a flat value, only if the stat is specified in this.stats
const stats = this.getStats(pokemon);
const statModifier = 20;
baseStats.forEach((v, i) => {
if (this.stats.includes(i)) {
const newVal = Math.floor(v + this.statModifier);
if (stats.includes(i)) {
const newVal = Math.floor(v + statModifier);
baseStats[i] = Math.min(Math.max(newVal, 1), 999999);
}
});
@ -1067,6 +1052,22 @@ export class PokemonBaseStatFlatModifier extends PokemonHeldItemModifier {
return true;
}
/**
* Get the lowest of HP/Spd, lowest of Atk/SpAtk, and lowest of Def/SpDef
* @returns Array of 3 {@linkcode Stat}s to boost
*/
getStats(pokemon: Pokemon): Stat[] {
const stats: Stat[] = [];
const baseStats = pokemon.getSpeciesForm().baseStats.slice(0);
// HP or Speed
stats.push(baseStats[Stat.HP] < baseStats[Stat.SPD] ? Stat.HP : Stat.SPD);
// Attack or SpAtk
stats.push(baseStats[Stat.ATK] < baseStats[Stat.SPATK] ? Stat.ATK : Stat.SPATK);
// Def or SpDef
stats.push(baseStats[Stat.DEF] < baseStats[Stat.SPDEF] ? Stat.DEF : Stat.SPDEF);
return stats;
}
override getScoreMultiplier(): number {
return 1.1;
}