def interact(self, player):
        """
        A method that controls what the story character says or does to the player character; controls the interaction
        ...

        Parameters
        ----------
        :param player: represents user
        :type player: player.character
        """
        if player.story_tracker <= 10:
            p("""THE END IS HERE!
            YOU CANNOT STOP THIS!
            MY MINION WILL SLAY YOU""")
            opponent = enemy(25, "Drakthor's Minon")
            winner = player.battle(opponent)
            time.sleep(2)
            if winner == player.name:
                p("""Well done against my minion, maybe I underestimated you...")
                HE IS HERE!!
                DRAGONTHOR!
                DRAGONTHOR:
                LETS TEST MY NEW STRENGTH ON YOU""")
                opponent = enemy(35, "DRAGONTHOR")
                winner = player.battle(opponent)
                time.sleep(2)
                if winner == player.name:
                    p("""Thank you for playing.
                    Hope you enjoyed this game
                    By Diljeet Jagpal""")
                    player.story_tracker = 11
                else:
                    p("YOU DO NOT STAND A CHANGE AGAINST THE MIGHTY DRAKTHOR")
            else:
                p("YOU DO NOT STAND A CHANGE AGAINST THE MIGHTY DRAKTHOR")
    def interact(self, player):
        """
        A method that controls what the story character says or does to the player character; controls the interaction
        ...

        Parameters
        ----------
        :param player: represents user
        :type player: player.character
        """
        if player.story_tracker <= 3:
            p("""You better have brought me some sheep...
            I guess you will have to do""")
            opponent = enemy(5, "Wolfernius")
            winner = player.battle(opponent)
            time.sleep(2)
            if winner == player.name:
                player.story_tracker = 4
                p("""You win, I will stop taking your sheep... 
                But if you think it ends here... HAH...
                Dark times are coming...
                When Drakthor takes final form...
                I will be back ... *cough*""")
            else:
                p("""HA!...
                YOU THOUGHT YOU COULD DEFEAT ME...""")
        elif player.story_tracker > 3:
            p("""You win, I will stop taking your sheep... 
            But if you think it ends here... HAH...
            Dark times are coming...
            When Drakthor takes final form...
            I will be back ... *cough*""")
    def interact(self, player):
        """
        A method that controls what the story character says or does to the player character; controls the interaction
        ...

        Parameters
        ----------
        :param player: represents user
        :type player: player.character
        """
        if player.story_tracker <= 8:
            p("""You DARE come to my lair...
            BIG MISTAKE!""")
            opponent = enemy(20, "Sion")
            winner = player.battle(opponent)
            time.sleep(2)
            if winner == player.name:
                player.story_tracker = 9
                p("""WHO ARE YOU???
                I will leave Queen Rachel alone...
                Just please dont hurt me anymore...""")
            else:
                p("""DRAKTHOR WILL DRINK THE BLOOD OF HIS ENEMIES
                I SHALL FEAST BY HIS SIDE""")
        elif player.story_tracker > 8:
            p("I wil do whatever you want...")
    def interact(self, player):
        """
        A method that controls what the story character says or does to the player character; controls the interaction
        ...

        Parameters
        ----------
        :param player: represents user
        :type player: player.character
        """
        if player.story_tracker <= 5:
            p("""SSSSSSSSsssssssssssssssssssssso you thinksss you can take my goldssss...
            thinkssss AGAIN!""")
            opponent = enemy(10, "Serpant Queen")
            winner = player.battle(opponent)
            time.sleep(2)
            if winner == player.name:
                player.story_tracker = 6
                p("""SSSssuch power...
                Get AWAY FROM ME!
                Drakthor will give me power...
                You will SSSSssseeeee....""")
                player.add_item(earls_gold)
            else:
                p("""So...
                PATHETIC""")
        elif player.story_tracker > 5:
            p("""You got your gold...
            What do you want from me...""")
    def interact(self, player):
        """
        A method that controls what the story character says or does to the player character; controls the interaction
        ...

        Parameters
        ----------
        :param player: represents user
        :type player: player.character
        """
        if player.story_tracker <= 7:
            p("HELPPP!!!")
        elif player.story_tracker > 7:
            p("If you need to get across the river, maybe you could get a boat from Queen Rachel of Town 4"
              )
    def interact(self, player):
        """
        A method that controls what the story character says or does to the player character; controls the interaction
        ...

        Parameters
        ----------
        :param player: represents user
        :type player: player.character
        """
        if player.story_tracker <= 8:
            p("""If your looking for the Queen, she is inside...
            If your looking for CAVE 4, it is south-east of here""")
        else:
            p("Everyone is so relieved since you defeated Sion, thank you!!")
    def interact(self, player):
        """
        A method that controls what the story character says or does to the player character; controls the interaction
        ...

        Parameters
        ----------
        :param player: represents user
        :type player: player.character
        """
        if player.story_tracker == 5:
            p("""Apprently the Serpant Queen took Earls gold...
            But what do I know?""")
        else:
            p("""WOW!
            You truly are a warrior!!!""")
    def interact(self, player):
        """
        A method that controls what the story character says or does to the player character; controls the interaction
        ...

        Parameters
        ----------
        :param player: represents user
        :type player: player.character
        """
        if player.story_tracker <= 10:
            p("""The end is near...
            Tonight Drakthor becomes DRAGONTHOR!
            Best thing to do...
            RUN!!!
            If you want to find him, hes at the very top""")
        else:
            p("Bringiner of light, I THANK YOU !!")
    def interact(self, player):
        """
        A method that controls what the story character says or does to the player character; controls the interaction
        ...

        Parameters
        ----------
        :param player: represents user
        :type player: player.character
        """
        if player.story_tracker == 5:
            p("""I heard the gold stashed at a tower just North-East of here....
            Maybe you should take a look...
            Careful, the tower is no place for games, dark forces are present there..."""
              )
        else:
            p("""I can not belive it...
            Good Job!""")
    def interact(self, player):
        """
        A method that controls what the story character says or does to the player character; controls the interaction
        ...

        Parameters
        ----------
        :param player: represents user
        :type player: player.character
        """
        if player.story_tracker <= 7:
            p("I... Ca..n't... speak....Drakt..hor...")
        elif player.story_tracker > 7:
            p("""Thank you for saving our town.
            I can tell you more about Drakthor...
            He used to be one of our own, but he took a dark turn...
            Using an Ancient ritual, he will be turning himself into a dragon...
            The new form comes with many powers and control over the darkworld...
            If he succeeds then it is the end for us all...
            I dont know when, but I know it will be ontop mount Bloodspike
            But to get there you will need to cross the red river...""")
Ejemplo n.º 11
0
    def limiter(self, placeholder):
        """
        Limits access based on story tracker to force progression of story in correct order
        ...

        Parameters
        ----------
        :param placeholder: key of a map
        :type placeholder: str

        Return
        ------
        :return True: To inform completion without error
        :type True: bool
        """
        x = self.story_tracker

        if x < 4 and placeholder in [
                '2TOWN', 'TOWER', '3TOWN', '4TOWN', '2CAVE'
        ]:
            p("You cannot go here yet...")
        elif x < 7 and placeholder in ['3TOWN', '4TOWN', '2CAVE']:
            p("You cannot go here yet...")
        elif x < 8 and placeholder in ['4TOWN', '2CAVE']:
            p("You cannot go here yet...")
        else:
            self.current_location.changemap(placeholder)

        return True
    def interact(self, player):
        """
        A method that controls what the story character says or does to the player character; controls the interaction
        ...

        Parameters
        ----------
        :param player: represents user
        :type player: player.character
        """
        if player.story_tracker == 1:
            p("""I see you got my message...
            I wish we were meeting under better circumstances but here it is...
            The village is being terrorised by Wolfernius, he is eating our livestock
            You are our last chance...
            I hear he comes from a cave not far, south-west of here.
            Speak to John before heading out. I have given him a few things for you...
            Good luck and safe journey!""")
            player.story_tracker = 2
        elif player.story_tracker == 2 or player.story_tracker == 3:
            p(f"Good Luck {player.name}, we are all counting on you...")
        elif player.story_tracker > 3:
            p("""YOU HERO!!!
            You have saved our village!
            I dont know much about this Drakthor, but maybe Chief Earl from 2TOWN does..."""
              )
    def interact(self, player):
        """
        A method that controls what the story character says or does to the player character; controls the interaction
        ...

        Parameters
        ----------
        :param player: represents user
        :type player: player.character
        """
        if player.story_tracker == 7:
            p("By Lord Drakthor you shall not pass")
            opponent = enemy(15, "Drakthor's Minion")
            winner = player.battle(opponent)
            time.sleep(2)
            if winner == player.name:
                player.story_tracker = 8
                p("In the end, Drakthor will still remain victorious...")
            else:
                p("YOU DO NOT STAND A CHANGE AGAINST THE MIGHTY DRAKTHOR")
        elif player.story_tracker > 7:
            p("In the end, Drakthor will still remain victorious... **Cough**")
    def interact(self, player):
        """
        A method that controls what the story character says or does to the player character; controls the interaction
        ...

        Parameters
        ----------
        :param player: represents user
        :type player: player.character
        """
        if player.story_tracker == 4:
            p("""You want to know about Drakthor...
            I might know something that could help...
            But you'll have to do something for me...
            Someone has stolen my gold and I need you to get it back...
            It will be worth your time, I promise.
            Ask around town, maybe someone knows something that might help.""")
            player.story_tracker = 5
        elif player.story_tracker == 5:
            p("Come on now, find me that gold !")
        elif player.story_tracker == 6:
            p(f"""Incredible...
            I wasnt sure you would make it but here you are!
            As promised here is some gold for your hard work...
            {player.name} got 2000 gold
            About Drakthor...
            I don't personally know a great deal but ...
            I have heard Drakthor is from Town3, maybe you should check it out..."""
              )
            player.gold += 2000  # Gains reward
            player.remove_item(earls_gold)  # Item is removed
            player.story_tracker = 7
        else:
            p("""About Drakthor...
            I don't personally know a great deal but ...
            I have heard Drakthor is from Town3, maybe you should check it out..."""
              )
    def interact(self, player):
        """
        A method that controls what the story character says or does to the player character; controls the interaction
        ...

        Parameters
        ----------
        :param player: represents user
        :type player: player.character
        """
        if player.story_tracker == 1:  # Until spoken to leader
            p(f"Good Morning {player.name}! \nChief wants to speak to you, maybe you should go over to his house \nMake sure your safe, its getting really bad out there..."
              )
        elif player.story_tracker == 2 or player.story_tracker == 3:
            p(f"Be careful out there son...")
        elif player.story_tracker > 3:
            p("Thank you son, you have really made us proud!!")
    def interact(self, player):
        """
        A method that controls what the story character says or does to the player character; controls the interaction
        ...

        Parameters
        ----------
        :param player: represents user
        :type player: player.character
        """
        if player.story_tracker == 1:
            p("Apprently the Chief was looking for you, I think he is at home..."
              )
        elif player.story_tracker == 2:
            p("""If your heading out of town, prepare youself.
            There are monsters everywhere and they will not think twice before attacking you...
            Heres a sword and a health potion to help you on your journey""")
            player.add_item(hp_pot)
            player.add_item(basic_sword)
            player.story_tracker = 3
        elif player.story_tracker == 3:
            p("Good luck...")
        elif player.story_tracker > 3:
            p("YOUR A HEROOO!!!!!")
    def interact(self, player):
        """
        A method that controls what the story character says or does to the player character; controls the interaction
        ...

        Parameters
        ----------
        :param player: represents user
        :type player: player.character
        """
        if player.story_tracker <= 8:
            p("""I can give you a boat...
            but you have to do something for me in return.
            I need you to defeat Sion, the beast at CAVE 4
            All my men are too scared to go anywhere near that cave, if you do this the boat is yours."""
              )
        elif player.story_tracker == 9:
            p("""Unbelieveable...
            As I promised here is your boat """)
            player.add_item(boat)
            player.story_tracker = 10
        else:
            p("Your mission is perilous, good luck to you...")
Ejemplo n.º 18
0
    def add_item(self, item):
        """
        function to add a new item to user bag
        ...

        Parameters
        ----------
        :param item: item in bag
        :type item: item
         
        Return
        ------
        :return item_added: to inform shop if a purchase was made or not
        :type item_added: bool
        """
        x = type(item)  # log what the item is
        contents = []  # Log of types of items in bag
        things_list = []  # Log of items in bag
        item_added = False
        for thing in self.items.keys():
            things_list.append(thing.name.lower())
            contents.append(type(thing))
        if item.name.lower() in things_list:  # if item is already in bag
            if x == pot:  # if it is a pot then player can have more than 1 otherwise is limited
                self.items[item] += 1
                item_added = True
                p(f"You now have another {item.name}")
            elif x == weapon or x == shield or x == armour:
                p("You already have one")
        else:  # If it is not already in bag
            if x == pot:  # New pot
                self.items[item] = 1
                item_added = True
                #w(f"{item.name} has been added to your inventory")
            else:
                if x in contents:  # if it is not a pot then matching types cannot be bough until an old one is gotten rid off
                    removal = p(
                        "Please get rid of your old weapon/shield/armour before purchasing a new one \nWould you like to get rid of an item? (yes/no)",
                        inp=True)  # Allow user to delete old item
                    if removal.lower() == "yes":
                        to_be_removed = p(
                            "What item would you like removed? (Enter name)",
                            inp=True)  # Find item to be deleted
                        for i in all_items:
                            if i.name.lower() == to_be_removed.lower():
                                self.remove_item(i)
                                p(
                                    "Item was removed"
                                )  # If it was removed then this message will display
                else:
                    self.items[
                        item] = 1  # If it is not in bag or same type isnt in bag, simply add 1 unit to bag
                    item_added = True
                    if type(item) == weapon:
                        self.AD += item.AD  # scale Ad based on items
                    elif type(item) == shield or type(item) == armour:
                        self.HP += item.HP  # Scale hp based on items
                        self.max_HP += item.HP
                    #w(f"{item.name} has been added to your inventory")

        return item_added
Ejemplo n.º 19
0
    def battle(self, opponent):
        """
        Fight between player and an opponent
        ...

        Parameters
        ----------
        :param opponent: enemy for user to fight
        :param type: enemy.character

        Return
        ------
        :param winner: Name of the winner of the battle
        :type winner: str
        """
        sbm(True)  # Tell gui to switch to battle mode on
        winner = None  # Set winner equal to None, incase player decides to run away
        #w(f"{opponent.name} attacks...")
        while winner == None:  # When a new winner is set the battle is over
            opponent.attack(
                self
            )  # Since enemies suprise the player, they get to attack first
            if self.HP <= 0:  # Check if somone has won
                winner = opponent.name
                p(f"{self.name} has been defeated.")
                break
            next_move = "1"
            if next_move == "1":  # If user chooses to retaliate
                self.attack(opponent)
                if opponent.HP <= 0:  # Check if somone has won
                    winner = self.name
                    p(f"{opponent.name} has been defeated.")
            elif next_move == "2":  # If user chooses to use an item
                item_selected = False  # To ensure an item is actually selected and to loop around if it is not
                while item_selected == False:
                    # Item selection or exit
                    x = "exit"
                    if x == "exit":
                        item_selected = True
                    else:
                        outcome = self.use_item(x)
                        if outcome == True:
                            item_selected = True
                            #w(f"{x} was used")
                        else:
                            #w("Invalid Input")
                            pass
            elif next_move == "3":  # If user chooses to try and run away
                value = random()  # Generate float between 0 and 1
                if value > 0.75:  # To make it a 25% chance of success
                    p("You got away")
                    winner = "No winner"
                else:
                    p("You got blocked")
            else:  # If entry was invalid
                #w("Invalid entry, while you were choosing your were attacked....")
                pass
        if self.name == winner:  # If user has won
            for i in opponent.items:
                self.add_item(i)
            self.gold += opponent.gold  # Steal enemies gold
            self.exp_gain(opponent)  # Gain experinece points
            p(f"{self.name} wins..... {self.name} loot {opponent.gold} and {opponent.items}"
              )
        elif opponent.name == winner:  # If user has been killed
            p("You will be taken to your last save location")
            self.death()

        # To clear frame5
        pf5("", 0)
        pf5("", 1)
        sbm(False)  # Tell gui to switch back to battle mode false
        return winner
Ejemplo n.º 20
0
    def interact(self, typ, placeholder):
        """
        Logic behind interactions with "objects" on map
        ...

        Paramters
        ---------
        :param typ: Informs what type of object user is interacting with 
        :type typ: str
        :param palceholder: 2nd part of tuple from matrix on a map
        :type placeholder: str

        Return
        ------
        :return int: interger value based on typ to confirm completion 
        :type int: int
        """
        if typ == "storyCharacter":
            for character in all_story_characters:
                if placeholder == character.key:
                    p(
                        f"{character.name}:"
                    )  ############################************************************* fix this TODO
                    character.interact(self)
            return 0

        elif typ == "bed":
            for bed in all_beds:  # Determine which bed using bed keys and given key
                if bed.key == placeholder:
                    x = "no"  # User confirmation
                    if x.lower(
                    ) == "yes":  # Lowercase to avoid captil letter errors
                        if self.gold > bed.cost:  # Given user has enough gold (incase of hotel)
                            self.gold -= bed.cost  # Deducts gold cost
                            self.HP = self.max_HP  # Resets HP
                            self.savegame()  # Saves game
                            p("The game has been saved")
                        else:
                            p("You have insufficient gold")
                    elif x.lower(
                    ) == "no":  # If user chooses no, allow user back to map
                        pass
                    else:
                        p("Invalid input"
                          )  # Any other inputs are met with this error message
            return 1

        elif typ == "shop":
            for shop in all_shops:  # To determine which items to display search for shop in all shops
                if shop.key == placeholder:  # Once found, print list of available items
                    str1 = "Welcome,  we have: "
                    for i in shop.available_items:
                        str1 += f"\n{i.name} for {i.value} gold"
                    x = "exit"  # Ask user for purchase
                    if x == "exit":  # if user changes mind
                        break
                    else:
                        temp = None  # Need to initiate variable outside loop, set to None for convienence
                        for i in shop.available_items:
                            if i.name.lower() == x.lower(
                            ):  # puts all letters into lowercase to avoid captial letter errors
                                temp = i
                        if temp != None:  # If temp has been assigned a new value
                            if self.gold > temp.value:  # if player has enough gold
                                try:
                                    item_added = self.add_item(temp)
                                    if item_added == True:
                                        self.gold -= temp.value
                                except:
                                    pass
                                    #w("You can not have more than one, sword, shield or armour") # Error from player.add_item is due to multiple of same type of item
                            else:
                                p("insufficient gold")
                        else:
                            p("Invalid input, please try again")
            return 2