From 8b1d363fedc33716bee321b8878175f66322321d Mon Sep 17 00:00:00 2001 From: Dinko Galetic Date: Tue, 08 Jun 2010 23:06:49 +0000 Subject: Added game_loop(), the main loop in the game. Will go through major reworking soon. --- (limited to 'library') diff --git a/library/pippy/scholar/scholar.py b/library/pippy/scholar/scholar.py index 58a97f5..cc01b2f 100644 --- a/library/pippy/scholar/scholar.py +++ b/library/pippy/scholar/scholar.py @@ -121,3 +121,43 @@ def unalias(player, player_input): if player_input in item.aliases: return item return None + + +def game_loop(): + rooms = create_some_rooms() + player = login() + print "Welcome,", player.name + print + load() + player.position = rooms[0] + command = "" + examine(player, player.position) + while True: + command = raw_input("> ") + if command == "quit": + break + command = command.split(" ") + # Currently, only two word inputs supported. + # This will need some major reworking. + if len(command) < 2 or len(command) > 2: + print "What?" + continue + verb = command[0] + obj = command[1] + # if an item is in the room, you can do it. + # TODO: also, if it's in the inventory. + + if verb in player.known_commands: + real_obj = unalias(player, obj) + if real_obj == None: + print "No such thing here." + continue + if verb in real_obj.methods: + eval(verb)(player, real_obj) + else: + print "You can't", verb, obj + else: + print "You don't know how to \"" + verb + "\"" + + save() + print "Goodbye!" -- cgit v0.9.1