def enter_character_nature_func(): """ 请求玩家确认性格流程 """ cache_contorl.character_data["character"][0].init_attr() while 1: py_cmd.clr_cmd() creator_character_panel.enter_character_nature_head() input_s = see_nature_panel.see_character_nature_change_panel(0) input_s += creator_character_panel.enter_character_nature_end() yrn = game_init.askfor_all(input_s) if yrn in cache_contorl.character_data["character"][0].nature: if cache_contorl.character_data["character"][0].nature[yrn] < 50: cache_contorl.character_data["character"][0].nature[ yrn ] = random.uniform(50, 100) else: cache_contorl.character_data["character"][0].nature[ yrn ] = random.uniform(0, 50) elif int(yrn) == 0: cache_contorl.character_data["character"][0].init_attr() cache_contorl.now_flow_id = "acknowledgment_attribute" break elif int(yrn) == 1: cache_contorl.character_data["character"][ 0 ].nature = nature.get_random_nature()
def confirmation_overlay_save_func(save_id: str): """ 覆盖存档询问流程 玩家输入0:对存档进行覆盖 Keyword arguments: save_id -- 存档id """ cmd_list = save_handle_frame_panel.confirmation_overlay_save_panel() yrn = game_init.askfor_all(cmd_list) py_cmd.clr_cmd() if yrn == "0": save_handle.establish_save(save_id)
def confirmation_remove_save_func(save_id: str): """ 覆盖存档询问流程 玩家输入0:删除指定存档 Keyword arguments: save_id -- 存档id """ cmd_list = save_handle_frame_panel.confirmation_remove_save_panel() yrn = game_init.askfor_all(cmd_list) if yrn == "0": save_handle.remove_save(save_id) py_cmd.clr_cmd()
def confirmation_load_save_func(save_id: str): """ 读取存档询问流程 玩家输入0:读取指定存档 Keyword arguments: save_id -- 存档id """ cmd_list = save_handle_frame_panel.confirmation_load_save_panel() yrn = game_init.askfor_all(cmd_list) py_cmd.clr_cmd() if yrn == "0": save_handle.input_load_save(save_id) cache_contorl.now_flow_id = "main" return True return False
def ask_for_load_save_func(save_id: str): """ 读档处理询问流程 玩家输入0:进入读取存档询问流程 玩家输入1:进入删除存档询问流程 Keyword arguments: save_id -- 存档id """ cmd_list = save_handle_frame_panel.ask_load_save_panel() yrn = game_init.askfor_all(cmd_list) py_cmd.clr_cmd() if yrn == "0": return confirmation_load_save_func(save_id) elif yrn == "1": confirmation_remove_save_func(save_id) return False
def ask_for_overlay_save_func(save_id: str): """ 存档处理询问流程 玩家输入0:进入覆盖存档询问流程 玩家输入1:进入删除存档询问流程 Keyword arguments: save_id -- 存档id """ cmd_list = save_handle_frame_panel.ask_for_overlay_save_panel() yrn = game_init.askfor_all(cmd_list) yrn = str(yrn) py_cmd.clr_cmd() if yrn == "0": confirmation_overlay_save_func(save_id) elif yrn == "1": confirmation_remove_save_func(save_id)
def see_character_list_func(): """ 用于查看角色列表的流程 """ while True: max_page = get_character_list_page_max() input_s = [] see_character_list_panel_input = see_character_list_panel.see_character_list_panel( max_page ) start_id = len(see_character_list_panel_input) input_s = input_s + see_character_list_panel_input ask_for_see_character_list_panel_input = see_character_list_panel.ask_for_see_character_list_panel( start_id ) input_s = input_s + ask_for_see_character_list_panel_input yrn = game_init.askfor_all(input_s) yrn = str(yrn) character_id_list = cache_contorl.character_data.keys() page_id = int(cache_contorl.panel_state["SeeCharacterListPanel"]) if yrn == str(start_id): if page_id == 0: cache_contorl.panel_state["SeeCharacterListPanel"] = str( max_page ) else: page_id = str(page_id - 1) cache_contorl.panel_state["SeeCharacterListPanel"] = page_id elif yrn == str(start_id + 1): cache_contorl.character_data[0].target_character_id = 0 cache_contorl.panel_state["SeeCharacterListPanel"] = "0" cache_contorl.now_flow_id = cache_contorl.old_flow_id break elif yrn == str(start_id + 2): if page_id == max_page: cache_contorl.panel_state["SeeCharacterListPanel"] = "0" else: page_id = str(page_id + 1) cache_contorl.panel_state["SeeCharacterListPanel"] = page_id elif int(yrn) + character_page_show * page_id in character_id_list: yrn = int(yrn) + character_page_show * page_id cache_contorl.character_data[0].target_character_id = yrn cache_contorl.now_flow_id = "see_character_attr" cache_contorl.too_old_flow_id = cache_contorl.old_flow_id cache_contorl.old_flow_id = "see_character_list" break
def main_frame_func(): """ 游戏主页控制流程 """ input_s = [] flow_return = main_frame_panel.main_frame_panel() input_s = input_s + flow_return character_id = cache_contorl.character_data["character_id"] character_data = cache_contorl.character_data["character"][character_id] character_name = character_data.name ans = game_init.askfor_all(input_s) py_cmd.clr_cmd() cache_contorl.old_flow_id = "main" if ans == character_name: cache_contorl.now_flow_id = "see_character_attr" else: if ans == "0": clothing.init_character_clothing_put_on() cache_contorl.now_flow_id = main_frame_goto_data[ans]
def see_scene_func(judge: bool): """ 用于查看当前场景界面的流程 Keyword argument: judge -- 判断是否绘制角色列表界面的开关 """ while True: input_s = [] in_scene_panel.see_scene_panel() scene_path = cache_contorl.character_data["character"][0].position scene_path_str = map_handle.get_map_system_path_str_for_list( scene_path ) scene_character_name_list = map_handle.get_scene_character_name_list( scene_path_str ) name_list_max = int(game_config.in_scene_see_player_max) change_page_judge = False if len(scene_character_name_list) == 1: cache_contorl.character_data["character_id"] = 0 in_scene_cmd_list_1 = [] if judge: if cache_contorl.panel_state["SeeSceneCharacterListPage"] == "0": input_s = ( input_s + in_scene_panel.see_scene_character_list_panel() ) if len(scene_character_name_list) > name_list_max: in_scene_cmd_list_1 = ( in_scene_panel.change_scene_character_list_panel() ) change_page_judge = True input_s.append("SeeSceneCharacterListPage") start_id_1 = len(in_scene_cmd_list_1) in_scene_panel.see_character_info_panel() see_character_attr_panel.see_character_hp_and_mp_in_sence( cache_contorl.character_data["character_id"] ) see_character_attr_panel.see_character_status_panel( cache_contorl.character_data["character_id"] ) instruct_head = instruct_panel.see_instruct_head_panel() in_scene_cmd_list_2 = in_scene_panel.in_scene_button_panel(start_id_1) if change_page_judge: input_s += ( in_scene_cmd_list_1 + instruct_head + in_scene_cmd_list_2 ) else: input_s += instruct_head + in_scene_cmd_list_2 yrn = game_init.askfor_all(input_s) py_cmd.clr_cmd() now_page = int(cache_contorl.panel_state["SeeSceneCharacterListPanel"]) character_max = len(cache_contorl.character_data["character"]) - 1 page_max = math.floor(character_max / name_list_max) if yrn in scene_character_name_list: cache_contorl.character_data[ "character_id" ] = map_handle.get_character_id_by_character_name( yrn, scene_path_str ) elif ( judge and yrn not in in_scene_cmd_list_2 and yrn != "SeeSceneCharacterListPage" and change_page_judge ): if yrn == in_scene_cmd_list_1[0]: cache_contorl.panel_state["SeeSceneCharacterListPanel"] = 0 elif yrn == in_scene_cmd_list_1[1]: if int(now_page) == 0: cache_contorl.panel_state[ "SeeSceneCharacterListPanel" ] = page_max else: cache_contorl.panel_state["SeeSceneCharacterListPanel"] = ( int(now_page) - 1 ) elif yrn == in_scene_cmd_list_1[2]: cache_contorl.panel_state[ "SeeSceneCharacterListPanel" ] = in_scene_panel.jump_character_list_page_panel() elif yrn == in_scene_cmd_list_1[3]: if int(now_page) == page_max: cache_contorl.panel_state["SeeSceneCharacterListPanel"] = 0 else: cache_contorl.panel_state["SeeSceneCharacterListPanel"] = ( int(now_page) + 1 ) elif yrn == in_scene_cmd_list_1[4]: cache_contorl.panel_state[ "SeeSceneCharacterListPanel" ] = page_max elif yrn == in_scene_cmd_list_2[0]: cache_contorl.now_flow_id = "see_map" now_map = map_handle.get_map_for_path( cache_contorl.character_data["character"][0].position ) cache_contorl.now_map = now_map break elif yrn in [in_scene_cmd_list_2[1], in_scene_cmd_list_2[2]]: if yrn == in_scene_cmd_list_2[2]: cache_contorl.old_character_id = cache_contorl.character_data[ "character_id" ] cache_contorl.character_data["character_id"] = 0 cache_contorl.now_flow_id = "see_character_attr" cache_contorl.old_flow_id = "in_scene" break elif yrn == "SeeSceneCharacterListPage": panel_state_handle.panel_state_change(yrn) elif yrn in instruct_head: if cache_contorl.instruct_filter[yrn] == 0: cache_contorl.instruct_filter[yrn] = 1 else: cache_contorl.instruct_filter[yrn] = 0
def see_attr_on_every_time_func(): """ 通用用于查看角色属性的流程 """ while True: character_id = cache_contorl.character_data[0].target_character_id if cache_contorl.old_flow_id == "in_scene": now_scene = cache_contorl.character_data[0].position now_scene_str = map_handle.get_map_system_path_str_for_list( now_scene ) character_id_list = map_handle.get_scene_character_id_list( now_scene_str ) else: character_id_list = list(cache_contorl.character_data.keys()) character_id_index = character_id_list.index(character_id) input_s = [] see_attr_in_every_time_func() ask_see_attr = see_character_attr_panel.ask_for_see_attr() input_s += ask_see_attr inputs_1 = see_character_attr_panel.ask_for_see_attr_cmd() input_s += inputs_1 yrn = game_init.askfor_all(input_s) py_cmd.clr_cmd() show_attr_handle_data = text_loading.get_text_data( constant.FilePath.CMD_PATH, "seeAttrPanelHandle" ) character_max = character_id_list[len(character_id_list) - 1] if yrn in show_attr_handle_data: cache_contorl.panel_state["AttrShowHandlePanel"] = yrn elif yrn == "0": if character_id_index == 0: cache_contorl.character_data[ 0 ].target_character_id = character_max else: character_id = character_id_list[character_id_index - 1] cache_contorl.character_data[ 0 ].target_character_id = character_id elif yrn == "1": if cache_contorl.old_flow_id == "main": cache_contorl.character_data[0].target_character_id = 0 elif cache_contorl.old_flow_id == "see_character_list": character_list_show = int(game_config.character_list_show) now_page_id = character_id_index / character_list_show cache_contorl.panel_state[ "SeeCharacterListPanel" ] = now_page_id elif cache_contorl.old_flow_id == "in_scene": scene_path = cache_contorl.character_data[0].position scene_path_str = map_handle.get_map_system_path_str_for_list( scene_path ) name_list = map_handle.get_scene_character_name_list( scene_path_str, True ) now_character_name = cache_contorl.character_data[ cache_contorl.character_data[0].target_character_id ].name try: now_character_index = name_list.index(now_character_name) except ValueError: now_character_index = 0 name_list_max = int(game_config.in_scene_see_player_max) now_scene_character_list_page = math.floor( now_character_index / name_list_max ) cache_contorl.panel_state[ "SeeSceneCharacterListPanel" ] = now_scene_character_list_page cache_contorl.panel_state["AttrShowHandlePanel"] = "MainAttr" cache_contorl.now_flow_id = cache_contorl.old_flow_id cache_contorl.old_flow_id = cache_contorl.too_old_flow_id break elif yrn == "2": if character_id == character_max: character_id = character_id_list[0] cache_contorl.character_data[ 0 ].target_character_id = character_id else: character_id = character_id_list[character_id_index + 1] cache_contorl.character_data[ 0 ].target_character_id = character_id
def option_str( cmd_list: str, cmd_column=1, cmd_size="left", last_line=False, askfor=True, cmd_list_data=None, null_cmd="", return_data=None, normal_style_data={}, on_style_data={}, ) -> list: """ 绘制无id的文本命令列表 例: [长寿的青蛙] Keyword arguments: cmd_list -- 命令列表id,当cmd_list_data为None时,根据此id调用cmd_list内的命令数据 cmd_column -- 每行命令列数 (default 1) cmd_size -- 命令文本在当前列的对齐方式(left/center/right) (default 'left') last_line -- 最后一个命令换行绘制 (default False) cmd_list_data -- 命令列表数据 (default None) null_cmd -- 在列表中按纯文本绘制,并不加入监听列表的命令文本 return_data -- 命令返回数据 (default None) normal_style_data -- 按钮通常样式列表 on_style_data -- 按钮被按下时样式列表 """ if cmd_list_data is None: cmd_list_data = text_loading.get_text_data( constant.FilePath.CMD_PATH, cmd_list ).copy() input_s = [] text_width = game_config.text_width if last_line: if len(cmd_list_data) - 1 < cmd_column: cmd_column = len(cmd_list_data) - 1 else: if len(cmd_list_data) < cmd_column: cmd_column = len(cmd_list_data) cmd_index = int(text_width / cmd_column) now_null_cmd = null_cmd for i in range(0, len(cmd_list_data)): normal_style = "standard" on_style = "onbutton" if cmd_list_data[i] in normal_style_data: normal_style = normal_style_data[cmd_list_data[i]] if cmd_list_data[i] in on_style_data: on_style = on_style_data[cmd_list_data[i]] now_null_cmd = True if return_data is None: if null_cmd == cmd_list_data[i]: now_null_cmd = False cmd_text_bak = dictionaries.handle_text(cmd_list_data[i]) cmd_text = "[" + cmd_text_bak + "]" else: if null_cmd == return_data[i]: now_null_cmd = False cmd_text_bak = return_data[i] cmd_text = "[" + cmd_list_data[i] + "]" if i == 0: cmd_size_print( cmd_text, cmd_text_bak, None, cmd_index, cmd_size, now_null_cmd, normal_style, on_style, ) if now_null_cmd: input_s.append(cmd_text_bak) elif i / cmd_column >= 1 and i % cmd_column == 0: era_print.line_feed_print() cmd_size_print( cmd_text, cmd_text_bak, None, cmd_index, cmd_size, now_null_cmd, normal_style, on_style, ) if now_null_cmd: input_s.append(cmd_text_bak) elif i == len(cmd_list_data) - 1 and last_line: era_print.line_feed_print() cmd_size_print( cmd_text, cmd_text_bak, None, cmd_index, cmd_size, now_null_cmd, normal_style, on_style, ) if now_null_cmd: input_s.append(cmd_text_bak) else: cmd_size_print( cmd_text, cmd_text_bak, None, cmd_index, cmd_size, now_null_cmd, normal_style, on_style, ) if now_null_cmd: input_s.append(cmd_text_bak) era_print.line_feed_print() if askfor: ans = game_init.askfor_all(input_s) return ans else: return input_s