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 p(string:str, style='standard',richTextJudge=True): ''' 游戏基础的文本绘制实现 Keyword arguments: string -- 需要绘制的文本 style -- 文本的默认样式 (default 'standard') richTextJudge -- 启用富文本的开关 (default True) ''' if richTextJudge: barlist = TextLoading.getTextData(TextLoading.barConfigPath,'barlist') styleList = RichText.setRichTextPrint(string, style) global last_char if len(string) > 0: last_char = string[-1:] string = RichText.removeRichCache(string) string = r'' + string for i in range(0,len(string)): if styleList[i] in barlist: styledata = TextLoading.getTextData(TextLoading.barConfigPath,styleList[i]) truebar = styledata['truebar'] nullbar = styledata['nullbar'] if string[i] == '0': pimage(nullbar, 'bar') elif string[i] == '1': pimage(truebar, 'bar') else: IoInit.eraPrint(string[i], styleList[i]) else: IoInit.eraPrint(string[i], styleList[i]) else: IoInit.eraPrint(string,style)
def askfor_All(list, print_order=False): while True: order = order_deal('str', print_order) if order in list: IoInit.eraPrint(order + '\n') return order elif order == '': continue else: IoInit.eraPrint(order + '\n') IoInit.eraPrint( TextLoading.getTextData(TextLoading.errorPath, 'noInputListError') + '\n') continue
def askfor_All(list, print_order=False): ''' 用于请求一个位于列表中的输入,如果输入没有在列表中,则告知用户出错。 Keyword arguments: list -- 用于判断的列表内容 print_order -- 是否将输入的order输出到屏幕上 ''' while True: order = order_deal('str', print_order) if order in list: IoInit.eraPrint(order + '\n') return order elif order == '': continue else: IoInit.eraPrint(order + '\n') IoInit.eraPrint( TextLoading.getTextData(TextLoading.errorPath, 'noInputListError') + '\n') continue