forked from shivaylamba/Hacktoberfest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
castle.py
305 lines (258 loc) · 10.4 KB
/
castle.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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
from os import system
from random import randint
gametitle = "Castle Dungeons- An interactive story game"
system("mode 110,30")
system("Title"+gametitle)
def cls():
system("cls")
character_name = None
character_class = None
character_race = None
character_strength = None
character_magic = None
character_dexterity = None
character_life = None
cls()
print("Castle Dungeons- An interactive story fiction game in python")
def intro():
print("")
print("In this story, you are the hero")
print("")
print("Your main goal is to protect and save your fellow friends from the evil socerer's prison")
print("")
print("Your princess is also held captive in his castle.")
print("")
print("Defeat the socerer and win your princess back to be the most powerful being in this mystic universe")
print("")
print("Your choices, skills and your luck will determine the outcome of the game")
print("")
print("So buckle up and get ready to fight for your life")
print("")
input("Press Enter to Start...")
intro()
def create_character():
cls()
global character_name
character_name = input("""
Lets begin the game by making your character,
What's the name of your hero?
>""")
global character_race
while character_race is None:
race_choice = input("""
Choose a race for your character:
1. Human
2. Elf
>""")
if race_choice == "1":
character_race = "Human"
elif race_choice == "2":
character_race = "Elf"
else:
print("Not a valid choice, please try again.")
cls()
global character_class
while character_class is None:
class_choice = input("""
Excellent choice.
You are """+character_race + """
Now Time for you to choose your class:
1. Warrior
2. Magician
>""")
if class_choice == "1":
character_class = "Warrior"
elif class_choice == "2":
character_class = "Magician"
else:
print("Invalid Input, Please enter a Valid input")
create_character()
def create_character_skill_sheet():
global character_name, character_race, character_class, character_dexterity, character_magic, character_life, character_strength
print("""
Now let's determine your chatacter's skills, which you will use throughout the game.
In this game, your character has four skills:
-Strength, which you will use in a combat
-Magic, which will help you cast spells
-Dexterity, which you will use in a ability test
-Life, which determines your life energy, points will be lost when hurt
and when the life becomes 0, the character dies.
Depending upon your Race and Class,
you will have a certain point base already calculated automically.
You will shortly be able to increase your skill points by rolling a 6-faced Dice.
Here is your base character skill sheet:""")
character_strength = 5
character_magic = 0
character_dexterity = 3
character_life = 10
if character_race == "Human":
character_strength = character_strength+3
character_magic = character_magic+1
character_dexterity = character_dexterity+5
character_life = character_life+5
elif character_race == "Dwarf":
character_strength = character_strength+1
character_magic = character_magic+5
character_dexterity = character_dexterity+3
character_life = character_life+7
if character_class == "Warrior":
character_strength = character_strength+10
character_magic = character_magic+5
character_life = character_life+10
character_dexterity = character_dexterity+5
elif character_class == "Magician":
character_strength = character_strength+5
character_magic = character_magic+10
character_life = character_life+5
character_dexterity = character_dexterity+10
print("Name: "+character_name)
print("Race: "+character_race)
print("Class: "+character_class)
print("Strength: "+str(character_strength))
print("Magic: "+str(character_magic))
print("Dexterity: "+str(character_dexterity))
print("Life "+str(character_life))
input("Press enter")
create_character_skill_sheet()
def modify_skills():
cls()
global character_dexterity, character_strength, character_life
print("""To modify your skills, roll a 6-faced dice to determine the modified skill.
This is purely based on your luck
Let's see how lucky you are ;)""")
input("Press enter to roll for strength")
roll = randint(1, 6)
print("you rolled: "+str(roll))
character_strength = character_strength+roll
input("Press enter to roll for dexterity")
roll = randint(1, 6)
print("you rolled: "+str(roll))
character_dexterity = character_dexterity+roll
input("Press enter to roll for Life")
roll = randint(1, 6)
print("you rolled: "+str(roll))
character_life = character_life+roll
input("Press enter to continue...")
cls()
print("Your updated skill sheet is:")
print("Name: "+character_name)
print("Race: "+character_race)
print("Class: "+character_class)
print("Strength: "+str(character_strength))
print("Magic: "+str(character_magic))
print("Dexterity: "+str(character_dexterity))
print("Life "+str(character_life))
print()
input("Press Enter to enter your adventure...")
modify_skills()
def scene_1():
cls()
choice = None
while choice is None:
user_input = input("""
You have entered the castle.
It is dark but thankfully your torch is lit and you can see upto 20ft from you.
The stone walls are damp and the smell of rats and orc is strong.
you walk down a narrow corridor, untill you reach a thick stone wall.
The corridor continues on the left and on right.
Its your choice now:
1. Turn Left
2. Turn Right
""")
if user_input == "1" or user_input == "turn left":
choice = "1"
scene_2()
elif user_input == "2" or user_input == "turn right":
choice = "2"
scene_3()
else:
print("""
Not a valid choice, enter a number or enter
"turn left" or "turn right" to continue... """)
def scene_2():
cls()
choice = None
while choice is None:
user_input = input("""
From the darkness behind you, you hear a strange noise...
What will you do?
1. Continue walking
2. Stop to listen
>""")
if user_input == "1" or user_input == "continue":
choice = "1"
combat()
elif user_input == "2" or user_input == "stop":
choice = "2"
skill_check()
else:
print("""Not a valid choice, please enter a number or enter
"continue" or "stop" """)
def scene_3():
cls()
choice = None
while choice is None:
user_input = input("""
From the darkness ahead of you, you hear a strange noise...
What will you do?
1. Continue walking
2. Stop to listen
>""")
if user_input == "1" or user_input == "continue":
choice = "1"
combat()
elif user_input == "2" or user_input == "stop":
choice = "2"
skill_check()
else:
print("""
Not a valid choice, please enter a number or enter
"continue" or "stop""")
def skill_check():
cls()
print("""A giant rock falls from the ceiling.
Roll a die to see if You can dodge it... or you'll die from it
The number you get from rolling the die added to your dexterity is greater than 15 than you'll survive.
OR
YOU WILL DIE!""")
input("Click enter to roll a die...")
roll = randint(1, 6)
print("you rolled "+str(roll))
if roll+character_dexterity >= 15:
print("""You've survived the stone fall
BUT
the strange noise from the darkness is still here and danger is not over yet...
Prepare for next survival task...""")
print()
input("Press Enter to continue...")
combat()
else:
print(
"Sorry but you've failed to survive the stone fall and you are buried under it.")
print("GAME OVER!!")
input("Press enter to exit the game")
exit()
def combat():
cls()
global character_life
print("A horrible orc attacks you out of no where...")
input("Press Enter to combat...")
orc = [15, 10]
while orc[1] > 0 or character_life > 0:
char_roll = randint(1, 6)
print("You rolled: " + str(char_roll))
orc_roll = randint(1, 6)
print("The Orc rolled: " + str(orc_roll))
if char_roll+character_strength >= orc_roll+orc[0]:
print("You've hit the Orc!!")
orc[1] = orc[1] - randint(1, 6)
else:
print("The Orc hits you!!")
character_life = character_life - randint(1, 6)
if character_life > 0:
print("You've defeated the Orc and won the game!!")
input("Press enter to exit the game")
else:
print("The Orc defeated you!!")
input("Press Enter to exit")
scene_1()