def start_game(self): label = self.get_label() game = SimpleGame(label, self._dir_name) game.start_game() print(f'{self._user.get_strings()["press"]}') while getch.getch() != '\r': pass
def start_enemy_game(self): label = self.get_label() speed = self._user.stat['max_speed'] game = EnemyGame(speed + 5, label, self._dir_name) game.start_game() print(f'{self._user.get_strings()["press"]}') while getch.getch() != '\r': pass
def run(self): if not os.path.exists(f'{settings.PATH}/statistics.json'): self.change_name() while True: self.print_options() option = getch.getch() if option in self._actions: self._actions[option]() if option == "5": break self._user.load_statistics()
def get_label(self, text_storage, text_name): print(self._strings['label']) print(f"1. {self._strings['yes']}") print(f"2. {self._strings['no']}") choice = getch.getch() label = None if choice == "1": label = input(self._strings['write_label']) if label is not None: text_storage.add_label(text_name, label)
def get_label(self): print(self._strings['choose_label']) print(f"1. {self._strings['choose_label_yes']}") print(f"2. {self._strings['choose_label_no']}") choice = getch.getch() if choice == "1": print(self.get_all_labels()) label = input(self._strings['write_label']) if label in self._text_st.get_all_labels(): return label else: return None elif choice == "2": return None
def show_stat(self): SimpleGame.clear() stat = self._user.get_stat() res = f'{self._strings["user"]} {self._user.name}\n' \ f'{self._strings["text_count"]}: {stat["text_count"]}\n' \ f'{self._strings["symbol_count"]}: {stat["symbol_count"]}\n' \ f'{self._strings["average_speed"]}: {stat["average_speed"]} ' \ f'{self._strings["speed"]}\n' \ f'{self._strings["average_errors"]}: {stat["average_errors"]}\n' \ f'{self._strings["dynamics"]}:\n' dynamic = stat['dynamic'] for k, v in dynamic.items(): res += f'{k}: {v["average_speed"]} {self._strings["speed"]}\n' print(res) print(f'{self._user.get_strings()["press"]}') while getch.getch() != '\r': pass
def get_user_input(self): key = getch.getch() if key == '\x1b': return None return key