def exeSYS(self): code = self._mem[self._pc] if code == 0: self._Acc = ord(utilities.getch()) elif code == 1: sys.stdout.write(chr(self._Acc)) self._pc += 1
def main_loop(self): self.__game.load_top_scores('data.bin') self.__game.start() while self.__game.get_state() == State.running: self.refresh() char = getch() self.user_input(char) if char == chr(26): break if self.__game.get_state() == State.game_over: print('Game Over!') if self.__game.check_score(): print('Your score is within the top 10!') print('Enter your name:') name = input() score = self.__game.score() while not match(r'[a-zA-Z0-9]', name): print('\'{}\' is not a valid name.'.format(name)) print('Please try again.') print('Enter your name:') name = input() self.__game.add_player_to_chart(name, score) print('\nHigh Scores') self.print_high_scores() self.__game.save_top_scores('data.bin') print('Do you want to play again? y/n') choice = input() if choice == 'y' or choice == 'Y': self.__game.change_state(State.running) self.__game.reset() if self.__game.get_state() == State.game_won: self.refresh() print('Congratulations! You reached 2048!') print('Do you want to continue to play? y/n') choice = input() if choice == 'y' or choice == 'Y': self.__game.change_state(State.running) else: if self.__game.check_score(): print('Your score is within the top 10!') print('Enter your name:') name = input() score = self.__game.score() while not match(r'[a-zA-Z0-9]', name): print('\'{}\' is not a valid name.'.format(name)) print('Please try again.') print('Enter your name:') name = input() self.__game.add_player_to_chart(name, score) print('\nHigh Scores') self.print_high_scores() self.__game.save_top_scores('data.bin')
def explore_node(asker, root, parents): asker.update(is_pointer_now(), root) while True: #TODO print the parents root = asker.refresh(root) lines = asker.ask(outline_to_lines(root)).firm_answer utilities.clear() asker.ask(print_lines_simple(lines)) c = utilities.getch() if c == 'q': return asker.reply() else: root = asker.refresh(root) asker.ask(process_char(root, T.from_char(c), parents))