From 0c85823645b2e2676a3bb5416dc85463d2172867 Mon Sep 17 00:00:00 2001 From: prime <10091050+prime-dialga@users.noreply.github.com> Date: Wed, 12 Jun 2024 15:56:23 +0200 Subject: [PATCH] [Enhancement] Golden IVs Chart when all IVs are perfect (#2019) * golden chart for perfect IVs The IVs chart is now golden in case all IVs are perfect. A few overrides have also been added to make testing easier: - the opponents IVs can be overridden - the color can be modded via the window.perfectIVsChartColor variable. * added perfectIVsChartColor to window * added changes as requested - removed global variable - removed chart versatility - changed color --- src/battle-scene.ts | 13 +++++++++++++ src/overrides.ts | 1 + src/ui/stats-container.ts | 17 ++++++++++++++++- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/battle-scene.ts b/src/battle-scene.ts index 8b469022e31..f1f53e54d2b 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -68,6 +68,12 @@ export const bypassLogin = import.meta.env.VITE_BYPASS_LOGIN === "1"; const DEBUG_RNG = false; +const OPP_IVS_OVERRIDE_VALIDATED : integer[] = ( + Array.isArray(Overrides.OPP_IVS_OVERRIDE) ? + Overrides.OPP_IVS_OVERRIDE : + new Array(6).fill(Overrides.OPP_IVS_OVERRIDE) +).map(iv => isNaN(iv) || iv === null || iv > 31 ? -1 : iv); + export const startingWave = Overrides.STARTING_WAVE_OVERRIDE || 1; const expSpriteKeys: string[] = []; @@ -766,6 +772,13 @@ export default class BattleScene extends SceneBase { if (postProcess) { postProcess(pokemon); } + + for (let i = 0; i < pokemon.ivs.length; i++) { + if (OPP_IVS_OVERRIDE_VALIDATED[i] > -1) { + pokemon.ivs[i] = OPP_IVS_OVERRIDE_VALIDATED[i]; + } + } + pokemon.init(); return pokemon; } diff --git a/src/overrides.ts b/src/overrides.ts index 782cc6552cd..676baaf0452 100644 --- a/src/overrides.ts +++ b/src/overrides.ts @@ -85,6 +85,7 @@ export const OPP_GENDER_OVERRIDE: Gender = null; export const OPP_MOVESET_OVERRIDE: Array = []; export const OPP_SHINY_OVERRIDE: boolean = false; export const OPP_VARIANT_OVERRIDE: Variant = 0; +export const OPP_IVS_OVERRIDE: integer | integer[] = []; /** * MODIFIER / ITEM OVERRIDES diff --git a/src/ui/stats-container.ts b/src/ui/stats-container.ts index 5414508ef70..11154bd700b 100644 --- a/src/ui/stats-container.ts +++ b/src/ui/stats-container.ts @@ -69,6 +69,7 @@ export class StatsContainer extends Phaser.GameObjects.Container { if (ivs) { const ivChartData = new Array(6).fill(null).map((_, i) => [ (ivs[ivChartStatIndexes[i]] / 31) * ivChartSize * ivChartStatCoordMultipliers[ivChartStatIndexes[i]][0], (ivs[ivChartStatIndexes[i]] / 31) * ivChartSize * ivChartStatCoordMultipliers[ivChartStatIndexes[i]][1] ] ).flat(); const lastIvChartData = this.statsIvsCache || defaultIvChartData; + const perfectIVColor: string = getTextColor(TextStyle.SUMMARY_GOLD, false, (this.scene as BattleScene).uiTheme); this.statsIvsCache = ivChartData.slice(0); this.ivStatValueTexts.map((t: BBCodeText, i: integer) => { @@ -76,7 +77,7 @@ export class StatsContainer extends Phaser.GameObjects.Container { // Check to see if IVs are 31, if so change the text style to gold, otherwise leave them be. if (ivs[i] === 31) { - label += `[color=${getTextColor(TextStyle.SUMMARY_GOLD, false, (this.scene as BattleScene).uiTheme)}][shadow]${ivs[i].toString()}[/shadow][/color]`; + label += `[color=${perfectIVColor}][shadow]${ivs[i].toString()}[/shadow][/color]`; } else { label = ivs[i].toString(); } @@ -90,6 +91,13 @@ export class StatsContainer extends Phaser.GameObjects.Container { t.setText(`[shadow]${label}[/shadow]`); }); + const newColor = ivs.every(iv => iv === 31) ? parseInt(perfectIVColor.substr(1), 16) : 0x98d8a0; + const oldColor = this.ivChart.fillColor; + const interpolateColor = oldColor !== newColor ? [ + Phaser.Display.Color.IntegerToColor(oldColor), + Phaser.Display.Color.IntegerToColor(newColor) + ] : null; + this.scene.tweens.addCounter({ from: 0, to: 1, @@ -98,6 +106,13 @@ export class StatsContainer extends Phaser.GameObjects.Container { onUpdate: (tween: Phaser.Tweens.Tween) => { const progress = tween.getValue(); const interpolatedData = ivChartData.map((v: number, i: integer) => v * progress + (lastIvChartData[i] * (1 - progress))); + if (interpolateColor) { + this.ivChart.setFillStyle( + Phaser.Display.Color.ValueToColor( + Phaser.Display.Color.Interpolate.ColorWithColor(interpolateColor[0], interpolateColor[1], 1, progress) + ).color, + 0.75); + } this.ivChart.setTo(interpolatedData); } });