@@ -105,68 +105,69 @@ export class StatsContainer extends Phaser.GameObjects.Container {
105
105
}
106
106
}
107
107
108
- updateIvs ( ivs : number [ ] , originalIvs ?: number [ ] ) : void {
109
- if ( ivs ) {
110
- const ivChartData = new Array ( 6 )
111
- . fill ( null )
112
- . map ( ( _ , i ) => [
113
- ( ivs [ ivChartStatIndexes [ i ] ] / 31 ) * ivChartSize * ivChartStatCoordMultipliers [ ivChartStatIndexes [ i ] ] [ 0 ] ,
114
- ( ivs [ ivChartStatIndexes [ i ] ] / 31 ) * ivChartSize * ivChartStatCoordMultipliers [ ivChartStatIndexes [ i ] ] [ 1 ] ,
115
- ] )
116
- . flat ( ) ;
117
- const lastIvChartData = this . statsIvsCache || defaultIvChartData ;
118
- this . statsIvsCache = ivChartData . slice ( 0 ) ;
119
-
120
- this . ivStatValueTexts . map ( ( t : BBCodeText , i : number ) => {
121
- let label = "" ;
122
-
123
- // Check to see if IVs are 31, if so change the text style to gold, otherwise leave them be.
124
- if ( ivs [ i ] === 31 ) {
125
- label += getBBCodeFragment ( ivs [ i ] . toString ( ) , TextStyle . PERFECT_IV , true , true ) ;
126
- } else {
127
- label = ivs [ i ] . toString ( ) ;
128
- }
129
- if ( this . showDiff && originalIvs ) {
130
- if ( originalIvs [ i ] < ivs [ i ] ) {
131
- label += ` (${ getBBCodeFragment ( `+${ ivs [ i ] - originalIvs [ i ] } ` , TextStyle . SUMMARY_BLUE , true ) } )` ;
132
- } else {
133
- label += " (-)" ;
134
- }
135
- }
136
- t . setText ( `[shadow]${ label } [/shadow]` ) ;
137
- } ) ;
138
-
139
- const newColor = ivs . every ( ( iv ) => iv === 31 ) ? 0xe8e8a8 : 0x98d8a0 ;
140
- const oldColor = this . ivChart . fillColor ;
141
- const interpolateColor =
142
- oldColor !== newColor
143
- ? [ Phaser . Display . Color . IntegerToColor ( oldColor ) , Phaser . Display . Color . IntegerToColor ( newColor ) ]
144
- : null ;
145
-
146
- globalScene . tweens . addCounter ( {
147
- from : 0 ,
148
- to : 1 ,
149
- duration : 1000 ,
150
- ease : "Cubic.easeOut" ,
151
- onUpdate : ( tween : Phaser . Tweens . Tween ) => {
152
- const progress = tween . getValue ( ) ;
153
- const interpolatedData = ivChartData . map (
154
- ( v : number , i : number ) => v * progress + lastIvChartData [ i ] * ( 1 - progress ) ,
155
- ) ;
156
- if ( interpolateColor ) {
157
- this . ivChart . setFillStyle (
158
- Phaser . Display . Color . ValueToColor (
159
- Phaser . Display . Color . Interpolate . ColorWithColor ( interpolateColor [ 0 ] , interpolateColor [ 1 ] , 1 , progress ) ,
160
- ) . color ,
161
- 0.75 ,
162
- ) ;
163
- }
164
- this . ivChart . setTo ( interpolatedData ) ;
165
- } ,
166
- } ) ;
167
- } else {
108
+ updateIvs ( ivs : number [ ] | null , originalIvs ?: number [ ] ) : void {
109
+ if ( ! ivs ) {
168
110
this . statsIvsCache = defaultIvChartData ;
169
111
this . ivChart . setTo ( defaultIvChartData ) ;
112
+ return ;
170
113
}
114
+
115
+ const ivChartData = new Array ( 6 )
116
+ . fill ( null )
117
+ . map ( ( _ , i ) => [
118
+ ( ivs [ ivChartStatIndexes [ i ] ] / 31 ) * ivChartSize * ivChartStatCoordMultipliers [ ivChartStatIndexes [ i ] ] [ 0 ] ,
119
+ ( ivs [ ivChartStatIndexes [ i ] ] / 31 ) * ivChartSize * ivChartStatCoordMultipliers [ ivChartStatIndexes [ i ] ] [ 1 ] ,
120
+ ] )
121
+ . flat ( ) ;
122
+ const lastIvChartData = this . statsIvsCache || defaultIvChartData ;
123
+ this . statsIvsCache = ivChartData . slice ( 0 ) ;
124
+
125
+ this . ivStatValueTexts . map ( ( t : BBCodeText , i : number ) => {
126
+ let label = "" ;
127
+
128
+ // Check to see if IVs are 31, if so change the text style to gold, otherwise leave them be.
129
+ if ( ivs [ i ] === 31 ) {
130
+ label += getBBCodeFragment ( ivs [ i ] . toString ( ) , TextStyle . PERFECT_IV , true , true ) ;
131
+ } else {
132
+ label = ivs [ i ] . toString ( ) ;
133
+ }
134
+ if ( this . showDiff && originalIvs ) {
135
+ if ( originalIvs [ i ] < ivs [ i ] ) {
136
+ label += ` (${ getBBCodeFragment ( `+${ ivs [ i ] - originalIvs [ i ] } ` , TextStyle . SUMMARY_BLUE , true ) } )` ;
137
+ } else {
138
+ label += " (-)" ;
139
+ }
140
+ }
141
+ t . setText ( `[shadow]${ label } [/shadow]` ) ;
142
+ } ) ;
143
+
144
+ const newColor = ivs . every ( ( iv ) => iv === 31 ) ? 0xe8e8a8 : 0x98d8a0 ;
145
+ const oldColor = this . ivChart . fillColor ;
146
+ const interpolateColor =
147
+ oldColor !== newColor
148
+ ? [ Phaser . Display . Color . IntegerToColor ( oldColor ) , Phaser . Display . Color . IntegerToColor ( newColor ) ]
149
+ : null ;
150
+
151
+ globalScene . tweens . addCounter ( {
152
+ from : 0 ,
153
+ to : 1 ,
154
+ duration : 1000 ,
155
+ ease : "Cubic.easeOut" ,
156
+ onUpdate : ( tween : Phaser . Tweens . Tween ) => {
157
+ const progress = tween . getValue ( ) ;
158
+ const interpolatedData = ivChartData . map (
159
+ ( v : number , i : number ) => v * progress + lastIvChartData [ i ] * ( 1 - progress ) ,
160
+ ) ;
161
+ if ( interpolateColor ) {
162
+ this . ivChart . setFillStyle (
163
+ Phaser . Display . Color . ValueToColor (
164
+ Phaser . Display . Color . Interpolate . ColorWithColor ( interpolateColor [ 0 ] , interpolateColor [ 1 ] , 1 , progress ) ,
165
+ ) . color ,
166
+ 0.75 ,
167
+ ) ;
168
+ }
169
+ this . ivChart . setTo ( interpolatedData ) ;
170
+ } ,
171
+ } ) ;
171
172
}
172
173
}
0 commit comments