repl.it
@MATHyou/

Gladiator Battles 3

Pygame

No description

fork
loading
Files
  • main.py
  • nohup.out
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
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
Version = "V 1.5"
"""
Welcome to Gladiator Battles 3!

CHANGELOG:
V 0.1:
    Added the Menu Room!
V 0.2:
    Added the Stats Room!
V 0.3:
    Added the Shop!
V 0.4:
    Changed the refunding of the HP Increasers so no profit would be made.
V 0.5:
    Added Wining and Losing screens for Training!
    Added Decreasing your Attack Cooldown!
V 0.6:
    Added Training! There isn't currently an AI for your enemy, so it won't do anything!
V 0.7:
    Added a loading screen!
    Added Battles counter!
V 0.8:
    Added enemy AI!
    Added upgrading speed!
    Lots of modifications to the code to prepare for the Battling section!
V 0.9:
    Added Battling!
V 1.0:
    FULLY RELEASED!
    Tweaked Battling.
    Fixed a bug when battling in either Battling or Training.
    Brought default money back down to 10.
V 1.1:
    Added pausing during battles!
    Tweaked the enemy's speed in Battling.
    Made it possible to decrease your attack cooldown to 1.
    Tweaked how long it takes for one second to pass when battling.
    Your attack cooldown is now 7 by default.
    Note: The speed in which the game runs is based on your computer.
V 1.2:
    Tweaked Battling
    Fixed a bug in Battling where the enemy wouldn't get tougher after Battle 10.
V 1.3:
    You now unlock the Final Boss when you get to Battle 20! Note: If you restart Battling after you have unlocked the Final Boss, you will still have it unlocked.
V 1.4:
    Added WASD controls in the Menu!
    Made it possible to run into the corner in which the sign "<--Back[a]" is in to use it.
V 1.5:
    Modified all costs in the shop to be more balanced.
"""
import pygame
import random
class battles:
    def __init__(self, battles):
        self.battles = battles
battles = battles(0)
run = True
pygame.init()
winheight = 500
winwidth = 500
win = pygame.display.set_mode((winheight, winwidth))
pygame.display.set_caption("Gladiator Battles 3")
def message(msg, color, cords, size):
    fontsize = int(size)
    font = pygame.font.SysFont(None, fontsize)
    screen_text = font.render(msg, True, color)
    win.blit(screen_text, cords)
loading = 10
while loading < 290:
    win.fill((255,255,255))
    pygame.time.delay(5)
    message("Gladiator Battles 3", (0, 0, 0), [90, 100], 50)
    message(Version, (0, 0, 0), [228, 150], 25)
    loading += random.randint(0, 5)
    pygame.draw.rect(win, (0,0,0), (90, 225, 10, 40))
    pygame.draw.rect(win, (0,0,0), (390, 225, 10, 40))
    pygame.draw.rect(win, (0,0,0), (90, 240, loading, 10))
    pygame.display.update()
maxhp = 10
dmg = 5
acd = 7
tecd = 4
UHPIcost = 35
UTcost = 25
battlingroom = 1
TrainingDamageMultiplier = 1
TrainingDamageAddition = 0
TrainingHealthAddition = 0
pspeed = 5
FinalBoss = False
FirstTraining = True
HPIcost = 2
HPIncreasers = 0
HPIHealthIncreased = 10
menu = True
stats = False
shop = False
training = False
battling = False
Battle = 1
BATTLE = False
money = 10
buttonw = False
buttona = False
buttons = False
buttond = False
buttone = False
buttonq = False
msplayerwidth = 15
msplayerheight = 15
msplayerx = winwidth/2-msplayerwidth/2
msplayery = winheight/2-msplayerheight/2
vel = 4
black = (0, 0, 0)
white = (255, 255, 255)
mtimer = 0
mmessage = "on"
damagewon = 10.0
def battle(php, pdmg, pacd, pspeed, ehp, edmg, eacd, espeed, edc, title, titlex):
    bplayery = 200
    bplayerx = 10
    playerwidth = 20
    playerheight = 20
    playerx = 100
    ymiddle = 250 - msplayerheight
    yup = 150
    ydown = 350
    enemyx = 400
    onesecond = 75
    PACD = onesecond * pacd
    PTimer = PACD
    pcanattack = True
    EACD = onesecond * eacd
    ETimer = EACD
    ecanattack = False
    buttonw = False
    buttond = False
    buttons = False
    buttone = False
    playerpos = "middle"
    enemypos = "middle"
    pattack = False
    eattack = False
    pattackforward = True
    pattackbackward = False
    eattackforward = True
    eattackbackward = False
    win.fill((255,255,255))
    message("Controls:", (0, 0, 0), [170, 10], 50)
    message("Use W & S to dodge up and down", (0, 0, 0), [170, 200], 25)
    message("Use D to attack", (0, 0, 0), [170, 225], 25)
    message("Press A to exit during battle", (0, 0, 0), [170, 250], 25)
    message("Press E to pause and resume the battle.", (0, 0, 0), [170, 275], 25)
    message("Continue[d]-->", (0, 0, 0), [375, 475], 25)
    pygame.display.update()
    while True:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                run = False
        keys = pygame.key.get_pressed()
        if keys[pygame.K_d]:
            buttond = True
            break
    while True:
        win.fill((255, 255, 255))
        pygame.time.delay(5)
        if not eattack:
            if random.randint(1, edc) == 25:
                em = random.randint(1, 3)
                if em == 1:
                    enemypos = "middle"
                elif em == 2:
                    enemypos = "up"
                else:
                    enemypos = "down"
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                run = False
        keys = pygame.key.get_pressed()
        if keys[pygame.K_a]:
            return "Exit"
        if keys[pygame.K_w]:
            buttonw = True
        else:
            buttonw = False
        if keys[pygame.K_s]:
            buttons = True
        else:
            buttons = False
        if keys[pygame.K_d]:
            if not buttond:
                buttond = True
                if pcanattack:
                    pattack = True
                    pcanattack = False
        else:
            buttond = False
        if ehp <= 0:
            battles.battles += 1
            return "Win"
        elif php <= 0:
            battles.battles += 1
            return "Lose"
        if not pattack:
            if buttons and buttonw:
                playerpos = "middle"
            elif buttons:
                playerpos = "down"
            elif buttonw:
                playerpos = "up"
            else:
                playerpos = "middle"
        if not pcanattack:
            PTimer -= 1 
            if PTimer <= 0:
                PTimer = PACD
                pcanattack = True
        if not ecanattack:
            ETimer -= 1 
            if ETimer <= 0:
                ETimer = EACD
                ecanattack = True
        if ecanattack:
            ecanattack = False
            if random.randint(1,3) >= 2:
                enemypos = playerpos
            eattack = True
        if eattack:
            if eattackforward:
                enemyx -= espeed
                if enemyx - playerwidth <= playerx and enemypos == playerpos:
                    php -= edmg
                    eattackforward = False
                    eattackbackward = True
                elif enemypos != playerpos and enemyx - playerwidth <= 100:
                    eattackforward = False
                    eattackbackward = True
            elif eattackbackward:
                enemyx += espeed
                if enemyx >= 400:
                    eattack = False
                    eattackbackward = False
                    eattackforward = True
        if pattack:
            if pattackforward:
                playerx += pspeed
                if playerx + playerwidth >= enemyx and enemypos == playerpos:
                    ehp -= pdmg
                    pattackforward = False
                    pattackbackward = True
                elif playerx + playerwidth >= 400 and playerpos != enemypos:
                    pattackforward = False
                    pattackbackward = True
            elif pattackbackward:
                playerx -= pspeed
                if playerx <= 100:
                    pattack = False
                    pattackbackward = False
                    pattackforward = True
        if playerpos == "middle":
            pygame.draw.rect(win, black, (playerx, ymiddle, playerwidth, playerheight))
        elif playerpos == "down":
            pygame.draw.rect(win, black, (playerx, ydown, playerwidth, playerheight))
        elif playerpos == "up":
            pygame.draw.rect(win, black, (playerx, yup, playerwidth, playerheight))
        if enemypos == "middle":
            pygame.draw.rect(win, black, (enemyx, ymiddle, playerwidth, playerheight))
        elif enemypos == "down":
            pygame.draw.rect(win, black, (enemyx, ydown, playerwidth, playerheight))
        elif enemypos == "up":
            pygame.draw.rect(win, black, (enemyx, yup, playerwidth, playerheight))
        message(title, (0, 0, 0), [titlex, 10], 50)
        message("<--Back[a]", (0, 0, 0), [10, 475], 25)
        message("HP: " + str(int(php)), (0, 0, 0), [85, 100], 25)
        message("HP: " + str(int(ehp)), (0, 0, 0), [385, 100], 25)
        message("Pause[e]", (0, 0, 0), [10, 10], 25)
        if pcanattack:
            message("Can attack", (0, 0, 0), [65, 400], 25)
        else:
            message(str(1+(int(PTimer/onesecond))), (0, 0, 0), [100, 400], 50)
        pygame.display.update()
        if keys[pygame.K_e]:
            if not buttone:
                buttone = True
                message("Paused", (0, 0, 0), [190, 200], 50)
                message("Press E to resume", (0, 0, 0), [180, 250], 25)
                pygame.display.update()
                while True:
                    for event in pygame.event.get():
                        if event.type == pygame.QUIT:
                            run = False
                    keys = pygame.key.get_pressed()
                    if keys[pygame.K_e]:
                        if not buttone:
                            buttone = True
                            break
                    else:
                        buttone = False
        else:
            buttone = False
while run:
    while menu:
        win.fill((255, 255, 255))
        pygame.time.delay(5)
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                run = False
        if event.type == pygame.QUIT:
            run = False
        keys = pygame.key.get_pressed()
        if keys[pygame.K_LEFT] and msplayerx > 0:
            msplayerx -= vel
        if keys[pygame.K_RIGHT] and msplayerx < winwidth - msplayerwidth:
            msplayerx += vel
        if keys[pygame.K_UP] and msplayery > 0:
            msplayery -= vel
        if keys[pygame.K_DOWN] and msplayery < winheight - msplayerheight:
            msplayery += vel
        if keys[pygame.K_c]:
            message(str(msplayerx)+ " " + str(msplayery), (0, 0, 0), [205,250], 25)
        if msplayerx <= 0 and msplayery <= 0 or keys[pygame.K_w]:
            if not buttonw:
                buttonw = True
                menu = False
                stats = True
                break
        else:
            buttonw = False
        if msplayerx >= winwidth - msplayerwidth and msplayery <= 0 or keys[pygame.K_a]:
            if not buttona:
                buttona = True
                menu = False
                shop = True
                break
        else:
            buttona = False
        if msplayerx <= 0 and msplayery >= winheight - msplayerheight or keys[pygame.K_s]:
            if not buttons:
                buttons = True
                menu = False
                training = True
                break
        else:
            buttons = False
        if msplayerx >= winwidth - msplayerwidth and msplayery >= winheight - msplayerheight or keys[pygame.K_d]:
            if not buttond:
                buttond = True
                menu = False
                battling = True
                break
        else:
            buttond = False
        mtimer += 1
        if mtimer <= 50:
            if mmessage == "on":
                message("Go the the corner of your choice!", (0, 0, 0), [winwidth/2-140, 10], 25)
        else:
            if mmessage == "on":
                mmessage = "off"
            elif mmessage == "off":
                mmessage = "on"
            mtimer = 0
        message("Gladiator Battles 3", (0, 0, 0), [90, 150], 50)
        message(Version, (0, 0, 0), [228, 200], 25)
        message("Stats[w]", (0, 0, 0), [10, 10], 25)
        message("Shop[a]", (0, 0, 0), [430, 10], 25)
        message("Training[s]", (0, 0, 0), [10, 475], 25)
        message("Battling[d]", (0, 0, 0), [405, 475], 25)
        pygame.draw.rect(win, black, (msplayerx, msplayery, msplayerwidth, msplayerheight))
        pygame.display.update()
    while stats:
        win.fill((255, 255, 255))
        pygame.time.delay(5)
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                run = False
        if event.type == pygame.QUIT:
            run = False
        keys = pygame.key.get_pressed()
        if keys[pygame.K_LEFT] and msplayerx > 0:
            msplayerx -= vel
        if keys[pygame.K_RIGHT] and msplayerx < winwidth - msplayerwidth:
            msplayerx += vel
        if keys[pygame.K_UP] and msplayery > 0:
            msplayery -= vel
        if keys[pygame.K_DOWN] and msplayery < winheight - msplayerheight:
            msplayery += vel
        if keys[pygame.K_c]:
            message(str(msplayery)+ " " + str(msplayerx), (0, 0, 0), [10,10], 25)
        if keys[pygame.K_a] or msplayerx <= 0 and msplayery >= winheight - msplayerheight:
            if not buttona:
                buttona = True
                msplayerx = winwidth/2-msplayerwidth/2
                msplayery = winheight/2-msplayerheight/2
                menu = True
                stats = False
                break
        else:
            buttona = False
        if keys[pygame.K_w]:
            if not buttonw:
                buttonw = True
                if HPIncreasers >= 1:
                    HPIncreasers -= 1
                    maxhp += HPIHealthIncreased
        else:
            buttonw = False
        if keys[pygame.K_s]:
            if not buttons:
                buttons = True
                if HPIncreasers >= 1:
                    money += 5
                    HPIncreasers -= 1
        else:
            buttons = False
        message("Stats Room", (0, 0, 0), [winwidth/2-100, 10], 50)
        message("Max HP: " + str(int(maxhp)), (0, 0, 0), [winwidth/2-50, 100], 25)
        message("Damage: " + str(int(dmg)), (0, 0, 0), [winwidth/2-50, 125], 25)
        message("Attack Cooldown: " + str(int(acd)) + " seconds", (0, 0, 0), [winwidth/2-50, 150], 25)
        message("Money: $" + str(int(money)), (0, 0, 0), [winwidth/2-50, 175], 25)
        message("HP Increasers[w]: " + str(int(HPIncreasers)), (0, 0, 0), [winwidth/2-50, 200], 25)
        message("Sell HP Increasers[s]", (0, 0, 0), [winwidth/2-50, 225], 25)
        message("Battles completed: " + str(int(battles.battles)), (0, 0, 0), [winwidth/2-50, 250], 25)
        message("<--Back[a]", (0, 0, 0), [10, 475], 25)
        pygame.draw.rect(win, black, (msplayerx, msplayery, msplayerwidth, msplayerheight))
        pygame.display.update()
    while shop:
        win.fill((255, 255, 255))
        pygame.time.delay(5)
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                run = False
        if event.type == pygame.QUIT:
            run = False
        keys = pygame.key.get_pressed()
        if keys[pygame.K_LEFT] and msplayerx > 0:
            msplayerx -= vel
        if keys[pygame.K_RIGHT] and msplayerx < winwidth - msplayerwidth:
            msplayerx += vel
        if keys[pygame.K_UP] and msplayery > 0:
            msplayery -= vel
        if keys[pygame.K_DOWN] and msplayery < winheight - msplayerheight:
            msplayery += vel
        if keys[pygame.K_c]:
            message(str(msplayery)+ " " + str(msplayerx), (0, 0, 0), [10,10], 25)
        if keys[pygame.K_a] or msplayerx <= 0 and msplayery >= winheight - msplayerheight:
            if not buttona:
                buttona = True
                msplayerx = winwidth/2-msplayerwidth/2
                msplayery = winheight/2-msplayerheight/2
                menu = True
                shop = False
                break
        else:
            buttona = False
        if keys[pygame.K_w]:
            if not buttonw:
                buttonw = True
                if money >= HPIcost:
                    HPIncreasers += 1
                    money -= HPIcost
                    HPIcost += 1
        else:
            buttonw = False
        if keys[pygame.K_d]:
            if not buttond:
                buttond = True
                if money >= UHPIcost:
                    money -= UHPIcost
                    UHPIcost += 15
                    HPIHealthIncreased += 10
        else:
            buttond = False
        if keys[pygame.K_s]:
            if not buttons:
                buttons = True
                if money >= UTcost:
                    money -= UTcost
                    UTcost += 15
                    TrainingDamageMultiplier += 0.5
        else:
            buttons = False
        if keys[pygame.K_e]:
            if not buttone:
                buttone = True
                if money >= 75 and acd >= 2:
                    money -= 75
                    acd -= 1
        else:
            buttone = False
        if keys[pygame.K_q]:
            if not buttonq:
                buttonq = True
                if money >= 50:
                    money -= 50
                    pspeed += 5
        else:
            buttonq = False
        message("Shop", (0, 0, 0), [winwidth/2-50, 10], 50)
        message("Money: $" + str(money), (0, 0, 0), [385, 10], 25)
        message("HP Increasers[w]: $" + str(HPIcost), (0, 0, 0), [winwidth/2-50, 100], 25)
        message("Upgrade all HP Increasers[d]: $" + str(UHPIcost), (0, 0, 0), [winwidth/2-50, 125], 25)
        message("Upgrade Training[s]: $" + str(UTcost), (0, 0, 0), [winwidth/2-50, 150], 25)
        message("Upgrade Attack speed[q]: $50", (0, 0, 0), [winwidth/2-50, 175], 25)
        if acd >= 2:
            message("Decrease Attack Cooldown[e]: $75", (0, 0, 0), [winwidth/2-50, 200], 25)
        message("<--Back[a]", (0, 0, 0), [10, 475], 25)
        pygame.draw.rect(win, black, (msplayerx, msplayery, msplayerwidth, msplayerheight))
        pygame.display.update()
    if battling:
        while True:
            win.fill((255, 255, 255))
            pygame.time.delay(5)
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    run = False
            if event.type == pygame.QUIT:
                run = False
            keys = pygame.key.get_pressed()
            if keys[pygame.K_c]:
                message(str(msplayerx)+ " " + str(msplayery), (0, 0, 0), [205,250], 25)
            if keys[pygame.K_a]:
                if not buttona:
                    buttona = True
                    BATTLE = False
                    menu = True
                    battling = False
                    msplayerx = winwidth/2-msplayerwidth/2
                    msplayery = winheight/2-msplayerheight/2
                    break
            else:
                buttona = False
            if keys[pygame.K_d]:
                if not buttond:
                    buttond = True
                    BATTLE = True
                    break
            else:
                buttond = False
            if keys[pygame.K_s]:
                if not buttons:
                    buttons = True
                    Battle = 1
                    BATTLE = True
                    break
            else:
                buttons = False
            if keys[pygame.K_w]:
                if not buttonw and FinalBoss:
                    buttonw = True
                    battlereturn = battle(maxhp, dmg, acd, pspeed, 1000, 250, 1, 65, 25, "Final Boss", 160)
                    if battlereturn == "Win":
                        win.fill((255, 255, 255))
                        message("YOU WON!", (0, 0, 0), [165, 190], 50)
                        message("What you got:", (0, 0, 0), [195, 230], 25)
                        money += 100000000000
                        message("+" + str(int(100000000000)) + " Dollars", (0, 0, 0), [195, 255], 25)
                        message("Continue[d]-->", (0, 0, 0), [375, 475], 25)
                        pygame.display.update()
                        buttond = True
                        while True:
                            for event in pygame.event.get():
                                if event.type == pygame.QUIT:
                                    run = False
                            if event.type == pygame.QUIT:
                                run = False
                            keys = pygame.key.get_pressed()
                            if keys[pygame.K_d]:
                                if not buttond:
                                    buttond = True
                                    msplayerx = winwidth/2-msplayerwidth/2
                                    msplayery = winheight/2-msplayerheight/2
                                    menu = True
                                    training = False
                                    break
                            else:
                                buttond = False
                    elif battlereturn == "Lose":
                        win.fill((255, 255, 255))
                        message("YOU LOST!", (0, 0, 0), [165, 190], 50)
                        message("You don't get anything for losing.", (0, 0, 0), [125,230], 25)
                        message("Continue[d]-->", (0, 0, 0), [375, 475], 25)
                        pygame.display.update()
                        buttond = True
                        while True:
                            for event in pygame.event.get():
                                if event.type == pygame.QUIT:
                                    run = False
                            if event.type == pygame.QUIT:
                                run = False
                            keys = pygame.key.get_pressed()
                            if keys[pygame.K_d]:
                                if not buttond:
                                    buttond = True
                                    msplayerx = winwidth/2-msplayerwidth/2
                                    msplayery = winheight/2-msplayerheight/2
                                    menu = True
                                    training = False
                                    break
                            else:
                                buttond = False
            else:
                buttonw = False
            message("Continue[d]", (0, 0, 0), [400, 10], 25)
            message("Restart[s]", (0, 0, 0), [415, 475], 25)
            message("<--Back[a]", (0, 0, 0), [10, 475], 25)
            if FinalBoss:
                message("Final Boss[w]", (0, 0, 0), [10, 10], 25)
            message("Battling", (0, 0, 0), [185, 175], 50)
            message("Menu", (0, 0, 0), [205, 210], 50)
            pygame.display.update()
        while BATTLE:
            if Battle >= 1:
                ecd = 6
                espeed = 10
                edc = 100
            if Battle >= 5:
                ecd = 5
                edc = 90
            if Battle >= 10:
                ecd = 4
                espeed = 15
                edc = 80
            if Battle >= 15:
                ecd = 3
                edc = 70
            if Battle >= 20:
                ecd = 2
                espeed = 20
                edc = 60
            if Battle >= 25:
                ecd = 1
                edc = 50
            if Battle >= 30:
                espeed = 25
                edc = 40
            if Battle >= 40:
                espeed = 30
            if Battle >= 20:
                FinalBoss = True
            battlereturn = battle(maxhp, dmg, acd, pspeed, (10 * Battle), (5 * Battle), ecd, espeed, edc, "Battle " + str(Battle), 180)
            if battlereturn == "Exit":
                BATTLE = False
                battling = True
                buttona = True
                break
            if battlereturn == "Win":
                win.fill((255, 255, 255))
                message("YOU WON!", (0, 0, 0), [165, 190], 50)
                message("What you got:", (0, 0, 0), [195, 230], 25)
                money += (Battle * 2)
                Battle += 1
                message("+" + str(Battle * 2) + " Dollars", (0, 0, 0), [195, 255], 25)
                message("Continue[d]-->", (0, 0, 0), [375, 475], 25)
                pygame.display.update()
                buttond = True
                while True:
                    for event in pygame.event.get():
                        if event.type == pygame.QUIT:
                            run = False
                    if event.type == pygame.QUIT:
                        run = False
                    keys = pygame.key.get_pressed()
                    if keys[pygame.K_d]:
                        if not buttond:
                            break
                    else:
                        buttond = False
            elif battlereturn == "Lose":
                win.fill((255, 255, 255))
                message("YOU LOST!", (0, 0, 0), [165, 190], 50)
                message("You don't get anything for losing.", (0, 0, 0), [125,230], 25)
                message("Continue[d]-->", (0, 0, 0), [375, 475], 25)
                pygame.display.update()
                buttond = True
                while True:
                    for event in pygame.event.get():
                        if event.type == pygame.QUIT:
                            run = False
                    if event.type == pygame.QUIT:
                        run = False
                    keys = pygame.key.get_pressed()
                    if keys[pygame.K_d]:
                        if not buttond:
                            buttond = True
                            BATTLE = False
                            battling = True
                            break
                    else:
                        buttond = False
    if training:
        win.fill((255, 255, 255))
        battlereturn = battle(maxhp, dmg, acd, pspeed, (20 + TrainingHealthAddition), (2 + TrainingDamageAddition), acd, pspeed, 75, "Training", 180)
        if battlereturn == "Exit":
            msplayerx = winwidth/2-msplayerwidth/2
            msplayery = winheight/2-msplayerheight/2
            menu = True
            training = False
            buttona = True
        elif battlereturn == "Win":
            win.fill((255, 255, 255))
            message("YOU WON!", (0, 0, 0), [165, 190], 50)
            message("What you got:", (0, 0, 0), [195, 230], 25)
            dmg += (damagewon * TrainingDamageMultiplier)
            TrainingDamageAddition += 15
            TrainingHealthAddition += ((damagewon * TrainingDamageMultiplier) + 2)
            message("+" + str(int(damagewon * TrainingDamageMultiplier)) + " Damage", (0, 0, 0), [195, 255], 25)
            message("Continue[d]-->", (0, 0, 0), [375, 475], 25)
            pygame.display.update()
            buttond = True
            while True:
                for event in pygame.event.get():
                    if event.type == pygame.QUIT:
                        run = False
                if event.type == pygame.QUIT:
                    run = False
                keys = pygame.key.get_pressed()
                if keys[pygame.K_d]:
                    if not buttond:
                        buttond = True
                        msplayerx = winwidth/2-msplayerwidth/2
                        msplayery = winheight/2-msplayerheight/2
                        menu = True
                        training = False
                        break
                else:
                    buttond = False
        elif battlereturn == "Lose":
            win.fill((255, 255, 255))
            message("YOU LOST!", (0, 0, 0), [165, 190], 50)
            message("You don't get anything for losing.", (0, 0, 0), [125,230], 25)
            message("Continue[d]-->", (0, 0, 0), [375, 475], 25)
            pygame.display.update()
            buttond = True
            while True:
                for event in pygame.event.get():
                    if event.type == pygame.QUIT:
                        run = False
                if event.type == pygame.QUIT:
                    run = False
                keys = pygame.key.get_pressed()
                if keys[pygame.K_d]:
                    if not buttond:
                        buttond = True
                        msplayerx = winwidth/2-msplayerwidth/2
                        msplayery = winheight/2-msplayerheight/2
                        menu = True
                        training = False
                        break
                else:
                    buttond = False
pygame.quit()