From 0aa202e6bea6ada0fb76f2c9b2e33ff79281c687 Mon Sep 17 00:00:00 2001 From: Bill Date: Tue, 31 Aug 2021 20:00:54 -0400 Subject: [PATCH] Fix getFigureClubLevel --- src/nitro/avatar/AvatarRenderManager.ts | 11 +++++++++-- src/nitro/avatar/IAvatarRenderManager.ts | 2 +- src/nitro/avatar/structure/figure/PartColor.ts | 10 +++++----- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/nitro/avatar/AvatarRenderManager.ts b/src/nitro/avatar/AvatarRenderManager.ts index 5675bec1..391abd02 100644 --- a/src/nitro/avatar/AvatarRenderManager.ts +++ b/src/nitro/avatar/AvatarRenderManager.ts @@ -352,7 +352,7 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa return !(isValid); } - public getFigureClubLevel(container: IAvatarFigureContainer, gender: string, searchParts: string[]): number + public getFigureClubLevel(container: IAvatarFigureContainer, gender: string, searchParts: string[] = null): number { if(!this._structure) return 0; @@ -363,7 +363,10 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa for(const part of parts) { - const set = figureData.getSetType(part); + const set = figureData.getSetType(part); + + if(!set) continue; + const setId = container.getPartSetId(part); const partSet = set.getPartSet(setId); @@ -378,6 +381,8 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa { const color = palette.getColor(colorId); + if(!color) continue; + clubLevel = Math.max(color.clubLevel, clubLevel); } } @@ -389,6 +394,8 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa { const set = figureData.getSetType(part); + if(!set) continue; + if(parts.indexOf(part) === -1) clubLevel = Math.max(set.optionalFromClubLevel(gender), clubLevel); } diff --git a/src/nitro/avatar/IAvatarRenderManager.ts b/src/nitro/avatar/IAvatarRenderManager.ts index 3bee9b2b..5b380022 100644 --- a/src/nitro/avatar/IAvatarRenderManager.ts +++ b/src/nitro/avatar/IAvatarRenderManager.ts @@ -15,7 +15,7 @@ export interface IAvatarRenderManager extends INitroManager isFigureContainerReady(container: IAvatarFigureContainer): boolean; createAvatarImage(figure: string, size: string, gender: string, listener?: IAvatarImageListener, effectListener?: IAvatarEffectListener): IAvatarImage; downloadAvatarFigure(container: IAvatarFigureContainer, listener: IAvatarImageListener): void; - getFigureClubLevel(container: IAvatarFigureContainer, gender: string, searchParts: string[]): number; + getFigureClubLevel(container: IAvatarFigureContainer, gender: string, searchParts?: string[]): number; isValidFigureSetForGender(setId: number, gender: string): boolean; getFigureStringWithFigureIds(k: string, _arg_2: string, _arg_3: number[]): string; getMandatoryAvatarPartSetIds(k: string, _arg_2: number): string[]; diff --git a/src/nitro/avatar/structure/figure/PartColor.ts b/src/nitro/avatar/structure/figure/PartColor.ts index 06e558b5..0bd79036 100644 --- a/src/nitro/avatar/structure/figure/PartColor.ts +++ b/src/nitro/avatar/structure/figure/PartColor.ts @@ -13,11 +13,11 @@ export class PartColor implements IPartColor { if(!data) throw new Error('invalid_data'); - this._id = data.id; - this._index = data.index; - this._clubLevel = data.club; - this._isSelectable = data.selectable; - this._rgb = parseInt('0x' + data.hexCode, 16); + this._id = data.id; + this._index = data.index; + this._clubLevel = (data.club || 0); + this._isSelectable = data.selectable; + this._rgb = parseInt('0x' + data.hexCode, 16); } public get id(): number