def order_deal(flag='order', print_order=True): ''' 处理命令函数 Keyword arguments: flag -- 类型,默认为order,如果为console,这回执行输入得到的内容 print_order -- 是否将输入的order输出到屏幕上 ''' global __skip_flag__ __skip_flag__ = False while True: time.sleep(0.01) while not IoInit._order_queue.empty(): order = IoInit.getorder() if CacheContorl.flowContorl['quitGame']: os._exit(0) if CacheContorl.flowContorl['restartGame'] == 1: CacheContorl.flowContorl['restartGame'] = 0 reset_func() return if print_order == True and order != '': IoInit.eraPrint('\n' + order + '\n') if flag == 'str': if order.isdigit(): order = str(int(order)) return order if flag == 'console': exec(order) if flag == 'order' and order.isdigit(): if _cmd_valid(int(order)): _cmd_deal(int(order)) return else: global tail_deal_cmd_func tail_deal_cmd_func(int(order)) return
def order_deal(flag='order', print_order=True): global __skip_flag__ __skip_flag__ = False while True: time.sleep(0.01) while not IoInit._order_queue.empty(): order = IoInit.getorder() if CacheContorl.flowContorl['quitGame']: os._exit(0) return if CacheContorl.flowContorl['restartGame'] == 1: CacheContorl.flowContorl['restartGame'] = 0 reset_func() return if print_order == True and order != '': IoInit.print('\n' + order + '\n') if flag == 'str': return order if flag == 'console': # TODO add_console_method exec(order) if flag == 'order' and order.isdigit(): if _cmd_valid(int(order)): _cmd_deal(int(order)) return else: global tail_deal_cmd_func tail_deal_cmd_func(int(order)) return