-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathg_all_once.py
81 lines (55 loc) · 2.92 KB
/
g_all_once.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
from game import Game
import pygame
import constants
from strings_on_screen import StringImage
from letter_handler import LetterHandler
class GameAllOnce(Game):
def __init__(self):
super().__init__()
self.mode_name = self.trans.tr('In order', self.lang)
if self.letter_case == "Both":
self.letter_case = "Both In Order"
self.letter_handler = None
self.set_letter_handler()
self.string_in_use = self.letter_handler.set_letter_in_use()
self.string_image = StringImage(self.font_path, self.string_in_use, self.screen, 1800, 0, 0, self.background_color, self.text_color)
#self.mt_unique_txt = self.menu_texts[self.lang_code]["Unique"]
pygame.display.set_caption(f"{self.caption} - {self.mode_name}")
def set_letter_handler(self):
self.letter_handler = LetterHandler("", 1, 9999, self.lang, 1, self.letter_case, self.excluded_chars)
def init_extended(self):
self.draw_mode_welcome()
self.tts.queue_text(self.mode_name, False)
if self.instructions:
self.tts.queue_text(self.trans.tr('Press', self.lang))
self.tts.queue_text(self.string_in_use)
def win(self):
self.tts.queue_text(self.trans.tr('Passed', self.lang))
self.tts.queue_text(f"{self.user_name}!")
self.tts.queue_text(self.trans.tr('Very good', self.lang))
self.progress = constants.PROGRESS_WIN
def handle_correct_key_pressed(self, key_pressed):
more_letters = True
if not self.letter_handler.available_letters and not self.letter_handler.letters_to_add:
more_letters = False
else:
self.letter_handler.check_add_letter_counter()
if not more_letters and self.progress != constants.PROGRESS_WIN:
self.win()
else:
self.tts.queue_text(f"{key_pressed}", True)
self.string_in_use = self.letter_handler.set_letter_in_use()
if self.string_in_use:
if self.instructions:
self.tts.queue_text(self.trans.tr('Take', self.lang))
self.tts.queue_text(self.string_in_use)
self.draw()
self.string_image = StringImage(self.font_path, self.string_in_use, self.screen, 1800, 0, 0, self.background_color, self.text_color)
else:
self.win()
def handle_key_pressed(self, key_pressed):
if key_pressed.upper() == self.string_in_use.upper():
self.handle_correct_key_pressed(key_pressed)
return
self.tts.queue_text(f"{self.trans.tr('Try', self.lang)} {self.string_in_use}", True)
self.letter_handler.correct_counter = 0