def do_action(action,arguments): if action == "look direction": current_room = rooms.current_room if arguments in current_room.doors.keys(): this_door = doors.find_door(current_room.doors[arguments]) if this_door.closed: action = "look direction closed" arguments = this_door else: action = "look direction open" other_exit = rooms.find_room(this_door.exits[arguments]) arguments = other_exit else: action = "look direction error" elif action == "move": current_room = rooms.current_room if arguments in current_room.doors.keys(): this_door = doors.find_door(rooms.current_room.doors[arguments]) if this_door.closed: action = "move closed" arguments = this_door else: other_exit = rooms.find_room(this_door.exits[arguments]) arguments = other_exit rooms.previous_room = current_room rooms.current_room = other_exit else: action = "move direction error" response = output.generate_response(action,arguments) return response
def test_find_door(self): self.assertEqual(doors.find_door("test door"),self.test_door,"Should be able to find the test door.")