def main_menu():
    """Show Keahua Action Options

    Arguments: None
    """
    clear_screen()
    build_menu()
    choice = input(">> ")
    # print(choice)
    # input('^^choice')

    if choice == "1":
        annex_habitat(keahua)

    if choice == "2":
        release_animal(keahua)

    if choice == "3":
        redo_feed_animal(keahua)

    if choice == "4":
        add_plant(keahua)

    if choice == "5":
        build_facility_report(keahua)
        pass

    if choice != "6":
        main_menu()

    if choice == "6":
        os.system('say Goodbye' if os.name != 'nt' else '')

    return
    def start(self):
        """Begin the game."""
        super().start()
        utilities.clear_screen()
        self.show_welcome()
        self.setup()

        while self.playing:
            utilities.clear_screen()
            print("I'm thinking of a word. Can you guess what it is letter by letter?")
            print("You can guess wrong only {0.bad_guesses_allowed} times. Good luck!".format(self))
            self.draw()
            guess = self.get_guess()

            if guess in self.secret_word:
                self.good_guesses.append(guess)
                found = True
                for letter in self.secret_word:
                    if letter not in self.good_guesses:
                        found = False
                if found:
                    print("You win!")
                    self.print_secret_word()
                    self.playing = False

            else:
                self.bad_guesses.append(guess)
                if len(self.bad_guesses) == self.bad_guesses_allowed:
                    self.draw()
                    print("You lost!")
                    self.print_secret_word()
                    self.playing = False

        self.play_again_prompt()
def annex_habitat(arboretum):
    clear_screen()

    build_menu()
    choice = input("Choose your habitat > ")
    name = input("What would you like to name it? > ")
    if choice == "1":
        mountain = Mountain(name)
        arboretum.biomes["Mountains"].append(mountain)
        os.system(f'say you have annexed {name} Mountain!' if os.name != 'nt' else '')
    if choice == "2":
        swamp = Swamp(name)
        arboretum.biomes["Swamps"].append(swamp)
        os.system(f'say you have annexed {name} Swamp!' if os.name != 'nt' else '')
    if choice == "3":
        grassland = Grassland(name)
        arboretum.biomes["Grasslands"].append(grassland)
        os.system(f'say you have annexed {name} grassland!' if os.name != 'nt' else '')
    if choice == "4":
        forest = Forest(name)
        arboretum.biomes["Forests"].append(forest)
        os.system(f'say you have annexed {name} forest!' if os.name != 'nt' else '')
    if choice == "5":
        river = River(name)
        arboretum.biomes["Rivers"].append(river)
        os.system(f'say you have annexed {name} river!' if os.name != 'nt' else '')
    if choice == "6":
        coastline = Coastline(name)
        arboretum.biomes["Coastlines"].append(coastline)
        os.system(f'say you have annexed {name} coastline!' if os.name != 'nt' else '')

    return
Exemplo n.º 4
0
def date_search(data):
    """Search by entry date from timestamp"""
    clear_screen()
    found = False

    print("All Dates: \n")
    for entry in data:
        timestamp = entry.timestamp.strftime("%d/%m/%Y")
        print(timestamp)

    while True:
        input_date = input("\nEnter a Date from the List: ")
        if re.search(r'(\d\d/\d\d/\d\d\d\d)', input_date):
            break
        print("Please, Enter a valid date!")
    clear_screen()

    for entry in data:
        timestamp = entry.timestamp.strftime("%d/%m/%Y")
        if timestamp == input_date:
            print_entry(entry)
            found = True
    if found is False:
        print("No Entries Found..")
    return input_date
Exemplo n.º 5
0
def student_loop(usr):
    cmd = ''

    while cmd != 'logout':

        try:
            cmd = (input(f'{usr}> '))
            cmdlist = cmd.split()

            if len(cmdlist) == 5 and cmdlist[0] == 'edact':
                edact(usr, cmdlist)

            elif len(cmdlist) == 1 and cmdlist[0] == 'vtut':
                print()
                vtut()

            elif len(cmdlist) == 9 and cmdlist[0] == 'aapt':
                aapt(cmdlist, usr)

            elif cmdlist[0] == 'edapt':
                edapt(cmdlist)

            elif cmdlist[0] == 'dapt':
                dapt(cmdlist)

            elif len(cmdlist) == 1 and cmdlist[0] == 'emcon':
                emcon()

            elif len(cmdlist) == 1 and cmdlist[0] == 'emrem':
                emrem()

            elif len(cmdlist) == 1 and cmdlist[0] == 'psr':
                psr(usr)

            elif len(cmdlist) == 1 and cmdlist[0] == '--help':
                gethelp()

            elif len(cmdlist) == 1 and cmdlist[0] == 'clear':
                clear_screen()

            elif cmd != 'logout':
                print('Error: Invalid command')

        except IndexError as ind:
            if cmd == '\r' or '\n': continue
            else:
                print('Error: Wrong number of arguments')
                continue
        except HTTPError as http_err:
            print(f'HTTP Error: {http_err}')
            continue
        except KeyboardInterrupt as kybrd:
            cmd = 'logout'
            print()

        except Exception as err:
            print(f'Error: {err}')
            continue
Exemplo n.º 6
0
    def listen(self):
        self.text = ""
        utilities.clear_screen()
        print("I'm listening. Give me three seconds break before I answer.")

        if self.recorder.record():
            self.text = self.recorder.spoken_words

        return self.text
Exemplo n.º 7
0
    def main(self):
        """Welcomes player to Console Games then calls choose_game"""
        utilities.clear_screen()
        self.show_welcome()
        self.show_help()
        print("")

        while True:
            self.choose_game()
def get_time():
    """Collects time in minutes"""
    clear_screen()
    while True:
        try:
            time = int(input("Add Time in Minutes: "))
            break
        except ValueError:
            print("Please, Enter a Whole Number in Minutes!")
    return time
def get_name():
    """Collects user name"""
    clear_screen()
    while True:
        name = input("Add Name: ")
        if name == "":
            print("Please, Add Your Name!")
        else:
            break
    return name
Exemplo n.º 10
0
 def __init__(self, dataFrame, current_photo_indices):
     # Frame.__init__(self,master)
     utilities.clear_screen(utilities.data_global_scope['rootGlobalMaster'])
     self.checkButtonList = list()
     # self.master = master
     self.current_photo_indices = current_photo_indices
     self.creatingStringVarList(len(self.current_photo_indices))
     self.master = utilities.data_global_scope['rootGlobalMaster']
     self.dataFrame = dataFrame
     self.init_window(self.master)
Exemplo n.º 11
0
def get_task():
    """Collects task name"""
    clear_screen()
    while True:
        task = input("Add Task Name: ")
        if task == "":
            print("Please, Add Task Name!")
        else:
            break
    return task
Exemplo n.º 12
0
def track(yesterday: bool = False):
    """Run whole tracking sequence."""
    print(Colors.BLUE + '   TRACK  ' + Colors.NORMAL + '\n')
    if yesterday:
        print(Colors.YELLOW + 'Tracking for yesterday:\n' + Colors.NORMAL)
    try:
        tod_accomplishments = get_completed_tasks_in_tod()
        entry_dic = user_entry(tod_accomplishments)
    except FileNotFoundError:
        entry_dic = user_entry()
    entry = format_entry(entry_dic, yesterday)
    clear_screen()
    append_data(entry, os.getenv('TRACK_FP'))
    print('Entry recorded.')
Exemplo n.º 13
0
def choose_class(player, starting_room):
    clear_screen()
    class_choice = minimize_input(
        f"What class would you like to be?\nType either (F)ighter or (W)izard:"
    )
    if class_choice == "f":
        player = Fighter(starting_room)
    elif class_choice == "w":
        player = Wizard(starting_room)
    else:
        player = None
        return player
    clear_screen()
    choice = (f"############################\n"
              f"You have chosen {player.name}.\n"
              f"{player.view_stats_no_header()}\n"
              f"############################\n")
    print(choice)
    final = minimize_input(f"Would you like to keep this class? (Y/N)")
    if final == "y":
        clear_screen()
        player.journal.initialize_journal(starting_room)
        return player
    else:
        clear_screen()
        player = None
Exemplo n.º 14
0
def authorize(usr_name, pswrd):
    try:
        url = 'https://quanthu.life/tutorapp/users/login'
        data = {"username": usr_name, "password": pswrd}

        x = requests.post(url, json=data)
        response = json.loads(x.text)
        _id = ''
        if response["message"] == 'Login successfully.':
            if response['data']['role'] == 'STUDENT':
                clear_screen()
                student_loop(usr_name)
            elif response['data']['role'] == 'TUTOR':
                clear_screen()
                tutor_loop(usr_name)
            elif response['data']['role'] == 'FACULTY':
                clear_screen()
                fac_loop(usr_name)
            elif response['data']['role'] == 'ADMIN':
                clear_screen()
                admin_loop(usr_name)
        else:
            print(response['message'], "\n")

    except HTTPError as http_err:
        print(f'HTTP error occured: {http_err}')
Exemplo n.º 15
0
def search_term(data):
    """Use a search term on task name and notes"""
    clear_screen()
    found = False
    user_input = input("Enter a Search Term: ")
    clear_screen()

    for entry in data:
        if user_input.lower().strip() in entry.task_name.lower() \
                or user_input.lower() in entry.notes.lower():
            print_entry(entry)
            found = True
    if found is False:
        print("No Entries Found..")
    return user_input
Exemplo n.º 16
0
 def main_menu(self):
     while True:
         utilities.clear_screen()
         print("*" * 80)
         print("Hal main menu")
         print("*" * 80)
         print("\t press 1 to talk to Hal")
         print("\t press 2 to turn off Hal")
         inp = input("Please type 1 or 2 and press enter:")
         if inp == "1":
             self.start_listening()
         elif inp == "2":
             sys.exit()
         else:
             input(
                 "Wrong command please press enter to continue and repeat")
    def __init__(self, stage_instance, stage_no, photo_indices):
        utilities.clear_screen(utilities.data_global_scope['rootGlobalMaster'])
        self.master = utilities.data_global_scope['rootGlobalMaster']
        self.no_of_judges = utilities.data_global_scope['no_of_judges']
        self.tournament_name = utilities.data_global_scope['tournament_name']
        self.stage_instance = stage_instance
        self.stage_no = stage_no
        self.photo_indices = photo_indices
        # self.no_of_photos = entry_view.data_global_scope['no_of_photos']

        self.judge_vote_holders = list()
        self.transversed_photo = 0
        self.vote_holder_vars = list()
        for i in range(self.no_of_judges):
            self.vote_holder_vars.append(StringVar())
        self.total = StringVar()
        self.initializeUI(self.master)
        print('hello')
Exemplo n.º 18
0
def employee_search(data):
    """Search by employee name"""
    clear_screen()
    found = False

    print("All Employees: \n")
    for entry in data:
        print(entry.user_name)

    name = input("\nEnter a Name from the List: ")
    clear_screen()

    for entry in data:
        if name.lower().strip() in entry.user_name.lower():
            print_entry(entry)
            found = True
    if found is False:
        print("Name Not in List..")
    return name
Exemplo n.º 19
0
def main_menu():
    """Define the main menu."""
    utilities.show_main_menu_options()
    while True:
        selction = input("\nEnter 'a', 'b' or 'c' > ")

        if selction.upper() == 'A':  # Add new entry
            add_new_task()
            break
        if selction.upper() == 'B':  # search
            check_data()
            break
        if selction.upper() == 'C':  # Quit
            utilities.clear_screen()
            print('\nThanks for using WORK LOG :)\n')
            break
        else:
            utilities.show_main_menu_options()
            print("\nSorry, we did not recoginse '{}'"
                  ", please try again.".format(selction))
Exemplo n.º 20
0
def start_program():
    """Starts the WorkLog Program"""
    clear_screen()
    print("WorkLog | Time Tracking App")
    print("""
    [A] Create New Entry
    [B] Search Entries
    [C] Quit Program
    """)

    while True:
        user_input = input("What Would You Like to Do? ").lower().strip()
        if user_input == "c":
            print("Thank you! Bye!")
            sys.exit()
        elif user_input in main_menu:
            clear_screen()
            main_menu[user_input]()
        else:
            print("Enter A, B or C..")
Exemplo n.º 21
0
    def start(self):
        """Begin the game."""
        super().start()
        utilities.clear_screen()
        self.show_welcome()
        self.setup()
        print("How many questions can you get right out of {}?".format(len(self.questions)))
        print("The clock is ticking, so you better hurry!")
        while self.playing and len(self.answers) < len(self.questions):
            self.start_time = datetime.datetime.now()
            for question in self.questions:
                self.answers.append(self.ask(question))
            else:
                self.playing = False
                self.end_time = datetime.datetime.now()

        else:
            self.show_summary()
            self.cleanup()

        self.play_again_prompt()
Exemplo n.º 22
0
def fac_loop(usr):
    cmd = ''

    while cmd != 'logout':
        try:
            cmd = (input(f'{usr}> '))
            cmd_list = cmd.split()

            if len(cmd_list) == 2 and cmd_list[0] == 'rnrpt':
                rnrpt(cmd_list)

            elif len(cmd_list) == 1 and cmd_list[0] == 'srpt':
                srpt()

            elif len(cmd_list) == 1 and cmd_list[0] == 'psr':
                psr(usr)

            elif len(cmd_list) == 1 and cmd_list[0] == '--help':
                gethelp()

            elif len(cmd_list) == 1 and cmd_list[0] == 'clear':
                clear_screen()

            elif cmd != 'logout':
                print('Error: Invalid command')

        except IndexError as ind:
            if cmd == '\r' or '\n': continue
            else:
                print('Error: Wrong number of arguments')
                continue
        except HTTPError as http_err:
            print(f'HTTP Error: {http_err}')
            continue
        except KeyboardInterrupt as kybrd:
            cmd = 'logout'
            print()
        except Exception as err:
            print(f'Error: {err}')
            continue
Exemplo n.º 23
0
    def start(self):
        """Begin the game."""
        super().start()
        self.set_locations()
        logging.info("monster: {}; door: {}; player: {}".format(
            self.monster, self.door, self.player))
        utilities.clear_screen()
        print(
            "Welcome to the dungeon! There's a monster in here with you. Find the door before you get eaten!"
        )

        while self.playing:
            moves = self.get_moves()

            print("You're currently in room {}".format(self.player.location))
            self.draw_map()
            print("You can move {}".format(moves))
            print("Enter QUIT to quit")

            move = input("> ")
            move = move.upper()

            if move == self.QUIT_COMMAND:
                break

            if move in moves:
                self.move_player(move)
            else:
                print("You can't go that way! There's a wall there!")
                continue

            if self.player.location == self.door:
                print("You escaped! Great job!")
                self.stop()
            elif self.player.location == self.monster:
                print("You are a tasty treat for the monster. You lose!")
                self.stop()

        self.play_again_prompt()
Exemplo n.º 24
0
    def start(self):
        """Begin the game."""
        super().start()
        utilities.clear_screen()
        self.show_welcome()
        self.setup()

        while self.playing:
            utilities.clear_screen()
            print(
                "I'm thinking of a word. Can you guess what it is letter by letter?"
            )
            print(
                "You can guess wrong only {0.bad_guesses_allowed} times. Good luck!"
                .format(self))
            self.draw()
            guess = self.get_guess()

            if guess in self.secret_word:
                self.good_guesses.append(guess)
                found = True
                for letter in self.secret_word:
                    if letter not in self.good_guesses:
                        found = False
                if found:
                    print("You win!")
                    self.print_secret_word()
                    self.playing = False

            else:
                self.bad_guesses.append(guess)
                if len(self.bad_guesses) == self.bad_guesses_allowed:
                    self.draw()
                    print("You lost!")
                    self.print_secret_word()
                    self.playing = False

        self.play_again_prompt()
Exemplo n.º 25
0
class Main:
    # test for Python 2
    try:
        input = raw_input
    except NameError:
        pass

    while player is None:
        player = choose_class(player, starting_room)

    try:
        while True:
            clear_screen()
            # TODO: Implement and check DoT and HoT. Move counter has been moved to player.advance_turn(); Check will
            #   happen there. At end of player turn?
            columns = shutil.get_terminal_size().columns
            with term.location(x=0, y=0):
                print(f"Class: {player.name}")
            with term.location(x=term.width//2):
                print(health_bar(player))
            # Because the stamina can go off of the right side of the window, we pull back the length of both stamina
            # displays and all the needed space (i.e. 10 + 2*(len(stamina)))
            with term.location(x=term.width - (10 + len({player.stamina})*2)):
                print(f"Stamina: {player.stamina}/{player.stamina}")
            print("\n")
            if player.messages:
                player.print_messages()
                player.messages = None
            turn(player)

    except EndGameDied as e:
        print(f"{e.message}")
        pass
    except ZoneAlreadyExists:
        print(f"Zone already exists. The dev done f****d up.")
        pass
    except ZoneCreationError:
        print(f"Zone Creation Error")
        pass
    except RoomDoesNotExist:
        print(f"Room does not exist. The dev done f****d up.")
        pass
    except NotEnoughRoomsInZone:
        print(f"There aren't enough rooms in the Zone List to create this Zone Type.")
        pass
    except ItemNotInDictionary as e:
        print(f"{e.message}")
        pass
    except EndGame:
        pass
Exemplo n.º 26
0
def tutor_loop(usr, pswrd):
    #curTutor = Tutor(usr, pswrd)
    #getSched(usr)
    name = usr.split("@")[0]
    
    cmd = ""
    while cmd != "logout":

        try:
            cmd = (input(f'{name}> '))
            cmdList = cmd.split()

            if cmdList[0] == "papt":
                papt(name)
            elif cmdList[0] == "capt":
                capt()
            elif cmdList[0] == "aapt":
                aapt()
            elif cmdList[0] == "edapt":
                edapt()
            elif cmdList[0] == "dapt":
                dapt()
            elif cmdList[0] == "--help":
                getHelp()
            elif cmdList[0] == "psr":
                pswrdReset()
            elif cmdList[0] == 'exit':
                clear_screen()
                return
            elif cmd != "logout":
                print("Error: invalid command")
        except IndexError as ind:
            print("Error: wrong number of arguements")
            continue
        except KeyboardInterrupt as kybrd:
            return
Exemplo n.º 27
0
def time_search(data):
    """Search by time spent on task"""
    clear_screen()
    found = False

    print("Logged Time Data (Minutes): \n")
    for entry in data:
        print(entry.work_time)

    while True:
        try:
            time = int(input("\nEnter a Time from the List: "))
            break
        except ValueError:
            print("Please, Enter a Valid Number!")
    clear_screen()

    for entry in data:
        if entry.work_time == time:
            print_entry(entry)
            found = True
    if found is False:
        print("No Entries Found..")
    return time
Exemplo n.º 28
0
    def start(self):
        """Begin the game."""
        super().start()
        self.set_locations()
        logging.info("monster: {}; door: {}; player: {}".format(self.monster, self.door, self.player))
        utilities.clear_screen()
        print("Welcome to the dungeon! There's a monster in here with you. Find the door before you get eaten!")

        while self.playing:
            moves = self.get_moves()

            print("You're currently in room {}".format(self.player.location))
            self.draw_map()
            print("You can move {}".format(moves))
            print("Enter QUIT to quit")

            move = input("> ")
            move = move.upper()

            if move == self.QUIT_COMMAND:
                break

            if move in moves:
                self.move_player(move)
            else:
                print("You can't go that way! There's a wall there!")
                continue

            if self.player.location == self.door:
                print("You escaped! Great job!")
                self.stop()
            elif self.player.location == self.monster:
                print("You are a tasty treat for the monster. You lose!")
                self.stop()

        self.play_again_prompt()
Exemplo n.º 29
0
    def start(self):
        """Start and manage the game."""
        super().start()
        utilities.clear_screen()
        self.show_welcome()
        self.setup()
        print("I'm thinking of a number between {0.min_number} and {0.max_number}.".format(self))
        print("Can you guess what it is with {0.guesses_allowed} guesses?".format(self))
        print("Let's see.")

        while self.playing and len(self.guesses) < self.guesses_allowed:
            self.get_guess()
            try:
                self.guess = int(self.guess)
            except ValueError:
                print("{} isn't a number!".format(self.guess))
            else:
                # add guess to guesses
                self.guesses.append(self.guess)

                # compare guess to secret number
                if self.guess == self.secret_number:
                    print("Wow! You got it! My number was {}. You are pretty amazing.".format(self.secret_number))
                    break
                # print hit/miss
                elif self.guess < self.secret_number:
                    print("Nope. Think higher.")
                else:
                    print("Nope. Lower.")


        else:
            print("I win! You didn't guess it! My number was {}. Try again if you think you can beat me.".format(
                self.secret_number))

        self.play_again_prompt()
Exemplo n.º 30
0
def search_entries():
    """Search for existing entries in the database"""
    clear_screen()
    entries = Entry.select().order_by(Entry.timestamp.desc())
    print("Search All Entries:")
    print("""
    [A] Search for Employee
    [B] Search by Date
    [C] Search by Time Spent
    [D] Use a Search Term
    [E] Return to Main Menu
    """)

    while True:
        user_input = input("How Would You Like to Search? ").lower().strip()
        if user_input == "e":
            clear_screen()
            start_program()
        elif user_input in sub_menu:
            clear_screen()
            sub_menu[user_input](entries)
            new_search()
        else:
            print("Please, Try Again!")
Exemplo n.º 31
0
def add_plant(arboretum):
    clear_screen()

    plant = None
    build_plant_menu()
    plant_choice = input("Choose plant to cultivate > ")

    if plant_choice == "1":
        plant = Mountain_Apple_Tree()
    elif plant_choice == "2":
        plant = Silversword()
    elif plant_choice == "3":
        plant = Rainbow_Eucalyptus_Tree()
    elif plant_choice == "4":
        plant = Blue_Jade_Vine()
    else:
        print("No plant chosen. Press any key to return to main menu.")
        input()
        return

    clear_screen()
    build_plant_biome_menu(plant)

    print()
    habitat_choice = input("Choose your habitat type > ")

    #Set reference to chosen habitat
    try:
        chosen_habitat = plant.habitats[int(habitat_choice) - 1]
    except (IndexError, ValueError):
        input("Invalid input. Returning to main.")
        return

    #Print statement if no biomes of that type exist
    if len(arboretum.biomes[chosen_habitat]) == 0:
        print(
            "No biomes of that type exist. Press any key to return to main menu."
        )
        os.system(
            'say no biomes of that type exist' if os.name != 'nt' else '')
        input()
        return

    clear_screen()

    #Loop thru biomes of selected type unless all biomes are at max population
    # open_biomes = False
    bad_choices = ["bad choices"]

    open_biomes = build_individual_biome_menu(arboretum, chosen_habitat,
                                              bad_choices)

    if open_biomes == False:
        print()
        print(
            "All biomes of that type are at maximum population. Press any key to return to main menu."
        )
        input()
        return

    print()
    biome_choice = input("Choose your biome > ")

    if int(biome_choice) in bad_choices:
        input(
            "Told you not to press the button. Now you gotta go to the main menu lol."
        )
        return

    #Add plant to selected biome
    try:
        arboretum.biomes[chosen_habitat][int(biome_choice) -
                                         1].plants.append(plant)
    except (IndexError, ValueError):
        input("Invalid input. Returning to main.")
        return

    clear_screen()

    new_home = arboretum.biomes[chosen_habitat][int(biome_choice) - 1]
    display_plant_report(plant, new_home)

    input('Press any key to return to main menu.')
Exemplo n.º 32
0
def admin_loop(usr):
    cmd = ''

    while cmd != 'logout':
        try:
            cmd = (input(f'{usr}> '))
            cmd_list = cmd.split()

            if len(cmd_list) == 3 and cmd_list[0] == 'adad':
                add_account(cmd_list, 'ADMIN')

            elif cmd_list[0] == 'edad':
                edit_account(cmd_list, 'ADMIN')

            elif len(cmd_list) == 3 and cmd_list[0] == 'delad':
                del_account(cmd_list)

            elif cmd_list[0] == 'adfac':
                add_account(cmd_list, 'FACULTY')

            elif cmd_list[0] == 'edfac':
                edit_account(cmd_list, 'FACULTY')

            elif cmd_list[0] == 'delfac':
                del_account(cmd_list)

            elif cmd_list[0] == 'adtut':
                add_account(cmd_list, 'TUTOR')

            elif cmd_list[0] == 'edtut':
                edit_account(cmd_list, 'TUTOR')

            elif cmd_list[0] == 'deltut':
                del_account(cmd_list)

            elif len(cmd_list) == 9 and cmd_list[0] == 'adts':
                adts(cmd_list)

            elif cmd_list[0] == 'edts':
                edts()

            elif cmd_list[0] == 'delts':
                delts()

            elif cmd_list[0] == 'psa':
                psa(cmd_list)

            elif cmd_list[0] == 'papt':
                papt()

            elif cmd_list[0] == 'psr':
                psr(usr)

            elif cmd_list[0] == 'rnrpt':
                rnrpt()

            elif cmd_list[0] == 'srpt':
                srpt()

            elif len(cmd_list) == 1 and cmd_list[0] == '--help':
                gethelp()

            elif len(cmd_list) == 1 and cmd_list[0] == 'clear':
                clear_screen()

            elif cmd != 'logout':
                print('Error: Invalid command')

        except IndexError as ind:
            if cmd == '\r' or '\n': continue
            else:
                print('Error: Wrong number of arguments')
                continue
        except HTTPError as http_err:
            print(f'HTTP Error: {http_err}')
            continue
        except KeyboardInterrupt as kybrd:
            cmd = 'logout'
            print()
        except Exception as err:
            print(f'Error: {err}')
            continue
Exemplo n.º 33
0
from random import shuffle
from utilities import clear_screen, banner_message

# I will begin with only 5 numbers. But it can be changed to anything
begin_with = 5

# This list will store all the words
words = []
for i in range(begin_with):
    word = input("Enter word #" + str(i + 1) + ": ")
    words.append(word)  # add the word at the end of the list

# Loop infinitely
while True:
    failed = False  # variable indicating failure
    clear_screen()
    banner_message("Game begins now!")
    total_word_count = len(words)
    # indexes contain 0, 1, 2...total_word_count
    indexes = list(range(total_word_count))
    # this function does not return anything, but shuffles the values in "indexes" list directly
    shuffle(indexes)
    for i in indexes:
        # Ask for a word
        word = input("Do you remember the word #" + str(i + 1) + "? ")
        if word != words[i]:
            # If wrong, add a new word and make the game even harder
            print("Wrong word! the game just got harder...")
            failed = True  # set the value to true to indicate failure
            new_word = input("Enter a new word (#" +
                             str(total_word_count + 1) + "): ")
Exemplo n.º 34
0
 def quit(self):
     """Quit game and return to menu"""
     utilities.clear_screen()
     print(
         "Welcome back. I hope you had a great time playing {0.TITLE}. Would you like to play another game?".format(
             self))