Avatar updates

This commit is contained in:
Bill 2021-08-04 02:54:46 -04:00
parent 90fe77abd1
commit 35a91d4ffb
4 changed files with 17 additions and 15 deletions

View File

@ -18,7 +18,7 @@ export class AvatarFigureContainer implements IAvatarFigureContainer
public hasPartType(k: string): boolean public hasPartType(k: string): boolean
{ {
return this.partSets().get(k) !== null; return !!this.partSets().get(k);
} }
public getPartSetId(k: string): number public getPartSetId(k: string): number
@ -39,18 +39,18 @@ export class AvatarFigureContainer implements IAvatarFigureContainer
return existing.get('colorids'); return existing.get('colorids');
} }
public updatePart(k: string, _arg_2: number, _arg_3: number[]): void public updatePart(setType: string, partSetId: number, colorIds: number[]): void
{ {
const set: Map<string, any> = new Map(); const set: Map<string, any> = new Map();
set.set('type', k); set.set('type', setType);
set.set('setid', _arg_2); set.set('setid', partSetId);
set.set('colorids', _arg_3); set.set('colorids', colorIds);
const existingSets = this.partSets(); const existingSets = this.partSets();
existingSets.delete(k); existingSets.delete(setType);
existingSets.set(k, set); existingSets.set(setType, set);
} }
public removePart(k: string): void public removePart(k: string): void

View File

@ -1,8 +1,9 @@
import { AdvancedMap } from '../../../../core';
import { IPartColor } from './IPartColor'; import { IPartColor } from './IPartColor';
export interface IPalette export interface IPalette
{ {
getColor(id: number): IPartColor; getColor(id: number): IPartColor;
id: number; id: number;
colors: Map<string, IPartColor>; colors: AdvancedMap<string, IPartColor>;
} }

View File

@ -1,3 +1,4 @@
import { AdvancedMap } from '../../../../core';
import { IFigureDataPalette } from '../../interfaces'; import { IFigureDataPalette } from '../../interfaces';
import { IPalette } from './IPalette'; import { IPalette } from './IPalette';
import { IPartColor } from './IPartColor'; import { IPartColor } from './IPartColor';
@ -6,14 +7,14 @@ import { PartColor } from './PartColor';
export class Palette implements IPalette export class Palette implements IPalette
{ {
private _id: number; private _id: number;
private _colors: Map<string, IPartColor>; private _colors: AdvancedMap<string, IPartColor>;
constructor(data: IFigureDataPalette) constructor(data: IFigureDataPalette)
{ {
if(!data) throw new Error('invalid_data'); if(!data) throw new Error('invalid_data');
this._id = data.id; this._id = data.id;
this._colors = new Map(); this._colors = new AdvancedMap();
this.append(data); this.append(data);
} }
@ -24,7 +25,7 @@ export class Palette implements IPalette
{ {
const newColor = new PartColor(color); const newColor = new PartColor(color);
this._colors.set(color.id.toString(), newColor); this._colors.add(color.id.toString(), newColor);
} }
} }
@ -32,7 +33,7 @@ export class Palette implements IPalette
{ {
if((id === undefined) || id < 0) return null; if((id === undefined) || id < 0) return null;
return (this._colors.get(id.toString()) || null); return (this._colors.getValue(id.toString()) || null);
} }
public get id(): number public get id(): number
@ -40,7 +41,7 @@ export class Palette implements IPalette
return this._id; return this._id;
} }
public get colors(): Map<string, IPartColor> public get colors(): AdvancedMap<string, IPartColor>
{ {
return this._colors; return this._colors;
} }

View File

@ -60,13 +60,13 @@ export class SetType implements ISetType
for(const set of setType.sets) this._partSets.add(set.id.toString(), new FigurePartSet(this._type, set)); for(const set of setType.sets) this._partSets.add(set.id.toString(), new FigurePartSet(this._type, set));
} }
public getDefaultPartSet(k: string): IFigurePartSet public getDefaultPartSet(gender: string): IFigurePartSet
{ {
for(const set of this._partSets.getValues()) for(const set of this._partSets.getValues())
{ {
if(!set) continue; if(!set) continue;
if((set.clubLevel === 0) && ((set.gender === k) || (set.gender === 'U'))) return set; if((set.clubLevel === 0) && ((set.gender === gender) || (set.gender === 'U'))) return set;
} }
return null; return null;