Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/__tests__/player/data/player/createPlayerDtoBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ export default class CreatePlayerDtoBuilder
profile_id: undefined,
battleCharacter_ids: [],
avatar: {
head: 1,
hair: 1,
eyes: 1,
nose: 1,
mouth: 1,
eyebrows: 1,
clothes: 1,
feet: 1,
hands: 1,
head: { id: 1, color: '#ffffff' },
hair: { id: 1, color: '#ffffff' },
eyes: { id: 1, color: '#ffffff' },
nose: { id: 1, color: '#ffffff' },
mouth: { id: 1, color: '#ffffff' },
eyebrows: { id: 1, color: '#ffffff' },
clothes: { id: 1, color: '#ffffff' },
feet: { id: 1, color: '#ffffff' },
hands: { id: 1, color: '#ffffff' },
skinColor: '#f5cba7',
},
};
Expand Down
18 changes: 9 additions & 9 deletions src/__tests__/player/data/player/playerBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ export default class PlayerBuilder {
clan_id: undefined,
battleCharacter_ids: [],
avatar: {
head: 1,
hair: 1,
eyes: 1,
nose: 1,
mouth: 1,
eyebrows: 1,
clothes: 1,
feet: 1,
hands: 1,
head: { id: 1, color: '#ff0000' },
hair: { id: 1, color: '#ff0000' },
eyes: { id: 1, color: '#ff0000' },
nose: { id: 1, color: '#ff0000' },
mouth: { id: 1, color: '#ff0000' },
eyebrows: { id: 1, color: '#ff0000' },
clothes: { id: 1, color: '#ff0000' },
feet: { id: 1, color: '#ff0000' },
hands: { id: 1, color: '#ff0000' },
skinColor: '#f5cba7',
},
clanRole_id: null,
Expand Down
18 changes: 9 additions & 9 deletions src/__tests__/player/data/player/playerDtoBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ export default class PlayerDtoBuilder implements IDataBuilder<PlayerDto> {
parentalAuth: false,
currentAvatarId: 101,
avatar: {
head: 1,
hair: 1,
eyes: 1,
nose: 1,
mouth: 1,
eyebrows: 1,
clothes: 1,
feet: 1,
hands: 1,
head: { id: 1, color: '#ffffff' },
hair: { id: 1, color: '#ffffff' },
eyes: { id: 1, color: '#ffffff' },
nose: { id: 1, color: '#ffffff' },
mouth: { id: 1, color: '#ffffff' },
eyebrows: { id: 1, color: '#ffffff' },
clothes: { id: 1, color: '#ffffff' },
feet: { id: 1, color: '#ffffff' },
hands: { id: 1, color: '#ffffff' },
skinColor: '#f5cba7',
},
gameStatistics: {
Expand Down
96 changes: 44 additions & 52 deletions src/player/dto/avatar.dto.ts
Original file line number Diff line number Diff line change
@@ -1,83 +1,75 @@
import { Expose } from 'class-transformer';
import { Expose, Type } from 'class-transformer';
import { IsNumber, IsHexColor, ValidateNested } from 'class-validator';

export class AvatarDto {
export class AvatarPieceDto {
/**
* Head variant identifier
*
* Piece identifier
* @example 1
*/
@Expose()
head: number;
@IsNumber()
id: number;

/**
* Hairstyle identifier
*
* @example 2
* Piece color in HEX format
* @example "#ff0000"
*/
@Expose()
hair: number;
@IsHexColor()
color: string;
}

/**
* Eye style identifier
*
* @example 3
*/
export class AvatarDto {
@Expose()
eyes: number;
@ValidateNested()
@Type(() => AvatarPieceDto)
head: AvatarPieceDto;

/**
* Nose style identifier
*
* @example 1
*/
@Expose()
nose: number;
@ValidateNested()
@Type(() => AvatarPieceDto)
hair: AvatarPieceDto;

/**
* Mouth style identifier
*
* @example 2
*/
@Expose()
mouth: number;
@ValidateNested()
@Type(() => AvatarPieceDto)
eyes: AvatarPieceDto;

/**
* Eyebrows style identifier
*
* @example 1
*/
@Expose()
eyebrows: number;
@ValidateNested()
@Type(() => AvatarPieceDto)
nose: AvatarPieceDto;

/**
* Clothes identifier
*
* @example 4
*/
@Expose()
clothes: number;
@ValidateNested()
@Type(() => AvatarPieceDto)
mouth: AvatarPieceDto;

/**
* Feet (footwear) identifier
*
* @example 1
*/
@Expose()
feet: number;
@ValidateNested()
@Type(() => AvatarPieceDto)
eyebrows: AvatarPieceDto;

@Expose()
@ValidateNested()
@Type(() => AvatarPieceDto)
clothes: AvatarPieceDto;

@Expose()
@ValidateNested()
@Type(() => AvatarPieceDto)
feet: AvatarPieceDto;

/**
* Hands (gloves, etc.) identifier
*
* @example 2
*/
@Expose()
hands: number;
@ValidateNested()
@Type(() => AvatarPieceDto)
hands: AvatarPieceDto;

/**
* Avatar skin color in HEX format
*
* @example "#FAD9B5"
*/
@Expose()
@IsHexColor()
skinColor: string;
}
125 changes: 50 additions & 75 deletions src/player/dto/modifyAvatar.dto.ts
Original file line number Diff line number Diff line change
@@ -1,83 +1,58 @@
import { IsInt, IsString } from 'class-validator';
import { IsHexColor, IsOptional, ValidateNested } from 'class-validator';
import { Type } from 'class-transformer';
import { AvatarPieceDto } from './avatar.dto';

export class ModifyAvatarDto {
/**
* Head variant ID
*
* @example 1
*/
@IsInt()
head: number;

/**
* Hair style ID
*
* @example 3
*/
@IsInt()
hair: number;

/**
* Eyes style ID
*
* @example 2
*/
@IsInt()
eyes: number;

/**
* Nose style ID
*
* @example 1
*/
@IsInt()
nose: number;

/**
* Mouth style ID
*
* @example 2
*/
@IsInt()
mouth: number;

/**
* Eyebrows style ID
*
* @example 1
*/
@IsInt()
eyebrows: number;

/**
* Clothes set ID
*
* @example 4
*/
@IsInt()
clothes: number;

/**
* Feet (footwear) ID
*
* @example 1
*/
@IsInt()
feet: number;

/**
* Hands (gloves/accessories) ID
*
* @example 2
*/
@IsInt()
hands: number;
@IsOptional()
@ValidateNested()
@Type(() => AvatarPieceDto)
head?: AvatarPieceDto;

@IsOptional()
@ValidateNested()
@Type(() => AvatarPieceDto)
hair?: AvatarPieceDto;

@IsOptional()
@ValidateNested()
@Type(() => AvatarPieceDto)
eyes?: AvatarPieceDto;

@IsOptional()
@ValidateNested()
@Type(() => AvatarPieceDto)
nose?: AvatarPieceDto;

@IsOptional()
@ValidateNested()
@Type(() => AvatarPieceDto)
mouth?: AvatarPieceDto;

@IsOptional()
@ValidateNested()
@Type(() => AvatarPieceDto)
eyebrows?: AvatarPieceDto;

@IsOptional()
@ValidateNested()
@Type(() => AvatarPieceDto)
clothes?: AvatarPieceDto;

@IsOptional()
@ValidateNested()
@Type(() => AvatarPieceDto)
feet?: AvatarPieceDto;

@IsOptional()
@ValidateNested()
@Type(() => AvatarPieceDto)
hands?: AvatarPieceDto;

/**
* Skin color as a hex string
*
* @example "#FAD9B5"
*/
@IsString()
skinColor: string;
@IsOptional()
@IsHexColor()
skinColor?: string;
}
2 changes: 1 addition & 1 deletion src/player/player.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export default class PlayerController {
player: PlayerDto,
body: UpdatePlayerDto,
) {
if (player?.avatar?.clothes !== body?.avatar?.clothes) {
if (player?.avatar?.clothes?.id !== body?.avatar?.clothes?.id) {
this.emitterService.EmitNewDailyTaskEvent(
body._id,
ServerTaskName.CHANGE_AVATAR_CLOTHES,
Expand Down
Loading