from modules.conditional_judgement_module import judgment_module from modules.chat_module import chat_module from modules.interact_module import interact_module from utils.configuration import Configuration import argparse parser = argparse.ArgumentParser(description="生成文字游戏") parser.add_argument("-n", "--name", required=True, help="config文件夹中配置的文件夹名称") parser.add_argument("-t", "--type", required=True, help="开始的第一个组件的类型") parser.add_argument("-c", "--classname", required=True, help="开始的第一个组件的classname") parser.add_argument("-i", "--id", required=True, help="开始的第一个组件的id") args = parser.parse_args() next_module = { "type": args.type, "class": args.classname, "id": eval(args.id) } configuration=Configuration(args.name) while True: if next_module["type"]=="Chat": input_path,prompt_input_declare,prompt_path,output,next_module_temp=configuration.read_chat_config(next_module["class"],next_module["id"]) prompt_input_value=configuration.input_process(input_path,prompt_input_declare) prompt=configuration.read_prompt(prompt_path) chat_module(next_module["class"],next_module["id"],prompt_input_value,prompt,output) next_module=next_module_temp elif next_module["type"]=="Judgement": input_path,judgement_input_declare,value,judgement=configuration.read_judgement_config(next_module["class"],next_module["id"]) judgement_input_value=configuration.input_process(input_path,judgement_input_declare) next_module=judgment_module(judgement_input_value,value,judgement) elif next_module["type"]=="Interact": input,choices,output,next_module_temp=configuration.read_interact_config(next_module["class"],next_module["id"]) choices_value=configuration.interact_input_process(input,choices) interact_module(next_module["class"],next_module["id"],choices_value,output) next_module=next_module_temp else: break