-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquest.py
1820 lines (1370 loc) · 70.9 KB
/
quest.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
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Imports
import pygame
from config import *
from sprites import *
from typing import List
import math, random as r
class Quest:
def __init__(self, game):
"""
Make more complex quests here.
"""
self.game = game
self.things_to_buy = {"level teleporter": (pygame.image.load("img/doctor_who.png"), 125),
"referat": (pygame.image.load("img/amper_referat.png"), 30),
"map": (pygame.image.load("img/amper_map.png"), 150),
"retake": (pygame.image.load("img/amper_retake.png"), 50),
"vujcheek fender": (pygame.image.load("img/amper_fender.png"), 90)
}
def bench_press(self, bench_done: bool):
"""
Tst quest - Bench press
"""
self.bench_done = bench_done
grade: int = 5
# Already did bench press
if not self.bench_done: self.game.talking("I already did this."); return False
# Music
if self.game.music_on: pygame.mixer.Sound.stop(self.game.theme); pygame.mixer.Sound.play(self.game.tsv_theme, -1)
# Bench press quest for stronk bois
background = pygame.image.load("img/bench_press.png").convert()
dumbbell = pygame.image.load("img/bench_press_dumbbell.png").convert_alpha()
dumbbell_rect = dumbbell.get_rect(x=0, y=50)
back_button = Button(500, 400, 120, 50, fg=WHITE, bg=BLACK, content="Back", fontsize=32)
working_out: bool = True
counter: int = 0
push_strength: int = 20
weak: bool = True
exited: bool = False
start: int = pygame.time.get_ticks()
while working_out and counter < 5:
# You have 1 min for this
if pygame.time.get_ticks() - start > 60 * 1000: working_out = False
t = str(round((pygame.time.get_ticks() - start) // 1000)) if len(str(round((pygame.time.get_ticks() - start) // 1000))) > 1 else "0" + str(round((pygame.time.get_ticks() - start) // 1000))
time = self.game.font.render("0:" + t + " / 1:00", True, WHITE)
time_rect = time.get_rect(x=525, y=10)
# Position and click of the mouse
mouse_pos = pygame.mouse.get_pos()
mouse_pressed = pygame.mouse.get_pressed()
# Events
for event in pygame.event.get():
# Close button
if event.type == pygame.QUIT: self.game.exiting()
# Clicking
if event.type == pygame.MOUSEBUTTONDOWN or event.type == pygame.KEYDOWN and event.key == pygame.K_SPACE:
if dumbbell_rect.y >= -100:
if counter == 2: dumbbell_rect.y -= push_strength - 3
elif counter == 3: dumbbell_rect.y -= push_strength - 5
elif counter == 4: dumbbell_rect.y -= push_strength - 7
else: dumbbell_rect.y -= push_strength
else: dumbbell_rect.y = 50; counter += 1
# Dumbbell down
if dumbbell_rect.y <= 50:
if counter == 2: dumbbell_rect.y += 1.1
elif counter == 3: dumbbell_rect.y += 1.2
elif counter == 4: dumbbell_rect.y += 1.3
else: dumbbell_rect.y += 1
# Background, button, image
self.game.screen.blit(background, (0, 0))
self.game.screen.blit(self.game.font.render("Times lifted: {} of 5".format(counter), True, WHITE), (10, 10))
self.game.screen.blit(time, time_rect)
self.game.screen.blit(dumbbell, dumbbell_rect)
self.game.screen.blit(back_button.image, back_button.rect)
if back_button.is_pressed(mouse_pos, mouse_pressed): working_out = False; weak = True; exited = True
self.game.clock.tick(FPS)
pygame.display.update()
# Made it
if not exited:
weak = False
if grade - counter == 0: grade = 1
else: grade -= counter
self.game.info("You've recieved a grade for TSV", WHITE, 30)
self.game.grades["TSV"] = grade
# Music
if self.game.music_on: pygame.mixer.Sound.stop(self.game.tsv_theme); pygame.mixer.Sound.play(self.game.theme, -1)
# Return
return weak
def programming(self):
"""
Potitat
"""
# Potitat v LROB
if self.game.interacted[2] == 0 and self.game.interacted[1] == 25 and self.game.program_test:
in_potitat = True
# Background
bg = pygame.image.load("img/LROB.png")
# active
active_def = False
active_self = False
active_item = False
active_even = False
active_tuple = False
# Color
color = GRAY
# To fill
fill_def = pygame.Rect(84, 91, 26, 16)
fill_self = pygame.Rect(220, 93, 29, 14)
fill_item = pygame.Rect(248, 207, 30, 16)
fill_even = pygame.Rect(496, 206, 42, 19)
fill_tuple = pygame.Rect(248, 227, 35, 15)
# text
text_def = ""
text_self = ""
text_item = ""
text_even = ""
text_tuple = ""
# Button
back_button = Button(10, 400, 120, 50, fg=WHITE, bg=BLACK, content="Back", fontsize=32)
grade_button = Button(500, 400, 120, 50, fg=WHITE, bg=BLACK, content="Grade", fontsize=32)
while in_potitat:
# Position and click of the mouse
mouse_pos = pygame.mouse.get_pos()
mouse_pressed = pygame.mouse.get_pressed()
# Events
for event in pygame.event.get():
# Close button
if event.type == pygame.QUIT: self.game.exiting()
# Click
elif event.type == pygame.MOUSEBUTTONDOWN:
if fill_def.collidepoint(event.pos): active_def = True; active_self = False; active_item = False; active_even = False; active_tuple = False # Def
elif fill_self.collidepoint(event.pos): active_def = False; active_self = True; active_item = False; active_even = False; active_tuple = False # Self
elif fill_item.collidepoint(event.pos): active_def = False; active_self = False; active_item = True; active_even = False; active_tuple = False # Item
elif fill_even.collidepoint(event.pos): active_def = False; active_self = False; active_item = False; active_even = True; active_tuple = False # Even
elif fill_tuple.collidepoint(event.pos): active_def = False; active_self = False; active_item = False; active_even = False; active_tuple = True # Tuple
# Keyboard
if event.type == pygame.KEYDOWN:
# Esc
if event.key == pygame.K_ESCAPE: in_potitat = False
# Check for backspace
elif event.key == pygame.K_BACKSPACE:
if active_def: text_def = text_def[:-1]
elif active_self: text_self = text_self[:-1]
elif active_item: text_item = text_item[:-1]
elif active_even: text_even = text_even[:-1]
elif active_tuple: text_tuple = text_tuple[:-1]
elif active_def: text_def += event.unicode
elif active_self: text_self += event.unicode
elif active_item: text_item += event.unicode
elif active_even: text_even += event.unicode
elif active_tuple: text_tuple += event.unicode
# Back button
if back_button.is_pressed(mouse_pos, mouse_pressed): in_potitat = False
# Grade buttoin
if grade_button.is_pressed(mouse_pos, mouse_pressed):
self.game.program_test = False
grade: int = self.game.grade_program(text_def, text_self, text_item, text_even, text_tuple)
self.game.grades['PRO'] = grade
self.game.info("You've recieved a grade for PRO")
in_potitat = False
# Background
self.game.screen.blit(bg, (0, 0))
# Button
self.game.screen.blit(back_button.image, back_button.rect)
self.game.screen.blit(grade_button.image, grade_button.rect)
# Def
pygame.draw.rect(self.game.screen, color, fill_def) if active_def else None
text_surface_def = self.game.lrob_font.render(text_def, True, (255, 255, 255))
self.game.screen.blit(text_surface_def, (fill_def.x+1, fill_def.y-1))
# Self
pygame.draw.rect(self.game.screen, color, fill_self) if active_self else None
text_surface_self = self.game.lrob_font.render(text_self, True, (255, 255, 255))
self.game.screen.blit(text_surface_self, (fill_self.x+1, fill_self.y-1))
# Item
pygame.draw.rect(self.game.screen, color, fill_item) if active_item else None
text_surface_item = self.game.lrob_font.render(text_item, True, (255, 255, 255))
self.game.screen.blit(text_surface_item, (fill_item.x+1, fill_item.y-1))
# Even
pygame.draw.rect(self.game.screen, color, fill_even) if active_even else None
text_surface_even = self.game.lrob_font.render(text_even, True, (255, 255, 255))
self.game.screen.blit(text_surface_even, (fill_even.x+1, fill_even.y-1))
# Tuple
pygame.draw.rect(self.game.screen, color, fill_tuple) if active_tuple else None
text_surface_tuple = self.game.lrob_font.render(text_tuple, True, (255, 255, 255))
self.game.screen.blit(text_surface_tuple, (fill_tuple.x+1, fill_tuple.y-1))
# Updates
self.game.clock.tick(FPS)
pygame.display.update()
def check_suplovanie(self):
"""
Player checks for the substitution, very yes
"""
checking = True
# Screen of the game
bg = pygame.image.load("img/screen.png")
# Phone
iphone = pygame.image.load("img/mobile.png")
# Screens
first_screen = pygame.image.load("img/screenshot_first.png")
first_rect = first_screen.get_rect(x=WIN_WIDTH // 2 - first_screen.get_width() // 2, y=WIN_HEIGHT // 2 - first_screen.get_height() // 2)
second_screen = pygame.image.load("img/screenshot_second.png")
second_rect = second_screen.get_rect(x=WIN_WIDTH // 2 - second_screen.get_width() // 2, y=WIN_HEIGHT // 2 - second_screen.get_height() // 2)
grades_one = pygame.image.load("img/grades_first.png")
grades_one_rect = grades_one.get_rect(x=WIN_WIDTH // 2 - grades_one.get_width() // 2, y=WIN_HEIGHT // 2 - grades_one.get_height() // 2)
grades_two = pygame.image.load("img/grades_second.png")
grades_two_rect = grades_two.get_rect(x=WIN_WIDTH // 2 - grades_two.get_width() // 2, y=WIN_HEIGHT // 2 - grades_two.get_height() // 2)
# Button
back_button = Button(500, 400, 120, 50, fg=WHITE, bg=BLACK, content="Back", fontsize=32)
# "Button"
empty_rect = pygame.Rect(193, 320, 127, 21)
back_rect = pygame.Rect(302, 422, 36, 22)
grade_rect = pygame.Rect(193, 245, 127, 24)
main_app = True
sub = False
grades_app = False
up = True
# Grades
grades_to_write = {
"SJL": 0,
"ANJ": 0,
"DEJ": 0,
"OBN": 0,
"MAT": 0,
"TSV": 0,
"PRO": 0,
"SIE": 0,
"ICD": 0,
"OSY": 0,
"AEN": 0,
"IOT": 0,
"DSY": 0
}
# From dictionary
for i in self.game.grades: grades_to_write[i] = self.game.grades[i]
while checking:
# Position and click of the mouse
mouse_pos = pygame.mouse.get_pos()
mouse_pressed = pygame.mouse.get_pressed()
# Events
for event in pygame.event.get():
# Close button
if event.type == pygame.QUIT: self.game.exiting()
# Keyboard
elif event.type == pygame.KEYDOWN:
# Esc
if event.key == pygame.K_ESCAPE: checking = False
# Down
elif event.key == pygame.K_DOWN and grades_app: up = False
# Up
elif event.key == pygame.K_UP and grades_app: up = True
# Mouse
elif event.type == pygame.MOUSEBUTTONDOWN:
# Sub
if empty_rect.collidepoint(event.pos): main_app = not main_app; sub = not sub
# Back
elif back_rect.collidepoint(event.pos):
if main_app: checking = False; self.game.info("What day even is today?", BRITISH_WHITE); return False
elif sub: main_app = not main_app; sub = not sub
elif grades_app: main_app = not main_app; grades_app = not grades_app
# Grades
elif grade_rect.collidepoint(event.pos): main_app = not main_app; grades_app = not grades_app
# Background
self.game.screen.blit(bg, (0, 0))
self.game.screen.blit(iphone, (WIN_WIDTH // 2 - iphone.get_width() // 2, WIN_HEIGHT // 2 - iphone.get_height() // 2))
pygame.draw.rect(self.game.screen, BLACK, back_rect)
# Main app
if main_app:
self.game.screen.blit(first_screen, first_rect)
pygame.draw.rect(self.game.screen, NAVY, empty_rect, 1)
pygame.draw.rect(self.game.screen, NAVY, grade_rect, 1)
# Substitution
elif sub: self.game.screen.blit(second_screen, second_rect)
# Grades
elif grades_app:
if up: self.game.screen.blit(grades_one, grades_one_rect); self.render_grades(up, grades_to_write)
elif not up: self.game.screen.blit(grades_two, grades_two_rect); self.render_grades(up, grades_to_write)
# Back button
if back_button.is_pressed(mouse_pos, mouse_pressed): checking = False
self.game.screen.blit(back_button.image, back_button.rect)
# Updates
self.game.clock.tick(FPS)
pygame.display.update()
def render_grades(self, up, grades):
"""
Renders grades in EduPage
"""
n = 0
# SJL, ANJ, DEJ, OBN, MAT, TSV, PRO
if up:
for i in grades:
self.game.screen.blit(self.game.font.render(str(grades[i]), True, WHITE), (425, 97 + 44 * n)); n += 1
if n == 7: break
# PRO, SIE, ICDL, OSY, AEN, IOT, DSY
elif not up:
for i in grades:
if n > 5: self.game.screen.blit(self.game.font.render(str(grades[i]), True, WHITE), (425, 97 + 44 * (n - 6)))
n += 1
def anglictina(self):
"""
ANJ Skusanie quest
"""
testing: bool = True
bg = pygame.image.load("img/anj_bg.png")
word: int = 0
# Answers/Questions
assignment: List[str] = ["bottle of water".upper(), "aardvark".upper(), "carpet".upper(), "your".upper(), "religion".upper(), "keyboard".upper(), "universe".upper(), "wardrobe".upper(), "balcony".upper(), "printer".upper()]
assignment_answers: List[str] = ["flasa vody", "mravciar", "koberec", "tvoj", "nabozentvo", "klavesnica", "vesmir", "skrina", "balkon", "tlaciaren"]
answer: List[str] = []
answer_rect = pygame.Rect(155, 215, 302, 67)
answer_text: str = ""
# Button
back_button = Button(500, 400, 120, 50, fg=WHITE, bg=BLACK, content="Back", fontsize=32)
paper = pygame.image.load("img/paper.png")
paper_rect = paper.get_rect(x=20, y=0)
assign_rect = pygame.Rect(151, 141, 273, 50)
while testing:
# Position and click of the mouse
mouse_pos = pygame.mouse.get_pos()
mouse_pressed = pygame.mouse.get_pressed()
# Text of assignment
assign: str = assignment[word]
# Events
for event in pygame.event.get():
# Close button
if event.type == pygame.QUIT: self.game.exiting()
# Logic
if pygame.KEYDOWN == event.type:
# Enter
if event.key == pygame.K_RETURN: word += 1; answer.append(answer_text); answer_text = ""
# Check for backspace
elif event.key == pygame.K_BACKSPACE: answer_text = answer_text[:-1]
# Escape
elif event.key == pygame.K_ESCAPE: testing = False
# Unicode
else: answer_text += event.unicode
# Grading
if word == len(assignment_answers):
grade: int = 5 - math.floor(len(tuple(i for i in zip(assignment_answers, answer) if i[0] == i[1])) / 2)
self.game.anj_test = False
self.game.info("You've recieved a grade for ANJ", WHITE)
return grade if grade != 0 else 1, False
# Background
self.game.screen.blit(bg, (0, 0))
# Button
self.game.screen.blit(back_button.image, back_button.rect)
# Paper
self.game.screen.blit(paper, paper_rect)
# Text
text_surface_answer = self.game.big_font.render(answer_text, True, BLACK)
pygame.draw.rect(self.game.screen, PAPER_WHITE, answer_rect)
self.game.screen.blit(text_surface_answer, (answer_rect.x+5, answer_rect.y+5))
assing_text_surface = self.game.font.render(assign, True, BLACK)
self.game.screen.blit(assing_text_surface, (assign_rect.x+100, assign_rect.y+5))
answer_text_surface = self.game.font.render(str(word + 1) + "/10", True, BLACK)
self.game.screen.blit(answer_text_surface, (assign_rect.x+230, assign_rect.y-50))
# Button pressed
if back_button.is_pressed(mouse_pos, mouse_pressed): testing = not testing; return True
# Updates
self.game.clock.tick(FPS)
pygame.display.update()
def slovak_bs(self):
"""
SJL quest
"""
testing: bool = True
bg = pygame.image.load("img/sjl_bg.png")
word: int = 0
# Answers/Questions
assignment: List[str] = ["Lovecke ps_.".upper(), "Napadol __ uzasny napad.".upper(), "__ máš namierené?".upper(), "Videl som lietať v_ra.".upper(), "Kr_štálový".upper(), "Autor Mor ho.".upper(), "___ Botto.".upper(), "Materinský _____.".upper(), "ˇ%053!4P3%!".upper(), "1#!@%^d6n".upper()]
assignment_answers: List[str] = ["y", "mi", "Kam" , "ý", "y", "Samo Chalupka", "Ján", "jazyk", "LLJHLJK", "LK:{DA"]
answer: List[str] = []
answer_rect = pygame.Rect(155, 215, 302, 67)
answer_text: str = ""
# Button
back_button = Button(500, 400, 120, 50, fg=WHITE, bg=BLACK, content="Back", fontsize=32)
paper = pygame.image.load("img/paper.png")
paper_rect = paper.get_rect(x=20, y=0)
assign_rect = pygame.Rect(61, 141, 273, 50)
while testing:
# Position and click of the mouse
mouse_pos = pygame.mouse.get_pos()
mouse_pressed = pygame.mouse.get_pressed()
# Text of assignment
assign: str = assignment[word]
# Events
for event in pygame.event.get():
# Close button
if event.type == pygame.QUIT: self.game.exiting()
# Logic
if pygame.KEYDOWN == event.type:
# Enter
if event.key == pygame.K_RETURN: word += 1; answer.append(answer_text); answer_text = ""
# Check for backspace
elif event.key == pygame.K_BACKSPACE: answer_text = answer_text[:-1]
# Escape
elif event.key == pygame.K_ESCAPE: testing = False
# Unicode
else: answer_text += event.unicode
# Grading
if word == len(assignment_answers):
grade: int = 5 - math.floor(len(tuple(i for i in zip(assignment_answers, answer) if i[0] == i[1])) / 2)
self.game.sjl_test = False
self.game.info("You've recieved a grade for SJL", WHITE)
return grade if grade != 0 else 1, False
# Background
self.game.screen.blit(bg, (0, 0))
# Button
self.game.screen.blit(back_button.image, back_button.rect)
# Paper
self.game.screen.blit(paper, paper_rect)
# Text
text_surface_answer = self.game.big_font.render(answer_text, True, BLACK)
pygame.draw.rect(self.game.screen, PAPER_WHITE, answer_rect)
self.game.screen.blit(text_surface_answer, (answer_rect.x+5, answer_rect.y+5))
assing_text_surface = self.game.font.render(assign, True, BLACK)
self.game.screen.blit(assing_text_surface, (assign_rect.x+100, assign_rect.y+5))
answer_text_surface = self.game.font.render(str(word + 1) + "/10", True, BLACK)
self.game.screen.blit(answer_text_surface, (assign_rect.x+230, assign_rect.y-50))
# Button pressed
if back_button.is_pressed(mouse_pos, mouse_pressed): testing = not testing; return True
# Updates
self.game.clock.tick(FPS)
pygame.display.update()
def obn_testo(self):
"""
High effort quest, obn skusanie
"""
obning: bool = True
# Button
back_button = Button(10, 400, 120, 50, fg=WHITE, bg=BLACK, content="Back", fontsize=32)
done_button = Button(500, 400, 120, 50, fg=WHITE, bg=BLACK, content="Done", fontsize=32)
# active
active_text: bool = True
# To fill
fill_ans = pygame.Rect(10, 150, 200, 40)
# text
text_ans = ""
# Question counter
guesses = 0
# Points
p = 0
# Answers
answer: List[str] = ["ombutsman", "27", "zuzana caputova", "slovenska republika", "prvej"]
# Guess
guess: List[str] = []
# Questions
questions: List[str] = ["Advokat po svedsky?", "Kolko je statov v EU?", "Kto je prezident SR?", "Co znamena skratka SR?", "Pravo na zivot parti medzi prava ktorej generacie?"]
# Button
back_button = Button(10, 400, 120, 50, fg=WHITE, bg=BLACK, content="Back", fontsize=32)
assign: str = questions[guesses]
while obning:
# Position and click of the mouse
mouse_pos = pygame.mouse.get_pos()
mouse_pressed = pygame.mouse.get_pressed()
# Events
for event in pygame.event.get():
# Close button
if event.type == pygame.QUIT: self.game.exiting()
# Click
elif event.type == pygame.MOUSEBUTTONDOWN:
if fill_ans.collidepoint(event.pos): active_text = True
else: active_text = False
# Keyboard
if event.type == pygame.KEYDOWN:
# Esc
if event.key == pygame.K_ESCAPE: obning = False
# Enter
if event.key == pygame.K_RETURN and guesses < 4: guesses += 1; self.game.draw(); self.game.update(); guess.append(text_ans); text_ans = ""; assign: str = questions[guesses]
elif event.key == pygame.K_RETURN and guesses == 4: guesses += 1; self.game.draw(); self.game.update(); guess.append(text_ans)
# Check for backspace
elif event.key == pygame.K_BACKSPACE:
if active_text: text_ans = text_ans[:-1]
elif active_text: text_ans += event.unicode
# Back button
if back_button.is_pressed(mouse_pos, mouse_pressed): obning = False
# Grading
if guesses == len(questions):
obning = False
for i in range(len(guess)):
if guess[i].lower() == answer[i]: p += 1
if p == 5: return 1
elif p == 4: return 2
elif p == 3: return 3
elif p == 2: return 4
else: return 5
# Button
self.game.screen.blit(back_button.image, back_button.rect)
# Text stuff
pygame.draw.rect(self.game.screen, BLACK, fill_ans) if active_text else None
text_surface = self.game.font.render(text_ans, True, (255, 255, 255))
self.game.screen.blit(text_surface, (fill_ans.x+5, fill_ans.y+5))
question = self.game.font.render(assign, True, RED)
self.game.screen.blit(question, (10, 10))
# Updates
self.game.clock.tick(FPS)
pygame.display.update()
pygame.time.delay(600)
def maths(self):
"""
MAT quest
"""
testing: bool = True
bg = pygame.image.load("img/maths_bg.png")
word: int = 0
# Answers/Questions
assignment: List[str] = ["10x - 1 = 15 - 6x".upper(), "9x - 8 = 11x - 10".upper(), "7 + x/3 = 8 + x/4".upper(), "x/2 + x/3 = 5".upper(), "x - 2/3 = 5x/7 + 1/2".upper(), "2x - x/2 + 4 = x + x/3".upper(), "5x - 9 - 4/15 = (2x - 1)/3".upper(), "-1 - (3x - x)/4 = (2x - 5)/6".upper(), "(-17/19)x + 51 = 0".upper(), "|x - 7| = 0".upper()]
assignment_answers: List[str] = ["1", "1", "12", "6", "49/12", "-24", "3/5", "-1/5", "57", "7"]
answer: List[str] = []
answer_rect = pygame.Rect(155, 215, 302, 67)
answer_text: str = ""
# Button
back_button = Button(500, 400, 120, 50, fg=WHITE, bg=BLACK, content="Back", fontsize=32)
paper = pygame.image.load("img/paper.png")
paper_rect = paper.get_rect(x=20, y=0)
assign_rect = pygame.Rect(81, 141, 273, 50)
while testing:
# Position and click of the mouse
mouse_pos = pygame.mouse.get_pos()
mouse_pressed = pygame.mouse.get_pressed()
# Text of assignment
assign: str = assignment[word]
# Events
for event in pygame.event.get():
# Close button
if event.type == pygame.QUIT: self.game.exiting()
# Logic
if pygame.KEYDOWN == event.type:
# Enter
if event.key == pygame.K_RETURN: word += 1; answer.append(answer_text); answer_text = ""
# Check for backspace
elif event.key == pygame.K_BACKSPACE: answer_text = answer_text[:-1]
# Escape
elif event.key == pygame.K_ESCAPE: testing = False
# Unicode
else: answer_text += event.unicode
# Grading
if word == len(assignment_answers):
grade: int = 5 - math.floor(len(tuple(i for i in zip(assignment_answers, answer) if i[0] == i[1])) / 2)
self.game.mat_test = False
self.game.info("You've recieved a grade for MAT", WHITE)
return grade if grade != 0 else 1, False
# Background
self.game.screen.blit(bg, (0, 0))
# Button
self.game.screen.blit(back_button.image, back_button.rect)
# Paper
self.game.screen.blit(paper, paper_rect)
# Text
text_surface_answer = self.game.big_font.render(answer_text, True, BLACK)
pygame.draw.rect(self.game.screen, PAPER_WHITE, answer_rect)
xisequalto = self.game.big_font.render("x=", True, BLACK)
self.game.screen.blit(xisequalto, (answer_rect.x+5, answer_rect.y+5))
self.game.screen.blit(text_surface_answer, (answer_rect.x+35, answer_rect.y+5))
assing_text_surface = self.game.font.render(assign, True, BLACK)
self.game.screen.blit(assing_text_surface, (assign_rect.x+100, assign_rect.y+5))
answer_text_surface = self.game.font.render(str(word + 1) + "/10", True, BLACK)
self.game.screen.blit(answer_text_surface, (assign_rect.x+230, assign_rect.y-50))
# Button pressed
if back_button.is_pressed(mouse_pos, mouse_pressed): testing = not testing; return True
# Updates
self.game.clock.tick(FPS)
pygame.display.update()
def grading_tests(self):
"""
Grading tests for bananky
"""
grading = True
# Questions
questions = [pygame.image.load("img/mat1.png"), pygame.image.load("img/mat2.png"), pygame.image.load("img/mat3.png"), pygame.image.load("img/mat4.png"), pygame.image.load("img/mat5.png"), pygame.image.load("img/mat6.png")]
# Correct answers
correct_ans = ["K = {-6; 6}", "K = {1; 4}", "K = {1}", "K = {4}", "K = {16/25}", "K = {6; 22/9}"]
# Answers
answers = [
"K = {}".format("{" + str(r.randint(-6, -4)) + "; " + str(r.randint(4, 6)) + "}"),
"K = {}".format("{" + str(r.randint(-1, 3)) + "; " + str(r.randint(2, 6)) + "}"),
"K = {}".format("{" + str(r.randint(-2, 3)) + "}"),
"K = {}".format("{" + str(r.randint(0, 8)) + "}"),
"K = {}".format("{" + str(r.randint(14, 17)) + "/" + str(r.randint(23, 26)) + "}"),
"K = {}".format("{" + str(r.randint(5, 6)) + "; " + str(r.randint(20, 25)) + "/" + str(r.randint(7, 11)) + "}")
]
# Counter
c = 0
p = 0
click = pygame.time.get_ticks()
# Buttons
correct = Button(20, 190, 120, 50, fg=BLACK, bg=GREEN, content="Correct", fontsize=32)
incorrect = Button(500, 190, 120, 50, fg=BLACK, bg=RED, content="Wrong", fontsize=32)
# Background
bg = pygame.Rect(0, 0, 640, 480)
paper = pygame.image.load("img/paper.png")
paper_rect = paper.get_rect(x=20, y=0)
while grading:
# Position and click of the mouse
mouse_pos = pygame.mouse.get_pos()
mouse_pressed = pygame.mouse.get_pressed()
# Events
for event in pygame.event.get():
# Close button
if event.type == pygame.QUIT: self.game.exiting()
# Keyboard
if event.type == pygame.KEYDOWN:
# Escape
if event.key == pygame.K_ESCAPE: grading = False
if correct.is_pressed(mouse_pos, mouse_pressed) and click + 1000 < pygame.time.get_ticks():
if ans == correct_ans[c]: p += 1
c += 1
click = pygame.time.get_ticks()
if incorrect.is_pressed(mouse_pos, mouse_pressed) and click + 1000 < pygame.time.get_ticks():
if ans != correct_ans[c]: p += 1
c += 1
click = pygame.time.get_ticks()
if c == len(questions): break
# Background
pygame.draw.rect(self.game.screen, BROWN, bg)
self.game.screen.blit(paper, paper_rect)
# Question
self.game.screen.blit(questions[c], (200, 200))
# Anwer
ans = self.game.font.render(answers[c], True, BLACK)
self.game.screen.blit(ans, (250, 250))
# Buttons
self.game.screen.blit(correct.image, correct.rect)
self.game.screen.blit(incorrect.image, incorrect.rect)
# Updates
self.game.clock.tick(FPS)
pygame.display.update()
# After grading
self.game.draw(); self.game.update()
# Bananky
self.game.talking("Here, take these bananky as reward for helping me.", True, LIGHTBLUE) if p > 0 else self.game.talking("You didn't help at all. No bananky for you.", True, LIGHTBLUE)
if "bananok" in self.game.inv.keys(): self.game.number_bananok += p * 9
else: self.game.inv["bananok"] = "img/bananok.png"; self.game.number_bananok += p * 9
def router(self):
"""
Connecting router\n
If someone knows how to make it look like they are connected pls do cause I don't want to think
"""
connecting = True
exited = False
# Background
bg = pygame.image.load("img/router.png")
# Button
back_button = Button(10, 400, 120, 50, fg=WHITE, bg=BLACK, content="Back", fontsize=32)
done_button = Button(500, 400, 120, 50, fg=WHITE, bg=BLACK, content="Done", fontsize=32)
# Clickable router
a1 = pygame.Rect(313, 330, 35, 33)
a2 = pygame.Rect(348, 330, 33, 33)
a3 = pygame.Rect(381, 330, 34, 33)
a4 = pygame.Rect(415, 330, 34, 33)
ans = 0
answers = [0, 0, 0, 0]
# Cables
start1 = (232, 112)
start2 = (312, 112)
start3 = (392, 112)
start4 = (472, 112)
end1 = (232, 112)
end2 = (312, 112)
end3 = (392, 112)
end4 = (472, 112)
ends = [end1, end2, end3, end4]
first_rect = pygame.Rect(200, 80, 64, 64)
second_rect = pygame.Rect(280, 80, 64, 64)
third_rect = pygame.Rect(360, 80, 64, 64)
fourth_rect = pygame.Rect(440, 80, 64, 64)
# 023
if self.game.saved_room_data == "023":
# Router
first_text = self.game.font.render("W", True, WHITE)
second_text = self.game.font.render("B", True, BLUE)
third_text = self.game.font.render("R", True, RED)
fourth_text = self.game.font.render("G", True, GREEN)
# Colors
colors = [WHITE, BLUE, RED, GREEN]
# Correct
correct = [1, 3, 4, 2]
# 130
elif self.game.saved_room_data == "130":
# Router
first_text = self.game.font.render("G", True, GREEN)
second_text = self.game.font.render("W", True, WHITE)
third_text = self.game.font.render("B", True, BLUE)
fourth_text = self.game.font.render("R", True, RED)
# Colors
colors = [GREEN, WHITE, BLUE, RED]
# Correct
correct = [2, 4, 1, 3]
# 217
elif self.game.saved_room_data == "217":
# Router
first_text = self.game.font.render("R", True, RED)
second_text = self.game.font.render("G", True, GREEN)
third_text = self.game.font.render("B", True, BLUE)
fourth_text = self.game.font.render("W", True, WHITE)
# Colors
colors = [RED, GREEN, BLUE, WHITE]
# Correct
correct = [3, 1, 2, 4]
# 402
elif self.game.saved_room_data == "402":
# Route
first_text = self.game.font.render("B", True, BLUE)
second_text = self.game.font.render("R", True, RED)
third_text = self.game.font.render("G", True, GREEN)
fourth_text = self.game.font.render("W", True, WHITE)
# Colors
colors = [BLUE, RED, GREEN, WHITE]
# Correct
correct = [4, 2, 3, 1]
while connecting:
# Position and click of the mouse
mouse_pos = pygame.mouse.get_pos()
mouse_pressed = pygame.mouse.get_pressed()
# Buttons pressed
if back_button.is_pressed(mouse_pos, mouse_pressed): connecting = False; exited = True
if done_button.is_pressed(mouse_pos, mouse_pressed): connecting = False
# Events
for event in pygame.event.get():
# Close button
if event.type == pygame.QUIT: self.game.exiting()
# Keyboard
if pygame.KEYDOWN == event.type:
# Escape
if event.key == pygame.K_ESCAPE: connecting = False; exited = True
# Enter
if event.key == pygame.K_RETURN: connecting = False
# Mouse
elif event.type == pygame.MOUSEBUTTONDOWN:
# First rect
if first_rect.collidepoint(event.pos): ans = 1
# Second rect
elif second_rect.collidepoint(event.pos): ans = 2
# Third rect
elif third_rect.collidepoint(event.pos): ans = 3
# Fourth rect
elif fourth_rect.collidepoint(event.pos): ans = 4
# First rect
elif a1.collidepoint(event.pos):
if ans != 0: answers[ans-1] = 1; ends[ans-1] = (330, 346)
# Second rect
elif a2.collidepoint(event.pos):
if ans != 0: answers[ans-1] = 2; ends[ans-1] = (364, 346)
# Third rect
elif a3.collidepoint(event.pos):
if ans != 0: answers[ans-1] = 3; ends[ans-1] = (398, 346)
# Fourth rect
elif a4.collidepoint(event.pos):
if ans != 0: answers[ans-1] = 4; ends[ans-1] = (432, 346)
# Background
self.game.screen.blit(bg, (0, 0))
# Button
self.game.screen.blit(back_button.image, back_button.rect)
self.game.screen.blit(done_button.image, done_button.rect)
# Clickable router