[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
This commit is contained in:
prime 2024-06-12 15:56:23 +02:00 committed by GitHub
parent 6e52bc7980
commit 0c85823645
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 30 additions and 1 deletions

View File

@ -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;
}

View File

@ -85,6 +85,7 @@ export const OPP_GENDER_OVERRIDE: Gender = null;
export const OPP_MOVESET_OVERRIDE: Array<Moves> = [];
export const OPP_SHINY_OVERRIDE: boolean = false;
export const OPP_VARIANT_OVERRIDE: Variant = 0;
export const OPP_IVS_OVERRIDE: integer | integer[] = [];
/**
* MODIFIER / ITEM OVERRIDES

View File

@ -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);
}
});