From 03011c4601c5fb84c5aa6048fc18079469411c03 Mon Sep 17 00:00:00 2001 From: AJ Fontaine <36677462+Fontbane@users.noreply.github.com> Date: Tue, 11 Feb 2025 17:35:24 -0500 Subject: [PATCH] [Balance] Change IV Scanner to single stack (#5299) * Make IV Scanner max stack 1 * Apply suggestions from code review Co-authored-by: Sirz Benjie <142067137+SirzBenjie@users.noreply.github.com> --------- Co-authored-by: Sirz Benjie <142067137+SirzBenjie@users.noreply.github.com> Co-authored-by: damocleas --- .../encounters/safari-zone-encounter.ts | 2 +- src/modifier/modifier.ts | 12 +++++------ src/phases/encounter-phase.ts | 2 +- src/phases/mystery-encounter-phases.ts | 2 +- src/phases/scan-ivs-phase.ts | 19 ++++------------- src/ui/battle-message-ui-handler.ts | 21 ++----------------- 6 files changed, 15 insertions(+), 43 deletions(-) diff --git a/src/data/mystery-encounters/encounters/safari-zone-encounter.ts b/src/data/mystery-encounters/encounters/safari-zone-encounter.ts index fd078e1ffaa4..aa497e3c8fcd 100644 --- a/src/data/mystery-encounters/encounters/safari-zone-encounter.ts +++ b/src/data/mystery-encounters/encounters/safari-zone-encounter.ts @@ -315,7 +315,7 @@ async function summonSafariPokemon() { const ivScannerModifier = globalScene.findModifier(m => m instanceof IvScannerModifier); if (ivScannerModifier) { - globalScene.pushPhase(new ScanIvsPhase(pokemon.getBattlerIndex(), Math.min(ivScannerModifier.getStackCount() * 2, 6))); + globalScene.pushPhase(new ScanIvsPhase(pokemon.getBattlerIndex())); } } diff --git a/src/modifier/modifier.ts b/src/modifier/modifier.ts index 37f88deea7fb..d955385ecee5 100644 --- a/src/modifier/modifier.ts +++ b/src/modifier/modifier.ts @@ -165,9 +165,9 @@ export abstract class PersistentModifier extends Modifier { public stackCount: number; public virtualStackCount: number; - constructor(type: ModifierType, stackCount?: number) { + constructor(type: ModifierType, stackCount: number = 1) { super(type); - this.stackCount = stackCount === undefined ? 1 : stackCount; + this.stackCount = stackCount; this.virtualStackCount = 0; } @@ -3295,7 +3295,7 @@ export class ContactHeldItemTransferChanceModifier extends HeldItemTransferModif export class IvScannerModifier extends PersistentModifier { constructor(type: ModifierType, stackCount?: number) { - super(type, stackCount); + super(type); } match(modifier: Modifier): boolean { @@ -3303,7 +3303,7 @@ export class IvScannerModifier extends PersistentModifier { } clone(): IvScannerModifier { - return new IvScannerModifier(this.type, this.stackCount); + return new IvScannerModifier(this.type); } /** @@ -3311,11 +3311,11 @@ export class IvScannerModifier extends PersistentModifier { * @returns always `true` */ override apply(): boolean { - return true; + return true; //Dude are you kidding me } getMaxStackCount(): number { - return 3; + return 1; } } diff --git a/src/phases/encounter-phase.ts b/src/phases/encounter-phase.ts index 7e62ca17f7c4..1dd275ab130f 100644 --- a/src/phases/encounter-phase.ts +++ b/src/phases/encounter-phase.ts @@ -478,7 +478,7 @@ export class EncounterPhase extends BattlePhase { })); const ivScannerModifier = globalScene.findModifier(m => m instanceof IvScannerModifier); if (ivScannerModifier) { - enemyField.map(p => globalScene.pushPhase(new ScanIvsPhase(p.getBattlerIndex(), Math.min(ivScannerModifier.getStackCount() * 2, 6)))); + enemyField.map(p => globalScene.pushPhase(new ScanIvsPhase(p.getBattlerIndex()))); } } diff --git a/src/phases/mystery-encounter-phases.ts b/src/phases/mystery-encounter-phases.ts index be07dbfc1961..da78f59535f0 100644 --- a/src/phases/mystery-encounter-phases.ts +++ b/src/phases/mystery-encounter-phases.ts @@ -396,7 +396,7 @@ export class MysteryEncounterBattlePhase extends Phase { if (encounterMode !== MysteryEncounterMode.TRAINER_BATTLE) { const ivScannerModifier = globalScene.findModifier(m => m instanceof IvScannerModifier); if (ivScannerModifier) { - enemyField.map(p => globalScene.pushPhase(new ScanIvsPhase(p.getBattlerIndex(), Math.min(ivScannerModifier.getStackCount() * 2, 6)))); + enemyField.map(p => globalScene.pushPhase(new ScanIvsPhase(p.getBattlerIndex()))); } } diff --git a/src/phases/scan-ivs-phase.ts b/src/phases/scan-ivs-phase.ts index 519d7913b792..9230844ff9be 100644 --- a/src/phases/scan-ivs-phase.ts +++ b/src/phases/scan-ivs-phase.ts @@ -1,7 +1,6 @@ import { globalScene } from "#app/global-scene"; import type { BattlerIndex } from "#app/battle"; -import { CommonBattleAnim, CommonAnim } from "#app/data/battle-anims"; -import { Stat } from "#app/enums/stat"; +import { PERMANENT_STATS, Stat } from "#app/enums/stat"; import { getPokemonNameWithAffix } from "#app/messages"; import { getTextColor, TextStyle } from "#app/ui/text"; import { Mode } from "#app/ui/ui"; @@ -9,21 +8,14 @@ import i18next from "i18next"; import { PokemonPhase } from "./pokemon-phase"; export class ScanIvsPhase extends PokemonPhase { - private shownIvs: number; - constructor(battlerIndex: BattlerIndex, shownIvs: number) { + constructor(battlerIndex: BattlerIndex) { super(battlerIndex); - - this.shownIvs = shownIvs; } start() { super.start(); - if (!this.shownIvs) { - return this.end(); - } - const pokemon = this.getPokemon(); let enemyIvs: number[] = []; @@ -34,12 +26,11 @@ export class ScanIvsPhase extends PokemonPhase { for (let e = 0; e < enemyField.length; e++) { enemyIvs = enemyField[e].ivs; const currentIvs = globalScene.gameData.dexData[enemyField[e].species.getRootSpeciesId()].ivs; // we are using getRootSpeciesId() here because we want to check against the baby form, not the mid form if it exists - const ivsToShow = globalScene.ui.getMessageHandler().getTopIvs(enemyIvs, this.shownIvs); statsContainer = enemyField[e].getBattleInfo().getStatsValueContainer().list as Phaser.GameObjects.Sprite[]; statsContainerLabels = statsContainer.filter(m => m.name.indexOf("icon_stat_label") >= 0); for (let s = 0; s < statsContainerLabels.length; s++) { const ivStat = Stat[statsContainerLabels[s].frame.name]; - if (enemyIvs[ivStat] > currentIvs[ivStat] && ivsToShow.indexOf(Number(ivStat)) >= 0) { + if (enemyIvs[ivStat] > currentIvs[ivStat] && PERMANENT_STATS.indexOf(Number(ivStat)) >= 0) { const hexColour = enemyIvs[ivStat] === 31 ? getTextColor(TextStyle.PERFECT_IV, false, uiTheme) : getTextColor(TextStyle.SUMMARY_GREEN, false, uiTheme); const hexTextColour = Phaser.Display.Color.HexStringToColor(hexColour).color; statsContainerLabels[s].setTint(hexTextColour); @@ -53,9 +44,7 @@ export class ScanIvsPhase extends PokemonPhase { globalScene.ui.setMode(Mode.CONFIRM, () => { globalScene.ui.setMode(Mode.MESSAGE); globalScene.ui.clearText(); - new CommonBattleAnim(CommonAnim.LOCK_ON, pokemon, pokemon).play(false, () => { - globalScene.ui.getMessageHandler().promptIvs(pokemon.id, pokemon.ivs, this.shownIvs).then(() => this.end()); - }); + globalScene.ui.getMessageHandler().promptIvs(pokemon.id, pokemon.ivs).then(() => this.end()); }, () => { globalScene.ui.setMode(Mode.MESSAGE); globalScene.ui.clearText(); diff --git a/src/ui/battle-message-ui-handler.ts b/src/ui/battle-message-ui-handler.ts index 93de69240c38..c87ac18c65da 100644 --- a/src/ui/battle-message-ui-handler.ts +++ b/src/ui/battle-message-ui-handler.ts @@ -6,7 +6,6 @@ import { addWindow } from "./ui-theme"; import type BBCodeText from "phaser3-rex-plugins/plugins/bbcodetext"; import { Button } from "#enums/buttons"; import i18next from "i18next"; -import type { Stat } from "#app/enums/stat"; import { PERMANENT_STATS, getStatKey } from "#app/enums/stat"; export default class BattleMessageUiHandler extends MessageUiHandler { @@ -191,13 +190,12 @@ export default class BattleMessageUiHandler extends MessageUiHandler { }); } - promptIvs(pokemonId: number, ivs: number[], shownIvsCount: number): Promise { + promptIvs(pokemonId: number, ivs: number[]): Promise { return new Promise(resolve => { globalScene.executeWithSeedOffset(() => { let levelUpStatsValuesText = ""; - const shownStats = this.getTopIvs(ivs, shownIvsCount); for (const s of PERMANENT_STATS) { - levelUpStatsValuesText += `${shownStats.includes(s) ? this.getIvDescriptor(ivs[s], s, pokemonId) : "???"}\n`; + levelUpStatsValuesText += `${this.getIvDescriptor(ivs[s], s, pokemonId)}\n`; } this.levelUpStatsValuesContent.text = levelUpStatsValuesText; this.levelUpStatsIncrContent.setVisible(false); @@ -211,21 +209,6 @@ export default class BattleMessageUiHandler extends MessageUiHandler { }); } - getTopIvs(ivs: number[], shownIvsCount: number): Stat[] { - let shownStats: Stat[] = []; - if (shownIvsCount < 6) { - const statsPool = PERMANENT_STATS.slice(); - // Sort the stats from highest to lowest iv - statsPool.sort((s1, s2) => ivs[s2] - ivs[s1]); - for (let i = 0; i < shownIvsCount; i++) { - shownStats.push(statsPool[i]); - } - } else { - shownStats = PERMANENT_STATS.slice(); - } - return shownStats; - } - getIvDescriptor(value: number, typeIv: number, pokemonId: number): string { const starterSpecies = globalScene.getPokemonById(pokemonId)!.species.getRootSpeciesId(); // we are using getRootSpeciesId() here because we want to check against the baby form, not the mid form if it exists const starterIvs: number[] = globalScene.gameData.dexData[starterSpecies].ivs;