repl.it
@_Sniper_Turtle_/

RPGish game

Python

No description

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
from time import sleep
from replit import clear
from random import randint
from termcolor import colored as c
clear()
print(c("Current State: Almost In Beta",'yellow'))
print(c('V0.02 CLOSED ALPHA','blue'))
sleep(1)
clear()
NotLettersList=["1","2","3","4","5","6","7","8","9","0","!","@","#","$","%","^","&","*","(",")","-","_","+","=","{","}","[","]","|","\"",":",";","'",'"',"<",">",",",".","?","/"]
space="\n"
P_name=""
def oldMan(txt,t='t',v='t'):
  def anim():
    clear()
    print('______')
    print('|*  *|')
    print('| __ |'+'< '+c(txt,'blue'))
    print('||__||')
    print('|____|')
    sleep(3)
    clear()
    print('______')
    print('|*  *|')
    print('|vvvv|'+'< '+c(txt,'blue'))
    print('|^^^^|')
    print('|____|')
    sleep(3)
    clear()
  anim()
  anim()
  options(t,v)
def options(p='f',v='f'):
  #print(p,v)
  clear()
  pT=''
  vT=''
  def inval():
    clear()
    print(c('your answer was INVALID','red'))
    sleep(1)
    options(p,v)
  print('What do you want to do?')
  print('f) fight')
  if p=='t':
    print('t) talk')
    pT='t to talk'
  if v=='t':
    print('v) Go to the village')
    vT='v to go to the village'
  print('or check your i) inventory?')
  print('press f for fight, '+pT+' '+vT+' '+'or press i for inventory')
  print(c("NOTE: TO SAY ANYTHING, PRESS ENTER AFTER YOU SAY IT",'red'))
  pick=input('')
  pick=pick.lower()
  if pick == 'f' or pick == 'i':
    return pick
  elif pick=='t':
    if p=='t':
      return pick
    else:
      inval()
  elif pick=='v':
    if v=='t':
      return pick
    else:
      inval()
  else:
    inval()
def victory(hp,x=1):
  hp=hp+x
  return hp
def clen(x):
  clen=len(x)-1
  return clen
def sym_num_check(x,a=NotLettersList):
  y=len(a)-1
  no=""
  while y > -1:
    z=x.find(a[y])
    y=y-1
    if z != -1:
      clear()
      print(space,space,space,c("That had INVALID characters.",'red'))
      sleep(2)
      return False
      break
  return True

def inv():
  clear()
  print('.')
  sleep(1)
  clear()
  print('..')
  sleep(1)
  clear()
  print('...')
  sleep(1)
  clear()
  print('You have no weapon. It is impossible to get one.')
  print('You have no armor other than your skin.')
  print('press '+c('ENTER','green')+' to finish')
  fin=input('')
  clear()

def ask(x=" Whats your name?",l='blue',a=NotLettersList):
  print(space,space)
  #print(c(l,'green'))
  if l != 'none':
    print(c(x,l))
  if l == 'none':
    print(x)
  q=input("")
  P_name_wrong=sym_num_check(q,a)
  if P_name_wrong == False:
    clear()
    sleep(1)
    q=ask(x,l,a)
  return q

def askAge():
  age=ask("How old are you?",'none',['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'])
  if age == "2":
    age=2
  elif age == "3":
    age=3
  elif age == "4":
    age=4
  elif age == "5":
    age=5
  elif age == "6":
    age=6
  elif age == "7":
    age=7
  elif age == "8":
    age=8
  elif age == "9":
    age=9
  elif age == "10":
    age=10
  else:
    clear()
    print("I don't believe you!")
    print(c("you MUST pick a number between 2 and 10 as you age!",'red'))
    sleep(2)
    clear()
    age=ask("How old are you?",'none',['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'])
def fight(enem,atks_dmg,atks,turnsN,hp="20"):
  clear()
  print('its a '+enem)
  turns=0
  atk_reduce=0
  def enem_atk(atk_red,hp):
    atkSel=randint(0,clen(atks))
    atk=atks[atkSel]
    atkD=atks_dmg[atkSel]-atk_red
    print(enem+' '+atk[randint(0,clen(atks))])
    hp=hp-int(atkD)
    clear()
    print('its a '+enem)
    print(str(atkD)+' damage done! Against you.')
    return hp
  def player_atk():
    clear()
    print('its a '+enem)
    print('what do you wish to do?')
    print('d) defend')
    print('a) attack')
    whatDo=input('')
    if whatDo=='a':
      cap_atk_reduce=int(atks_dmg[clen(atks_dmg)])
      cap_atk_reduce=cap_atk_reduce/2
      atk_reduce=randint(0,int(cap_atk_reduce))
      if atk_reduce > cap_atk_reduce/2 and atk_reduce < cap_atk_reduce/1.5:
        atk_reduce=randint(0,cap_atk_reduce)
      print(c('You are attacking!','red'))  
      return atk_reduce
    if whatDo=='d':
      cap_atk_reduce=int(atks_dmg[clen(atks_dmg)])
      cap_atk_reduce=cap_atk_reduce/2
      atk_reduce=randint(0,cap_atk_reduce)
      if atk_reduce > cap_atk_reduce/4 and atk_reduce < cap_atk_reduce/3:
        atk_reduce=randint(0,cap_atk_reduce)
      if atk_reduce > cap_atk_reduce/3 and atk_reduce < cap_atk_reduce: 
        atk_reduce=randint(0,cap_atk_reduce)
      print(c('You are defending!','red'))  
      return atk_reduce
    else:
      print(c('THATS INVALID','red'))
      player_atk()
  while turns<turnsN:
    atk_red=player_atk()
    sleep(1)
    enem_atk(atk_red,hp)
    sleep(1)
    turns=turns+1
    sleep(1)
  clear()
  print('you won!')
  hp=victory(hp,atks_dmg[0])
  if 'dummy' in enem:
    oldMan("Good. That WAS a training dummy. Now, it is dust. You learn quickly, my friend.")
    oldMan('You have had 1 health restored. It can be restored above your maximum.')talk
  return hp
  area(0,'tutorial','yellow')
def area(lvl,place,color):
  print(str(lvl)+':',c(place,color))
  def areacall(lvl):
    if lvl==0:
      atk_enem_dmg_list=[1,1,1,1]
      atk_enem_desc_list=['does nothing','is there','wonders about the meaning of life','sits there']
      enem_list=['normal dummy','abnormal dummy','dummy dummy']
      act=options('t','t')
      if act=='f':
        enem=enem_list[randint(0,clen(enem_list))]
        hp=fight(enem,atk_enem_dmg_list,atk_enem_desc_list,1,20)
        area(1,'forest','green')
      if act=='i':
        inv()
      if act=='t':
        oldMan('Hello. I am an old man. I am here to teach you the basics of fighting.')
        oldMan('Once I finish talking fight the dummy with \'f\'.')
      if act=='v':
        print("This village sheltered you when you were young. Now it has abandoned you. Best to let things be. For now.")
    if lvl==1:
      here='t'
      atk_enem_dmg_list=[1,2,2,0]
      atk_enem_desc_list=['JUMPS AT YOU!','IS SCARY','IS CLAWING YOU','SITS THERE NOT DOING ANYTHING']
      enem_list=['CAT','FAT CAT']
      act=options('t','f')
      if act=='i':
        inv()
      if act=='t':
        if here=='t':
          oldMan('Well. Time for me to depart','t','f')
          oldMan('Goodbye. Don\'t get eaten','t','f')
          here='f'
          options('t','f')
        else:
          print('He left.')
          sleep(2)
          clear()
          options('t','f')
      if act=='f':
        clear()
        print('This time, you must survive for 2 turns')
        sleep(1)
        clear()
        enem=enem_list[randint(0,clen(enem_list))]
        hp=fight(enem,atk_enem_dmg_list,atk_enem_desc_list,2,hp)
        
    theInput=input('')
    clear()
    areacall(lvl)
  areacall(lvl)  
P_Name=ask()
#P_Name="RPG player"
sleep(1)
clear()
print(space,space,space)
print("Hi,",P_Name)
sleep(1)
clear()
print(space)
age=askAge()
#age=2
clear()
print(c('WOW!','yellow'),c('you are so old!','green'),c('I am only','yellow'),c("1",'red')+c("!",'yellow')+c("!",'red')+c("!",'yellow')+c("!",'red'))
sleep(3)
clear()
area(0,'tutorial','yellow')
#tutorial finished. Forest... needs to be debugged and tested
?