Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDinko Galetic <dgaletic@everflame.(none)>2010-06-08 23:06:49 (GMT)
committer Dinko Galetic <dgaletic@everflame.(none)>2010-06-08 23:06:49 (GMT)
commit8b1d363fedc33716bee321b8878175f66322321d (patch)
tree80db079adeea7be2e08b2d999c2cf720e47cb573
parentae3912e7607781fc7f9c941ee4f2bf86f551bc83 (diff)
Added game_loop(), the main loop in the game.
Will go through major reworking soon.
-rw-r--r--library/pippy/scholar/scholar.py40
1 files changed, 40 insertions, 0 deletions
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!"