Beispiel #1
0
def test_dungeon_build():
    """method to build a dungeon for testing and dev."""
    dungeon_name = "Test Dungeon"
    room_one_date =["Entry Room", "The first room in the test dungeon"]
    room_one = Room(room_one_date)
    roomtwo_data = ["second Room", "The second room of the test dungeon"]
    room_two = Room(roomtwo_data)
    exit1 = Exit("n", room_one, room_two)
    exit2 = Exit("s", room_two, room_one)
    room_one.add_exit(exit1)
    room_two.add_exit(exit2)
    test_dungeon = Dungeon(dungeon_name, room_one)
    test_dungeon.add_room(room_two)
    item_one_stats = ["Apple", "A red Fuji Apple", .2]
    item_one_actions = {"eat": "consume-You eat the apple", "examine": "It's a\
         red apple. It looks really tasty.", "throw": "destroy-You hurl the \
             apple agaisnt the wall. It smashes agaisnt it with a splat."}
    item_one_date = ["Apple", "A red Fuji Apple", 0.2,item_one_actions]
    item_one = item(item_one_date)
    item_two_stats = ["Spoon", "a metal spoon", .01]
    item_two_actions = {"examine": "examine-The spoon is made of some form of lite metal, perhaps tin.", "throw": "remove-You hurl the \
             spoon agaisnt the wall. It clashes against the wall with a clatter."}
    item_two_data = ["Spoon", "a metal spoon", 0.01,item_two_actions]
    item_two = item(item_two_data)
    room_one.add_item(item_one)
    room_one.add_item(item_two)
    return test_dungeon
Beispiel #2
0
def rat_in_three_room_dungeon() -> Rat:
    """Return a rat object ready to explore a dungeon with three rooms in a row."""
    r0 = Room('start here', 1, 0, 1)
    d = Dungeon(r0)
    r1 = Room('one', 1, 0, 2)
    r2 = Room('two', 2, 0, 3)
    r0.add_neighbor(r1, Direction.NORTH)
    r1.add_neighbor(r2, Direction.NORTH)
    d.add_room(r1)
    d.add_room(r2)
    rat = Rat(d, r0)
    return rat
Beispiel #3
0
def rat_in_fully_connected_grid() -> Rat:
    """Return a rat in a fully connected dungeon of 20 by 20 rooms"""
    start = Room("0,0", 1, 0, 0)
    d = Dungeon(start)
    for row in range(0, 20):
        for col in range(0, 20):
            if row > 0 or col > 0:
                d.add_room(Room(str(row) + "," + str(col), 1, col, row))
    for row in range(0, 20):
        for col in range(0, 20):
            connect_neighbors(d, row, col)
    rat = Rat(d, start)
    return rat
Beispiel #4
0
def rat_in_looped_dungeon() -> Rat:
    """Return a rat object ready to explore a dungeon with 6 rooms where there
    are two paths from the start to the finish.
    """
    r0 = Room('start', 0, 9, 9)
    d = Dungeon(r0)
    r1 = Room('one', 1, 9, 8)
    r2 = Room('two', 1, 9, 7)
    r3 = Room('three', 1, 9, 6)
    r4 = Room('four', 1, 9, 5)
    r5 = Room('five', 1, 9, 4)
    unconnected = Room('unconnected', 1, 8, 8)
    # r0 -> r1, r1 -> r2, r3; r2 -> r0, r3 -> r4, r4 -> r5
    r0.add_neighbor(r1, Direction.DOWN)
    r1.add_neighbor(r2, Direction.NORTH)
    r1.add_neighbor(r3, Direction.SOUTH)
    r2.add_neighbor(r0, Direction.UP)
    r3.add_neighbor(r4, Direction.EAST)
    r4.add_neighbor(r5, Direction.SOUTH)
    d.add_room(r1)
    d.add_room(r2)
    d.add_room(r3)
    d.add_room(r4)
    d.add_room(r5)
    d.add_room(unconnected)
    rat = Rat(d, r0)
    return rat
Beispiel #5
0
def rat_in_square_dungeon() -> Rat:
    """Return a rat object ready to explore a dungeon with 4 rooms in a square."""
    top_left_room = Room('top left', 1, 1, 0)
    bottom_left_room = Room('bottom left', 1, 0, 0)
    top_right_room = Room('top right', 1, 1, 1)
    bottom_right_room = Room('bottom right', 1, 0, 1)
    d = Dungeon(top_left_room)
    d.add_room(bottom_left_room)
    d.add_room(top_right_room)
    d.add_room(bottom_right_room)
    top_left_room.add_neighbor(top_right_room, Direction.EAST)
    top_left_room.add_neighbor(bottom_left_room, Direction.SOUTH)
    bottom_right_room.add_neighbor(bottom_left_room, Direction.WEST)
    bottom_right_room.add_neighbor(top_right_room, Direction.NORTH)
    rat = Rat(d, top_left_room)
    return rat
Beispiel #6
0
def rat_in_dungeon_x() -> Rat:
    """Return a rat in a dungeon with several long paths and one loop."""
    # The following pseudo-map describes the basic structure of the
    # dungeon, where rooms next to each other and dashed lines indicate
    # neighbors.
    #                  north2
    #                  north1
    # west1 downstairs center east1
    #  |               south1 
    # sw2              south2 stair1 upstairs-east1
    # sw3 -----------------------------> food
    #
    center = Room("center", 1, 5, 5)
    d = Dungeon(center)
    north1 = Room("north1", 1, 5, 6)
    north2 = Room("north2", 1, 5, 7)
    east1 = Room("east1", 1, 6, 5)
    down = Room("downstairs", 0, 5, 5)
    west1 = Room("west1", 0, 5, 4)
    sw2 = Room("sw2", 0, 4, 4)
    sw3 = Room("sw3", 0, 4, 3)
    south1 = Room("south1", 1, 5, 4)
    south2 = Room("south2", 1, 5, 3)
    stair1 = Room("stair1", 2, 5, 3)
    upstairs_east1 = Room("upstairs-east1", 2, 6, 3)
    food_room = Room("food", 1, 6, 2)
    d.add_room(north1)
    d.add_room(north2)
    d.add_room(east1)
    d.add_room(down)
    d.add_room(west1)
    d.add_room(sw2)
    d.add_room(sw3)
    d.add_room(south1)
    d.add_room(south2)
    d.add_room(stair1)
    d.add_room(upstairs_east1)
    d.add_room(food_room)

    center.add_neighbor(north1, Direction.NORTH)
    north1.add_neighbor(north2, Direction.NORTH)
    center.add_neighbor(down, Direction.DOWN)
    down.add_neighbor(west1, Direction.WEST)
    west1.add_neighbor(sw2, Direction.SOUTH)
    sw2.add_neighbor(sw3, Direction.SOUTH)
    sw3.add_neighbor(food_room, Direction.UP)
    center.add_neighbor(east1, Direction.EAST)
    center.add_neighbor(south1, Direction.SOUTH)
    south1.add_neighbor(south2, Direction.SOUTH)
    south2.add_neighbor(stair1, Direction.UP)
    stair1.add_neighbor(upstairs_east1, Direction.EAST)
    upstairs_east1.add_neighbor(food_room, Direction.DOWN)
    rat = Rat(d, center)
    return rat