Esempio n. 1
0
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
Esempio n. 2
0
	def test_find_room(self):
		self.assertEqual(rooms.find_room("test room"),self.test_room,"Should be able to find test room.")