Beispiel #1
0
	def test_get_action(self):
		self.assertEqual(engine.get_action("fish"),(None,None),"Get action should return (None,None) for input 'fish'.")
		self.assertEqual(engine.get_action("castle"),(None,None),"Get action should return (None,None) for input 'castle'.")
		self.assertEqual(engine.get_action("q"),("quit",None),"Get action should return ('quit',None) for input 'q'.")
		self.assertEqual(engine.get_action("look"),("look",None),"Get action should return ('look',None) for input 'look'.")
		self.assertEqual(engine.get_action("look n"),("look direction","north"),"Get action should return ('look direction,'north') for input 'look n'.")
		self.assertEqual(engine.get_action("look fish"),("look error",None),"Get action should return ('look error',None) for input 'look fish'.")
		self.assertEqual(engine.get_action("north"),("move","north"),"Get action should return ('move','north') for input 'north'.")
Beispiel #2
0
def main():
	print "Welcome!"
	print rooms.current_room.show_full_desc()

	while True:
		rooms.previous_room = rooms.current_room
		user_input = raw_input("Enter a command: ").lower()
		action, arguments = engine.get_action(user_input)
		response = engine.do_action(action,arguments)
		print response
		if action == "quit":
			break
		print rooms.show_room()