Esempio n. 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(1,1) # set starting location of player; you may change the x, y coordinates here as appropriate

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

    World.load_map(WORLD, "map.txt")
    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)
from game_data import World, Item, Location
from player import Player
import winsound

if __name__ == "__main__":
    WORLD = World("map.txt", "locations.txt", "items.txt")
    PLAYER = Player(7, 1, 20)

    menu = ["look", "inventory", "score", "save", "load", "quit", "back"]
    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()
Esempio n. 3
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
Esempio n. 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
Esempio n. 5
0
                        location.items.append(item)
                    # count the movement
                    player.count_move()
        # if list is empty
        else:
            print("You got nothing!")
    # get the score if wants to check
    elif action == 'score':
        print('\n' + str(player._score))
    # quit the game if player wants
    elif action == 'quit':
        player.victory = True


if __name__ == "__main__":
    WORLD = World("map.txt", "locations.txt", "items.txt")
    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:
Esempio n. 6
0
import os
from game_data import World, Item, Location
from player import Player

if __name__ == "__main__":
    WORLD = World()
    PLAYER = Player(0, 0)

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

    while not PLAYER.victory and PLAYER.moves_remaining > 0 and quit == False:
        location = WORLD.get_location(PLAYER.x, PLAYER.y)

        if location.is_new():
            print(location.get_full_description())
            PLAYER.score += location.points
        else:
            print(location.get_brief_description())
        location.visit()

        print('You have ' + str(PLAYER.moves_remaining) + ' moves remaining.')
        print("What shall you do? \n")
        print("Menu")
        for action in WORLD.get_available_actions(location,
                                                  PLAYER.get_inventory()):
            print(action)
        choice = ''

        while (choice not in WORLD.get_available_actions(
                location, PLAYER.get_inventory()) and quit == False):
Esempio n. 7
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(
        1, 1
    )  # set starting location of player; you may change the x, y coordinates here as appropriate

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

    World.load_map(WORLD, "map.txt")
    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"
Esempio n. 8
0
from game_data import World, Item, Location
from player import Player


if __name__ == "__main__":

    """
    Creates local variables for future calling
    """
    WORLD = World("map.txt", "locations.txt", "items.txt")

    PLAYER = Player(0, 0)

    total_turns = 50

    turns_counter = 0

    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: