repl.it
@me002/

Text Fighting

Python

Fight game using text, with level up system and completly randomised everything!

fork
loading
Files
  • main.py
  • Packager files
  • poetry.lock
  • pyproject.toml
  • requirements.txt
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
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
import colors
import random
import os
import time

#------------starter stats------------#

level = 0
xp = 0
fightswon = 0
fightslost = 0

#------------starter levels------------#

punchdamage = 5
kickdamage = 9
smackdamage = 2

punchdamagecrit = 10
kickdamagecrit = 19
smackdamagecrit = 5

stamina = 10

#------------other------------#

beatenboris = False


#------------important lists------------#

win = ["a fight", "a win", "bloodshed", "violence", "a savage beating"]
attacksuccess = ["hits them!", "critically injures them!"]
attackfail = ["misses them!", "annoys them!"]
opattack = ["punch", "smack", "kick"]
criticals = ["punch", "kick"]

#------------choose name------------#

while True:
  name = str(input(colors.green("What is your name? "))).title()
  areyousure = input(colors.green("Are you sure you want to use the name '"+name+"'? y/n ")).lower()
  if areyousure == "y":
    break
  if areyousure == "n":
    os.system("clear")
  else:
    print(colors.red("That is not a valid option!"))
    time.sleep(2)
    os.system("clear")

#------------game------------#

while True:

    if beatenboris == True:
      clubname = (colors.blue(name+"'s Fight Club"))
    else:
      clubname = (colors.blue("Big Boris' Fight Club"))


    os.system("clear")
    print(clubname)
    print(colors.blue("---------------------"))
    print("1 - Fights")
    print("2 - Statistics")
    print(colors.blue("---------------------"))
    menuoptions = input(colors.blue(">> "))

    #------------statisitcs------------#
    if menuoptions == "2":
      while True:
        os.system("clear")
        print(colors.blue(name+"'s Statistics:"))
        print(colors.blue("---------------------"))
        print("Your level is -",level)
        statstotalxp = level * 100
        statstotalxp = statstotalxp + xp
        print("Your total xp is -", statstotalxp)
        print("You have won",fightswon,"fights.")
        print("You have lost",fightslost,"fights.")
        totalfights = fightslost + fightswon
        print("You have fought in",totalfights,"total fights.")
        print(colors.blue("---------------------"))
        print(colors.blue("Type 'B' to go back"))
        goback = input(colors.blue(">> ")).lower()
        if goback == "b":
          break
        else:
          print(colors.red("That is not a valid option!"))
          time.sleep(1)

    elif menuoptions == "1":
      while True:
        os.system("clear")

        firstname = ["Dave","Barry","Clive","Bob","Jimmy","Andrew","Frank"]
        lastname = ["Smith","Brown","Blevins","Frost","Roberts"]

        fname = random.choice(firstname)
        lname = random.choice(lastname)
        dname = (fname + " " + lname)

        print(colors.blue("Available Fights:"))
        print(colors.blue("---------------------"))
        print("1 - Easy")
        print("2 - Medium")
        print("3 - Hard")
        print(colors.blue("---------------------"))
        if beatenboris == False:
          print("4 - Boris Johnson - Impossible")
        else:
          print("YOU HAVE ALREADY BEATEN BORIS!")
        print(colors.blue("---------------------"))
        print(colors.blue("Choose an option. (Type 'B' to go back)"))
        options = input(colors.blue(">>")).lower()

        #difficulty options

        if options == "b":
          break

        if options == "1":
          fightingboris  = False
          stamina = 10
          xpgained = 0
          HP = 100
          opponentHP = 100
          firstopponent = dname
          difficulty = [1,2,3,4]
          oppunchdamage = 4
          opkickdamage = 7
          opsmackdamage = 2

        if options == "2":
          fightingboris  = False
          stamina = 10
          xpgained = 0
          HP = 100
          opponentHP = 100
          firstopponent = dname
          difficulty = [1,2,3]
          oppunchdamage = 6
          opkickdamage = 10
          opsmackdamage = 3

        if options == "3":
          fightingboris  = False
          stamina = 10
          xpgained = 0
          HP = 100
          opponentHP = 150
          firstopponent = dname
          difficulty = [2,3]
          oppunchdamage = 8
          opkickdamage = 15
          opsmackdamage = 4

        if options == "4":
          fightingboris  = True
          stamina = 10
          xpgained = 0
          HP = 100
          opponentHP = 200
          firstopponent = "Boris Johnson"
          difficulty = [2]
          oppunchdamage = 12
          opkickdamage = 22
          opsmackdamage = 7


        os.system("clear")
        time.sleep(1)
        print(firstopponent,"enters the ring.")
        time.sleep(1)
        print("")
        time.sleep(1)
        want = random.choice(win)
        print(firstopponent, "eye's you up looking for", want+".")
        time.sleep(1)
        print("")
        time.sleep(1)
        print("You step into the ring.")
        time.sleep(1)
        print("")
        time.sleep(1)
        print("The fight begins!")
        time.sleep(3)

#------------code for fighting------------#

        while True:
          if opponentHP <= 0:
            youwon = 1
            os.system("clear")
            print("You knocked out",firstopponent,"!")
            time.sleep(4)
            break
          
          if HP <= 0:
            youwon = 2
            os.system("clear")
            print(firstopponent,"knocked you out!")
            time.sleep(4)
            break

          randomnumber = [1,2]

          staminatext = colors.green(stamina)

          os.system("clear")
          print("Your level -",level)
          print("HP -",HP)
          print("Stamina -",staminatext)
          print("Opponent HP -",opponentHP)
          print(colors.blue("-------------------"))
          print("1 - Punch")
          print("2 - Kick")
          print("3 - Smack")
          print("4 - Dodge")
          print(colors.blue("-------------------"))
          move = int(input("Choose your attack! "))
          print("")

        #punch---

          if move == 7:
            opponentHP = 0
            xpgained = xp + 500

          if move == 1:
            
            enoughstamina = stamina - 4

            if enoughstamina == 0 or enoughstamina < 0:
              print(colors.red("Not enough stamina!"))
              time.sleep(3)

            else:

              result = random.choice(randomnumber)
              stamina = stamina - 3

              if result ==  1:
                success = random.choice(attacksuccess)
                print("Your punch",success)
                if success == "hits them!":
                  opponentHP = opponentHP - punchdamage
                  print(firstopponent+"'s HP is now -",opponentHP)
                  xpgained = xpgained + 5
                  print("You gained 5 xp!")
                  time.sleep(3)
                elif success == "critically injures them!":
                  opponentHP = opponentHP - punchdamagecrit
                  print(firstopponent+"'s HP is now -",opponentHP)
                  xpgained = xpgained + 7
                  print("You gained 7 xp!")
                  time.sleep(3)

              elif result == 2:

                fail = random.choice(attackfail)

                print("Your punch",fail)

                if fail == "misses them!":
                  print("You missed",firstopponent+".")
                  attack = random.choice(opattack)
                  if attack == "kick":
                    print(firstopponent,"kicks you!")
                    HP = HP - opkickdamage
                    print("Your HP is now",HP,"!")
                    time.sleep(3)
                  elif attack == "smack":
                    print(firstopponent,"smacks you!")
                    HP = HP - opsmackdamage
                    print("Your HP is now",HP,"!")
                    time.sleep(3)
                  elif attack == "punch":
                    print(firstopponent,"punches you!")
                    HP = HP - oppunchdamage
                    print("Your HP is now",HP,"!")        
                    time.sleep(3)

                elif fail == "annoys them!":
                  print("You annoyed",firstopponent+"!")
                  print("They are now angry!")
                  annoyed1 = random.choice(opattack)
                  annoyed2 = random.choice(opattack)
                  print(firstopponent,"lands a",annoyed1,"and a",annoyed2)
                  HP = HP - 16
                  print("Your HP is now",HP,"!")  
                  time.sleep(3)
              
        #kick---
          if move == 2:

            enoughstamina = stamina - 5

            if enoughstamina == 0 or enoughstamina < 0:
              print(colors.red("Not enough stamina!"))
              time.sleep(3)

            else:

              result = random.choice(randomnumber)
              stamina = stamina - 5

              if result ==  1:
                success = random.choice(attacksuccess)
                print("Your kick",success)
                if success == "hits them!":
                  opponentHP = opponentHP - kickdamage
                  print(firstopponent+"'s HP is now -",opponentHP)
                  xpgained = xpgained + 4
                  print("You gained 4 xp!")
                  time.sleep(3)
                elif success == "critically injures them!":
                  opponentHP = opponentHP - kickdamagecrit
                  print(firstopponent+"'s HP is now -",opponentHP)
                  xpgained = xpgained + 5
                  print("You gained 5 xp!")
                  time.sleep(3)

              elif result == 2:

                fail = random.choice(attackfail)

                print("Your kick",fail)

                if fail == "misses them!":
                  print("You missed",firstopponent+".")
                  attack = random.choice(opattack)
                  if attack == "kick":
                    print(firstopponent,"kicks you!")
                    HP = HP - opkickdamage
                    print("Your HP is now",HP,"!")
                    time.sleep(3)
                  elif attack == "smack":
                    print(firstopponent,"smacks you!")
                    HP = HP - opsmackdamage
                    print("Your HP is now",HP,"!")
                    time.sleep(3)
                  elif attack == "punch":
                    print(firstopponent,"punches you!")
                    HP = HP - oppunchdamage
                    print("Your HP is now",HP,"!")        
                    time.sleep(3)

                elif fail == "annoys them!":
                  print("You annoyed",firstopponent+"!")
                  print("They are now angry!")
                  annoyed1 = random.choice(opattack)
                  annoyed2 = random.choice(opattack)
                  print(firstopponent,"lands a",annoyed1,"and a",annoyed2)
                  HP = HP - 16
                  print("Your HP is now",HP,"!")  
                  time.sleep(3)

        #smack---
          if move == 3:

            enoughstamina = stamina - 2

            if enoughstamina == 0 or enoughstamina < 0:
              print(colors.red("Not enough stamina!"))
              time.sleep(3)

            else:

              result = random.choice(randomnumber)
              stamina = stamina - 2

              if result ==  1:
                success = random.choice(attacksuccess)
                print("Your smack",success)
                if success == "hits them!":
                  opponentHP = opponentHP - smackdamage
                  print(firstopponent+"'s HP is now -",opponentHP)
                  xpgained = xpgained + 6
                  print("You gained 6 xp!")
                  time.sleep(3)
                elif success == "critically injures them!":
                  opponentHP = opponentHP - smackdamagecrit
                  print(firstopponent+"'s HP is now -",opponentHP)
                  xpgained = xpgained + 10
                  print("You gained 10 xp!")
                  time.sleep(3)

              elif result == 2:

                fail = random.choice(attackfail)

                print("Your smack",fail)

                if fail == "misses them!":
                  print("You missed",firstopponent+".")
                  attack = random.choice(opattack)
                  if attack == "kick":
                    print(firstopponent,"kicks you!")
                    HP = HP - opkickdamage
                    print("Your HP is now",HP,"!")
                    time.sleep(3)
                  elif attack == "smack":
                    print(firstopponent,"smacks you!")
                    HP = HP - opsmackdamage
                    print("Your HP is now",HP,"!")
                    time.sleep(3)
                  elif attack == "punch":
                    print(firstopponent,"punches you!")
                    HP = HP - oppunchdamage
                    print("Your HP is now",HP,"!")        
                    time.sleep(3)

                elif fail == "annoys them!":
                  print("You annoyed",firstopponent+"!")
                  print("They are now angry!")
                  annoyed1 = random.choice(opattack)
                  annoyed2 = random.choice(opattack)
                  print(firstopponent,"lands a",annoyed1,"and a",annoyed2)
                  HP = HP - 16
                  print("Your HP is now",HP,"!")  
                  time.sleep(3)

        #dodge--
          if move == 4:
            movedodged = random.choice(opattack)
            print("You dodged",firstopponent+"'s",movedodged+"!")
            print("You gained 5 xp!")
            xpgained = xpgained + 5
            if stamina < 10:
              stamina = stamina + 5
              print("You gained 5 stamina for dodging the attack!")
            time.sleep(3)

          #----- Opponent Turn -----#
          os.system("clear")
          print(firstopponent+"'s turn!")
          print(colors.blue("---------------------"))
          result = random.choice(difficulty)
          
          #opponent successful attack
          if result == 1:
            attack = random.choice(opattack)
            print(firstopponent,"manages to",attack,"you!")

            if attack == "punch":
              HP = HP - oppunchdamage
              print("Your HP is now",HP)
              time.sleep(4)

            if attack == "kick":
              HP = HP - opkickdamage
              print("Your HP is now",HP)
              time.sleep(4)

            if attack == "smack":
              HP = HP - opsmackdamage
              print("Your HP is now",HP)
              time.sleep(4)

          #criticals
          if result == 2:
            criticalrandom = [1,2]
            randomc = random.choice(criticalrandom)
            if randomc == 1:
              attack = random.choice(criticals)
              print(firstopponent,"managed to land a critical",attack,"on you!")
              if attack == "punch":
                HP = HP - 10
                print("Your HP is now ",HP)
                time.sleep(4)
              if attack == "kick":
                HP = HP - 15
                print("Your HP is now ",HP)
                time.sleep(4)

            if randomc == 2:
              attack = random.choice(criticals)
              attack1 = random.choice(criticals)
              print(firstopponent,"is angry and manages to land a",attack,"and a",attack1,"on you!")
              HP = HP - 25
              print("Your HP is now",HP)
              time.sleep(4)

          #opponent failed attack
          randomnumbers = [1,2,3]
          if result == 3 or 4:
            opattacknumber = random.choice(randomnumbers)
            attack = random.choice(opattack)
            
            if opattacknumber == 1:
              print(firstopponent,"trys to",attack,"you, but fails because you dodge it.")
              xpgained = xpgained + 1
              print("You gained 1 xp for dodging the",attack+".")
              if stamina < 10:
                stamina = stamina + 5
                print("You gained 5 stamina for dodging the attack!")
              time.sleep(4)

            if opattacknumber == 2:
              print(firstopponent,"tries to",attack,"you but misses!")
              yourattack = random.choice(opattack)

              if yourattack == "punch":
                print("You manage to punch",firstopponent+".")
                opponentHP = opponentHP - punchdamage
                print(firstopponent+"'s HP is now -",opponentHP)
                xpgained = xpgained + 5
                print("You gained 5 xp!")
                time.sleep(4)

              if yourattack == "kick":
                print("You manage to kick",firstopponent+".")
                opponentHP = opponentHP - kickdamage
                print(firstopponent+"'s HP is now -",opponentHP)
                xpgained = xpgained + 4
                print("You gained 4 xp!")
                time.sleep(4)

              if yourattack == "smack":
                print("You manage to smack",firstopponent+".")
                opponentHP = opponentHP - smackdamage
                print(firstopponent+"'s HP is now -",opponentHP)
                xpgained = xpgained + 7
                print("You gained 7 xp!")
                time.sleep(4)

            if opattacknumber == 3:
              print(firstopponent,"tries to",attack,"you but misses and makes you angry!")
              annoyed1 = random.choice(opattack)
              annoyed2 = random.choice(opattack)
              print("You land a",annoyed1,"and a",annoyed2)
              opponentHP = opponentHP - 18
              print(firstopponent+"'s HP is now -",opponentHP)
              xpgained = xpgained + 10
              print("You gained 10 xp!")
              time.sleep(5)

        #congratulations

        if youwon == 1:

          xp = xp + xpgained

          fightswon = fightswon + 1

          if fightingboris == True:
            print("")
            print("Congratualtions",name+"! You managed to defeat Big Boris!")
            print("Boris has decided to give his fight club to you!")
            beatenboris = True

          else:
            print("Well done",name+". You managed to defeat",firstopponent+"!")

          print(colors.blue("-----------------------------------------------------------------"))
          print("You gained",xp,"xp that round.")
          if xp >= 100:
            while True:
              xp = xp - 100
              level = level + 1

              punchdamage = punchdamage + 2
              kickdamage = kickdamage + 3
              slapdamage = smackdamage + 1

              punchdamagecrit = punchdamagecrit + 4
              kickdamagecrit = kickdamagecrit + 6
              smackdamagecrit = smackdamagecrit + 3

              print("Well done you leveled up to level",level,"!")
              print("Your punch, kick and slap now does more damage!")

              if xp < 100:
                break

        if youwon == 2:

          xp = xp + xpgained

          fightslost = fightslost + 1
          print("")
          print("Unlucky",name+". You couldn't defeat",firstopponent+"!")
          print(colors.blue("-----------------------------------------------------------------"))
          print("You gained",xp,"xp that round.")
          print("")
          if xp >= 100:
            while True:
              xp = xp - 100
              level = level + 1

              punchdamage = punchdamage + 2
              kickdamage = kickdamage + 3
              slapdamage = smackdamage + 1

              punchdamagecrit = punchdamagecrit + 4
              kickdamagecrit = kickdamagecrit + 6
              smackdamagecrit = smackdamagecrit + 3

              print("Well done you leveled up to level",level,"!")
              print("Your punch, kick and slap now does more damage!")

              if xp < 100:
                break

        input("Type any key to continue. ")
        youwon = 0
        os.system("clear")
        break
Fetching token
?