"""Character creation flow for new players."""


async def character_creation(
    name: str,
    read_func,
    write_func,
) -> dict:
    """Run character creation prompts for a new player.

    Args:
        name: Player name
        read_func: Async function to read a line of input (returns str or None)
        write_func: Async function to write output

    Returns:
        Dict with creation data: {"description": str}
    """
    await write_func("\r\n--- Character Creation ---\r\n\r\n")
    await write_func(
        "Describe yourself in a short sentence or two.\r\n"
        "(This is what others see when they look at you.)\r\n\r\n"
    )
    await write_func("Description: ")

    desc_input = await read_func()
    description = ""
    if desc_input is not None:
        description = desc_input.strip()

    if description:
        await write_func(f'\r\nYou will be known as: "{description}"\r\n')
    else:
        await write_func("\r\nNo description set. You can change it later.\r\n")

    return {"description": description}
