a
    
ic                     @   s@   d Z ddlZddlZdd Zdd Zdd Zd	d
 Zdd ZdS )a^  
Character Appearance Module

This module contains functions for generating character appearance attributes
including hair color, hair type, facial hair, accessories, and skin color.

These functions are used during character creation to generate realistic
and age-appropriate appearance characteristics based on demographics and
biological factors.
    Nc                    sD  ddddddddddd	dd
dddddddddddddddddg
  fdd}t |  | jjdv r|d|d|d|dg}nX| jjdkr|d|d|dg}n4| jjdv r|d|dg}n|d|d
|dg}| jdkr:|d|v r||dgd  |d|v r:||dgd  t|S )ak  
    Determine hair color based on skin color and age.

    Args:
        person: A personClass instance with avatar_settings.skin_color and ageYears

    Returns:
        str: Hex color code for hair color

    Notes:
        - Hair color options are influenced by skin tone
        - Older characters (>50 years) have higher probability of blonde/grey hair
    Black2c1b18)namehexz
Dark Brown4a312czChestnut Brown724133Auburna55728zGolden Brownb58143Redc93305Blonded6b370z
Light Greye8e1e1z	Dark GreyecdcbfCopperf59797c                    s&    D ]}|d | kr|d   S qd S )Nr   r    )
color_namecolor
haircolorsr   5/var/www/lichun.app/lichun/ws/character/appearance.pyget_hex.   s    zget_hair_color.<locals>.get_hex)PALELIGHTBROWN)
DARK_BROWNBLACK2      )printavatar_settings
skin_colorageYearsextendrandomchoice)personr   hair_colorsr   r   r   get_hair_color   s4    r*   c                 C   s^   dg}| j dk rd}n:| j dkr4| jdkr4ddg}n| jdkrHg d}ng d}t|}|S )a  
    Determine hair style/type based on sex and age.

    Args:
        person: A personClass instance with sex and ageYears attributes

    Returns:
        str: Hair type identifier (e.g., 'shortFlat', 'curly', 'NONE')

    Notes:
        - Infants (<1 year) have no hair
        - Older males (>50 years) have higher probability of balding
        - Different hair style options for male vs female characters
    NONE   r   Malesides)dreadsdreads01dreads02froshaggyshaggyMullet	shortFlat	theCaesartheCaesarAndSidePartshavedSidesr.   
shortWavedfrizzle
shortRound
shortCurly)bigHairbobbuncurlyr2   curvyfroBandlongButNotTooLong
miaWallace
straight01
straight02straightAndStrand)r$   sexr&   r'   )r(   
hair_types	hair_typer   r   r   get_hair_typeI   s    




rK   c                 C   s6   | j dkr.| jdkr.| jdkr.tg d}nd}|S )ab  
    Determine facial hair style based on sex and age.

    Args:
        person: A personClass instance with sex and ageYears attributes

    Returns:
        str: Facial hair type identifier or 'NONE'

    Notes:
        - Only males between 18-50 years can have facial hair
        - Options include light beard, medium beard, or magnum moustache
    r-      r   )
beardLightbeardMediummoustacheMagnumr+   )rH   r$   r&   r'   )r(   facial_hairr   r   r   get_facial_hairg   s    rQ   c                 C   s`   g d}| j dk rg d}n,d| j   kr2dkr@n n
g d}ng d}tj||ddd	 }|S )
a  
    Determine if character wears glasses/accessories based on age.

    Args:
        person: A personClass instance with ageYears attribute

    Returns:
        str: Accessory type identifier (e.g., 'round', 'NONE')

    Notes:
        Age-based probabilities for wearing glasses:
        - Children (<18): 20% wear glasses
        - Young adults (18-39): 40% wear glasses/contacts
        - Older adults (40+): 60% wear glasses/contacts
    )r+   roundrR   rR   rL   )g?x&?rS   rS   '   )333333?/$?rV   rV   )皙?皙?rX   rX   r,   )weightskr   )r$   r&   choices)r(   accessoriesprobs	accessoryr   r   r   get_accessory}   s    


r_   c                     s  dddddddd} g d}g d}t |fd	d
|D }ddgg dg dg dddgg dg}ddgg dg dg dddgg dg}tt|D ]*}t ||   fdd
|| D ||< qtjj||d}tjj||| ||| d}| | S )a  
    Generate skin color based on US demographic race distribution.

    Returns:
        str: Hex color code for skin tone

    Notes:
        - Uses US Census race probability distribution
        - Race categories: White, Black/African American, American Indian/Alaska Native,
          Asian, Native Hawaiian/Pacific Islander, Some Other Race
        - Returns hex value from predefined skin tone palette
        - Probabilities are normalized to ensure valid distribution
    ffdbb4edb98ad08b5bae5d29614335)r   r   r   r   r   ZASIANZPACIFIC_ISLANDER)ZWhitezBlack or African Americanz American Indian or Alaska NativeZAsianz)Native Hawaiian or Other Pacific IslanderzSome Other Race)gK?gx&?g;On?gX9v?gMb`?g r?c                    s   g | ]}|  qS r   r   .0x)total_race_probsr   r   
<listcomp>       z"get_skin_color.<locals>.<listcomp>r   r   )r   r   r   )r   r   r   )r   r   r   r   r   rU   rW   )rX   rW   rW   )rW   rW   rX   )333333?rk   rX   皙?rl   c                    s   g | ]}|  qS r   r   re   )totalr   r   ri      rj   )p)sumrangelennpr&   r'   index)Zskin_color_dictZracesZ
race_probsZskin_colorsZskin_color_probsiZraceZskin_color_namer   )rm   rh   r   get_skin_color   s(    
(($ru   )	__doc__r&   numpyrr   r*   rK   rQ   r_   ru   r   r   r   r   <module>   s   8"