Esempio n. 1
0
    def gates_of_village(self):
        """starts the gameplay loops of being at the gates of the village,
         asking the user where they would like to travel"""

        # starts the respective methods to take the user to the location they choose based on input
        while True:

            clear_screen()
            colour_print(
                "You are at the gates of the village. "
                "Would you like to venture to the (W)ilderness or (V)illage\n\n(Q) to Quit Game"
            )
            venture_choice = str_input()

            if venture_choice == 'w' or venture_choice == 'wilderness':

                play_music('soundtrack/wilderness_music.mp3')
                self.wilderness()
                break
                # once they enter the wilderness, they no longer need the gates of the village gameplay loop

            elif venture_choice == 'v' or venture_choice == 'village':

                self.village()
                # village does not break as once a player leaves the village, they remain at the gates

            elif venture_choice == 'q' or venture_choice == 'quit':

                save_quit(self)
                break

            else:

                invalid_input()
Esempio n. 2
0
    def open_safe(self):

        while True:

            colour_print(
                "You arrive at your safe. Would you like to (O)pen it or (L)eave?\n\n(Q) to Quit Game"
            )
            safe_choice = str_input()

            if safe_choice == 'o' or safe_choice == 'open':

                colour_print("You unlock your safe...")
                self.player.safe_interface()

            elif safe_choice == 'l' or safe_choice == 'leave':

                colour_print("You leave your safe")
                break

            elif safe_choice == 'q' or safe_choice == 'quit':

                save_quit(self)

            else:

                invalid_input()
Esempio n. 3
0
    def village(self):
        """starts the village gameplay loop"""

        play_music('soundtrack/village_music.mp3')

        # starts the respective methods to take the user to where they would like to go based on input
        while True:

            colour_print(
                "Would you like to visit the (F)orgery, (P)otion shop, (W)eapon Dealer, (A)rmor shop, "
                "(U)pgrade center, (M)arketplace, (S)afe, (M)anually save game, or (L)eave?"
                "\n\n(Q) to Quit Game")
            village_choice = str_input()

            if village_choice == 'f' or village_choice == 'forgery':

                self.forgery()

            elif village_choice == 'p' or village_choice == 'potion':

                self.potion_shop()

            elif village_choice == 'w' or village_choice == 'weapon':

                self.weapon_dealer()

            elif village_choice == 'a' or village_choice == 'armour':

                self.armour_shop()

            elif village_choice == 'u' or village_choice == 'upgrade':

                self.upgrade_center()

            elif village_choice == 'm' or village_choice == 'marketplace':

                self.marketplace()

            elif village_choice == 's' or village_choice == 'safe':

                self.open_safe()

            elif village_choice == 'g' or village_choice == 'save':

                self.village_save()

            elif village_choice == 'q' or village_choice == 'quit':

                save_quit(self)

            elif village_choice == 'l' or village_choice == 'leave':

                break

            else:

                invalid_input()
Esempio n. 4
0
    def boss_fight(self, boss):
        """initiates a boss fight"""

        while True:

            colour_print(
                "You have reached the abode of a boss, would you like to (F)ight or (L)eave"
                "\n\n(Q) to Quit Game")
            boss_fight_choice = str_input()

            if boss_fight_choice == 'f' or boss_fight_choice == 'fight':

                starting_health = self.player.get_health()
                # saves the player's starting health before the fight
                starting_inventory = self.player.get_inventory()
                # saves the player's starting inventory before the fight
                self.hostile = boss_object_dictionary[boss]
                # loads the boss object into the game save's hostile attribute

                if self.fight():

                    # initiates a boss fight and checks if the player wins
                    self.tile_list[self.player.get_tile_list_index(
                    )].remove_composition()
                    # if boss is defeated, it is removed from the tile
                    self.player_tile = self.tile_list[
                        self.player.get_tile_list_index()]
                    # removes the boss from the dictionary as it has been defeated
                    self.wilderness()
                    # if the player wins the battle, they return to the wilderness

                    break

                else:

                    self.player.die(starting_health, starting_inventory)
                    self.player.respawn()
                    self.enter_new_tile()
                    # if the player loses the battle and dies, they spawn back at the village at their starting health

                    break

            elif boss_fight_choice == 'l' or boss_fight_choice == 'leave':

                self.wilderness()
                # sends the player back to the wilderness

            elif boss_fight_choice == 'q' or boss_fight_choice == 'quit':

                save_quit(self)

            else:

                invalid_input()
Esempio n. 5
0
    def wilderness(self):
        """starts the wilderness gameplay loop"""

        while True:

            clear_screen()
            colour_print(self.player.display_navigation_stats())
            colour_print(
                "Would you like to move (N)orth, (S)outh, (E)ast, (W)est, or (R)eturn to village?"
                "\n\n(Q) to Quit Game")
            wilderness_choice = str_input()
            # displays the player's location and stats and asks them with direction they would like to go

            if wilderness_choice == 'n' or wilderness_choice == 'north':

                self.player.move([0, 1])
                # north increases the y value by 1
                break

            elif wilderness_choice == 's' or wilderness_choice == 'south':

                self.player.move([0, -1])
                # south decreases the y value by 1
                break

            elif wilderness_choice == 'e' or wilderness_choice == 'east':

                self.player.move([1, 0])
                # east increases the x value by 1
                break

            elif wilderness_choice == 'w' or wilderness_choice == 'west':

                self.player.move([-1, 0])
                # west decreases the x value by 1
                break

            elif wilderness_choice == 'r' or wilderness_choice == 'return':

                self.player.spawn_at_village()
                self.gates_of_village()
                break

            elif wilderness_choice == 'q' or wilderness_choice == 'quit':

                save_quit(self)
                break

            else:

                invalid_input()
Esempio n. 6
0
    def forgery(self):
        """starts the forgery gameplay loop, giving the player the option to reforge their weapon or leave"""

        # executes the player's choice based on input
        while True:

            self.player.display_monetary_stats()
            colour_print(
                "Would you like to (R)eforge your weapon for 20 coins or (L)eave the shop?"
                "\n\n(Q) to Quit Game")
            forgery_choice = str_input()

            if forgery_choice == 'r' or forgery_choice == 'reforge':

                self.player.reforge_weapon()
                # once a player reforges their weapon, they remain in the shop until they chose to leave
                # they remain in the shop through recursion of the forgery method

            elif forgery_choice == 'l' or forgery_choice == 'leave':

                if self.player.is_reputation_high():
                    # colour_prints exit dialogue for high reputation if the player has high reputation

                    colour_print(
                        random.choice(
                            shop_dialogue['forgery']['high_reputation']))

                else:
                    # colour_prints exit dialogue for low reputation if player does not have high reputation

                    colour_print(
                        random.choice(
                            shop_dialogue['forgery']['low_reputation']))

                break

            elif forgery_choice == 'q' or forgery_choice == 'quit':

                save_quit(self)

            else:

                invalid_input()
Esempio n. 7
0
    def tutorial(self):
        """starts the tutorial gameloop, teaching the player how to fight and giving them some information to understand
        the gameplay mechanics"""

        colour_print(
            "Welcome to the UNIVERSE.\nA 13x15 grid sprawling with monsters to fight."
            "\nYou can seek refuge in the village, where you can find all kinds of shops to gear up for the "
            "challenge ahead.\nWhen you're ready for adventure, you can leave into the wilderness."
            "\nPRESS ENTER TO CONTINUE")
        input()
        colour_print(
            "You will have weapons (each with their own unique attacks) and potions at your disposal."
            "\nNow you will face a practice enemy in this tutorial before entering the UNIVERSE."
            "\nPRESS ENTER TO CONTINUE")
        input()

        # starts the fight, if the player loses, the loop will continue
        while not self.fight():

            colour_print("Would you like to (t)ry again or (q)uit?")
            tutorial_death_choice = input()

            if tutorial_death_choice == 't' or tutorial_death_choice == 'try':

                continue

            elif tutorial_death_choice == 'q' or tutorial_death_choice == 'quit':

                save_quit()

            else:

                invalid_input()

        time.sleep(0.5)
        colour_print(
            "Impressive. You're now ready to go out into the UNIVERSE.\nPRESS ENTER TO CONTINUE"
        )
        input()
        play_music('soundtrack/village_music.mp3')
        self.gates_of_village()
Esempio n. 8
0
    def armour_shop(self):
        """stars the armour shop game loop, allowing the player to purchase armour"""

        armour_group_key_list = [
            armour_group_key for armour_group_key in armour_object_dictionary
        ]
        armour_group_list = [
            armour_object_dictionary[armour_group_key]
            for armour_group_key in armour_group_key_list
        ]
        # puts weapons into a fixed list for the entire duration of this method's call
        # to prevent variance in the order displayed, as dictionaries are unordered
        armour_order_list = ['helmet', 'chestplate', 'boots']
        # specifies the types of armour and their order

        while True:

            self.player.display_monetary_stats()
            colour_print(
                "Welcome to the armour shop, would you like to (B)uy armour or (L)eave\n\n(Q) to Quit Game"
            )
            armour_shop_choice = str_input()

            if armour_shop_choice == 'b' or armour_shop_choice == 'buy':

                index = 1

                for armour_group in armour_group_list:

                    colour_print("\n" + armour_group[random.choice(
                        armour_order_list)].get_set().upper() + "\n")
                    # loops through and colour_prints the sets of armour

                    for armour_piece in armour_group:
                        colour_print(
                            str(index) + ". " + armour_order_list[
                                index % len(armour_order_list)].capitalize() +
                            ": " + str(armour_group[armour_piece]) +
                            "\nCost: " +
                            str(armour_group[armour_piece].get_cost() *
                                self.player.get_price_multiplier()))
                        # loops through and colour_prints all the armor pieces within each set of armour

                        index += 1

                colour_print(str(index) + ". Back out")

                colour_print(
                    "Which armour piece would you like to purchase? (Enter the number of the armour piece)"
                )
                armour_choice = int_input()

                if armour_choice < index:
                    # checks if the selection is within range of the list of weapons

                    self.player.equip_armour(
                        armour_group_list[armour_choice //
                                          len(armour_order_list)]
                        [armour_order_list][armour_choice %
                                            len(armour_order_list)])
                    # uses floored division dividing the armour choice by the amount of pieces of armor per set
                    # to find the index of the armour set in the first set of squared brackets
                    # then uses modulus to find the index of the armour piece within the set of armour in the second
                    # squared brackets

                elif armour_choice == index:

                    pass
                    # if player chooses to back out they're returned to the first armour shop prompt

                else:

                    invalid_input()

            elif armour_shop_choice == 'l' or armour_shop_choice == 'leave':

                colour_print("Thanks for coming by!")
                break

            elif armour_shop_choice == 'q' or armour_shop_choice == 'quit':

                save_quit(self)

            else:

                invalid_input()
Esempio n. 9
0
    def weapon_dealer(self):
        """starts the weapon dealer game loop, allowing the player to purchase weapons"""

        weapon_list = [
            weapon_dealer_weapons[weapon_key]
            for weapon_key in weapon_dealer_weapons
        ]
        # puts weapons into a fixed list for the entire duration of this method's call

        while True:

            self.player.display_monetary_stats()
            colour_print(
                "I am Paul the weapon dealer! Would you like to (B)uy weapons or (L)eave\n\n(Q) to Quit Game"
            )
            weapon_dealer_choice = str_input()

            if weapon_dealer_choice == 'b' or weapon_dealer_choice == 'buy':

                index = 1
                colour_print("WEAPONS: \n")

                for weapon in weapon_list:
                    colour_print(
                        str(index) + ". " + str(weapon).capitalize() +
                        "\nPrice: " + str(weapon.get_cost() *
                                          self.player.get_price_multiplier()) +
                        "\n")
                    index += 1
                    # loops through the weapons and colour_prints them out in a numbered list

                colour_print(str(index) + ". Back out\n")

                colour_print(
                    "Which weapon would you like to purchase? (Enter the number of the weapon)"
                )
                weapon_choice = int_input()

                if 0 < weapon_choice < index:
                    # checks if the selection is within range of the list of weapons

                    self.player.purchase(weapon_list[weapon_choice -
                                                     1].get_cost())
                    self.player.equip_weapon(weapon_list[weapon_choice - 1])
                    # removes the cost from the player's balance, and adds the potion of choice to their inventory

                elif weapon_choice == index:

                    pass
                    # if player chooses to back out they're returned to the first potion shop prompt

                else:

                    invalid_input()

            elif weapon_dealer_choice == 'l' or weapon_dealer_choice == 'leave':

                colour_print("Thank you for coming by!")
                break

            elif weapon_dealer_choice == 'q' or weapon_dealer_choice == 'quit':

                save_quit(self)

            else:

                print("Invalid input", "red")
Esempio n. 10
0
    def potion_shop(self):
        """starts the potion shop game loop, allowing the player to purchase potions"""

        potion_list = [
            potion_object_dictionary[potion_key]
            for potion_key in potion_object_dictionary
        ]
        # puts potions into a fixed list for the entire duration of this method's call

        while True:

            self.player.display_monetary_stats()
            colour_print(
                "Welcome to the potion shop! Would you like to (B)uy potions or (L)eave\n\n(Q) to Quit Game"
            )
            potion_shop_choice = str_input()

            if potion_shop_choice == 'b' or potion_shop_choice == 'buy':

                index = 1
                colour_print("POTIONS: \n")

                for potion in potion_list:
                    colour_print(
                        str(index) + ". " + str(potion).capitalize() +
                        "\nPrice: " + str(potion.get_cost() *
                                          self.player.get_price_multiplier()) +
                        "\n")
                    index += 1
                    # loops through the potions and colour_prints them out in a numbered list

                colour_print(str(index) + ". Back out\n")

                colour_print(
                    "Which potion would you like to purchase? (Enter the number of the potion)"
                )
                potion_choice = int_input()

                if 0 < potion_choice < index:
                    # checks if the selection is within range of the list of potions

                    self.player.purchase(potion_list[potion_choice -
                                                     1].get_cost())
                    self.player.add_item_to_inventory(
                        potion_list[potion_choice - 1])
                    # removes the cost from the player's balance, and adds the potion of choice to their inventory

                elif potion_choice == index:

                    pass
                    # if player chooses to back out they're returned to the first potion shop prompt

                else:

                    invalid_input()

            elif potion_shop_choice == 'l' or potion_shop_choice == 'leave':

                if self.player.is_reputation_high():
                    # colour_prints exit dialogue for high reputation if the player has high reputation

                    colour_print(
                        random.choice(
                            shop_dialogue['potion_shop']['high_reputation']))

                else:
                    # colour_prints exit dialogue for low reputation if player does not have high reputation

                    colour_print(
                        random.choice(
                            shop_dialogue['potion_shop']['low_reputation']))

                break

            elif potion_shop_choice == 'q' or potion_shop_choice == 'quit':

                save_quit(self)