Example #1
0
def test_room_paths():
   center = Room("Center", "Test room in the center.")
   north = Room("North", "Test room in the north.")
   south = Room("South", "Test room in the south.")

   center.add_paths({'north': north, 'south': south})
   assert_equal(center.go('north'), north)
   assert_equal(center.go('south'), south)
Example #2
0
def test_map():
   start = Room("Start", "You can go west and down a hole.")
   west = Room("Trees", "There are trees here, you can go east.")
   down = Room("Dungeon", "It's dark down here, you can go up.")

   start.add_paths({'west': west, 'down': down})
   west.add_paths({'east': start})
   down.add_paths({'up': start})

   assert_equal(start.go('west'), west)
   assert_equal(start.go('west').go('east'), start)
   assert_equal(start.go('down').go('up'), start)
Example #3
0
                        That is great, you bring the pine nuts out of your bag which you peek on the way coming.
                        And you sing a song to catch the attention of the squirrel. 
                        
                        The squirrel comes out, take the pine nuts,and make frinds with you. 
                        He tells you there is a mysterious thing in the tree room. 
                        You continue to climb with the squirrel.
                           """)
squirrel_room.actions=["ignore the squirrel","give pine nuts to the squirrel","bite the squirrel"]

tree_room=Room("Tree Room","""Open the door. A wondrous world comes in your eyes. 
                You gradually walk into the room with a hot-bloooded heart. 
                There is a little bed  decorated with flowers and leaves, layed on the window.
                A desk and four bamboo stools stand in the middle of the room. Four little cups 
                lay on the desk. You walk in the room around and around. Oh, you find a wood box on the 
                desk behind the window. It needs a key to open it.""")
tree_room.actions=["find the key","ignore the box","open the box with hammer"]

death = Room("death", """You died!!!""")
win = Room("win", """A fairy fly out!""")

generic_death = None

#==================================添加room间的逻辑关系====================================
START = forest_plane
START.add_paths({"player climb ladder":squirrel_room})
squirrel_room.add_paths({"player give pine_nuts":tree_room})
tree_room.add_paths({"player find key":win})

path_list = ("death", "win", "player climb ladder","player give pine_nuts","player find key")
room_list = {"Forest Plane":forest_plane,"Squirrel Room":squirrel_room,"Tree Room":tree_room}
Example #4
0
#!/usr/bin/env python
# coding=utf-8
from map import Room

central_corridor = Room(
    'Central Corridor', ''' 
The Gothons of Planet Percal #25 have invaded your ship and destroyed
your entire crew. You are the last surviving member and your last
mission is to get the neutron destruct bomb from the Weapons Armory,
put it in the bridge, and blow the ship up after getting into an
escape pod.
You're running down the central corridor to the Weapons Armory when
a Gothon jumps out, red scaly skin, dark grimy teeth, and evil clown costume
flowing around his hate filled body. He's blocking the door to the
Armory and about to pull a weapon to blast you.''')

generic_death = Room('death', 'You died, next life to survive')

central_corridor.add_paths({
    'shoot': generic_death,
    'dodge': generic_death,
    'tell a joke': generic_death
})

START = central_corridor
Example #5
0
                      The container clicks open and the seal breaks, letting gas out.
                      You grab the neutron bomb and run as fast as you can to the 
                      bridge where you must place it in the right spot.
                      """)
the_bridge.actions = ["run", "sing a song", "sleep"]

death = Room("death", """You died!!!""")
win = Room("win", """You survived!""")

# ======================================list======================================

path_list = ("death", "win", "Central Corridor", "Laser Weapon Armory",
             "The Bridge", "player type number", "player tell joke",
             "player run")
room_list = {
    "Central Corridor": central_corridor,
    "Laser Weapon Armory": laser_weapon_armory,
    "The Bridge": the_bridge,
    "death": death,
    "win": win
}

# 错误反馈
generic_death = None

# =============================房间之间逻辑添加========================================
START = central_corridor
START.add_paths({"player tell joke": laser_weapon_armory})
laser_weapon_armory.add_paths({"player type number": the_bridge})
the_bridge.add_paths({"player run": win})