Example #1
0
from game_data import World, Item, Location
from player import Player

if __name__ == "__main__":
    WORLD = World("map.txt", "locations.txt", "items.txt")
    PLAYER = Player(
        2, 2
    )  # set starting location of player; you may change the x, y coordinates here as appropriate

    menu = ["look", "inventory", "score", "quit", "back"]

    while not PLAYER.victory:
        location = WORLD.get_location(PLAYER.x, PLAYER.y)

        # ENTER CODE HERE TO PRINT LOCATION DESCRIPTION
        # depending on whether or not it's been visited before,
        #   print either full description (first time visit) or brief description (every subsequent visit)

        print("What to do? \n")
        print("[menu]")
        for action in location.available_actions():
            print(action)
        choice = input("\nEnter action: ")
        if (choice == "[menu]"):
            print("Menu Options: \n")
            for option in menu:
                print(option)
            choice = input("\nChoose action: ")

        # CALL A FUNCTION HERE TO HANDLE WHAT HAPPENS UPON USER'S CHOICE
        #    REMEMBER: the location = w.get_location(p.x, p.y) at the top of this loop will update the location if the
Example #2
0
    World.load_locations(WORLD, "locations.txt")
    World.load_items(WORLD, "items.txt")

    inventoryI = ["T-card", "Lucky Pen", "Cheat Sheet"]
    inventoryF = []
    counter = 0
    score = 0

    print("You studied ridiculously hard last night and lost your tcard, lucky pen and cheat sheet. GO FIND THEM")
    print ("Valid commands are : go north, go south, go east, go west, look, look around, pick up, drop, inventory, score, quit and where am i?")
    print ("You have 50 minutes to find everything and go to the exam hall. every step you take is one minute gone lol")
    print ("Each item successfully dropped at the exam hall is 20 points. The faster you get all three items to the hall, the more points you'll earn")
    print ("Good Luck Bro")

    while not PLAYER.victory:
        location = WORLD.get_location(PLAYER.x, PLAYER.y)

        # ENTER CODE HERE TO PRINT LOCATION DESCRIPTION
        # depending on whether or not it's been visited before,
        #   print either full description (first time visit) or brief description (every subsequent visit)


        print("What to do? \n")


        choice = input("\nEnter action: ")



        if (choice == "go west" and not WORLD.map[PLAYER.x][PLAYER.y -1] == '-1'):
            PLAYER.move_north()
    choice = ""
    init_item_list = WORLD.load_items("items.txt")
    spec_item_list = WORLD.load_special_items("special.txt")

    item1 = False
    item2 = False
    item3 = False

    intro = open("intro.txt", "r")
    for line in intro:
        print(line.strip("\n"))

    while True:

        # check for actions and set up location
        location = WORLD.get_location(PLAYER.x, PLAYER.y, True, PLAYER)
        if item1 == True and item2 == True and item3 == True and WORLD.locations.index(location) == 2:
            PLAYER.score += 100
            break
        if WORLD.locations.index(location) == 14:
            print("You have been eaten by a grue.")
            quit()
        # depending on whether or not it's been visited before,
        # print either full description (first time visit) or brief description (every subsequent visit)
        # don't print it if the look command was used
        if choice != "looked at":
            if location.is_visited():
                print("\n" + location.get_brief_description())
            else:
                print("\n" + location.get_full_description()[: len(location.get_full_description()) - 1])
                location.visited()
Example #4
0
from game_data import World, Item, Location
from player import Player

if __name__ == "__main__":
    WORLD = World("map.txt", "locations.txt", "items.txt")
    PLAYER = Player(2,2) # set starting location of player; you may change the x, y coordinates here as appropriate

    menu = ["look", "inventory", "score", "quit", "back"]

    while not PLAYER.victory:
        location = WORLD.get_location(PLAYER.x, PLAYER.y)

        # ENTER CODE HERE TO PRINT LOCATION DESCRIPTION
        # depending on whether or not it's been visited before,
        #   print either full description (first time visit) or brief description (every subsequent visit)

        print("What to do? \n")
        print("[menu]")
        for action in location.available_actions():
            print(action)
        choice = input("\nEnter action: ")
        if (choice == "[menu]"):
            print("Menu Options: \n")
            for option in menu:
                print(option)
            choice = input("\nChoose action: ")

        # CALL A FUNCTION HERE TO HANDLE WHAT HAPPENS UPON USER'S CHOICE
        #    REMEMBER: the location = w.get_location(p.x, p.y) at the top of this loop will update the location if the
        #               choice the user made was just a movement, so only updating player's position is enough to change
        #               the location to the next appropriate location
Example #5
0
    PLAYER = Player(1, 1)  # set starting location of player;
    # you may change the x, y coordinates here as appropriate
    # MOVE is the limited movements, the player has to
    # finish within this num of movements
    MOVE = 32

    menu = ["look", "inventory", "score", "quit", "back"]

    # ge the total score of all the items
    total_score = 0
    for item in WORLD.items.values():
        total_score += item.target_points

    # to start the game
    while not PLAYER.victory:
        location = WORLD.get_location(PLAYER.x, PLAYER.y)
        location.refresh_points()
        # ENTER CODE HERE TO PRINT LOCATION DESCRIPTION
        # depending on whether or not it's been visited before,
        # print either full description (first time visit) or
        # brief description (every subsequent visit)
        # if location has been visited, print short description
        if location.has_visit:
            print("Location " + str(location.num))
            print(location.bdescrip)
        # print long one if first visit
        else:
            print("Location " + str(location.num))
            print(location.ldescrip)
            location.has_visit = True
Example #6
0
    print(
        "You studied ridiculously hard last night and lost your tcard, lucky pen and cheat sheet. GO FIND THEM"
    )
    print(
        "Valid commands are : go north, go south, go east, go west, look, look around, pick up, drop, inventory, score, quit and where am i?"
    )
    print(
        "You have 50 minutes to find everything and go to the exam hall. every step you take is one minute gone lol"
    )
    print(
        "Each item successfully dropped at the exam hall is 20 points. The faster you get all three items to the hall, the more points you'll earn"
    )
    print("Good Luck Bro")

    while not PLAYER.victory:
        location = WORLD.get_location(PLAYER.x, PLAYER.y)

        # ENTER CODE HERE TO PRINT LOCATION DESCRIPTION
        # depending on whether or not it's been visited before,
        #   print either full description (first time visit) or brief description (every subsequent visit)

        print("What to do? \n")

        choice = input("\nEnter action: ")

        if (choice == "go west"
                and not WORLD.map[PLAYER.x][PLAYER.y - 1] == '-1'):
            PLAYER.move_north()
            counter = counter + 1
            print(WORLD.get_location(PLAYER.x, PLAYER.y))
            print("You have ", 40 - counter, " moves left.")
    menu = ["look", "inventory", "score", "quit", "back"]

    list_of_location_history = []

    load_map = WORLD.map

    item_list = WORLD.item

    score = 0

    victory_items = []

    while not PLAYER.victory:

        location = WORLD.get_location(PLAYER.x, PLAYER.y)

        """
        for each object stored in gamedata, find it position and if player
        have already visited. if the location number of the object matches
        the current, prints out description of location
        """
        for search_object in WORLD.store_location:

            visit_or_not = getattr(search_object[0], 'is_visit')

            get_location = getattr(search_object[0], 'position_num')

            if str(get_location) == location:

                if visit_or_not is False: