-
Notifications
You must be signed in to change notification settings - Fork 0
/
text_preparer.py
116 lines (94 loc) · 4.2 KB
/
text_preparer.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
import texts
class TextPreparer(object):
"""
Class for prepare text for show and text for speak from text.py
"""
def init(self):
pass
@staticmethod
def say_do_not_get(command_text, attempt):
not_get = texts.not_get_move.format(command_text)
not_get_tts = not_get
# if attempt % 3 == 1:
# # every N case try to remember of
# not_get += texts.names_for_files.format('', '', '', '', '', '', '')
# not_get_tts += texts.names_for_files.format('sil <[60]>',
# 'sil <[60]>',
# 'sil <[60]>',
# 'sil <[60]>',
# 'sil <[60]>',
# 'sil <[60]>',
# 'sil <[60]>')
# not_get += texts.names_for_pieces.format('', '', '', '', '')
# not_get_tts += texts.names_for_pieces.format('sil <[70]>',
# 'sil <[60]>',
# 'sil <[60]>',
# 'sil <[60]>',
# 'sil <[60]>')
#
# not_get += texts.coord_rules.format('Слон d3')
# not_get_tts += texts.coord_rules.format('Слон дэ 3')
return not_get, not_get_tts
@staticmethod
def say_your_move(comp_move='', move_to_say='', prev_turn='',
prev_turn_tts='', text_to_show='', text_to_say=''):
# form speech for your move
text = text_to_show if text_to_show else ''
tts = text_to_say if text_to_say else ''
if prev_turn:
# if previous turn was given
tts += f'{prev_turn_tts} пошли '
text += f'{prev_turn_tts} пошли '
if comp_move:
# if comp move was given
# move_to_say = speaker.say_move(comp_move, 'ru')
text += f'{comp_move}. '
tts += f'{move_to_say}. '
text += 'Ваш ход!'
tts += 'Ваш ход!'
return text, tts
@staticmethod
def say_not_legal_move(user_move, say_user_move):
text = texts.not_legal_move.format(user_move)
tts = texts.not_legal_move.format(say_user_move)
return text, tts
@staticmethod
def say_result(comp_move, comp_move_tts, reason, reason_tts,
prev_turn_tts):
winner = ''
if reason == '#':
winner = 'Победили ' + prev_turn_tts
text = texts.gameover_text.format(comp_move, '', reason_tts,
winner)
text_tts = texts.gameover_text.format(comp_move_tts, 'sil <[70]>',
reason_tts, winner)
return text, text_tts
@staticmethod
def say_choose_color():
text = texts.choose_turn_text
text_tts = text
return text, text_tts
@staticmethod
def say_undo_unavailable():
text = texts.undo_unavailable.strip()
text_tts = text
return text, text_tts
@staticmethod
def say_help_text():
text = texts.help_text_intro
text_tts = texts.help_text_intro
text += texts.names_for_pieces.format('', '', '', '', '')
text_tts += texts.names_for_pieces.format('sil <[70]>',
'sil <[60]>',
'sil <[60]>',
'sil <[60]>',
'sil <[60]>')
text += texts.coord_rules.format('Слон d3')
text_tts += texts.coord_rules.format('Слон дэ 3')
text += texts.undo_unavailable
text_tts += texts.undo_unavailable
text += texts.engine_info
text_tts += texts.engine_info
# text += texts.current_level_text.format(level)
# text_tts += texts.current_level_text.format(level)
return text, text_tts