def check():
        check_game = get_game_state()

        result, message = mod_valid_action(user_id, 'countdown', check_game)
        if not result:
            return False, message

        all_alive = status.get_all_alive(game_state)
        yet_to_vote_list = [player_id for player_id in all_alive if not status.has_voted(game_state, player_id)]
        if len(yet_to_vote_list) > 1:
            return False, 'Countdown cannot start now.'

        yet_to_vote = yet_to_vote_list[0]
        return True, yet_to_vote
def start_night_round(game_state):
    """Start the night round by setting all villas without a night action to completed, set all
    villas/wolves with a night action to false and send night action PM's
    """
    all_alive = status.get_all_alive(game_state)

    new_game = update_game_state(game_state, 'round', round='night')

    for player_id in all_alive:
        new_game = update_game_state(new_game,
                    'change_night_action_status',
                    player=player_id,
                    completed_night_action=status.does_have_night_action(game_state, player_id))

    return "It is night time. \n Werewolves type_'/dm moderator !eat {who you want to eat}_ \n\n *Talking is NOT Allowed.*"
def should_countdown(user_id, action, game_state):
    """Check if we can start a countdown. To do so it must be day and the command must come
   from a player in the game.
   """
    if status.get_current_round(game_state) != "day":
        return False, RESPONSE['not_day']

    elif not status.is_player_alive(game_state, user_id):
        return False, RESPONSE['no_countdown']

    elif len(status.get_all_alive(game_state)) - 1 == len(
            status.get_all_votes(game_state).keys()):
        return True, None

    else:
        return False, RESPONSE['no_countdown']
 def can_countdown():
    """
    Must be day.
    Must be one player left to vote.
    """
    if get_current_round(g) != "day":
        return False, 'It is not day.'
    elif not is_player_alive(g, user_id):
        return False, 'You are not in the game.'
    # get list of all alive
    # get list of votes
    # if list of votes == all alive - 1
    elif len(get_all_alive(g))- 1 == len(get_all_votes(g).keys()):
        return True, None
    else:
        return False, 'Can not start countdown now.'
    def check():
        # who hasn't voted.
        # if round is still day
        check_g = get_game_state() # make sure state hasn't changed.
        result, message = mod_valid_action(user_id, 'countdown', check_g)
        if not result:
            return False, message

        all_alive = get_all_alive(g)
        yet_to_vote_list = [
                p_id for p_id in all_alive
                if not has_voted(g, p_id)]

        if len(yet_to_vote_list) > 1:
            return False, 'Countdown cannot start now.'

        yet_to_vote = yet_to_vote_list[0]
        return True, yet_to_vote
def start_night_round(g):
    """
    1.) Set state to night round.
    2.) For each player,
        if it is a character without a night action (ie. 'v'):
            set completed_night_action: True
            else completed_night_action: False
    3.) Send night message.
    """
    all_alive = get_all_alive(g)

    new_g = update_game_state(g, 'round', round='night')

    for player_id in all_alive:
        new_g = update_game_state(new_g,
                    'change_night_action_status',
                    player=player_id,
                    completed_night_action=does_have_night_action(g, player_id))

    return "It is night time. \n Werewolf type_'/dm moderator !kill {who you want to eat}_ \n\n *Talking is NOT Allowed.*"