From f9243a41bca43464e24a06c89dce77a0733c7bd2 Mon Sep 17 00:00:00 2001 From: LeoKu Date: Tue, 7 Jun 2022 22:15:37 +0800 Subject: [PATCH] Handle case --- src/utils/index.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/utils/index.ts b/src/utils/index.ts index b0cca9e..cce06b4 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -58,6 +58,11 @@ export function getRandomAvatarOption( usually: [NONE], }) + const hairShape = getRandomValue(topList, { + avoid: [useOption.widgets?.tops?.shape], + }) + const hairColor = getRandomFillColor() + const avatarOption: AvatarOption = { gender, @@ -66,7 +71,10 @@ export function getRandomAvatarOption( background: { color: getRandomValue(SETTINGS.backgroundColor, { - avoid: [useOption.background?.color], + avoid: [ + useOption.background?.color, + hairShape === TopsShape.Punk && hairColor, // Handle special cases and prevent color conflicts. + ], }), }, @@ -75,10 +83,8 @@ export function getRandomAvatarOption( shape: getRandomValue(SETTINGS.faceShape), }, tops: { - shape: getRandomValue(topList, { - avoid: [useOption.widgets?.tops?.shape], - }), - fillColor: getRandomFillColor(), + shape: hairShape, + fillColor: hairColor, }, ear: { shape: getRandomValue(SETTINGS.earShape, { -- GitLab