1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
import re
f = open('levels.txt', 'r')
contents = f.read()
f.close()
blocks = contents.split('\n\n')
playing = True
count = 0
room = blocks[0].split('\n')
for line in room:
if re.match(r'Room:', line):
print('You are in ' + line[6:])
elif re.match(r'Desc:', line):
print('You see ' + line[6:])
while playing:
cmd = input(':>')
count = count + 1
if count == 5:
playing = False
print('Game over!')