@@ -163,9 +163,15 @@ export function isBlueSkin(itemInfo: ItemInfo): boolean {
163163 ) ;
164164}
165165
166- export function getFadeCalculatorAndSupportedWeapon (
166+ export function getFadeParams (
167167 asset : rgAsset
168- ) : [ typeof FadeCalculator | typeof AcidFadeCalculator | typeof AmberFadeCalculator , string , string ] | undefined {
168+ ) :
169+ | {
170+ calculator : typeof FadeCalculator | typeof AcidFadeCalculator | typeof AmberFadeCalculator ;
171+ weaponName : string ;
172+ className : string ;
173+ }
174+ | undefined {
169175 const FADE_TYPE_TO_CALCULATOR = {
170176 Fade : FadeCalculator ,
171177 'Acid Fade' : AcidFadeCalculator ,
@@ -175,7 +181,11 @@ export function getFadeCalculatorAndSupportedWeapon(
175181 for ( const [ fadeType , calculator ] of Object . entries ( FADE_TYPE_TO_CALCULATOR ) ) {
176182 for ( const supportedWeapon of calculator . getSupportedWeapons ( ) ) {
177183 if ( asset . market_hash_name . includes ( `${ supportedWeapon } | ${ fadeType } ` ) ) {
178- return [ calculator , supportedWeapon . toString ( ) , fadeType . replace ( ' ' , '-' ) . toLowerCase ( ) ] ;
184+ return {
185+ calculator,
186+ weaponName : supportedWeapon . toString ( ) ,
187+ className : fadeType . replace ( ' ' , '-' ) . toLowerCase ( ) ,
188+ } ;
179189 }
180190 }
181191 }
@@ -185,14 +195,14 @@ export function getFadePercentage(
185195 asset : rgAsset ,
186196 itemInfo : ItemInfo
187197) : { percentage : number ; fadeType : string } | undefined {
188- const fadeCalculatorAndSupportedWeapon = getFadeCalculatorAndSupportedWeapon ( asset ) ;
198+ const fadeInfo = getFadeParams ( asset ) ;
189199
190- if ( fadeCalculatorAndSupportedWeapon !== undefined ) {
191- const [ calculator , supportedWeapon , fadeType ] = fadeCalculatorAndSupportedWeapon ;
200+ if ( fadeInfo !== undefined ) {
201+ const { calculator, weaponName , className } = fadeInfo ;
192202
193203 return {
194- percentage : calculator . getFadePercentage ( supportedWeapon , itemInfo . paintseed ) . percentage ,
195- fadeType,
204+ percentage : calculator . getFadePercentage ( weaponName , itemInfo . paintseed ) . percentage ,
205+ fadeType : className ,
196206 } ;
197207 }
198208}
0 commit comments