repl.it
@SagaciousPan/

Text_Adventure_Version_05

Python

A simple text adventure game. [DISCONTINUED] V.5 notes: - Reworked (once again) - Added some scenes (koamojis) - Changed the story

fork
loading
Files
  • main.py
main.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
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
#######################################################
############|       GAME      SETUP      |#############
#######################################################
fast_mode = False

#Imports
import replit
from termcolor import colored
import time
import sys

#classes
class text_edit:
  bold = '\033[1m'
  underline = '\033[4m'
  italic = '\033[3m'
  end= '\033[0m'

#Variables
inventory = []
  #To add an iteam to inventory:
  #inventory.append(['Excaliber','The great holy sword',20,5])

  #Item Layout:
  #'Name(str)', 'description(str)', 'damage\armor(int)', 'reach\null(int)'

  #Item Examples:
  #['Old Faithful', 'This is an old and rusty short sword.', 6, 2]
  #['Plain Jacket','A plain black jacket', 0,0]

#Functions
def clear():
  time.sleep(0.75)
  replit.clear()
  time.sleep(0.75)
#<end of clear function>

def enter_to_continue(before_space, clear_code):
  if(before_space == 1):
    print()
  i = 'enter'
  while (i != ''):
    print('Press enter to continue.')
    i = input('')
    if(i == ''):
      i='enter'
      break
  if(clear_code == 1):
    clear()
#<end of enter_to_continue function>

def type_text(text,speed=0.08,after_space=0,italic=0):
    if(italic == 1):
      print(text_edit.italic, end='')
    for c in text:
        print (c, end=''),
        sys.stdout.flush()
        if(fast_mode==False):
          time.sleep(speed)
    if(after_space == 1):
      print()
    if(italic == 1):
      print(text_edit.end, end='')
    return text
#<end of type_text function>

def user_choice_function(acceptable_responses): #['1','2','carpet','magical carpet','familiar']
  user_choice = ''
  while(user_choice not in acceptable_responses):
    user_choice = input('>').lower()
    if(user_choice == 'help'):
      print('Acceptable Responses: ', str(acceptable_responses))
    elif(user_choice not in acceptable_responses):
      print('Type help to see acceptable responses.')
  return(user_choice)
#<end of user_choice_function>

def find_item(item_name):
  for item in inventory:
    if(item[0] == item_name):
      return item
#<end of find_item function>

def print_inventory():
  for item in inventory:
    print(item[0])
#<end of print_inventory function>

def print_Item_stats(item_name, item_type):
  item_obj = find_item(item_name)
  if(item_type == 'weapon'):
    print ('%s:\n "%s"\n - Damage: %s\n - Range: %s' % (item_obj[0].upper(),item_obj[1],item_obj[2],item_obj[3]))
  elif(item_type == 'armor'):
    print ('%s:\n "%s"\n - Armor: %s' % (item_obj[0].upper(),item_obj[1],item_obj[2]))
  elif(item_type == 'mount'):
    print ('%s %s\n "%s"' % (item_obj[0].upper(),item_obj[2],item_obj[1]))
  elif(item_type == 'light'):
    print ('%s\n %s\n Fuel: %s' % (item_obj[0].upper(),item_obj[1],item_obj[2]))
  else:
    print ('%s:\n "%s"' % (item_obj[0].upper(),item_obj[1]))
#<end of print_Item_stats function>

def print_room(room):
  for thing in room:
    print('  '+thing[0]+': '+thing[1])
#<end of print_inventory function>
def get_object_in_room(obj, room):
  for thing in room:
    if(thing[0] == obj):
        return thing

#######################################################
############|       GAME      START      |#############
#######################################################

#################### Game Functions ###################
def game_title_screen():
  print(''' _____ _           ______           _       ___                  
|_   _| |          |  _  \         | |     / _ \ \n  | | | |__   ___  | | | |__ _ _ __| | __ / /_\ \ __ _  ___  ___\n  | | | '_ \ / _ \ | | | / _` | '__| |/ / |  _  |/ _` |/ _ \/ __|\n  | | | | | |  __/ | |/ / (_| | |  |   <  | | | | (_| |  __/\__ \ \n  \_/ |_| |_|\___| |___/ \__,_|_|  |_|\_\ \_| |_/\__, |\___||___/\n                                                  __/ |\n                                                 |___/''')
  time.sleep(1)
  print('''\n            ___      _   ___                   _             ___\n           | _ )_  _(_) / __|__ _ __ _ __ _ __(_)___ _  _ __| _ \__ _ _ _\n           | _ | || |_  \__ / _` / _` / _` / _| / _ | || (_-|  _/ _` | ' \ \n           |___/\_, (_) |___\__,_\__, \__,_\__|_\___/\_,_/__|_| \__,_|_||_|\n                |__/             |___/''')
  time.sleep(1)
#<end of game_title_screen function>

###################### Game Code ######################
clear()
game_title_screen()
enter_to_continue(1,1)

text = type_text('You have been fleeing from a group of Steel Eclipse members for what feels like the better part of an hour and noticed that you are approaching the mountain in the distance at an alarming rate. This is of course due to the fact that you have spent the last two years training, studying and practicing the art of wizardry. Right now you are zooming across the landscape on your')
type_text('...',after_space=1)
time.sleep(2)
print(colored('\n     ε=ε=ε=ε=ε=┌(; ・_・)┘','cyan'))
print(colored('  1. Magical carpet that you enchanted yourself.\n  2. Familiar that you called into existance.',"yellow"))
user_choice = user_choice_function(['1','2','carpet','magical carpet','familiar'])
clear()

item_chose = 'magical carpet'
if(user_choice == '1' or user_choice == 'carpet' or user_choice == 'magical carpet'):
  inventory.append(['Magical Carpet','A carpet that hovers over the ground that you controll.','~~~~~~~ᵒ',0])
  print(colored('NEW ITEM!',"green"))
  print_Item_stats('Magical Carpet', 'mount')
else:
  clear()
  type_text('What type of animal is your familiar?',after_space=1)
  print(colored('\n  1. Bear ʕ•ᴥ•ʔ\n  2. lion (^=◕ᴥ◕=^)\n  3. Wolf ▽・ᴥ・▽',"yellow"))
  user_choice = user_choice_function(['1','2','3','bear','lion','wolf'])
  item_chose = ''
  clear()
  print(colored('NEW ITEM!',"green"),)
  if(user_choice == '1' or user_choice == 'bear'):
    item_chose = 'bear familiar'
    inventory.append([item_chose,'Your familiar bear and mount.','ʕ•ᴥ•ʔ'])
  elif(user_choice == '2' or user_choice == 'lion'):
    item_chose = 'lion familiar'
    inventory.append([item_chose,'Your familiar lion and mount.','(^=◕ᴥ◕=^)'])
  else:
    item_chose = 'wolf familiar'
    inventory.append([item_chose,'Your familiar wolf and mount.','▽・ᴥ・▽'])
  print_Item_stats(item_chose, 'mount')

time.sleep(1)
print('\n'+text, end='')
time.sleep(2)
type_text(' '+item_chose+'.'+"\nOf course you didn't call your "+item_chose+', "'+item_chose+'". You decided to call it...\n')
mount_name = input('>')

clear()
text_temp = (str(text)+' '+str(item_chose)+".\nOf course you didn't call your "+str(item_chose)+', "'+str(item_chose)+'".')
text = text + text_temp
print(text_temp, end='')
text_temp = type_text(' You called it '+mount_name+'.',after_space=1)
text = text + text_temp
time.sleep(1)
print(colored('\n( ・_・)( ・_・)(╯°Д°)╯             ','yellow'),end='')
print(colored('(・ิᴗ・ิ )', 'cyan'))
time.sleep(1)
type_text('''You stopped at the base of the mountian and turned around to face the Steel Eclipse members.
 "Stop where you are!" The male member in the front of the group yelled.''',after_space=1)
type_text('He is probably the leader of this group.',after_space=1,italic=1)
type_text(' "Where is the pandemonium crystal!?"',after_space=1)
type_text('Wha...? pandemonium crystal?',italic=1)

time.sleep(2)
print(colored('\n\n  1. Tell him that you have no idea what he is talking about.\n  2. Attempt to push pass the group and hope that they stop chasing you.',"yellow"))
user_choice = user_choice_function(['1','2','convince','run','flee'])
clear()
if(user_choice == '1' or user_choice == 'convince'):
  type_text('''"I didn't take any pandemonium crystal, I have no idea what you are talking about."
 "Nonsense! We saw you take it yesterday, but you vanished before we could capture you."
"But I was at home all day yes... ter... day."
Your vision slowly starts to dim and you notice that you are no longer standing up, but are laying facedown.''',after_space=1)
else:
  type_text('''Before you get a chance to move your vision starts to dim and you notice that you are no longer standing up, but are laying facedown.''',after_space=1)
type_text(' "Pick him up," you faintly hear someone say before you pass out.',after_space=1)
time.sleep(1)
enter_to_continue(1,1)

print("""
   ___ _              _             _        
  / __| |_  __ _ _ __| |_ ___ _ _  / |       
 | (__| ' \/ _` | '_ |  _/ -_| '_| | |       
  \___|_||_\__,_| .__/\__\___|_|   |_|       
    _____ _     |_|  ___                     
   |_   _| |_  ___  | __|_____ __ _ _ __ ___ 
     | | | ' \/ -_) | _|(_-/ _/ _` | '_ / -_)
     |_| |_||_\___| |___/__\__\__,_| .__\___|
                                   |_|       """)
time.sleep(1)
enter_to_continue(1,1)

def chapter_01(times_called=0):
  #first time chapter 01 checkpoint 01 was loaded
  if(times_called == 0):
    #set variables
    cell_inventory = [['mirror','A mirror too dirty to see you reflection.'],['bed','A stone block... as you can imagine it is very uncomfortable.'],['pillow','Its filled with feathers.'],['door','A barred metal door.'],['lamp','An old kerosene oil lamp.', 100]]
    checkpoint_01_called = 0
    times_called = 1

  def chapter_01_checkpoint_01():
    #clear
    clear()
    nonlocal checkpoint_01_called
    checkpoint_01_called += 1
    if(checkpoint_01_called == 1):
      #print some text
      print(colored('Checkpoint Reached', 'green'))
      print(colored('ヾ(  ̄O ̄)ツ', 'cyan'))
      type_text('yaaaaawn',0.1,1,1)
      time.sleep(0.5)
      type_text('You wake up to find yourself in a dark dungeon cell.',0.1,1)
      time.sleep(0.5)
      type_text('How did I get here?',0.1,1,1)
      time.sleep(0.5)
      type_text('ohhhh...',0.1,1,1)
      time.sleep(0.5)
      type_text('yeah...',0.1,1,1)
      time.sleep(0.5)
      type_text('Those Steel Eclipse members must have locked me up.',0.1,1,1)
      time.sleep(1)

    #print some text
    type_text('You examine your cell.',after_space=1)
    print()
    print_room(cell_inventory)
    print(colored('\nWhat to do?\n  1. inspect\n  2. wait\n  3. yell',"yellow"))

    #user interaction
    user_choice = user_choice_function(['1','2','3','inspect','wait','yell'])

    #timeout and clear
    time.sleep(0.25)
    clear()

    #handle user choice
    if(user_choice == '1' or user_choice == 'inspect'):
      type_text('What do you want to inspect?',after_space=1)
      print()
      print_room(cell_inventory)

      #user interaction
      user_choice = user_choice_function(['mirror','bed','pillow','door','lamp','back','cancel'])

      #handle user choice
      if(user_choice == 'back' or user_choice == 'cancel'):
        chapter_01_checkpoint_01()
      user_choice_obj = get_object_in_room(user_choice,cell_inventory)
      item_name = user_choice_obj[0]
      print('You inspected '+item_name+'.')

      #Mirror
      if(item_name == 'mirror'):
        type_text('There is not much I can do except break it.',0.08,1,1)
        type_text('Do you break the mirror?',after_space=1)
        user_choice = user_choice_function(['yes','no'])
        if(user_choice=='yes' and cell_inventory[0][1]=='A mirror too dirty to see you reflection.'):
          inventory.append(['Glass Shard','You broke this off your cell mirror.',1,1])
          cell_inventory[0][1] = 'A broken mirror.'
          clear()
          time.sleep(0.25)
          print(colored('NEW ITEM!',"green"))
          print_Item_stats('Glass Shard', 'weapon')
        else:
          type_text('It is already broken.')

      #Bed
      elif(item_name == 'bed'):
        type_text('The bed is just a large rectangular block of stone.',after_space=1)
        time.sleep(0.5)
        type_text('No wonder my back hurts.',0.08,1,1)

      #Pillow
      elif(item_name == 'pillow'):
        note = '''  "To you who ever is in this cell,
        A couple of weeks ago the leader of the Steel Eclipse was assassinated and the
        second in command, Anibal, became the new leader. Many people were against
        this because he is notorious for how cruel and aggresive he is and some started
        to protest on the matter, but Anibal quickly put a stop to that.
        He sentence anyone whom was against him to death.
        The reason why I put this here is because I belive that you did not steal the
        crystal. Since Anibal's leadership many people have been brought in to this dungeon
        accused of diffrent crimes that they did not commit.
        Luckliy for you there is a secret group of people (that I'm apart of) that are
        working to stop him. There shouldn't be any guards until you reach the enterance
        of the dungeon, so it should be safe to open your cell without anyone hearing the door squeak open.
    Anyway, goodluck escaping."'''
        if(find_item('Cell Key')is None):
          type_text('You feel something hard in the pillow.',after_space=1)
          time.sleep(0.5)
          type_text("What's this?",0.08,1,1)
          time.sleep(0.5)
          type_text('You rip open the pillow to find a key and a note.',after_space=1)
          time.sleep(0.5)
          type_text(note,after_space=1)
          enter_to_continue(1,1)
          inventory.append(['Cell Key','An old rusty skeleton key.'])
          print(colored('NEW ITEM!',"green"))
          print_Item_stats('Cell Key', 'item')
        else:
          type_text('You feel the note in the pillow.',after_space=1)
          type_text('Would you like to read it?',after_space=1)
          user_choice = user_choice_function(['yes','no'])
          if(user_choice =='yes'):
            type_text(note,after_space=1)
            enter_to_continue(1,0)

      #Cell Door
      elif(item_name == 'door'):
        if(find_item('Cell Key')is None):
          type_text("It's barred metal door that takes a skeleton key.",after_space=1)
          time.sleep(0.5)
          type_text('How am I suposed to get out here?',0.08,1,1)
        else:
          type_text("You stick the key into the lock and...",after_space=1)
          time.sleep(1)
          type_text("*click*",after_space=1)
          time.sleep(0.5)
          type_text('IT WORKED!',0.08,1,1)

      #Lamp
      elif(item_name == 'lamp'):
        type_text('Do you take the lamp?',after_space=1)
        user_choice = user_choice_function(['yes','no'])
        if(user_choice=='yes' and cell_inventory[4][1]=='An old kerosene oil lamp.'):
          inventory.append(['Lamp','An old kerosene oil lamp.',100])
          cell_inventory[4][1] = 'An old kerosene oil lamp (Taken).'
          clear()
          time.sleep(0.25)
          print(colored('NEW ITEM!',"green"))
          print_Item_stats('Lamp', 'light')
        else:
          type_text('You already took the lamp.')

      time.sleep(2)
      chapter_01_checkpoint_01()
    elif(user_choice == '2' or user_choice == 'wait'):
      type_text('You wait.',after_space=1)
      time.sleep(1)
      type_text('''Nothing happens.   
Do you want to wait again?''',after_space=1)
      user_choice = user_choice_function(['yes','no'])
      if(user_choice =='yes'):
        print()
        type_text('You wait... ')
        time.sleep(0.5)
        type_text('longer this time.',after_space=1)
        time.sleep(1)
        type_text('''Nothing happens.   
Do you want to wait once more?''',after_space=1)
        user_choice = user_choice_function(['yes','no'])
        if(user_choice =='yes'):
          print()
          type_text('You wait...',after_space=1)
          time.sleep(1)
          type_text('And wait...',after_space=1)
          time.sleep(1)
          type_text("Just sitting here won't help me.",0.1,italic=1)
      time.sleep(3)
      chapter_01_checkpoint_01()

    elif(user_choice == '3' or user_choice == 'yell'):
      type_text('"ANYONE HERE!?"',after_space=1)
      time.sleep(1)
      type_text('There is no reply.',after_space=1)
      time.sleep(1)
      type_text('I guess no one is guarding me.',0.1,italic=1)
      time.sleep(3)
      chapter_01_checkpoint_01()

    else:
      print('ERROR: 101')
      exit()

  #chapter 01 start



  #call checkpoint 01
  chapter_01_checkpoint_01()



chapter_01()
exit()