-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRPG.py
250 lines (199 loc) · 7.94 KB
/
RPG.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
# I want to make an RPG Game based sorta like Legend of Zelda but, with levels
# I also want to make a map but how? alt codes maybe ???
# Inventory System - David Lunt
# https://stackoverflow.com/questions/32486754/i-want-to-make-an-inventory-system-for-my-game-in-python-v-3-4-3
# Imports
import sys, time, os, random, pickle, items
import os.path
# Check if the file to save has been created.
file_exists = os.path.isfile("loadfile.txt")
# Load the text file (Bring down to save below us once working ...)
def load():
if file_exists:
file = open("loadfile.txt", "r")
room = file.read()
file.close()
else:
room = "Start Room"
#===================================================================#
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = #
#===================================================================#
# Save the file
def save(s):
file = open ("loadfile.txt", "w")
file.write(s)
file.close()
#===================================================================#
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = #
#===================================================================#
# Login
print(f'\n{"-"*36}\nWelcome to the Text RPG login screen\n{"-"*36}\n')
username_create = input('Please set a username: ')
password_create = input('Please set a password: ')
print (f'User Creation Successful.\n')
user_login = input('Enter Username: ')
if user_login == username_create:
print(f'Initiating Login for {username_create}')
time.sleep(1.5)
if user_login != username_create:
print('User is not registered.')
count = 0
while count < 3:
user_login_pw = input('Enter Password: ')
if user_login_pw == password_create:
print ('Password Accepted')
break
if user_login_pw != password_create:
print('Incorrect Password, Try Again.')
count += 1
if count == 3:
exit()
#===================================================================#
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = #
#===================================================================#
############################
## ##
## Welcome ##
## ##
############################
print (f'WELCOME {username_create} TO TEXT RPG V 1.1\n')
os.system("start F:\Python\Adventure.mp3")
#===================================================================#
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = #
#===================================================================#
class Weapon:
# A simple class
# attribute
attr1 = 'Wooden'
attr2 = 'Bronze'
attr3 = 'Iron'
attr4 = 'Emerald'
attr5 = 'Steel'
attr6 = 'Sapphire'
attr7 = 'Diamond'
attr8 = 'Dragon Slayer'
attr9 = 'Enchanted'
# Driver code
# Object instantiation
weapon = Weapon()
#===================================================================#
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = #
#===================================================================#
############################
## ##
## Chapter 1 ##
## Prologue ##
## ##
############################
# Level Selection
# Tutorial
# Story 1
# Story 2
# Story 3
Levels = ['Tutorial, Phobotane, Veillantif']
Tutorial = "Tutorial"
Story_1 = "Phobotane"
Story_2 = "Veillantif"
Fight = ['Attack, Defend, Run']
Attack = "Attack"
Defend = "Defend"
Run = "Run"
#===================================================================#
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = #
#===================================================================#
# Typing Speeds
typing_speed = 50 #wpm
def slow(text):
for letter in text:
sys.stdout.write(letter)
sys.stdout.flush()
time.sleep(random.random()*10.0/typing_speed)
print('')
def normal(text):
for letter in text:
sys.stdout.write(letter)
sys.stdout.flush()
time.sleep(random.random()*6.0/typing_speed)
print('')
def sprint(text):
for letter in text:
sys.stdout.write(letter)
sys.stdout.flush()
time.sleep(random.random()*3.0/typing_speed)
print('')
#===================================================================#
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = #
#===================================================================#
Game_Start = input(f"Please choose a Level - {Levels}: ")
print('\n')
while True:
#===================================================================#
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = #
#===================================================================#
if Game_Start == Tutorial:
slow(f'''
Welcome to the Tutorial!
Here you will understand the in and out of the game.''')
normal(f'''
You are going on an adventure and will experience a handfull of scenarios.
Some of which will be fruitful while others will be dangerous.
These scenarios will look something like this.
''')
sprint(f'''
A wild Kobald has appeared from the bushes near you!
''')
input(f"Choose your action! - {Fight}: ")
if Attack:
print("You swing your fist and break it, Why did you try to attack when you haven't been properly equipped?!")
elif Defend:
print("You attempt to defend... However you failed and are not bleeding all over. (What were you thinking?!)")
elif Run:
print("You turn around and attempt to run... The Kobald notices you and strikes you back while you are running away!")
else:
print("You stand around doing nothing... The Kobald did not notice you... It went on it's merry way.")
break
#===================================================================#
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = #
#===================================================================#
# Start Gap
if Game_Start == Story_1:
print(f'{"-"*36}\nPrologue\n{"-"*36}\n')
slow(f'''
Phobotane is a world of peace and prosperity. It is a
land in which all races live together in harmony.
The gnomes build their machines and live among
the humans. Elves run the academies in which
people come to learn. Ogres have no qualms
living in the same town as humans or gnomes.
Yet, all is not well.
You are {username_create}, a human alchemist in the
kingdom of Kuzos. You've lived in the town of
Gerzona your entire life. You've been training in
the local alchemist guild and have come to be a
respected member of the guild. The town is small,
but it's enough to keep you busy. The town is
surrounded by a wall to protect it from enemy
attack. ''')
break
#===================================================================#
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = #
#===================================================================#
if Game_Start == Story_2:
print(f'{"-"*36}\nPrologue\n{"-"*36}\n')
slow(f'''
For Zelani the Dragon, the ancient world of Veillantif is a
dangerous one. Her friends, Marque the Cavernstrike and Sinon
the Werewolf, fair no better. Creatures like them are hunted
ceaselessly, leaving orphans and ghost towns in the human's wake.
Like her father, she wishes to change the human's mind about
Varelsians. To fix what went wrong in the past. Though, it's tough
when humans only see you as a blood bag.
''')
normal(f'''
In eras past,testing speed testing speed testing speed...''')
break
else:
print("Incorrect Selection")
#===================================================================#
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = #
#===================================================================#