Exemplo n.º 1
0
 def __init__(self, hero, monster):
     """ Constructor function initiates battle sequence. """
     self.hero = hero
     self.monster = monster
     prompt("\n\n\t\t\t" + self.hero.name + " vs. " + self.monster.name + "\n")
     self.first_strike = self.get_first_strike()
     self.battle_loop()
Exemplo n.º 2
0
 def __init__(self, hero, monster):
     """ Constructor function initiates battle sequence. """
     self.hero = hero
     self.monster = monster
     prompt("\n\n\t\t\t" + self.hero.name + " vs. " + self.monster.name +
            "\n")
     self.first_strike = self.get_first_strike()
     self.battle_loop()
Exemplo n.º 3
0
 def meeting1(self):
     """ King gives you Treasure Map """
     # Mission 3: Get a treasure map.
     for message in messages.oldendrab1:
         paragraph = message.replace("Hero", self.hero.name)
         prompt(paragraph + "\n")
     self.hero.inventory.append(items.t_map)
     self.hero.missions[3] = True
     prompt("You get:\n\tTreasure Map")
Exemplo n.º 4
0
 def shortcut(self):
     for i in range(0, 2):
         prompt(messages.shortcut[i] + "\n")
     import battle_system, monsters
     boss = monsters.Guillek()
     battle_system.Battle(self.hero, boss)
     if self.hero.health:
         prompt(messages.shortcut[2] + "\n")
         self.hero.missions[5] = True
Exemplo n.º 5
0
 def inv_function(self):
     """ Allows hero to use item on himself while at a location's menu. """
     self.hero.inventory_menu()
     item = self.hero.item_pick()
     if item != False:
         if item.personal_use == True:
             self.hero.use_item(item, self.hero)
         else:
             prompt("You cannot use this here.")
Exemplo n.º 6
0
 def inv_function(self):
     """ Allows hero to use item on himself while at a location's menu. """
     self.hero.inventory_menu()
     item = self.hero.item_pick()
     if item != False:
         if item.personal_use == True:
             self.hero.use_item(item, self.hero)
         else:
             prompt("You cannot use this here.")
Exemplo n.º 7
0
 def boss2(self):
     for i in range(0, 8):
         prompt(messages.boss2[i] + "\n")
     import battle_system, monsters
     boss = monsters.Guillek()
     battle_system.Battle(self.hero, boss)
     if self.hero.health:
         for i in range(8, 10):
             prompt(messages.boss2[i] + "\n")
         self.hero.missions[5] = True
Exemplo n.º 8
0
    def travelor(self):
        """ Missions 0 and 1:  Helping a travelor. """
        print("\"Hi, stranger.  Going to Cow-Hip?  Do you mind if I \
come along?  I could certainly use the protection since I'll be \
transporting these goods.\"")
        answer = ""
        while answer != "y" and answer != "n":
            answer = prompt("\nWhat do you say? (y/n) ").lower()
            if answer == "y":
                self.hero.missions[1] = True
                prompt("\"Many thanks!  I will repay you when we arrive.\"")
            elif answer == "n":
                prompt("\"Okay.  Well I guess I'll just hire someone else.\"")
            self.hero.missions[0] = True
Exemplo n.º 9
0
    def go(self, endpoint):
        print("Your journey beginneth.  Press 'I' at any time to use items.")
        for segment in range(self.distance):
            if self.hero.health:
                # Opportunity to use item
                entry = prompt("").upper()
                while entry == "I":
                    self.hero.inventory_menu()
                    item = self.hero.item_pick()
                    if item != False:
                        self.hero.use_item(item, self.hero)
                    if entry == "I":
                        print("\nPress 'I' to use another item.")
                    entry = prompt("").upper()

                # Start message string, get occurence
                message = ""
                occurence = random.randint(1, 100)
                
                # Determine time and day, add to message
                if segment in range(0,20,3):
                    message += "On the morning of day " + str(int((segment+3)/3))
                elif segment in range(1,21,3):
                    message += "On the afternoon of day " + str(int((segment+2)/3))
                else:
                    message += "On the evening of day " + str(int((segment+1)/3))

                # If occurence == monster, update message, print message, start battle
                if occurence < self.fight_chance:
                    monster = self.monster_pick()
                    message += " a monster approaches!"
                    print(message)
                    battle = battle_system.Battle(self.hero, monster)
                    if self.hero.health:
                        print("Your journey continues.  Press 'I' at any \
time to use an item.")

                # Or if occurence != monster, update message, print message
                else:
                    message += " nothing happens."
                    print(message)
                    
        # If hero is still alive, return the proper endpoint.
        if self.hero.health:
            return endpoint
        
        # Otherwise, return None
        else:
            return None
Exemplo n.º 10
0
 def update(self):
     if self.hero.missions[1] == True:
         self.messages = messages.cow_hip[0:2]
     # Mission 2: If hero arrives safely with travelor, reward hero.
     # Also add leather armor to shop inventory.
     if self.hero.missions[2] == False:
         self.hero.missions[2] = True
         if self.hero.missions[1] == True:
             reward = 18
             prompt("\n\"Thank you for your protection!  Here is your reward.\"")
             print("You gain: ")
             prompt("\t" + str(reward) + " coins")
             self.hero.coins += reward
             if items.leather not in self.inventory:
                 self.inventory.append(items.leather)
Exemplo n.º 11
0
    def menu(self):
        """ Run the menu and return the next_location """
        response = ""
        while self.hero.health:
            print("\nYOU ARE IN " + self.name.upper() + ".")
            print("""
D - DIG
J - JOURNEY
I - INVENTORY
R - REST
G - GAME SAVE
Q - QUIT""")
            response = prompt("").upper()
            if response == "J":
                destination = self.get_destination()
                if destination:
                    next_location = self.journey(destination[0], destination[1])
                    return next_location
            elif response == "D":
                if self.hero.missions[3] == True and self.hero.missions[4] == False:
                    self.boss1()
                else:
                    self.dig()
            elif response == "I":
                self.inv_function()
            elif response == "R":
                print("Inn")
            elif response == "G":
                print("save")
            elif response == "Q":
                return None
            else:
                print("\a")
        
        return None
Exemplo n.º 12
0
    def get_destination(self):
        response = prompt("""
Where shall you journey?
N) Fiddlestick
E) Cow-Hip
S) Wrathful Pass
W) Valley of Forbidden Objects
\nEnter the direction or location.  Or press enter to exit.
""").lower()
        if response == "n" or response == "fiddlestick":
            destination = (paths.north, fiddlestick)
        elif response == "e" or response == "cow-hip":
            if self.hero.missions[0] == False:
                # Missions 0 and 1: Helping a travelor.
                self.travelor()
            destination = (paths.east, cowhip)
        elif response == "s" or response == "wrathful pass":
            destination = self.south_path()
        elif response == "w" or response == "valley of forbidden objects":
            destination = (paths.west, valley)
        elif response == "":
            destination = None
        else:
            print("\a")
            destination = None       
        return destination
Exemplo n.º 13
0
    def menu(self):
        """ Run the menu and return the next_location """
        response = ""
        while self.hero.health:
            print("\nYOU ARE IN " + self.name.upper() + ".")
            print("""
J - JOURNEY
T - TALK TO KING
I - INVENTORY
R - REST
G - GAME SAVE
Q - QUIT""")
            response = prompt("").upper()
            if response == "J":
                destination = self.get_destination()
                if destination:
                    next_location = self.journey(destination[0], destination[1])
                    return next_location
            elif response == "T":
                if self.hero.missions[3] == False:
                    self.meeting1()
                else:
                    print("\"The King cannot be seen right now.\"")
            elif response == "I":
                self.inv_function()
            elif response == "R":
                self.rest()
            elif response == "G":
                print("save")
            elif response == "Q":
                return None
            else:
                print("\a")

        return None
Exemplo n.º 14
0
    def tactic(self, opponent):
        """ The hero's tactic method consists of the battle menu. """
        end_turn = False
        while end_turn == False:
            print(self.name + " has " + str(self.health) + \
                  " / " + str(self.health_max) +" health.")
            print("""
A - Attack
I - Item
R - Run Away""")
            choice = prompt("").upper()
            if choice == "A":
                self.attack(opponent)
                end_turn = True
            elif choice == "I":
                self.inventory_menu()
                item = self.item_pick()
                if item != False:
                    if item.personal_use == True:
                        self.use_item(item, self)
                    else:
                        self.use_item(item, opponent)
                    end_turn = True
            elif choice == "R":
                opponent.run_away()
                end_turn = True
Exemplo n.º 15
0
    def tactic(self, opponent):
        """ The hero's tactic method consists of the battle menu. """
        end_turn = False
        while end_turn == False:
            print(self.name + " has " + str(self.health) + \
                  " / " + str(self.health_max) +" health.")
            print("""
A - Attack
I - Item
R - Run Away""")
            choice = prompt("").upper()
            if choice == "A":
                self.attack(opponent)
                end_turn = True
            elif choice == "I":
                self.inventory_menu()
                item = self.item_pick()
                if item != False:
                    if item.personal_use == True:
                        self.use_item(item, self)
                    else:
                        self.use_item(item, opponent)
                    end_turn = True
            elif choice == "R":
                opponent.run_away()
                end_turn = True
Exemplo n.º 16
0
def opening_menu():
    choice = ""
    while choice != "Q":
        print("\nMAIN MENU")
        print("R - Resume Game")
        print("N - New Game")
        print("Q - Quit")
        print("T FOR TESTING!!!!")
        choice = prompt("").upper()
        if choice == "R":
            print("LOAD")
        elif choice == "N":
            import items
            data = introduction.intro()
            hero = characters.New_Hero(data[0], data[1])
            game = New_game(hero, locations.shmucksburg)

        # For testing only!!!!!!!!
        elif choice == "T":
            import items
            hero = characters.New_Hero("Bob", "Hooray!")
            hero.missions = [True, True, True, True, False, False]
            hero.weapon = items.shiny_sword
            hero.shield = items.sturdy_shield
            hero.armor = items.sweet_armor
            hero.coins = 100
            hero.inventory = [
                items.herbenol, items.shiny_sword, items.sturdy_shield,
                items.sweet_armor, items.kings_loot, items.t_map
            ]
            for i in range(1, 7):
                hero.inventory.append(items.bandage)
            game = New_game(hero, locations.silverrock)
Exemplo n.º 17
0
    def boss1(self):
        print("You dig where the map directs you to dig.")
        prompt("And you find:\n\t" + items.kings_loot.name)
        self.hero.inventory.append(items.kings_loot)
        self.hero.inventory.remove(items.t_map)
        prompt("King's First Servant: I see that much of this treasure was made by \
orcs.  Perhaps Good King Vinny is trying to make amends by returning goods \
taken during one of the old wars.")
        prompt("King's Second Servant: I don't believe the orcs would even \
realize....  What ho!  Who goes there!?\n")
        prompt("\nYou turn around to find that a stranger has snuck up on you!")
        prompt("Prepare for battle!\n")
        import battle_system, monsters
        boss = monsters.Simon_Slick()
        battle = battle_system.Battle(self.hero, boss)
        if self.hero.health:
            self.hero.missions[4] = True
Exemplo n.º 18
0
    def south_path(self):
        """ Make sure the user really wants to travel this path. """
        answer = prompt("That is a very dangerous path.  Are you sure \
you want to proceed? (y/n) ").lower()
        if answer == "y":
            return (paths.south, wrathful)
        elif answer == "n":
            return None
        else:
            return None
Exemplo n.º 19
0
    def rest(self):
        """ Allows hero to rest at an inn. """
        price = 20
        answer = prompt("\"Welcome to the " + self.name + " inn!  \
A room costs " + str(price) + " silver.  Care to rest a while?\" (y/n) ").lower()
        if answer == "y":
            if self.hero.coins >= price:
                print("\"Have a nice stay\"!")
                self.hero.coins -= price
                self.hero.gain_health(50)
                print(self.hero.name + " gains 50 health!")
            else:
                print("\"I'm sorry sir, but you haven't enough silver.\"")
Exemplo n.º 20
0
    def get_destination(self):
        response = prompt("""
Where shall you journey?
SW) Fiddlestick
""").lower()
        if response == "sw" or response == "fiddlestick":
            destination = (paths.northeast, fiddlestick)
        elif response == "":
            destination = None
        else:
            print("\a")
            destination = None
        return destination
Exemplo n.º 21
0
    def get_destination(self):
        response = prompt("""
Where shall you journey?
N) Shmucksburg
""").lower()
        if response == "n" or response == "shmucksburg":
            destination = (paths.south, shmucksburg)
        elif response == "":
            destination = None
        else:
            print("\a")
            destination = None
        return destination
Exemplo n.º 22
0
    def donation_menu(self):
        response = ""
        print("\t\t\tYou have entered the Armory.\n")
        print("\"Welcome, patron!\"")
        while response != "X":
            print("""
ARMORY
V - View Contents
D - Donate
X - Exit
""")
            response = prompt("\"Are we feeling philanthropic today?\" ").upper()
            if response == "V":
                print("ITEM\t\tCLASS")
                for item in self.donations:
                    print(item.name + "\t" + item.item_class)
            elif response == "D":
                self.donate()
            elif response == "X":
                prompt("\"Have a grand day!\"\n")
            else:
                print("\"Could you repeat that?\"\a")
Exemplo n.º 23
0
    def shop_menu(self):
        print("\n\t\t\tYou have entered Ye Olde Item Shoppe.\n")
        print("\"Greetings, stranger!\"")
        option = ""
        while option != "X":
            print("""
P - Purchase Item
S - Sell Item
I - View Inventory
X - Exit
""")
            print("Silver: " + str(self.hero.coins))
            option = prompt("What can I do for ye?\n").upper()
            if option == "X":
                prompt("\"Good day to you sir!\"\n")
            elif option == "P":
                self.hero_purchase()
            elif option == "S":
                self.hero_sell()
            elif option == "I":
                self.hero.inventory_menu()
            else:
                print("\a\"What jibberish thou art speaketh?!\"")
Exemplo n.º 24
0
    def shop_menu(self):
        print("\n\t\t\tYou have entered Ye Olde Item Shoppe.\n")
        print("\"Greetings, stranger!\"")
        option = ""
        while option != "X":
            print("""
P - Purchase Item
S - Sell Item
I - View Inventory
X - Exit
""")
            print("Silver: " + str(self.hero.coins))
            option = prompt("What can I do for ye?\n").upper()
            if option == "X":
                prompt("\"Good day to you sir!\"\n")
            elif option == "P":
                self.hero_purchase()
            elif option == "S":
                self.hero_sell()
            elif option == "I":
                self.hero.inventory_menu()
            else:
                print("\a\"What jibberish thou art speaketh?!\"")
Exemplo n.º 25
0
    def rest(self):
        """ Allows hero to rest at an inn. """
        price = 20
        answer = prompt("\"Welcome to the " + self.name + " inn!  \
A room costs " + str(price) +
                        " silver.  Care to rest a while?\" (y/n) ").lower()
        if answer == "y":
            if self.hero.coins >= price:
                print("\"Have a nice stay\"!")
                self.hero.coins -= price
                self.hero.gain_health(50)
                print(self.hero.name + " gains 50 health!")
            else:
                print("\"I'm sorry sir, but you haven't enough silver.\"")
Exemplo n.º 26
0
    def get_destination(self):
        response = prompt("""
Where shall you journey?
W) Shmucksburg
\nEnter the direction or location.  Or press enter to exit.
""").lower()
        if response == "w" or response == "shmucksburg":
            destination = (paths.east, shmucksburg)
        elif response == "":
            destination = None
        else:
            print("\a")
            destination = None
        return destination
Exemplo n.º 27
0
    def hero_sell(self):
        # Show inventory, input item to sell
        self.hero.inventory_menu()
        item = prompt("\"What would ye like to sell?\" ").lower()

        # If item does not exist, converter will print appropriate message
        # and hero_sell() function will end.
        item = converter.convert(item)

        # If hero has the item and the item does not belong to the King, commence sale.
        if item in self.hero.inventory and item.name != "Treasure Map" and item.name != "King's Loot":
            sale_price = int(item.price * 0.8)
            print("\"I'll offer you " + str(sale_price) + " silver.\"")
            response = prompt("Is that agreeable to you?\" (y/n) ").upper()

            # If sale price is accepted, commence sale
            if response == "Y":
                self.hero.drop(item)
                self.hero.coins += sale_price
                print("\"Nice doing business with you, sir!\"")

            # If sale price is not accepted, end function
            elif response == "N":
                print("\"Tis the best I can do!\"")

            # If response is invalid, end function
            else:
                print("\a\"What?\"")

        # If the item is in hero's inventory, but does not belong to him, reject sale.
        elif item in self.hero.inventory:
            print("You can't sell that -- it belongs to the King!")

        # If item does exist but is not in inventory, end function
        elif item != False:
            print("\"You don't have one!\a\"")
Exemplo n.º 28
0
    def hero_sell(self):
        # Show inventory, input item to sell
        self.hero.inventory_menu()
        item = prompt("\"What would ye like to sell?\" ").lower()

        # If item does not exist, converter will print appropriate message
        # and hero_sell() function will end.
        item = converter.convert(item)

        # If hero has the item and the item does not belong to the King, commence sale.
        if item in self.hero.inventory and item.name != "Treasure Map" and item.name != "King's Loot":
            sale_price = int(item.price * 0.8)
            print("\"I'll offer you " + str(sale_price) + " silver.\"")
            response = prompt("Is that agreeable to you?\" (y/n) ").upper()

            # If sale price is accepted, commence sale
            if response == "Y":
                self.hero.drop(item)
                self.hero.coins += sale_price
                print("\"Nice doing business with you, sir!\"")

            # If sale price is not accepted, end function
            elif response == "N":
                print("\"Tis the best I can do!\"")

            # If response is invalid, end function
            else:
                print("\a\"What?\"")

        # If the item is in hero's inventory, but does not belong to him, reject sale.
        elif item in self.hero.inventory:
            print("You can't sell that -- it belongs to the King!")

        # If item does exist but is not in inventory, end function
        elif item != False:
            print("\"You don't have one!\a\"")
Exemplo n.º 29
0
    def menu(self):
        """ Run the menu and return the next_location """
        response = ""
        while self.hero.health:
            print("\nYOU ARE IN " + self.name.upper() + ".")
            print("""
J - JOURNEY
T - TALK TO VILLAGERS
S - SHOP
I - INVENTORY
R - REST
G - GAME SAVE
Q - QUIT""")
            response = prompt("").upper()
            if response == "J":
                # Ask for next location via get_destination() method
                destination = self.get_destination()

                # If a destination was selected, call the journey function.
                # If the hero survives the journey, the desired endpoint will
                # be returned and fed back into the next_location of game.main_loop.
                # But an unsuccessful journey returns None, which is fed back to
                # the main_loop, and ends the game.main_loop.
                if destination:
                    next_location = self.journey(destination[0],
                                                 destination[1])
                    return next_location
            elif response == "T":
                self.talk()
            elif response == "S":
                self.shop_menu()
            elif response == "I":
                self.inv_function()
            elif response == "R":
                self.rest()
            elif response == "G":
                print("save")
            elif response == "Q":
                return None
            else:
                print("\a")

        # next_location is returned to the game.main_loop
        return None
Exemplo n.º 30
0
    def menu(self):
        """ Run the menu and return the next_location """
        response = ""
        while self.hero.health:
            print("\nYOU ARE IN " + self.name.upper() + ".")
            print("""
J - JOURNEY
T - TALK TO VILLAGERS
S - SHOP
I - INVENTORY
R - REST
G - GAME SAVE
Q - QUIT""")
            response = prompt("").upper()
            if response == "J":
                # Ask for next location via get_destination() method
                destination = self.get_destination()

                # If a destination was selected, call the journey function.
                # If the hero survives the journey, the desired endpoint will
                # be returned and fed back into the next_location of game.main_loop.
                # But an unsuccessful journey returns None, which is fed back to
                # the main_loop, and ends the game.main_loop.
                if destination:
                    next_location = self.journey(destination[0], destination[1])
                    return next_location
            elif response == "T":
                self.talk()
            elif response == "S":
                self.shop_menu()
            elif response == "I":
                self.inv_function()
            elif response == "R":
                self.rest()
            elif response == "G":
                print("save")
            elif response == "Q":
                return None
            else:
                print("\a")

        # next_location is returned to the game.main_loop
        return None
Exemplo n.º 31
0
    def get_destination(self):
        response = prompt("""
Where shall you journey?
NW) Silverrock
NE) Oldendrab Castle
S) Shmucksburg
\nEnter the direction or location.  Or press enter to exit.
""").lower()
        if response == "nw" or response == "silverrock":
            destination = (paths.northwest, silverrock)
        elif response == "ne" or response == "oldendrab castle":
            destination = (paths.northeast, oldendrab)
        elif response == "s" or response == "shmucksburg":
            destination = (paths.north, shmucksburg)
        elif response == "":
            destination = None
        else:
            print("\a")
            destination = None
        return destination
Exemplo n.º 32
0
    def hero_purchase(self):
        self.show_inventory()
        print("\"Which would ye like to purchase?\"")
        item = prompt("")
        item = converter.convert(item)

        # Check if item is a real item.
        if item != False:

            # If item is in stock and hero can afford it:
            if item in self.inventory and item.price <= self.hero.coins:
                self.hero.inventory.append(item)
                self.hero.coins -= item.price
                print("\"Nice doing business with you, sir!\"")

            # If item is in stock and hero cannot afford it:
            elif item in self.inventory and item.price > self.hero.coins:
                print("\a\"You can't afford that!\"")

            # If item is not in stock:
            else:
                print("\a\"Sorry I haven't got that in stock.\"")
Exemplo n.º 33
0
    def hero_purchase(self):
        self.show_inventory()
        print("\"Which would ye like to purchase?\"")
        item = prompt("")
        item = converter.convert(item)

        # Check if item is a real item.
        if item != False:
            
            # If item is in stock and hero can afford it:
            if item in self.inventory and item.price <= self.hero.coins:
                self.hero.inventory.append(item)
                self.hero.coins -= item.price
                print("\"Nice doing business with you, sir!\"")

            # If item is in stock and hero cannot afford it:
            elif item in self.inventory and item.price > self.hero.coins:
                print("\a\"You can't afford that!\"")

            # If item is not in stock:
            else:
                print("\a\"Sorry I haven't got that in stock.\"")
Exemplo n.º 34
0
    def menu(self):
        response = ""
        while self.hero.health:
            print("\nYOU ARE IN " + self.name.upper() + ".")
            print("""
J - JOURNEY
T - TALK TO VILLAGERS
S - SHOP
I - INVENTORY
D - DONATE
R - REST
G - GAME SAVE
Q - QUIT
""")
            response = prompt("").upper()
            if response == "J":
                destination = self.get_destination()
                if destination:
                    next_location = self.journey(destination[0], destination[1])
                    return next_location
            elif response == "T":
                self.talk()
            elif response == "S":
                self.shop_menu()
            elif response == "I":
                self.inv_function()
            elif response == "D":
                self.donation_menu()
            elif response == "R":
                self.rest()
            elif response == "G":
                print("save")
            elif response == "Q":
                return None
            else:
                print("\a")
        return None
Exemplo n.º 35
0
def opening_menu():
    choice = ""
    while choice != "Q":
        print("\nMAIN MENU")
        print("R - Resume Game")
        print("N - New Game")
        print("Q - Quit")
        print("T FOR TESTING!!!!")
        choice = prompt("").upper()
        if choice == "R":
            print("LOAD")
        elif choice == "N":
            import items
            data = introduction.intro()
            hero = characters.New_Hero(data[0], data[1])
            game = New_game(hero, locations.shmucksburg)

        # For testing only!!!!!!!!
        elif choice == "T":
            import items
            hero = characters.New_Hero("Bob", "Hooray!")
            hero.missions = [True, True, True, True, False, False]
            hero.weapon = items.shiny_sword
            hero.shield = items.sturdy_shield
            hero.armor = items.sweet_armor
            hero.coins = 100
            hero.inventory = [items.herbenol,
                              items.shiny_sword,
                              items.sturdy_shield,
                              items.sweet_armor,
                              items.kings_loot,
                              items.t_map
                              ]
            for i in range(1, 7):
                hero.inventory.append(items.bandage)
            game = New_game(hero, locations.silverrock)
Exemplo n.º 36
0
    def donate(self):
        """ For hero donating items to the armory. """

        # Get item
        import converter
        self.hero.inventory_menu()
        item = prompt("Select a weapon, shield or armor to donate.  Or \
press enter to exit. ").lower()
        item = converter.convert(item)

        # If item is a weapon, shield or armor, accept the donation
        if isinstance(item, items.Weapon) or isinstance(item, items.Shield) or isinstance(item, items.Armor):
            if item in self.hero.inventory:
                self.donations.append(item)
                self.hero.drop(item)
                self.sort_donations()
                prompt("\"Thank you for your donation.\"")
            else:
                prompt("You don't have one!")

        # If item is a real item but is not in the above classes, do not accept.
        elif item != False:
            prompt("That type of item is not needed.")
Exemplo n.º 37
0
            hero = characters.New_Hero(data[0], data[1])
            game = New_game(hero, locations.shmucksburg)

        # For testing only!!!!!!!!
        elif choice == "T":
            import items
            hero = characters.New_Hero("Bob", "Hooray!")
            hero.missions = [True, True, True, True, False, False]
            hero.weapon = items.shiny_sword
            hero.shield = items.sturdy_shield
            hero.armor = items.sweet_armor
            hero.coins = 100
            hero.inventory = [items.herbenol,
                              items.shiny_sword,
                              items.sturdy_shield,
                              items.sweet_armor,
                              items.kings_loot,
                              items.t_map
                              ]
            for i in range(1, 7):
                hero.inventory.append(items.bandage)
            game = New_game(hero, locations.silverrock)

def main():
    title()
    opening_menu()

# Execute main()
main()
prompt("Thanks for playing!")
Exemplo n.º 38
0
    def __init__(self, good_guys, mission_data):
        self.good_guys = good_guys
        self.mission_data = mission_data
        self.goods_health = 0
        self.bads_health = 0
        self.battle()

    def battle(self):
        # Each army attacks each other.  Then the remaining health is totaled.
        for i in range(0, 7):
            good_guys[i].attack(bad_guys[i])
            bad_guys[i].attack(good_guys[i])
            
            self.goods_health += good_guys[i].health
            self.bads_health += bad_guys[i].health
            
        both = (self.goods_health, self.bads_health)

        # If there is a tie, winner chosen randomly
        if self.goods_health == self.bads_health:
            winner = random.choice(both)
        # Otherwise, winner is whoever has more health left
        else:
            winner = max(both)

        return winner

if __name__ == "__main__":
    print("This is a module for 'Oh Great Knight'.")
    prompt("Press enter to exit.")
Exemplo n.º 39
0
def intro():
    print("Welcome to Shmucksburg: A knightless town in a dangerous world.")
    prompt("")
    print("Your name is Cecil.  Cecil Farmer.\n")
    prompt("You're a farmer.\n")
    prompt("You leave your cabin one morning and walk to the townsquare.  \
You can hear the beautiful sound of birds chirping.\n")
    prompt("\ttweet!\a")
    prompt("\ttweet tweet!\a\a")
    prompt("\ttweet tweet tweet!\a\a\a\n")
    print("You see your fellow villagers standing in the townsquare, \
mourning, as they've grown accustom to doing:\n")
    prompt("\"Oh, that the town would be safe!  \
Oh, that our goods would be returned!  Oh, that the robbers would be put to \
justice!  Oh, that we would be granted federal funding for our municipal \
improvements!\n \
\"But who?  Who will be our knight!?\"\n")
    prompt("You silently agree.  A hero is needed!  In the past, Shmucksburg \
has been able to defend itself because of its armory.  But since that was \
robbed last year, they've had little luck defending the village.  If only \
someone could find and retake the contents of your armory....\n")
    prompt("You return home.  You go into your barn to begin your work.  \
As you reach for a shovel, you find an old mask from your childhood.\n")
    prompt("\"Why this makes me look twice as dapper and three times as \
valiant!\"\n")
    prompt("'Tis fate, perhaps, but the mask inspires you.\n")
    prompt("\"A hero needs two things: heart, and a sweet mask!  \
Now that I have the latter, I can be our village knight!\"\n")
    
    name = ""
    while name == "":
        name = prompt("\tWhat shall you call yourself, sir knight?\n").title()

    catchphrase = ""
    while catchphrase == "":
        catchphrase = prompt("\tWhat shall your battle cry be?\n")
        
    prompt("\"When I wear this mask, I shall be known as " + name + "!  \
And when I march into battle, I will shout, '" + catchphrase + "!'\"\n")

    prompt("After some thought, you decide a hero may need some other things \
as well, such as weapons and armor and perhaps a shield.  You head to \
the townsquare to pawn your gold ring and buy some supplies.")
    
    prompt("\n\n\t\t\tYOUR JOURNEY BEGINS.\n\n")

    intro_data = (name, catchphrase)
    return intro_data
Exemplo n.º 40
0
 def use(self, target):
     prompt("The map shows where to dig at the valley's end.")
Exemplo n.º 41
0
 def win(self):
     prompt("Pretty Blob gives you a big kiss.")
Exemplo n.º 42
0
 def use(self, target):
     prompt("The map shows where to dig at the valley's end.")
Exemplo n.º 43
0
    def item_pick(self):
        item = prompt("Select an item to use or equip or press 'enter' to \
exit.\n").lower()
        item = converter.convert(item)
        return item
Exemplo n.º 44
0
 def win(self):
     prompt("\"" + self.catchphrase + "\"")
Exemplo n.º 45
0
 def win(self):
     prompt(self.name + " was having so much fun he tries to put you back together.")
Exemplo n.º 46
0
 def get_first_strike(self):
     """ First strike chosen at random """
     opponents = (self.hero, self.monster)
     first_strike = random.choice(opponents)
     prompt(first_strike.name + " strikes first!\n")
     return first_strike
Exemplo n.º 47
0
 def win(self):
     prompt("Tis a bad day to be a hero....\n")
Exemplo n.º 48
0
        self.good_guys = good_guys
        self.mission_data = mission_data
        self.goods_health = 0
        self.bads_health = 0
        self.battle()

    def battle(self):
        # Each army attacks each other.  Then the remaining health is totaled.
        for i in range(0, 7):
            good_guys[i].attack(bad_guys[i])
            bad_guys[i].attack(good_guys[i])

            self.goods_health += good_guys[i].health
            self.bads_health += bad_guys[i].health

        both = (self.goods_health, self.bads_health)

        # If there is a tie, winner chosen randomly
        if self.goods_health == self.bads_health:
            winner = random.choice(both)
        # Otherwise, winner is whoever has more health left
        else:
            winner = max(both)

        return winner


if __name__ == "__main__":
    print("This is a module for 'Oh Great Knight'.")
    prompt("Press enter to exit.")
Exemplo n.º 49
0
def title():
    print("\t\t\t****************")
    print("\t\t\tOh Great Knight!")
    print("\t\t\t****************")
    print("\nby Mark Lauber\n\n")
    prompt("Press enter to begin.\n\n")
Exemplo n.º 50
0
 def get_first_strike(self):
     """ First strike chosen at random """
     opponents = (self.hero, self.monster)
     first_strike = random.choice(opponents)
     prompt(first_strike.name + " strikes first!\n")
     return first_strike
Exemplo n.º 51
0
 def win(self):
     prompt(self.name + " decides she wasn't hungry after all!")