Ejemplo n.º 1
0
 def item_container_retrieving_items(self):
     """
     function used for interacting with items in the container and retrieving (adding them to player1 inventory)
     either 1 by 1 or all at the same time. It adjusts values both in player1.inventory and in self.contents.
     
     """
     while True:
         for item in self.contents:
             if self.contents[item] > 0:
                 print("Press " + str(list(self.contents.keys()).index(item) + 1) + " to take " + item + ".")
             else:
                 pass
         choice = (input("Press 'A' to take all, press 'E' to exit.\n")).lower()
         if choice.isdigit() is True and int(choice) in range(1, (len(list(self.contents.keys())) + 1)):
             selection = int(choice)
             selected_item = list(self.contents.keys())[selection - 1]
             if selected_item in player1.inventory:
                 self.contents[selected_item] -= 1
                 player1.inventory[selected_item] += 1
             else:
                 self.contents[selected_item] -= 1
                 player1.inventory[selected_item] = 1
         elif choice == 'a':
             for item in self.contents:
                 if item in player1.inventory:
                     player1.inventory[item] += self.contents[item]
                     self.contents[item] = 0
                 else:
                     player1.inventory[item] = self.contents[item]
                     self.contents[item] = 0
             break
         elif choice == 'e':
             break
         else:
             X_gen_mechanics.wrong_input()
Ejemplo n.º 2
0
    def craftstation_power_up(self):
        """
        This function serves to accomodate the added layer of difficulty - the possibility that the craftstation is
        powered down. It allows the player to use a pre-defined (__init__) item to power the craftstation up.

        """
        if self.power_status == 0:
            input(self.intro_powered_down + "\n")
            while True:
                if self.power_source in player1.inventory:
                    print("Press 'I' to use " + self.power_source + ".")
                else:
                    print("You don\'t have the necessary power source in your inventory.\n")
                choice = (input("Press 'E' to exit.\n")).lower()
                if choice == 'i' and self.power_source in player1.inventory:
                    self.power_status = 1
                    player1.inventory[self.power_source] -= 1
                    input(self.intro_powered_up)
                    break
                elif choice == 'e':
                    break
                else:
                    X_gen_mechanics.wrong_input()
        else:
            return self.intro_powered_up + "\n"
Ejemplo n.º 3
0
    def interaction(self):
        """
        function used dor the initial interaction with the container, encompasses the process of opening it with
        a skill. Most logical skill is hacking but left that as input in the __init__ as may vary from game to game.

        """
        print("This is a " + self.name + ".\n")
        if self.lock_status == 1:
            while True:
                print(self.intro_locked)
                if self.skill_used_to_open in player1.skills and \
                        player1.skills[self.skill_used_to_open] >= self.skill_lvl_required:
                    print("Press 'S' to use your " + self.skill_used_to_open + " skills to hack this terminal.")
                else:
                    X_gen_mechanics.insufficient_skill()
                    break
                choice = (input("Press '0' to exit.\n"))
                try:
                    if choice == 's' and player1.skills[self.skill_used_to_open] >= self.skill_lvl_required:
                        input(self.skill_open_message + "\n")
                        self.lock_status = 0
                        self.data_container_retrieving_data()
                        break
                    elif choice == '0':
                        break
                except ValueError:
                    X_gen_mechanics.wrong_input()
        elif self.lock_status == 0:
            print(self.intro_open)
            self.data_container_retrieving_data()
Ejemplo n.º 4
0
 def craftstation_crafting(self):
     """
     This function enables the player to add items from their inventory into the crafting pool and when they think
     they are done, they can attempt crafting which effectively compares the crafting pool to the recipe in the
     recipes dict and depending on whether they are the same or not, gives the player the crafted item or informs
     them that the crafting failed.
     """
     items_used = {}
     input("Select a known crafting recipe:\n")
     known_recipes = player1.crafting_recipes
     if len(known_recipes) != 0:
         for recipe in known_recipes:
             if recipe in self.crafting_recipes_allowed:
                 print("Press " + str(known_recipes.index(recipe) + 1) + " to craft " + recipe)
     else:
         input("You don\'t know any usable recipes.")
         return
     choice = int(input(""))
     selected_recipe = known_recipes[(choice - 1)]
     while True:
         available_items = player1.inventory
         for item in list(available_items.keys()):
             print("Press " + str(list(available_items.keys()).index(item) + 1) + " to add 1x " + item)
         try:
             selection = (input("Press 'C' to craft, press 'E' to exit.\n")).lower()
             if selection.isdigit() is True and int(selection) != 0:
                 selected_item = str(list(available_items.keys())[int(selection) - 1])
                 if selected_item not in items_used:
                     player1.inventory[selected_item] -= 1
                     items_used[selected_item] = 1
                 else:
                     player1.inventory[selected_item] -= 1
                     items_used[selected_item] += 1
                 continue
             elif selection == 'c':
                 if items_used == self.crafting_recipes_allowed[selected_recipe]:
                     if selected_recipe not in player1.inventory:
                         player1.inventory[selected_recipe] = 1
                     else:
                         player1.inventory[selected_recipe] += 1
                     input("You crafted a " + selected_recipe + ".\n")
                     break
                 else:
                     for item in list(items_used.keys()):
                         player1.inventory[item] += items_used[item]
                     input("You failed to craft a " + selected_recipe + ".\n")
                     break
             else:
                 X_gen_mechanics.wrong_input()
         except Error:
             X_gen_mechanics.wrong_input()
Ejemplo n.º 5
0
 def interaction(self):
     print("This place looks like " + self.name + "\n")
     print(self.intro)
     while True:
         for object in self.contents:
             print("Press " + str(list(self.contents.index(object) + 1) + " to interact with " + object.name + "."))
         choice = (input("Press 'I' to view inventory\nPress 'E' to exit.\n")).lower()
         if choice.isdigit() is True and int(choice) in range(1, (len(self.contents)) + 1):
             selection = int(choice)
             self.contents.index(selection).interaction()
         elif choice == 'e':
             X_gen_mechanics.relocate()
         elif choice == 'i':
             for item in player1.inventory.keys():
                 print(item + " x " + player1.inventory[item])
         else:
             X_gen_mechanics.wrong_input()
Ejemplo n.º 6
0
    def data_container_retrieving_data(self):
        """
        this function serves for the interaction of the player with the set of data contained in the terminal. They can
        view the data lines one by one in search of info/clues etc.

        """
        while True:
            for item in self.contents:
                print("Press " + str(list(self.contents.keys()).index(item) + 1) + " to view " + item + ".")
            choice = (input("Press 'E' to exit.\n")).lower()
            if choice.isdigit() is True and int(choice) in range(1, (len(list(self.contents.keys())) + 1)):
                selection = int(choice)
                selected_item = list(self.contents.keys())[selection - 1]
                print(self.contents[selected_item] + "\n")
            elif choice == 'e':
                break
            else:
                X_gen_mechanics.wrong_input()
Ejemplo n.º 7
0
    def interaction(self):
        """
        function used dor the initial interaction with the container, encompasses the process of opening it either with
        a skill or with an object assigned (like a key etc.)

        """
        print("This is a " + self.name + ".\n")
        if self.lock_status == 1:
            while True:
                print(self.intro_locked)
                if self.skill_used_to_open in player1.skills and \
                        player1.skills[self.skill_used_to_open] >= self.skill_lvl_required:
                    print("Press 'S' to use your " + self.skill_used_to_open + " skills to open this container.")
                elif self.item_used_to_open in player1.inventory:
                    print("Press 'I' to use  " + self.item_used_to_open + " to open this container.")
                choice = (input("Press '0' to exit.\n"))
                try:
                    if choice == 's' and player1.skills[self.skill_used_to_open] >= self.skill_lvl_required:
                        input(self.skill_open_message + "\n")
                        self.lock_status = 0
                        input("The contents are:\n")
                        X_gen_mechanics.list_contents(self.contents)
                        self.item_container_retrieving_items()
                        break
                    elif choice == 'i' and self.item_used_to_open in player1.inventory:
                        input(self.item_open_message + "\n")
                        self.lock_status = 0
                        input("The contents are:\n")
                        X_gen_mechanics.list_contents(self.contents)
                        self.item_container_retrieving_items()
                        break
                    elif choice == '0':
                        break
                except ValueError:
                    X_gen_mechanics.wrong_input()
        elif self.lock_status == 0:
            print(self.intro_open)
            input("The contents are:\n")
            X_gen_mechanics.list_contents(self.contents)
            self.item_container_retrieving_items()