@curtisautery/

Coding club demo

Python

No description

fork
loading
Files
  • main.py
  • levels.txt

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.458372861463626","path":"main.py","file":{"path":"main.py","content":{"asEncoding":{"base64":"aW1wb3J0IHJlCgpmID0gb3BlbignbGV2ZWxzLnR4dCcsICdyJykKY29udGVudHMgPSBmLnJlYWQoKQpmLmNsb3NlKCkKYmxvY2tzID0gY29udGVudHMuc3BsaXQoJ1xuXG4nKQpwbGF5aW5nID0gVHJ1ZQpjb3VudCA9IDAKCnJvb20gPSBibG9ja3NbMF0uc3BsaXQoJ1xuJykKZm9yIGxpbmUgaW4gcm9vbToKICBpZiByZS5tYXRjaChyJ1Jvb206JywgbGluZSk6CiAgICBwcmludCgnWW91IGFyZSBpbiAnICsgbGluZVs2Ol0pCiAgZWxpZiByZS5tYXRjaChyJ0Rlc2M6JywgbGluZSk6CiAgICBwcmludCgnWW91IHNlZSAnICsgbGluZVs2Ol0pCgp3aGlsZSBwbGF5aW5nOgogIGNtZCA9IGlucHV0KCc6PicpCiAgY291bnQgPSBjb3VudCArIDEKICBpZiBjb3VudCA9PSA1OgogICAgcGxheWluZyA9IEZhbHNlCgpwcmludCgnR2FtZSBvdmVyIScp"},"asBuffer":null},"loaded":true}}
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!')