-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTextRPGEngine.py
More file actions
35 lines (29 loc) · 967 Bytes
/
TextRPGEngine.py
File metadata and controls
35 lines (29 loc) · 967 Bytes
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
import os
import re
import StoryConnection
import GameHelper
gameHelper = GameHelper.GameHelper()
gameHelper.clearConsole()
storyConn = StoryConnection.StoryConnection(gameHelper.getGameFile())
gameExit = False
print(gameHelper.formatParagraph(storyConn.getRoomDescription()))
while not gameExit:
userCommand = re.sub( '\s+', ' ', input(">") ).strip().split(" ")
if userCommand[0] == "exit":
storyConn.closeConnection()
gameHelper.finishGameLoop()
break
elif userCommand[0] == "delete":
os.remove("gameSave.ntg")
gameExit = True
else:
response = storyConn.processUserInput(userCommand)
if "GAME OVER" in response:
os.remove("gameSave.ntg")
break
elif "&$%!" in response:
response = response.replace("&$%!", "")
print(gameHelper.formatParagraph(response))
break
else:
print(gameHelper.formatParagraph(response))