1. Jason R. Coombs
  2. adventure

Commits

Brandon Rhodes  committed 883f540

Made it possible to cleanly exit the custom prompt with control-D.

  • Participants
  • Parent commits 177dae8
  • Branches default

Comments (0)

Files changed (1)

File adventure/__main__.py

View file
         stdout.write(c)
         stdout.flush()
 
-game = Game()
-load_advent_dat(game)
-game.start()
-baudout(game.output)
-while not game.is_finished:
-    line = input('> ')
-    words = re.findall(r'\w+', line)
-    if words:
-        baudout(game.do_command(words))
+def loop():
+    game = Game()
+    load_advent_dat(game)
+    game.start()
+    baudout(game.output)
+
+    while not game.is_finished:
+        line = input('> ')
+        words = re.findall(r'\w+', line)
+        if words:
+            baudout(game.do_command(words))
+
+try:
+    loop()
+except EOFError:
+    pass