/
dash.py
52 lines (46 loc) · 1.33 KB
/
dash.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# dash.py
# Dungeon Adventure Shell
# Michael Rudden, 2016
import sys
from bash import bash
running = True
def welcome():
print """You find yourself somewhere in the middle of a dark dungeon.
Perhaps you should explore your environment, or type \"check guide\"
to consult the Explorer's Guide you always carry in your pocket."""
def run():
while running:
input = raw_input("\nWhat would you like to do? >")
print ""
if input == "check guide":
check_guide()
elif input == "look":
print "You quickly look at your surroundings. On first glance you see:"
print bash('ls')
elif input == "look up":
print "You look up above you and see:"
print bash('ls ..')
elif input == "look around":
print "You take a good look around you, stopping to make note of what you see:"
print bash('ls -a')
elif input == "bash":
bash_input = True
while bash_input:
bash_command = raw_input("$")
if bash_command == "exit":
bash_input = False
else:
print bash(bash_command)
elif input == "exit":
print "there is no escape"
sys.exit()
else:
print "Please enter a valid command"
def check_guide():
print """You open the worn book in your pocket and see the following:
look = ls
look around = ls -a
look up = ls ..
"""
welcome()
run()