def draw_map():
    """
        Draw map on console from 2 dimensional list
    """
    utilities.clear_console()
    # draw maze
    for Y in range(len(variables.game_map)):
        for X in range(len(variables.game_map[Y])):
            if (Y == variables.character_position["Y"]
                    and X == variables.character_position["X"]):
                # this is character position, draw it
                print(variables.character_symbol, end="")
            else:
                # no character here, draw maze
                print(variables.map_elements[variables.game_map[Y][X]]["Icon"],
                      end="")
        print()

    # show message if any
    if variables.game_message != "":
        print(variables.game_message)
        variables.game_message = ""
    else:
        print()

    # show game data
    print(
        f"Nombre d'actions effectuées : {variables.character_total_actions} (dont {variables.character_bad_actions} mauvaises)\n"
    )
def launch_fizz_buzz():

    utilities.clear_console()

    # Fizz-Buzz display logo et rules
    visuals.fizz_buzz_logo()
    languages.fizz_buzz_rules()

    fizz_buzz_victory = False

    b = 15 

    z1 = b % 5

    if z1 == 0:
        print("Fizz")

    #print(z1)

    z2 = b % 3 

    if z2 == 0:
        print("Buzz")

    #print(z2)

    if z1 == 0 and z2 == 0:
        print("Fizz Buzz")
def launch_sphynx():

    utilities.clear_console()

    sphynx_victory = False

    # Sphynx display logo et rules
    visuals.sphynx_logo()
    languages.sphynx_rules()
    languages.sphynx_question()

    print("Tu peux répondre par 'Oui' ou 'Non':")
    user_answer = str(input())


    # not user_answer.isalpha() and user_answer != "Oui" or not user_answer.isalpha() and user_answer != "Non" :

    a = 1

    while (a) :
        if user_answer == "Oui":
            a = 0
            right_number = 0

            def find_number(counter):
                # The sphynx calculate a random number
                sphynx_number = random.randint(0, 100)

                # Ask user a number
                for repeat_ask in range(20):
                    print("Veux-tu bien rentrer un nombre entre 1 et 100 ?")
                    user_number = int(input())

                    # Compare the sphynx_number and user_number
                    if sphynx_number > user_number:
                        print("Le nombre que j'ai en tête est plus grand")
                    elif sphynx_number < user_number:
                        print("Le nombre que j'ai en tête est plus petit")
                    else:
                        print("Tu as trouvé le bon nombre, serais-tu devin ?")
                        counter += 1
                        return counter

            while right_number < 3 :
                right_number = find_number(right_number)

        elif user_answer == "Non":
            a = 0
            break
        else:
            print("Tu dois répondre par 'Oui' ou 'Non'")
            user_answer = str(input())
    # The player as won the bronze key, first challenge
    print("Tu as gagné ce défi, tu obtiens donc la clef de Bronze")
def show_title_and_rules():
    """
        Prints title ans rules
    """

    utilities.clear_console()

    visuals.game_logo()
    print("\n")

    print("Pour te déplacer, tu as ces touches :")
    print("Z (Haut), S (Bas), Q (Gauche), D (Droite) ou C (Quitter)\n")
def launch_caesar():

    utilities.clear_console()

    # Caesar display logo et rules
    visuals.caesar_logo()
    languages.caesar_rules()

    caesar_victory = False

    # Part of Python zen
    zen_python = "Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex."

    print(zen_python)

    # Length of an object, here zen_python
    zen_length = len(zen_python)

    char_list = []

    encryption_key = 3

    # Loop to encrypt message
    for char in range(zen_length):

        # If the character is alphabetical
        if zen_python[char].isalpha():
            # Value in the ASCII table of each character
            tmp = ord(zen_python[char])
            # Add encryption key to the value of ASCII table
            tmp_encrypted = tmp + encryption_key
            # Verify if value of character exit the alphabetical part of ASCII table and loop at beginning (example: z + 3 = c)
            if (tmp_encrypted) > 122:
                tmp_encrypted -= 26
            # Add characters to list
            char_list.append(chr(tmp_encrypted))

        # When character isn't alpha, put it like that in the list
        else:
            char_list.append(zen_python[char])
        #print(d)

    # Recreate sentence in an encrypted version
    result = ''.join(char_list)

    print(result)