from typing import Tuple
import logging


async def mark_next_person(queue_array: list) -> Tuple[list, int]:
    """Mark next person in the queue (transfers current_turn to them).

    Parameters
    ----------
    queue_array : list
        This array represents the queue

    Returns
    -------
    Tuple[list, int]
        The modified queue_array & the id of the person marked
    """

    for index, member in enumerate(queue_array):
        if member["current_turn"]:
            queue_array[index]["current_turn"] = False

            # shouldnt fail when next person is at the beginning of the
            # queue
            next_person_pos = (index + 1) % len(queue_array)
            queue_array[next_person_pos]["current_turn"] = True

            return (queue_array, queue_array[next_person_pos]["user_id"])

    logging.error("Failed to find next person in the queue")
    return ([], 0)