Пример #1
0
    def location_input(self, board):
        """Gather the starting location of the ship."""
        functions.clear()
        board.print_board()
        print("Place your {} - length {}.".format(self.name, self.length))
        start = input("Please input the upper left corner of the ship: ")
        start = Guess(start)
        if start.quit_flag:
            return (start, 'quit')

        if start.row >= board.rows or start.column >= board.columns:
            board.message = "Sorry, your ship is off the map."
            start, direction = self.location_input(board)
        elif start.row > board.rows - self.length:
            if start.column > board.columns - self.length:
                board.message = "Sorry, your ship is off the map."
                start, direction = self.location_input(board)
            else:
                direction = 'h'
        else:
            if start.column > board.columns - self.length:
                direction = 'v'
            else:
                direction = ""
                while not (direction == 'v' or direction == 'h'):
                    direction = input("(v)ertical or (h)orizontal?")
                    direction = direction.lower()
        return (start, direction)
Пример #2
0
def settings_menu():
    menu = {}
    menu_items = [
        "Folder Settings", "FTP Settings", "Dropbox Settings",
        "Google Drive Settings"
    ]

    for i in range(len(menu_items)):
        menu[f"{i + 1}"] = menu_items[i]

    while True:
        print("Settings Menu\n")
        for entry in menu:
            print(f"[{entry}]:", menu[entry])

        print("\nPress Enter to go back")
        selection = input("Please Select: ")

        functions.clear()
        if selection.isdigit():
            if 1 <= int(selection) <= 4:
                switcher = {
                    1: lambda: setup.folders(),
                    2: lambda: setup.ftp(),
                    3: lambda: setup.dropbox(),
                    4: lambda: setup.googledrive()
                }
                func = switcher.get(int(selection),
                                    lambda: "Unknown option selected\n")
                return func()
        elif selection == "":
            break

        print("Unknown option selected\n")
Пример #3
0
    def place_ship(self, board, location):
        """Place ship."""
        for i in range(self.length):
            if location[1] == 'v':
                row = location[0].row + i
                column = location[0].column
            else:
                row = location[0].row
                column = location[0].column + i

            board.status[row][column] = self.letter
            current_position = functions.rc_to_str(row, column)
            self.damage[i] = Guess(current_position)

        if board.name == "Computer":
            answer = "y"
        else:
            functions.clear()
            board.print_board()
            answer = ""

        while not (answer == 'y' or answer == 'n'):
            answer = input("Place ship here (y/n)? ")

        if answer == 'n':
            for i in range(self.length):
                if location[1] == 'v':
                    row = location[0].row + i
                    column = location[0].column
                else:
                    row = location[0].row
                    column = location[0].column + i

                board.status[row][column] = functions.EMPTY
            self.set_location(board)
Пример #4
0
 def UI(self):
     functions.clear()
     #print current player stats in the first row and the room name + exits after
     print(
         "Level: " + str(self.get_level()) + "(" +
         str(self.get_exp() * 10) + "%)" + " Weapon: " +
         str(self.get_weapon().get_name()) + "  AP: " + str(self.get_ap()) +
         "  HP: " + ("*" * self.get_hp()) +
         "\n______________________________________________________________________"
         + "\nCurrent room: " + self.get_room().get_name() +
         "   Last room: " + self.get_last_room().get_name() + "\n" +
         "\nNorth:  " + str(self.get_room().get_exit_name()[0]) +
         "\nEast:   " + str(self.get_room().get_exit_name()[1]) +
         "\nSouth:  " + str(self.get_room().get_exit_name()[2]) +
         "\nWest:   " + str(self.get_room().get_exit_name()[3]))
     #check if room is a staircase == lenght of exit list > 4
     if len(self.get_room().get_exit()) > 4:
         print("up:     " + str(self.get_room().get_exit_name()[4]) +
               "\nDown:   " + str(self.get_room().get_exit_name()[5]))
     if self.get_room().get_enemy() is not None:
         print("\nEnemy: " + str(self.get_room().get_enemy().get_name()))
     else:
         print("\nEnemy: None")
     print(
         "_____________________________________________________________________"
     )
     print(str(self.get_room().get_description()))
Пример #5
0
def start_scenario(player):

    map_data = load_json("static/maps.JSON")

    options = [x for x in map_data if map_data[x]["min_level"] <= player.level]
    print("player level: ", player.level)
    map_decision = print_choices('Where would you like to travel?', options)
    clear()
    this_map = Map(map_decision)
    this_encounter = Encounter(this_map)
    this_encounter.start_encounter()
Пример #6
0
def lake_room():

  data['Room'] = 2

  # clears page for new room
  clear()

  # room's title
  print(f.GREEN +'LAKE OF DREAMS'+ s.RESET_ALL)

  #checks if you have been here before
  if data['fe2'] == 0:
    print('\nyou re-enter the Lake of Dreams')
    if data['torch'] == 0:

      print('\nOn the wall there is an lit Torch with something behind it')
      
  if data['fe2'] == 1:
    
    data['fe2'] = 0

    t.sleep(1)

    #room outline
    print('\nYou walk into a dimly lit room. in the center is a glowing blue lake which does not appear to relfect the cave. On the wall there is an lit Torch with something behind it ')

  #room game loop
  while True:
    answer = input('\n>')

    #check for torch command
    if 'torch' in answer:
      
      #checks torch status
      if data['torch'] == 0:
        
        #changes torch status
        data['torch'] = 1
        print('You grab the torch, as it comes away from the wall something drops on the floor')

    #sends the player to the previous room
    elif 'go back' in answer:
        go_back()

    #saves the game
    elif 'save' in answer:
      with open('save.json', 'w') as save:
        json.dump(data, save)
        print('Saved!')

    #quits the game
    elif 'quit' in answer:
      quit()
Пример #7
0
def homescreen():

  # tells us the the player is in room 0
  global data

  #help for the player
  command_list = ('save - saves the game\n quit - quits the game\n go back - takes you to the previous room you were in')

  #title
  print(f.BLUE +'------------------')
  print(' The Wills of Men' )
  print('------------------'+ s.RESET_ALL)

  start_text = ('\nType start to begin your adventure or load to countinue your adventure. Remeber type save to save and quit to quit at any point\n')

  for char in start_text:
    sys.stdout.write(char)
    sys.stdout.flush()
    #t.sleep(0.08)

# recives and converts answer to lower case
  answer = input("\n>").lower()

  #checks for start command
  if 'start' in answer:

    #creates save data
    with open('save.json', 'w') as save:
      json.dump(data, save)

    print('\nIt Begins')

    t.sleep(4)

    clear()

    #begins Room 1
    start()

  #prints command_list
  elif 'help' in answer:
    print(command_list)

  #checks for load command
  elif 'load' in answer:
    #trys to load a save
    try:
      with open('save.json') as save:
        data = json.load(save)
    except:
      print('')
    Room_Check()
Пример #8
0
def dropbox():
    while True:
        config.set_value("dropbox", "token", input("Enter Dropbox access token: "))
        config.write_config()
        functions.clear()
        try:
            login.dropbox_login()
            config.set_value("ftp", "enabled", "true")
            config.write_config()
            print("Successfully logged in\n")
            break
        except:
            print("Failed to log in\n")
Пример #9
0
def main():
    """Запрашивает комманду и вызывает функции из модуля functions"""
    querry = input(">>>: ")

    if querry == "index":
        os.system("clear")
        func.index(arrayName)
        main()
    elif querry == "count":
        os.system("clear")
        func.count(arrayName)
        main()
    elif querry == "pop":
        os.system("clear")
        func.pop(arrayName)
        main()
    elif querry == "clear":
        os.system("clear")
        func.clear(arrayName)
        main()
    elif querry == "list":
        os.system("clear")
        func.list(arrayName)
        main()
    elif querry == "tuple":
        os.system("clear")
        func.tup(arrayName)
        main()
    elif querry == "info":
        os.system("clear")
        func.info()
        main()
    elif querry == "create":
        os.system("clear")
        createArray()
    elif querry == "write":
        os.system("clear")
        func.writeFile(arrayName)
        main()
    elif querry == "read":
        os.system("clear")
        func.readFile()
        main()
    elif querry == "exit":
        os.system("clear")
        exit(0)
    else:
        print("Такой функции нет")
        main()
Пример #10
0
    def run(self):
        self._logger.info(
            f"Initialized '{self.__f_name}' from ID:{self.__chat_id}, "
            f"process: {self.__function}")

        p = self.__process
        LightFunction.threads.append(self)
        import control
        control.open_the_eyes()
        while self.__do_run:
            time.sleep(1)
        # stop
        control.close_the_eyes()
        p.terminate()
        clear(self.__stripe)
        self.__stripe.setBrightness(LED_BRIGHTNESS)
        LightFunction.threads.remove(self)
Пример #11
0
def main_program():
    func.set_console_title(const.heading_converter)
    init()
    while True:
        try:
            func.main_heading()
            func.sub_heading(const.heading_converter)
            func.back_heading()
            func.sub_heading_softwares('02',
                                       const.rea_converter,
                                       option_string='Photo Converter')
            exit_code = func.exit_heading('03')

            choice = func.input_heading()

            if choice == 0:
                func.exception_heading(const.heading_zero)
                input()
                func.clear()
                continue

            elif choice == 1:
                func.clear()
                main.main()
                break

            elif choice == 2:
                rea_converter()
                func.clear()
                continue

            elif choice == int(exit_code):
                func.remove_temp(is_wait=True)
                sys.exit()

            else:
                func.exception_range_heading(exit_code)
                input()
                func.clear()
                continue

        except Exception as err:
            func.exception_heading(f'Please input a number. {err}')
            input()
            func.clear()
Пример #12
0
def service_menu(menu_type):
    menu = {}
    online = []
    local = ["Local"]
    setup = ["Local", "FTP", "Dropbox", "Google Drive"]

    if config.get_value("ftp", "enabled") == "true":
        local.append("FTP")
        online.append("FTP")
    if config.get_value("dropbox", "enabled") == "true":
        local.append("Dropbox")
        online.append("Dropbox")
    if config.get_value("googledrive", "enabled") == "true":
        local.append("Google Drive")
        online.append("Google Drive")

    if menu_type == "local":
        for i in range(len(local)):
            menu[f"{i + 1}"] = local[i]
    elif menu_type == "online":
        for i in range(len(online)):
            menu[f"{i + 1}"] = online[i]
    elif menu_type == "setup":
        for i in range(len(setup)):
            menu[f"{i + 1}"] = setup[i]

    while True:
        print("Service Menu\n")
        for entry in menu:
            print(f"[{int(entry)}]:", menu[entry])

        print("\nPress Enter to go back")
        selection = input("Please Select: ")

        functions.clear()

        if selection.isdigit():
            if 1 <= int(selection) <= (len(menu)):
                return (menu.get(selection))
        elif selection == "":
            break

        print("Unknown option selected\n")
Пример #13
0
    def next_encounter(self, location_in_map=None):
        if self.map.passive is True:
            npcs = list(self.map.npcs.keys()) if location_in_map is None else [
                x for x in self.map.npcs.keys()
                if location_in_map in self.map.npcs[x]["locations"]
            ]
            npc_choice = print_choices('Who would you like to talk to?', npcs)
            clear()

            options = []
            if self.map.npcs[npc_choice]["trade"] == True:
                options = self.map.npcs[npc_choice]["trade_options"]
            if self.map.npcs[npc_choice]["quest"] == True:
                options.append(choice(self.map.npcs[npc_choice]["quests"]))
            interaction_choice = print_choices(
                choice(self.map.npcs[npc_choice]["dialogue"]), options)

        else:
            pass
Пример #14
0
    def play_game(self):
        """Battleship Game mechanics."""
        turn_count = 0
        # print(self.computer_fleet)
        while not self.done:
            functions.clear()
            self.print_game_status()
            user_guess = input("Please Enter a Guess: ")
            user_guess = Guess(user_guess)
            user_guess.check_if_on_board(self.user_board)
            if user_guess.quit_flag:
                break

            self.computer_board.check_damage(user_guess,
                                             self.guess_board,
                                             self.computer_fleet)
            turn_count += 1
            if self.computer_fleet.all_ships_sank():
                msg = "Congratulations you won!  It took you {} turns."
                print(msg.format(turn_count))
                self.done = True
Пример #15
0
def main():
    """Start the Application."""
    func.clear()
    choice = ''
    while(choice.lower() != 'q'):
        print(
"""
--------------------------
Godbound Character creator
--------------------------
(1) Create character
(2) Show sample character
(q) Exit the program
"""
            )
        choice = func._input(': ')

        func.clear()
        if choice is '1':
            create_character()
        elif choice is '2':
            func.print_character(sample_data)
Пример #16
0
def start_menu():
    menu = {}
    menu_items = [
        "Exit", "Create Build", "Restore Build", "List Builds",
        "Download Build", "Upload Build", "Delete Builds", "Settings"
    ]

    for i in range(len(menu_items)):
        menu[f"{i}"] = menu_items[i]

    # while True:
    print("Build Manager\n")
    for entry in menu:
        print(f"[{entry}]:", menu[entry])

    selection = input("\nPlease Select: ")

    functions.clear()
    if selection.isdigit():
        if 1 <= int(selection) <= 7:
            switcher = {
                1: lambda: functions.create_build(),
                2: lambda: functions.restore_build(),
                3: lambda: functions.list_builds(service_menu("local")),
                4: lambda: functions.download(service_menu("online")),
                5: lambda: functions.upload(service_menu("online")),
                6: lambda: functions.delete(service_menu("local")),
                7: lambda: settings_menu()
            }
            func = switcher.get(int(selection),
                                lambda: "Unknown option selected\n")
            return func()
        elif selection == "0":
            functions.clear()
            sys.exit()

    print("Unknown option selected\n")
Пример #17
0
def folders():
    functions.clear()
    print("Please follow the setup wizard\n")

    valid_folder_name = re.compile("[-.a-zA-Z0-9]+$")

    while True:
        data_folder = input("Enter data folder name (default: data): ")

        if data_folder == "":
            config.set_value("folders", "data-folder", "data")
            break
        elif (valid_folder_name.match(data_folder)):
            config.set_value("folders", "data-folder", data_folder)
            break

        functions.clear()
        print("Invalid input. Please use [- . A-Z a-z 0-9]\n")

    while True:
        builds_folder = input("Enter builds folder name(default: builds): ")

        if builds_folder == "":
            config.set_value("folders", "builds-folder", "builds")
            break
        elif (valid_folder_name.match(builds_folder)):
            config.set_value("folders", "builds-folder", builds_folder)
            break

        functions.clear()
        print("Invalid input. Please use [- . A-Z a-z 0-9]\n")

    functions.clear()

    # Check if folder already exists, if not create them
    if not os.path.isdir(config.get_folder('data')):
        os.mkdir(config.get_folder('data'))
    if not os.path.isdir(config.get_folder('builds')):
        os.mkdir(config.get_folder('builds'))

    config.write_config()
Пример #18
0
def ftp():
    while True:
        print("Please follow the setup wizard:\n")

        protocol = input("Do you want use ftps instead of ftp? (y, n): ")
        if protocol in ("y", "Y"):
            config.set_value("ftp", "protocol", "ftps")
        elif protocol in ("n", "N"):
            config.set_value("ftp", "protocol", "ftp")
        else:
            functions.clear()
            print("Wrong input, please try again:\n")

        config.set_value("ftp", "host", input("Enter ftp host: "))
        config.set_value("ftp", "username", input("Enter ftp username: "******"ftp", "password", getpass.getpass("Enter ftp password: "******"[-./a-zA-Z0-9]+$")
        while True:
            path = input("Enter ftp path (default: root): ")

            if path == "":
                config.set_value("ftp", "path", "/")
                break
            elif (valid_path.match(path)):
                config.set_value("ftp", "path", path)
                break

            functions.clear()
            print("Invalid input. Please use [/ - . A-Z a-z 0-9]\n")

        message = login.ftp_login()

        functions.clear()
        if message == "host_error":
            print("Failed to reach host\n")
        elif message == "login_error":
            print("Failed to login\n")
        else:
            config.set_value("ftp", "enabled", "true")
            config.write_config()

            print("Successfully logged in\n")
            break
Пример #19
0
def main():
    functions.clear()
    if not functions.exists():
        try:
            functions.intro()
        except KeyboardInterrupt:
            functions.clear()
            import sys
            sys.exit(0)
    functions.clear()
    try:
        password = getpass.getpass("Password: "******"Invalid password")
        import sys
        sys.exit(1)
    while True:
        functions.clear()
        print("Vault")
        print(
            "Use Ctrl+C to return back to this menu, or use it here to exit.\n"
        )
        try:
            action = input(
                "1: Encrypt a file\n2: Download and encrypt a file from a URL\n3: Decrypt a file\n4: Change password\nSelect an option: "
            )
        except:
            break
        action = action.strip().lstrip()
        try:
            action = int(action)
        except:
            continue
        if action not in [1, 2, 3, 4]:
            continue
        if action == 1:
            functions.clear()
            try:
                path = input("Please specify a file to encrypt: ")
            except KeyboardInterrupt:
                continue
            if functions.validate(path) and not path.endswith(".png"):
                functions.clear()
                try:
                    response = input(
                        "This file may be a valid image file. Convert to .png (y/n)? "
                    )
                except KeyboardInterrupt:
                    continue
                if response.lower().lstrip().strip() == "y":
                    temp = path
                    path = functions.convert(path)
                    delete = input("Delete original file (y/n)? ")
                    if delete.lower().lstrip().strip() == "y":
                        if not windows:
                            temp = temp.replace("\\", "")
                        try:
                            directory = os.path.dirname(os.path.realpath(temp))
                            os.chdir(directory)
                            os.remove(temp)
                        except:
                            pass
            functions.clear()
            try:
                save = functions.encodepath(path)
                if save == None:
                    continue
            except Exception as e:
                print(str(e))
                try:
                    input("Invalid file path. Press enter to continue. ")
                except KeyboardInterrupt:
                    continue
                continue
            else:
                try:
                    input(
                        "File encrypted.\nEncrypted file path: {}\nPress enter to continue. "
                        .format(save))
                except KeyboardInterrupt:
                    continue
                continue

        elif action == 2:
            functions.clear()
            try:
                url = input("Please specify a file URL to download: ")
            except KeyboardInterrupt:
                continue

            name = os.path.split(url)[-1]
            base = os.path.dirname(os.path.realpath(__file__))
            path = os.path.join(base, name)
            functions.clear()

            try:
                r = requests.get(url, stream=True)
                with open(path, 'wb') as out_file:
                    shutil.copyfileobj(r.raw, out_file)
            except:
                try:
                    input("Invalid URL: {}\nPress enter to continue. ".format(
                        url))
                except KeyboardInterrupt:
                    continue
                continue
            if functions.validate(path) and not path.endswith(".png"):
                functions.clear()
                try:
                    response = input(
                        "This file may be a valid image file. Convert to .png (y/n)? "
                    )
                except KeyboardInterrupt:
                    continue
                if response.lower().lstrip().strip() == "y":
                    temp = path
                    path = functions.convert(path)
                    delete = input("Delete original file (y/n)? ")
                    if delete.lower().lstrip().strip() == "y":
                        if not windows:
                            temp = temp.replace("\\", "")
                        try:
                            directory = os.path.dirname(os.path.realpath(temp))
                            os.chdir(directory)
                            os.remove(temp)
                        except:
                            pass
            functions.clear()
            try:
                save = functions.encodepath(path)
            except:
                try:
                    input("Invalid file path. Press enter to continue. ")
                except KeyboardInterrupt:
                    continue
                continue
            else:
                try:
                    input(
                        "File encrypted.\nEncrypted file path: {}\nPress enter to continue. "
                        .format(save))
                except KeyboardInterrupt:
                    continue
                continue
        elif action == 3:
            functions.clear()
            try:
                path = input("Please specify a .enc file to decrypt: ")
            except KeyboardInterrupt:
                continue
            functions.clear()
            try:
                save = functions.decodepath(path)
            except Exception as e:
                print(str(e))
                try:
                    input("Invalid file path. Press enter to continue. ")
                except KeyboardInterrupt:
                    continue
                continue
            else:
                try:
                    input(
                        "File decrypted.\nDecrypted file path: {}\nPress enter to continue. "
                        .format(save))
                except KeyboardInterrupt:
                    continue
                continue
        elif action == 4:
            try:
                functions.clear()
                current = input("Current password: "******"Passwords do not match. Press enter to continue. ")
                    continue
                new = input("New password: "******"You will need to decrypt all files with your old password. Your new password will not be able to decrypt already encrypted files.\nRetype your password to confirm: "
                )
                if confirm != new:
                    input("Passwords do not match. Press enter to continue. ")
                    continue
                functions.writepw(new)
                functions.clear()
                input("Password changed to: {}.\nPress enter to continue. ".
                      format(new))
            except KeyboardInterrupt:
                continue

    functions.clear()
Пример #20
0
def main_program():
    func.set_console_title(const.heading_utilities)
    init()
    while True:
        try:
            func.main_heading()
            func.sub_heading(const.heading_utilities)
            func.back_heading()
            func.sub_heading_softwares('02', const.c_cleaner)
            func.sub_heading_softwares('03', const.power_iso)
            func.sub_heading_softwares('04', const.fonts)
            func.sub_heading_softwares('05', const.winrar)
            func.sub_heading_portable('06', const.dism_p_p)
            func.sub_heading_softwares('07', const.eng_to_urdu_dic)
            func.sub_heading_portable('08', const.cpu_z)
            func.sub_heading_portable('09', const.hw_info)
            func.sub_heading_softwares('10', const.aomei_partition)
            func.sub_heading_portable('11', const.rufus)
            func.sub_heading_softwares('12', const.seven_zip)
            func.sub_heading_softwares('13', const.vs_redistributable)
            func.sub_heading_softwares('14', const.better_rename)
            func.sub_heading_softwares('15', const.auslogics_duplicate)
            func.sub_heading_softwares('16', const.print_conductor)
            func.sub_heading_softwares('17', const.wise_duplicate)
            func.sub_heading_portable('18', const.occt_checking_tool)
            exit_code = func.exit_heading('19')

            choice = func.input_heading()

            if choice == 0:
                func.exception_heading(const.heading_zero)
                input()
                func.clear()
                continue

            elif choice == 1:
                func.clear()
                main.main()
                break

            elif choice == 2:
                c_cleaner()
                func.clear()
                continue

            elif choice == 3:
                power_iso()
                func.clear()
                continue

            elif choice == 4:
                fonts()
                func.clear()
                continue

            elif choice == 5:
                winrar()
                func.clear()
                continue

            elif choice == 6:
                dism_p_p()
                func.clear()
                continue

            elif choice == 7:
                eng_to_urdu_dic()
                func.clear()
                continue

            elif choice == 8:
                cpu_z()
                func.clear()
                continue

            elif choice == 9:
                hw_info()
                func.clear()
                continue

            elif choice == 10:
                aomei_partition()
                func.clear()
                continue

            elif choice == 11:
                rufus()
                func.clear()
                continue

            elif choice == 12:
                seven_zip()
                func.clear()
                continue

            elif choice == 13:
                vs_redistributable()
                func.clear()
                continue

            elif choice == 14:
                better_rename()
                func.clear()
                continue

            elif choice == 15:
                auslogics_duplicate()
                func.clear()
                continue

            elif choice == 16:
                print_conductor()
                func.clear()
                continue

            elif choice == 17:
                wise_duplicate()
                func.clear()
                continue

            elif choice == 18:
                occt_checking_tool()
                func.clear()
                continue

            elif choice == int(exit_code):
                func.remove_temp(is_wait=True)
                sys.exit()

            else:
                func.exception_range_heading(exit_code)
                input()
                func.clear()
                continue

        except Exception as err:
            func.exception_heading(f'Please input a number. {err}')
            input()
            func.clear()
Пример #21
0
def quartett():
    #Deckerstellung
    deck = create_deck()

    #KI-Hilfskomponenten
    ki_comparelist = deck.copy()

    #Ausführung des Programms
    #Namen und Anzahl der Spieler
    rl_namelist = []
    cp_namelist = []
    full_namelist = []

    num_rl = ask_num_rl()
    num_cp = ask_num_cp(num_rl)
    num_full = num_rl + num_cp

    quartett_counter = []

    for i in range(num_rl):
        rl_namequestion = "Wie heißt Spieler "+str(i+1)+"? "
        rl_name_temp = restart(input(rl_namequestion))
        while rl_name_temp == " ":
            rl_name_temp = restart(input("Keine gültige Eingabe! Bitte geben Sie einen Namen ein: "))
        while rl_name_temp in rl_namelist:
            rl_name_temp = restart(input("Der Spielername ist vergeben! Bitte wähle einen anderen Namen: "))
        rl_namelist.append(rl_name_temp)
        full_namelist.append(rl_name_temp)

    for i in range(num_cp):
        cp_name_temp = "CP"+str(i+1)
        cp_namelist.append(cp_name_temp)
        full_namelist.append(cp_name_temp)

    horizont()
    print("Spielteilnehmer:")
    for i in range(len(full_namelist)):
        print(full_namelist[i])

    for i in range(num_full):
        quartett_counter.append([])

    #Verteilen der Karten
    hands = []
    for i in range(num_full):
        hands.append([])

    if num_full == 2:
        for i in range(2):
            for j in range(10):
                curr_card = deck[randint(0,len(deck) - 1)]
                deck.remove(curr_card)
                hands[i-1].append(curr_card)
    else:
        curr_player_index = 0
        while len(deck) > 0:
            curr_card = deck[randint(0,len(deck) - 1)]
            deck.remove(curr_card)
            hands[curr_player_index].append(curr_card)
            curr_player_index += 1
            if curr_player_index == num_full:
                curr_player_index = 0
            else:
                pass

    #Spielablauf
    curr_index = 0
    game = 0

    horizont()
    print("Das Spiel fängt an!")
    horizont()
    while game == 0:
        curr_name = full_namelist[curr_index]
        curr_hand = sort_cards(hands[curr_index])
        print(curr_name,"ist dran!")
        restart(input("Drücke eine Taste um fortzufahren."))
        if curr_name in rl_namelist:        
            clear()
            horizont()
            print("Deine Hand:", print_cards(curr_hand))
            curr_hand, ki_comparelist, quartett_counter = drop(curr_index, curr_hand, ki_comparelist, quartett_counter)
            game += win(hands, full_namelist, quartett_counter)
            while game == 0:
                if num_full == 2:
                    enemy_index = curr_index + 1
                    if enemy_index == 2:
                        enemy_index = 0
                    for i in range(len(hands)):
                        print(full_namelist[i],"hat",len(hands[i]),"Karten und", len(quartett_counter[i]) // 4, "Quartetten.")
                else:
                    enemy_index = ask_enemy(curr_name, full_namelist, hands, quartett_counter)
                enemy_hand = hands[enemy_index]
                wished_card = ask_card()
                wished_card = check(wished_card, enemy_hand)
                if wished_card == 0:
                    if len(deck) > 0:
                        card_draw = deck.pop()
                        curr_hand.append(card_draw)
                        print("Du hast",print_cards([card_draw]),"gezogen.")
                        curr_hand, ki_comparelist, quartett_counter = drop(curr_index, curr_hand, ki_comparelist, quartett_counter)
                        game += win(hands, full_namelist, quartett_counter)
                    break
                else:
                    curr_hand.append(wished_card)
                    enemy_hand.remove(wished_card)
                    curr_hand, ki_comparelist, quartett_counter = drop(curr_index, curr_hand, ki_comparelist, quartett_counter)
                    game += win(hands, full_namelist, quartett_counter)
                    if game != 0:
                        break
                    horizont()
                    print("Deine Hand:", print_cards(sort_cards(curr_hand)))
            if game != 0:
                break
            input("Drücke eine Taste um Zug zu beenden.")
            clear()
        else:
            horizont()
            curr_hand, ki_comparelist, quartett_counter = drop(curr_index, curr_hand, ki_comparelist, quartett_counter)
            win(hands, full_namelist, quartett_counter)
            if num_full == 2:
                enemy_index = curr_index + 1
                if enemy_index == 2:
                    enemy_index = 0
            else:
                enemy_index = ask_enemy_cp(full_namelist, hands)
            enemy_hand = hands[enemy_index]
            enemy_name = full_namelist[enemy_index]
            while game == 0:
                wished_card = check_cp(curr_name, curr_hand, enemy_name, enemy_hand)
                if wished_card == 0:
                    if len(deck) > 0:
                        card_draw = deck.pop()
                        curr_hand.append(card_draw)
                        print(curr_name, "hat eine Karte gezogen.")
                        curr_hand, ki_comparelist, quartett_counter = drop(curr_index, curr_hand, ki_comparelist, quartett_counter)
                        game += win(hands, full_namelist, quartett_counter)
                    break
                else:
                    curr_hand.append(wished_card)
                    enemy_hand.remove(wished_card)
                    curr_hand, ki_comparelist, quartett_counter = drop(curr_index, curr_hand, ki_comparelist, quartett_counter)
                    game += win(hands, full_namelist, quartett_counter)
                    if game != 0:
                        break
                if game != 0:
                    break
        curr_index += 1
        if curr_index == len(full_namelist):
            curr_index = 0
Пример #22
0
def misile(my_pixels):
  my_pixels[5] = RED
  my_pixels[15] = DARKMAGENTA
  functions.printme(my_pixels)
  time.sleep(.15)
  my_pixels[25] = PINK
  functions.printme(my_pixels)
  time.sleep(.15)
  my_pixels[35] = MAROON
  functions.printme(my_pixels)
  time.sleep(.15)
  my_pixels[44] = YELLOW
  my_pixels[45] = YELLOW
  my_pixels[46] = YELLOW
  my_pixels[53] = YELLOW
  my_pixels[57] = YELLOW
  my_pixels[42] = YELLOW
  my_pixels[48] = YELLOW
  functions.printme(my_pixels)
  time.sleep(.15)
  my_pixels[55] = DARKBLUE
  my_pixels[56] = DARKBLUE
  my_pixels[57] = DARKBLUE
  my_pixels[66] = DARKBLUE
  my_pixels[67] = DARKBLUE
  my_pixels[58] = DARKBLUE
  my_pixels[49] = DARKBLUE
  my_pixels[64] = DARKBLUE
  my_pixels[63] = DARKBLUE
  my_pixels[52] = DARKBLUE
  my_pixels[41] = DARKBLUE
  functions.printme(my_pixels)
  time.sleep(.15)  
  my_pixels[65] = LIGHTGREEN
  my_pixels[72] = LIGHTGREEN
  my_pixels[77] = LIGHTGREEN
  my_pixels[76] = LIGHTGREEN
  my_pixels[87] = LIGHTGREEN
  my_pixels[78] = LIGHTGREEN
  my_pixels[69] = LIGHTGREEN
  my_pixels[74] = LIGHTGREEN
  my_pixels[83] = LIGHTGREEN
  my_pixels[72] = LIGHTGREEN
  my_pixels[61] = LIGHTGREEN
  my_pixels[50] = LIGHTGREEN
  functions.printme(my_pixels)
  time.sleep(.15)
  my_pixels[75] = SILVER
  my_pixels[85] = SILVER
  my_pixels[75] = SILVER
  my_pixels[86] = SILVER
  my_pixels[97] = SILVER
  my_pixels[88] = SILVER
  my_pixels[79] = SILVER
  my_pixels[84] = SILVER
  my_pixels[93] = SILVER
  my_pixels[82] = SILVER
  my_pixels[71] = SILVER
  my_pixels[60] = SILVER
  functions.printme(my_pixels)
  time.sleep(.15)
  functions.clear(my_pixels)
  time.sleep(.15)
  return
Пример #23
0
#Add Entry field for  code data, calls class Constrained Entry for validation
code_entry= ConstrainedEntry(mainframe, width=7, textvariable=code_entered, show="*")
code_entry.delete(0, END)
code_entry.grid(columnspan = 2, column=2, row=5, sticky=(W, E))

#Add buttons to frame using grid layout
ttk.Button(mainframe, text="1", command=lambda: functions.one(code_entry)).grid(column=1, row=1, sticky=NW)
ttk.Button(mainframe, text="2", command=lambda: functions.two(code_entry)).grid(column=2, row=1, sticky=NW)
ttk.Button(mainframe, text="3", command=lambda: functions.three(code_entry)).grid(column=3, row=1, sticky=NW)
ttk.Button(mainframe, text="4", command=lambda: functions.four(code_entry)).grid(column=1, row=2, sticky=NW)
ttk.Button(mainframe, text="5", command=lambda: functions.five(code_entry)).grid(column=2, row=2, sticky=NW)
ttk.Button(mainframe, text="6", command=lambda: functions.six(code_entry)).grid(column=3, row=2, sticky=NW)
ttk.Button(mainframe, text="7", command=lambda: functions.seven(code_entry)).grid(column=1, row=3, sticky=NW)
ttk.Button(mainframe, text="8", command=lambda: functions.eight(code_entry)).grid(column=2, row=3, sticky=NW)
ttk.Button(mainframe, text="9", command=lambda: functions.nine(code_entry)).grid(column=3, row=3, sticky=NW)
ttk.Button(mainframe, text="Clear", command=lambda: functions.clear(code_entry)).grid(column=1, row=4, sticky=NW)
ttk.Button(mainframe, text="0", command=lambda: functions.zero(code_entry)).grid(column=2, row=4, sticky=NW)
ttk.Button(mainframe, text="Delete", command=lambda: functions.delete(code_entry)).grid(column=3, row=4, sticky=NW)

ttk.Button(mainframe, width=12, text="Disable Alarm", command =lambda: alarm.disableCode(code_entry)).grid(column=5, row=4, sticky=SE)
ttk.Button(mainframe, width=12,text="Enable Alarm", command =lambda: alarm.enableCode(code_entry, sensor_option, root)).grid(column=5, row=5, sticky=SE)

ttk.Label(mainframe, text="Alarm Code:").grid(column=1, row=5, sticky=W)
ttk.Label(mainframe, text="Sensor Option:").grid(column =4, row =1, sticky=NE)

sensor_option=Spinbox(mainframe, values=(sensoroptions), textvariable=sensor_choice)
sensor_option.grid(column =5, row =1, sticky=(N,E))

for child in mainframe.winfo_children(): child.grid_configure(padx=5, pady=5)

Пример #24
0
def abandoned_forge():

  data['Room'] = 3

  # clears page for neew room
  clear()

  # rooms title
  print(f.GREEN +'ABANDONED FORGE'+ s.RESET_ALL)
  if data['fe3'] == 0:
    print('you feel calm as you enter the forge')

    if data['coal_bucket'] == 0:
      print('\nin the corner there is a barrel of coal')
  if data['fe3'] == 1:

    data['fe3'] = 0
    t.sleep(1)

    # room outline for player
    print('\nYou walk into a new room. It appears to be an old forge with old will forging equipment and an anvil. there is a thin been of light coming into the room from a man made hole in the ceiling. in the corner there is a barrel of coal')

  #Room 3 game loop
  while True:
    answer = input('\n>')

    #sends the player to the previous room
    if 'go back' == answer:
      go_back()

    #saves the game
    elif 'save' == answer:
      with open('save.json', 'w') as save:
        json.dump(data, save)
        print('Saved!')

    #checks if the player wants to get the coal bucket
    elif 'get coal bucket' == answer:
      if data['coal_bucket'] == 0:
        data['coal_bucket'] = 1
        print('you grab the bucket of coal')

    #checks the player wants to light the forge
    elif 'light' or 'light forge' or 'light fire' == answer:
      if data['torch'] == 1 and data['coal_bucket'] == 1:
        t.sleep(2)
        print ('\nAs you place the coal in the forge and light the fire you feel a great increase in your power ' + f.YELLOW +'Somewhere a door to the outside can be found'+ s.RESET_ALL, )

        t.sleep(1)

        print('\na key materialises on the anvil')

        t.sleep(1)

        print ('\n do you want to pick it up y/n')

        answer = input('\n>')

        #check the player want the key
        if 'y' in answer:
          data['has_key'] = 1
          print('you get the key from the anvil.')
          print('\n on it there is an inscription .' + f.RED +'"The way to light is found in the darkest places"' +s.RESET_ALL)

        #the player says no (why would you)
        elif 'n' in answer:
          print('ok')
        
    #quits the game
    elif 'quit' in answer:
      quit()
Пример #25
0
def start():

  clear()

  #tells the code we are in room 1
  data['Room'] = 1
  
  # Room title
  print(f.GREEN +'DARK ROOM'+ s.RESET_ALL)

  #prints this if you have been here before
  if data['fe1'] == 0:
    print("\nyou're back in the dark room")
  
  #checks if this is your first entry
  if data['fe1'] == 1:

    data['fe1'] = 0

    with open('save.json', 'w') as save:
      json.dump(data, save)

    t.sleep(1)
    #Room outline
    print('\n Suddenly you wake into a dark cave. its pitch black but you begin to feel your way around the room ')
    t.sleep(3)
    print(' \nyou find two doors one to the left one to the right')

  t.sleep(1)
  #suggested commands
  print('\n l for left r for right or look to explore some more')

  #Room 1 game loop
  while True:

    # recives and converts answer to lower case
    answer = input("\n>").lower()

    # sends the player left
    if 'l' == answer:
      clear()
      print('you go left')
      t.sleep(3)
      lake_room()
    
    # sends the player right
    elif 'r' == answer:
      clear()
      print('you go right')
      t.sleep(3)
      abandoned_forge()

    # the player explore the area
    elif 'look' == answer:
      # if they have a torch they find something
      if data['torch'] == 1:
        print('\n you look around and find what appears to be another door in the wall')
        data['door_found'] = 1

    #check for the open door command
    elif 'open door' ==  answer:
      #check if the playere has found the door and has the key
      if  data['has_key'] == 1 and data['door_found'] == 1:
        print('The door flies open and you are blinded by the light of the outside world')

        t.sleep(2)

        print("You've finished 0.0.2 of The Wills of Men. Thank you for playing!! ")

        with open('save.json', 'w') as save:
          json.dump(data, save)
        break

    #saves the game
    elif 'save' in answer:
      with open('save.json', 'w') as save:
        json.dump(data, save)
        print('Saved!')

    #sends player to quit function
    elif 'quit' in answer:
      quit()

# player death condition
  else:
    game_over('you died of boredom') # so did I
Пример #26
0
def main_program():
    func.set_console_title(const.heading_developer)
    init()
    while True:
        try:
            func.main_heading()
            func.sub_heading(const.heading_developer)
            func.back_heading()
            func.sub_heading_softwares('02', const.android_studio)
            func.sub_heading_softwares('03', const.java_jdk_08)
            func.sub_heading_softwares('04', const.python)
            func.sub_heading_softwares('05', const.git)
            func.sub_heading_softwares('06', const.notepad_p_p)
            func.sub_heading_softwares('07', const.pycharm)
            func.sub_heading_softwares('08', const.java_jdk_15)
            func.sub_heading_softwares('09', const.sq_lite)
            exit_code = func.exit_heading('10')

            choice = func.input_heading()

            if choice == 0:
                func.exception_heading(const.heading_zero)
                input()
                func.clear()
                continue

            elif choice == 1:
                func.clear()
                main.main()
                break

            elif choice == 2:
                android_studio()
                func.clear()
                continue

            elif choice == 3:
                java_jdk(const.java_jdk_08)
                func.clear()
                continue

            elif choice == 4:
                python()
                func.clear()
                continue

            elif choice == 5:
                git()
                func.clear()
                continue

            elif choice == 6:
                notepad_p_p()
                func.clear()
                continue

            elif choice == 7:
                pycharm()
                func.clear()
                continue

            elif choice == 8:
                java_jdk(const.java_jdk_15)
                func.clear()
                continue

            elif choice == 9:
                sq_lite()
                func.clear()
                continue

            elif choice == int(exit_code):
                func.remove_temp(is_wait=True)
                sys.exit()

            else:
                func.exception_range_heading(exit_code)
                input()
                func.clear()
                continue

        except Exception as err:
            func.exception_heading(f'Please input a number. {err}')
            input()
            func.clear()
  for i in range(0,100):
    my_pixels[i] = (0, 0, 0)
  functions.printme(my_pixels)
  time.sleep(1)  

  return

while True:
  m = 10
  n = 10
  i=0
  j=0
  k=0
  l=0
  count = 0
  functions.clear(my_pixels)
  functions.printme(my_pixels)
  # functions.spiral(my_pixels , k , l , m , n , count)
  # functions.clear(my_pixels)
  sav = 0
  # HBD_dynamic(my_pixels)
  # while True:
  #   sav = sav + 1
  #   if sav > 1: break
    # HBD(my_pixels)
    # functions.printme(my_pixels)
    # time.sleep(1)
  functions.A(90,my_pixels,RED)
  # time.sleep(1)
  functions.clear(my_pixels)
  functions.B(90,my_pixels,RED)
Пример #28
0
def create_character():
    """All the steps to create a character."""
    # Set level
    func.clear()
    level = func.set_level()
    char_data['level'] = level

    # Set name
    func.clear()
    char_data['name'] = func._input("Choose a name: ")

    # Choose rolling or array-setting your attributes
    func.clear()
    roll_or_set = func._input(
        "Would you like to Roll stats or Set stats manually? "
    )
    func.clear()
    if roll_or_set.lower() == "set":
        func.clear()
        set_stat = func.set_stats()
    elif roll_or_set.lower() == "roll":
        score_set = []
        for i in range(0, 6):
            score_set.append(func.roll_stats())
        func.clear()
        set_stat = func.set_stats(score_set)
    else:
        func.clear()
        print('Invalid choice, defaults to "Set"')
        set_stat = func.set_stats()

    # Set attributes
    temp = {}
    for key, value in char_data['attributes'].items():
        func.clear()
        temp[key] = int(set_stat[key])
    char_data['attributes'] = temp

    # Set facts
    func.clear()
    char_data['facts'] = func.set_facts(level)

    # Set armor
    func.clear()
    char_data['armor'] = func.choose_armor()

    # Set shield
    # TODO(Fix shield func)
    shield = 0
    # Calc AC
    dex = char_data['attributes']['dexterity']
    char_data['ac'] = func.calc_ac(
        char_data['armor']['ac_mod'],
        shield,
        func.calc_attr_mod(dex)
    )

    # Calc saving throws
    char_data['saving_throws'] = func.calc_all_throws(
        char_data['attributes'],
        level,
        char_data['armor']
    )

    # Print char
    func.clear()
    func.print_character(char_data)
Пример #29
0
# how many incorrect guesses has the player made?
guesses = 0


# randomly select one of five words to play hangman
word = random.choice(["secret", "cucumber", "potpourri", "jumpoff", "queazy"])


# proxy is the placeholder text that hides the letters from the player
# if they haven't yet guessed a letter then proxy shows an underscore instead
proxy = ["_"] * len(word)


# clear the console
f.clear()


# play the intro text
f.intro()


# prompt the player to start the game
raw_input("\n\nPress ENTER when you are ready!")


# clear the console
f.clear()


# first drawing of the gallows!!
Пример #30
0
def main_program():
    func.set_console_title(const.heading_mobile)
    init()
    while True:
        try:
            func.main_heading()
            func.sub_heading(const.heading_mobile)
            func.back_heading()
            func.sub_heading_softwares('02', const.samsung_usb)
            func.sub_heading_softwares('03', const.smart_switch)
            func.sub_heading_softwares('04', const.i_tunes)
            func.sub_heading_softwares('05', const.sms_contacts_recover)
            func.sub_heading_softwares('06', const.i_mobie)
            func.sub_heading_softwares('07', const.fone_paw)
            exit_code = func.exit_heading('08')

            choice = func.input_heading()

            if choice == 0:
                func.exception_heading(const.heading_zero)
                input()
                func.clear()
                continue

            elif choice == 1:
                func.clear()
                main.main()
                break

            elif choice == 2:
                samsung_usb()
                func.clear()
                continue

            elif choice == 3:
                smart_switch()
                func.clear()
                continue

            elif choice == 4:
                i_tunes()
                func.clear()
                continue

            elif choice == 5:
                sms_contacts_recover()
                func.clear()
                continue

            elif choice == 6:
                i_mobie()
                func.clear()
                continue

            elif choice == 7:
                fone_paw()
                func.clear()
                continue

            elif choice == int(exit_code):
                func.remove_temp(is_wait=True)
                sys.exit()

            else:
                func.exception_range_heading(exit_code)
                input()
                func.clear()
                continue

        except Exception as err:
            func.exception_heading(f'Please input a number. {err}')
            input()
            func.clear()
Пример #31
0
print(hangman_art.logo)

#Testing code
#print(f'Pssst, the solution is {chosen_word}.')

#Create blanks
display = []
for _ in range(word_length):
    display += "_"

while not end_of_game:
    guess = input("Guess a letter: ").lower()

    #clear screen after guess
    functions.clear()

    if guess in display:
        print(f"You already guessed the letter \'{guess}\'")

    #Check guessed letter
    for position in range(word_length):
        letter = chosen_word[position]

        if letter == guess:
            display[position] = letter

    #Check if user is wrong.
    if guess not in chosen_word:
        print(f"Sorry, the letter \'{guess}\' is not in the word")
        lives -= 1
Пример #32
0
from functions import summary, register_user, main_menu, checkout, logout, login_user, clear, prRed, prYellow, prGreen
import time

clear()

prGreen('''
 /$$      /$$ /$$$$$$$$ /$$        /$$$$$$   /$$$$$$  /$$      /$$ /$$$$$$$$       /$$$$$$$$/$$$$$$        /$$$$$$$$/$$   /$$ /$$$$$$$$        /$$$$$$  /$$$$$$$$/$$$$$$  /$$$$$$$  /$$$$$$$$
| $$  /$ | $$| $$_____/| $$       /$$__  $$ /$$__  $$| $$$    /$$$| $$_____/      |__  $$__/$$__  $$      |__  $$__/ $$  | $$| $$_____/       /$$__  $$|__  $$__/$$__  $$| $$__  $$| $$_____/
| $$ /$$$| $$| $$      | $$      | $$  \__/| $$  \ $$| $$$$  /$$$$| $$               | $$ | $$  \ $$         | $$  | $$  | $$| $$            | $$  \__/   | $$ | $$  \ $$| $$  \ $$| $$      
| $$/$$ $$ $$| $$$$$   | $$      | $$      | $$  | $$| $$ $$/$$ $$| $$$$$            | $$ | $$  | $$         | $$  | $$$$$$$$| $$$$$         |  $$$$$$    | $$ | $$  | $$| $$$$$$$/| $$$$$   
| $$$$_  $$$$| $$__/   | $$      | $$      | $$  | $$| $$  $$$| $$| $$__/            | $$ | $$  | $$         | $$  | $$__  $$| $$__/          \____  $$   | $$ | $$  | $$| $$__  $$| $$__/   
| $$$/ \  $$$| $$      | $$      | $$    $$| $$  | $$| $$\  $ | $$| $$               | $$ | $$  | $$         | $$  | $$  | $$| $$             /$$  \ $$   | $$ | $$  | $$| $$  \ $$| $$      
| $$/   \  $$| $$$$$$$$| $$$$$$$$|  $$$$$$/|  $$$$$$/| $$ \/  | $$| $$$$$$$$         | $$ |  $$$$$$/         | $$  | $$  | $$| $$$$$$$$      |  $$$$$$/   | $$ |  $$$$$$/| $$  | $$| $$$$$$$$
|__/     \__/|________/|________/ \______/  \______/ |__/     |__/|________/         |__/  \______/          |__/  |__/  |__/|________/       \______/    |__/  \______/ |__/  |__/|________/
         
              .:'                        .:'                        .:'                        .:'                      .:'                        .:'                        .:' 
          __ :'__                   __ :'__                     __ :'__                   __ :'__                   __ :'__                   __ :'__                     __ :'__ 
       .'`__`-'__``.             .'`__`-'__``.               .'`__`-'__``.             .'`__`-'__``.             .'`__`-'__``.             .'`__`-'__``.               .'`__`-'__``.
      :__________.-'            :__________.-'              :__________.-'            :__________.-'            :__________.-'            :__________.-'              :__________.-'
      :_________:               :_________:                 :_________:               :_________:               :_________:               :_________:                 :_________:
       :_________`-;             :_________`-;               :_________`-;             :_________`-;             :_________`-;             :_________`-;               :_________`-; 
        `.__.-.__.'               `.__.-.__.'                 `.__.-.__.'               `.__.-.__.'               `.__.-.__.'               `.__.-.__.'                 `.__.-.__.'

''')

while True:
    existing_account = input("Do you have an account with us? (Y/N): ").upper()
    print()

    if existing_account[:1] == 'Y':
        login_user()
Пример #33
0
import random
import functions as f
from messages import m

# how many incorrect guesses has the player made?
guesses = 0

# randomly select one of five words to play hangman
word = random.choice(["secret", "cucumber", "potpourri", "jumpoff", "queazy"])

# proxy is the placeholder text that hides the letters from the player
# if they haven't yet guessed a letter then proxy shows an underscore instead
proxy = ["_"] * len(word)

# clear the console
f.clear()

# play the intro text
f.intro()

# prompt the player to start the game
raw_input("\n\nPress ENTER when you are ready!")

# clear the console
f.clear()

# first drawing of the gallows!!
f.draw(guesses)

#print a playful message to the player
f.message(guesses, random.choice(m[guesses]))
Пример #34
0
def mercenary_fight(player, fight_level):
    f.clear()
    mercenary = m.Monster.mercenary_gen(fight_level, player)
    print("You have entered a fight with " + mercenary.name)
    fight(mercenary, player)
Пример #35
0
def main_program():
    func.set_console_title(const.heading_pdf)
    init()
    while True:
        try:
            func.main_heading()
            func.sub_heading(const.heading_pdf)
            func.back_heading()
            func.sub_heading_softwares('02', const.foxit_adv_pdf_editor)
            func.sub_heading_softwares('03', const.infix_pdf_editor)
            func.sub_heading_softwares('04', const.pdf_creator)
            func.sub_heading_softwares('05', const.pdf_shaper)
            func.sub_heading_softwares('06', const.tri_sun_pdf_to_jpg)
            func.sub_heading_softwares('07', const.pdf_to_jpg)
            func.sub_heading_softwares('08', const.pdf_to_jpg_converter)
            func.sub_heading_softwares('09', const.doro_pdf_writer)
            exit_code = func.exit_heading('10')

            choice = func.input_heading()

            if choice == 0:
                func.exception_heading(const.heading_zero)
                input()
                func.clear()
                continue

            elif choice == 1:
                func.clear()
                main.main()
                break

            elif choice == 2:
                foxit_adv_pdf_editor()
                func.clear()
                continue

            elif choice == 3:
                infix_pdf_editor()
                func.clear()
                continue

            elif choice == 4:
                pdf_creator()
                func.clear()
                continue

            elif choice == 5:
                pdf_shaper()
                func.clear()
                continue

            elif choice == 6:
                tri_sun_pdf_to_jpg()
                func.clear()
                continue

            elif choice == 7:
                pdf_to_jpg()
                func.clear()
                continue

            elif choice == 8:
                pdf_to_jpg_converter()
                func.clear()
                continue

            elif choice == 9:
                doro_pdf_writer()
                func.clear()
                continue

            elif choice == int(exit_code):
                func.remove_temp(is_wait=True)
                sys.exit()

            else:
                func.exception_range_heading(exit_code)
                input()
                func.clear()
                continue

        except Exception as err:
            func.exception_heading(f'Please input a number. {err}')
            input()
            func.clear()
Пример #36
0
 def search_log(self):
     row_list = get_row_list(self.spreadsheet)
     fmt = '%m/%d/%Y'
     while True:
         clear()
         print("Log Search Menu\n")
         print("1. Search by date")
         print("2. Search by time spent")
         print("3. Search by exact match or pattern")
         print("4. Page through individual entries")
         print("5. Previous menu\n")
         print("Please enter the number of the option you wish to choose.")
         user_choice = input("> ")
         if user_choice == '1':
             search_by_date = True
             while search_by_date:
                 clear()
                 print("Search an entry by date\n")
                 print("Would you like to enter a specific date range?")
                 user_choice2 = input("Y/N ")
                 if user_choice2.upper() == 'Y':
                     fmt_date_list = []
                     search_list = []
                     start_date = get_date("Starting Date")
                     end_date = get_date("Ending Date")
                     start_date_fmt = datetime.datetime.strptime(
                         start_date, fmt)
                     end_date_fmt = datetime.datetime.strptime(
                         end_date, fmt)
                     for result in perdelta(
                             start_date_fmt,
                             end_date_fmt + datetime.timedelta(days=1),
                             datetime.timedelta(days=1)):
                         fmt_date_list.append(
                             datetime.datetime.strftime(result, fmt))
                     for i in row_list:
                         if i[0] in fmt_date_list:
                             search_list.append(i)
                     get_options_to_edit(search_list, row_list,
                                         self.spreadsheet)
                     search_by_date = False
                 else:
                     selected_dates = []
                     task_date = get_date(
                         "Chosen date will list all entrie" +
                         "s with matching Task Date")
                     for i in row_list:
                         if i[0] == task_date:
                             selected_dates.append(i)
                     get_options_to_edit(selected_dates, row_list,
                                         self.spreadsheet)
                     search_by_date = False
         elif user_choice == '2':
             selected_entries = []
             while True:
                 clear()
                 print("Seach an entry by time\n")
                 hours = input("Hours: ")
                 minutes = input("Minutes: ")
                 if hours == '':
                     hours = '0'
                 if minutes == '':
                     minutes = '0'
                 try:
                     int(hours)
                     int(minutes)
                 except ValueError:
                     print("Invalid Entry")
                     input("Press Enter")
                 else:
                     task_duration = TimeHandler(int(hours), int(minutes))
                     h_fmt, m_fmt = task_duration.get_hours_minutes()
                     time_spent = "Hours:{} Minutes:{}".format(h_fmt, m_fmt)
                     # Time spent
                     break
             for row in row_list:
                 if row[2] == time_spent:
                     selected_entries.append(row)
             get_options_to_edit(selected_entries, row_list,
                                 self.spreadsheet)
         elif user_choice == '3':
             clear()
             selected_entries = []
             while True:
                 clear()
                 print(
                     "Search an entry by exact match or regular expression\n"
                 )
                 print("Please enter text or regular expression" +
                       " to match entries")
                 print("Do not add spaces after commas.")
                 string = input("> ")
                 if len(string) < 1:
                     print("Invalid Input")
                     input("Press Enter")
                 else:
                     break
             search_string = '(?P<results>%s)' % string
             for row in row_list:
                 row_string = ",".join(row)
                 parse = re.search(r'%s' % search_string, row_string, re.I)
                 if parse is not None:
                     selected_entries.append(row)
             get_options_to_edit(selected_entries, row_list,
                                 self.spreadsheet)
         elif user_choice == '4':
             page_range = list(range(0, len(row_list)))
             page = 0
             while True:
                 clear()
                 if len(row_list) == 0:
                     print("You don't have any entries to view.")
                     input("Press enter")
                     break
                 else:
                     current_row = row_list[page]
                     print("Entry #: {}\n".format(page + 1))
                     print("Date {}".format(current_row[0]))
                     print("Task Name: {}".format(current_row[1]))
                     print("Time Spent: {}".format(current_row[2]))
                     print("Notes: {}\n".format(current_row[3]))
                     print("1. Next Entry")
                     print("2. Previous Entry")
                     print("3. Edit Entry")
                     print("4. Back to previous menu\n")
                     print("Please enter the number of the option" +
                           " you wish to choose.")
                     user_choice = input("> ")
                     if user_choice == '1':
                         if page + 1 in page_range:
                             page = page + 1
                         else:
                             print("There are no more further entries.")
                             input("Press Enter")
                     elif user_choice == '2':
                         if page - 1 in page_range:
                             page = page - 1
                         else:
                             print("There are no more previous entries.")
                             input("Press Enter")
                     elif user_choice == '3':
                         edit_delete(row_list[page], row_list,
                                     self.spreadsheet)
                         break
                     elif user_choice == '4':
                         break
                     else:
                         print("Invalid Input")
                         input("Press Enter")
         elif user_choice == '5':
             break
         else:
             print("Invalid Input")
             input("Press Enter")

class ERROR(enum.IntEnum):
    ZERO = 0
    FILE_NOT_FOUND = 2
    PATH_NOT_FOUND = 3
    BAD_FORMAT = 11
    ACCESS_DENIED = 5
    ASSOC_INCOMPLETE = 27
    DDE_BUSY = 30
    DDE_FAIL = 29
    DDE_TIMEOUT = 28
    DLL_NOT_FOUND = 32
    NO_ASSOC = 31
    OOM = 8
    SHARE = 26


if __name__ == '__main__':
    if ctypes.windll.shell32.IsUserAnAdmin():
        if not len(os.listdir(func.temp)) == 0:
            func.log_show('Please wait...')
            func.remove_temp(is_wait=False)
            func.clear()
        main()
    else:
        hinstance = ctypes.windll.shell32.ShellExecuteW(
            None, 'runas', sys.executable, sys.argv[0], None, SW.SHOWNORMAL)
        if hinstance <= 32:
            raise RuntimeError(ERROR(hinstance))
Пример #38
0
 def write_to_log(self):
     task_date = get_date("Task Date")
     while True:
         clear()
         print("Task Date: {}\n".format(task_date))
         tester = []
         task_name = input("Please enter the name of your task: ")
         # Task name
         if len(task_name) > 0:
             for i in task_name:
                 if i != " ":
                     tester.append(1)
         if len(tester) > 0:
             break
         else:
             print("Invalid Task Name")
             input("Press Enter")
     while True:
         clear()
         print("Task Date: {}".format(task_date))
         print("Task Name: {}\n".format(task_name))
         print("Enter the amount of time spent")
         hours = input("Hours: ")
         minutes = input("Minutes: ")
         if hours == '':
             hours = '0'
         if minutes == '':
             minutes = '0'
         try:
             int(hours)
             int(minutes)
         except ValueError:
             print("Invalid Entry")
             input("Press Enter")
         else:
             task_duration = TimeHandler(int(hours), int(minutes))
             hours_fmt, minutes_fmt = task_duration.get_hours_minutes()
             time_spent = "Hours:{} Minutes:{}".format(
                 hours_fmt, minutes_fmt)
             # Time spent
             break
     clear()
     print("Task Date: {}".format(task_date))
     print("Task Name: {}".format(task_name))
     print("Time Spent: {}\n".format(time_spent))
     notes = input("Enter additional notes (Optional): ")
     # Notes
     tester2 = []
     if len(notes) > 0:
         for i in task_name:
             if i != " ":
                 tester2.append(1)
     if len(tester2) < 1:
         notes = 'N/A'
     with open(self.spreadsheet, 'a') as csvfile:
         fieldnames = ['Date', 'Task Name', 'Time Spent', 'Notes']
         writer = csv.DictWriter(csvfile,
                                 fieldnames=fieldnames,
                                 lineterminator='\n')
         writer.writerow({
             'Date': task_date,
             'Task Name': task_name,
             'Time Spent': time_spent,
             'Notes': notes
         })