Example #1
0
def character_move(character_id: str, target_scene: list) -> (str, list, list, int):
    """
    通用角色移动控制
    Keyword arguments:
    character_id -- 角色id
    target_scene -- 寻路目标场景(在地图系统下的绝对坐标)
    Return arguments:
    str:null -- 未找到路径
    str:end -- 当前位置已是路径终点
    list -- 路径
    list -- 本次移动到的位置
    int -- 本次移动花费的时间
    """
    now_position = cache.character_data[character_id].position
    if now_position == target_scene:
        return "end", [], [], 0
    now_position_str = map_handle.get_map_system_path_str_for_list(now_position)
    target_scene_str = map_handle.get_map_system_path_str_for_list(target_scene)
    if (
        now_position_str not in map_handle.scene_path_edge
        or target_scene_str not in map_handle.scene_path_edge[now_position_str]
    ):
        return "null", [], [], 0
    now_path_data = map_handle.scene_path_edge[now_position_str][target_scene_str]
    return "", [], now_path_data[0], now_path_data[1]
Example #2
0
def see_scene_panel():
    """
    当前场景信息面板
    """
    title_text = text_loading.get_text_data(constant.FilePath.STAGE_WORD_PATH,
                                            "75")
    era_print.little_title_print(title_text)
    time_text = game_time.get_date_text()
    era_print.normal_print(time_text)
    era_print.normal_print(" ")
    scene_path = cache_contorl.character_data["character"][0].position
    scene_path_str = map_handle.get_map_system_path_str_for_list(scene_path)
    map_list = map_handle.get_map_hierarchy_list_for_scene_path(scene_path, [])
    map_path_text = ""
    map_list.reverse()
    for now_map in map_list:
        now_map_map_system_str = map_handle.get_map_system_path_str_for_list(
            now_map)
        map_name = cache_contorl.map_data[now_map_map_system_str]["MapName"]
        map_path_text += map_name + "-"
    scene_data = cache_contorl.scene_data[scene_path_str].copy()
    scene_name = map_path_text + scene_data["SceneName"]
    scene_info_head = text_loading.get_text_data(
        constant.FilePath.STAGE_WORD_PATH, "76")
    scene_info = scene_info_head + scene_name
    era_print.normal_print(scene_info)
    panel_state = cache_contorl.panel_state["SeeSceneCharacterListPage"]
    switch = panel_state_on_text
    if panel_state == "0":
        switch = panel_state_off_text
    scene_character_list = scene_data["SceneCharacterData"]
    if len(scene_character_list) > 1:
        era_print.normal_print(" ")
        py_cmd.pcmd(switch, "SeeSceneCharacterListPage")
    era_print.little_line_print()
Example #3
0
def settle_eat(character_id: int):
    """
    结算角色进食行为
    Keyword arguments:
    character_id -- 角色id
    """
    character_data = cache_contorl.character_data[character_id]
    if character_data.behavior["EatFood"] != None:
        food: game_type.Food = character_data.behavior["EatFood"]
        for feel in food.feel:
            if feel in character_data.status["BodyFeeling"]:
                if feel in ("Hunger", "Thirsty"):
                    character_data.status["BodyFeeling"][feel] -= food.feel[
                        feel]
                else:
                    character_data.status["BodyFeeling"][feel] += food.feel[
                        feel]
            elif feel in character_data.status["SexFeel"]:
                character_data.status["SexFeel"][feel] += food.feel[feel]
            elif feel in character_data.status["PsychologicalFeeling"]:
                character_data.status["PsychologicalFeeling"][
                    feel] += food.feel[feel]
        if character_id == cache_contorl.character_data[0].target_character_id:
            talk_cache.tg = character_data
            talk_cache.me = cache_contorl.character_data[0]
            scene_path_str = map_handle.get_map_system_path_str_for_list(
                character_data.behavior["MoveTarget"])
            scene_data = cache_contorl.scene_data[scene_path_str]
            talk_cache.scene = scene_data["SceneName"]
            talk_cache.scene_tag = scene_data["SceneTag"]
            talk.handle_talk(constant.Behavior.EAT)
        del character_data.food_bag[food.id]
Example #4
0
def change_scene_character_list_panel(start_id: int) -> list:
    """
    当前场景角色列表页切换控制面板
    Keyword arguments:
    start_id -- 指令的起始id
    """
    name_list_max = int(game_config.in_scene_see_player_max)
    now_page = int(cache_contorl.panel_state["SeeSceneCharacterListPanel"])
    scene_path = cache_contorl.character_data[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
    )
    character_max = len(scene_character_name_list)
    page_max = math.floor(character_max / name_list_max)
    page_text = "(" + str(now_page) + "/" + str(page_max) + ")"
    input_s = cmd_button_queue.option_int(
        constant.CmdMenu.CHANGE_SCENE_CHARACTER_LIST,
        cmd_column=5,
        askfor=False,
        cmd_size="center",
        start_id=start_id,
    )
    era_print.page_line_print(sample="-", string=page_text)
    era_print.line_feed_print()
    return input_s
Example #5
0
def identical_map_move(
    character_id: str,
    now_map: list,
    now_map_scene_id: str,
    target_map_scene_id: str,
) -> (str, list, list, int):
    """
    角色在相同地图层级内移动
    Keyword arguments:
    character_id -- 角色id
    now_map -- 当前地图路径
    now_map_scene_id -- 当前角色所在场景(当前地图层级下的相对坐标)
    target_map_scene_id -- 寻路目标场景(当前地图层级下的相对坐标)
    Return arguments:
    str:null -- 未找到路径
    str:end -- 当前位置已是路径终点
    list -- 路径
    list -- 本次移动到的位置
    int -- 本次移动花费的时间
    """
    now_map_str = map_handle.get_map_system_path_str_for_list(now_map)
    move_end, move_path = map_handle.get_path_finding(now_map_str,
                                                      now_map_scene_id,
                                                      target_map_scene_id)
    now_target_position = []
    now_need_time = 0
    if move_path != []:
        now_target_scene_id = move_path["Path"][0]
        now_need_time = move_path["Time"][0]
        now_character_position = map_handle.get_scene_path_for_map_scene_id(
            now_map, now_map_scene_id)
        now_target_position = map_handle.get_scene_path_for_map_scene_id(
            now_map, now_target_scene_id)
    return move_end, move_path, now_target_position, now_need_time
Example #6
0
def see_scene_character_list_panel() -> list:
    """
    当前场景角色列表面板
    """
    input_s = []
    see_character_text = text_loading.get_text_data(
        constant.FilePath.MESSAGE_PATH, "26")
    era_print.normal_print(see_character_text)
    era_print.line_feed_print()
    scene_path = cache_contorl.character_data["character"][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)
    name_list = get_now_page_name_list(name_list)
    character_id = cache_contorl.character_data["character_id"]
    character_data = cache_contorl.character_data["character"][character_id]
    character_name = character_data.name
    input_s = cmd_button_queue.option_str(
        "",
        cmd_column=10,
        cmd_size="center",
        askfor=False,
        cmd_list_data=name_list,
        null_cmd=character_name,
    )
    return input_s
Example #7
0
def get_character_officeroom_path_text(character_id: int) -> str:
    """
    获取角色教室路径描述信息
    Keyword arguments:
    character_id -- 角色id
    Return arguments:
    str -- 教室路径描述文本
    """
    officeroom = cache_contorl.character_data[character_id].officeroom
    map_path_text = text_loading.get_text_data(
        constant.FilePath.STAGE_WORD_PATH, "149")
    if officeroom != "":
        officeroom_path = map_handle.get_map_system_path_for_str(officeroom)
        map_list = map_handle.get_map_hierarchy_list_for_scene_path(
            officeroom_path, [])
        map_list.reverse()
        for now_map in map_list:
            now_map_map_system_str = map_handle.get_map_system_path_str_for_list(
                now_map)
            map_name = cache_contorl.map_data[now_map_map_system_str][
                "MapName"]
            map_path_text += map_name + "-"
        map_path_text += cache_contorl.scene_data[officeroom]["SceneName"]
    else:
        map_path_text += text_loading.get_text_data(
            constant.FilePath.STAGE_WORD_PATH, "150")
    return map_path_text
Example #8
0
def get_in_scene_func():
    """
    用于进入场景界面的流程
    """
    py_cmd.clr_cmd()
    scene_path = cache_contorl.character_data["character"][0].position
    scene_path_str = map_handle.get_map_system_path_str_for_list(scene_path)
    map_handle.sort_scene_character_id(scene_path_str)
    cache_contorl.now_map = map_handle.get_map_for_path(scene_path)
    scene_data = cache_contorl.scene_data[scene_path_str].copy()
    scene_character_list = scene_data["SceneCharacterData"]
    if 0 not in scene_character_list:
        character_id_list = [0]
        scene_character_list = scene_character_list + character_id_list
        cache_contorl.scene_data[scene_path_str][
            "SceneCharacterData"] = scene_character_list
    if (len(scene_character_list) > 1
            and cache_contorl.character_data["character_id"] == 0):
        now_name_list = map_handle.get_scene_character_name_list(
            scene_path_str)
        now_name_list.remove(cache_contorl.character_data["character"][0].name)
        cache_contorl.character_data[
            "character_id"] = map_handle.get_character_id_by_character_name(
                now_name_list[0], scene_path_str)
        if cache_contorl.old_character_id != 0:
            cache_contorl.character_data[
                "character_id"] = cache_contorl.old_character_id
            cache_contorl.old_character_id = 0
    if len(scene_character_list) > 1:
        see_scene_func(True)
    else:
        see_scene_func(False)
Example #9
0
 def draw(self):
     """ 绘制对象 """
     character_data: game_type.Character = cache.character_data[0]
     scene_position = character_data.position
     scene_position_str = map_handle.get_map_system_path_str_for_list(
         scene_position)
     scene_name = cache.scene_data[scene_position_str].scene_name
     title_draw = draw.TitleLineDraw(scene_name, self.width)
     handle_panel = panel.PageHandlePanel([], BuyItemByItemNameDraw, 10, 5,
                                          self.width, 1, 1, 0)
     while 1:
         return_list = []
         title_draw.draw()
         item_list = [
             i for i in game_config.config_item
             if i not in character_data.item
         ]
         handle_panel.text_list = item_list
         handle_panel.update()
         handle_panel.draw()
         return_list.extend(handle_panel.return_list)
         back_draw = draw.CenterButton(_("[返回]"), _("返回"), window_width)
         back_draw.draw()
         return_list.append(back_draw.return_text)
         yrn = flow_handle.askfor_all(return_list)
         if yrn == back_draw.return_text:
             cache.now_panel_id = constant.Panel.IN_SCENE
             break
Example #10
0
def settle_move(character_id: int):
    """
    结算角色移动行为
    Keyword arguments:
    character_id -- 角色id
    """
    character_data = cache_contorl.character_data[character_id]
    if (character_data.behavior["MoveTarget"]
            == cache_contorl.character_data[0].position
            or character_data.position
            == cache_contorl.character_data[0].position):
        talk_cache.tg = character_data
        talk_cache.me = cache_contorl.character_data[0]
        scene_path_str = map_handle.get_map_system_path_str_for_list(
            character_data.behavior["MoveTarget"])
        scene_data = cache_contorl.scene_data[scene_path_str]
        talk_cache.scene = scene_data["SceneName"]
        talk_cache.scene_tag = scene_data["SceneTag"]
        talk.handle_talk(constant.Behavior.MOVE)
    map_handle.character_move_scene(
        character_data.position,
        character_data.behavior["MoveTarget"],
        character_id,
    )
    character_data.status["BodyFeeling"]["Hunger"] += (
        character_data.behavior["Duration"] * 0.02)
    character_data.status["BodyFeeling"]["Thirsty"] += (
        character_data.behavior["Duration"] * 0.02)
Example #11
0
def get_scene_path_text(scene_path: List[str]) -> str:
    """
    从场景路径获取场景地址描述文本
    例:主教学楼-1F-101室
    Keyword arguments:
    scene_path -- 场景路径
    Return arguments:
    str -- 场景地址描述文本
    """
    map_list = map_handle.get_map_hierarchy_list_for_scene_path(scene_path, [])
    map_list.reverse()
    scene_path_str = map_handle.get_map_system_path_str_for_list(scene_path)
    scene_path_text = ""
    for now_map in map_list:
        now_map_map_system_str = map_handle.get_map_system_path_str_for_list(
            now_map)
        map_name = cache.map_data[now_map_map_system_str].map_name
        scene_path_text += map_name + "-"
    return scene_path_text + cache.scene_data[scene_path_str].scene_name
Example #12
0
def see_food_shop_head():
    """
    查看食物商店商品列表顶部面板
    """
    scene_position = cache_contorl.character_data[0].position
    scene_position_str = map_handle.get_map_system_path_str_for_list(
        scene_position
    )
    scene_name = cache_contorl.scene_data[scene_position_str]["SceneName"]
    era_print.little_title_print(scene_name)
Example #13
0
def see_move_path_panel() -> dict:
    """
    当前场景可直接通往的移动路径绘制面板
    """
    input_s = []
    now_scene = cache_contorl.character_data[0].position
    now_map = cache_contorl.now_map
    now_map_str = map_handle.get_map_system_path_str_for_list(now_map)
    map_data = cache_contorl.map_data[now_map_str]
    move_path_info = text_loading.get_text_data(constant.FilePath.MESSAGE_PATH,
                                                "27")
    era_print.normal_print("\n")
    era_print.line_feed_print(move_path_info)
    path_edge = map_data["PathEdge"]
    map_scene_id = map_handle.get_map_scene_id_for_scene_path(
        now_map, now_scene)
    scene_path = path_edge[map_scene_id].copy()
    if map_scene_id in scene_path:
        del scene_path[map_scene_id]
    scene_path_list = list(scene_path.keys())
    if len(scene_path_list) > 0:
        scene_cmd = []
        for scene in scene_path_list:
            now_map_str = map_handle.get_map_system_path_str_for_list(now_map)
            load_scene_data = map_handle.get_scene_data_for_map(
                now_map_str, scene)
            scene_name = load_scene_data["SceneName"]
            scene_cmd.append(scene_name)
        yrn = cmd_button_queue.option_str(
            cmd_list=None,
            cmd_list_data=scene_cmd,
            cmd_column=4,
            askfor=False,
            cmd_size="center",
        )
        input_s = input_s + yrn
    else:
        error_move_text = text_loading.get_text_data(
            constant.FilePath.MESSAGE_PATH, "28")
        era_print.normal_print(error_move_text)
    era_print.restart_line_print()
    return {"input_s": input_s, "scene_path_list": scene_path_list}
Example #14
0
def handle_in_dormitory(character_id: int) -> int:
    """
    校验角色是否在宿舍中
    Keyword arguments:
    character_id -- 角色id
    Return arguments:
    int -- 权重
    """
    character_data: game_type.Character = cache.character_data[character_id]
    now_position = map_handle.get_map_system_path_str_for_list(
        character_data.position)
    return now_position == character_data.dormitory
Example #15
0
def handle_scene_have_other_target(character_id: int) -> int:
    """
    校验场景里是否有其他角色
    Keyword arguments:
    character_id -- 角色id
    Return arguments:
    int -- 权重
    """
    character_data: game_type.Character = cache.character_data[character_id]
    scene_path = map_handle.get_map_system_path_str_for_list(
        character_data.position)
    scene_data: game_type.Scene = cache.scene_data[scene_path]
    return len(scene_data.character_list) - 1
Example #16
0
def see_map_panel() -> list:
    """
    地图绘制面板
    """
    input_s = []
    title_text = text_loading.get_text_data(constant.FilePath.STAGE_WORD_PATH,
                                            "78")
    now_map = cache_contorl.now_map
    now_map_map_system_str = map_handle.get_map_system_path_str_for_list(
        now_map)
    map_name = cache_contorl.map_data[now_map_map_system_str]["MapName"]
    era_print.little_title_print(title_text + ": " + map_name + " ")
    input_s = input_s + map_handle.print_map(now_map)
    return input_s
Example #17
0
 def draw(self):
     """ 绘制对象 """
     scene_position = cache.character_data[0].position
     scene_position_str = map_handle.get_map_system_path_str_for_list(
         scene_position)
     scene_name = cache.scene_data[scene_position_str].scene_name
     title_draw = draw.TitleLineDraw(scene_name, self.width)
     food_type_list = [_("主食"), _("零食"), _("饮品"), _("水果"), _("食材"), _("调料")]
     self.handle_panel = panel.PageHandlePanel([],
                                               SeeFoodListByFoodNameDraw,
                                               10, 5, self.width, 1, 1, 0)
     while 1:
         py_cmd.clr_cmd()
         food_name_list = list(
             cooking.get_restaurant_food_type_list_buy_food_type(
                 self.now_panel).items())
         self.handle_panel.text_list = food_name_list
         self.handle_panel.update()
         title_draw.draw()
         return_list = []
         for food_type in food_type_list:
             if food_type == self.now_panel:
                 now_draw = draw.CenterDraw()
                 now_draw.text = f"{food_type}]"
                 now_draw.style = "onbutton"
                 now_draw.width = self.width / len(food_type_list)
                 now_draw.draw()
             else:
                 now_draw = draw.CenterButton(
                     f"[{food_type}]",
                     food_type,
                     self.width / len(food_type_list),
                     cmd_func=self.change_panel,
                     args=(food_type, ),
                 )
                 now_draw.draw()
                 return_list.append(now_draw.return_text)
         line_feed.draw()
         line = draw.LineDraw("+", self.width)
         line.draw()
         self.handle_panel.draw()
         return_list.extend(self.handle_panel.return_list)
         back_draw = draw.CenterButton(_("[返回]"), _("返回"), window_width)
         back_draw.draw()
         line_feed.draw()
         return_list.append(back_draw.return_text)
         yrn = flow_handle.askfor_all(return_list)
         if yrn == back_draw.return_text:
             cache.now_panel_id = constant.Panel.IN_SCENE
             break
Example #18
0
def handle_talk(character_id):
    """
    处理行为结算对话
    Keyword arguments:
    character_id -- 角色id
    """
    character_data = cache.character_data[character_id]
    behavior_id = character_data.behavior.behavior_id
    now_talk_data = {}
    if behavior_id in game_config.config_talk_data:
        for talk_id in game_config.config_talk_data[behavior_id]:
            now_weight = 1
            for premise in game_config.config_talk_premise_data[talk_id]:
                now_add_weight = cache.handle_premise_data[premise](
                    character_id)
                if now_add_weight:
                    now_weight += now_add_weight
                else:
                    now_weight = 0
                    break
            if now_weight:
                now_talk_data.setdefault(now_weight, set())
                now_talk_data[now_weight].add(talk_id)
    now_talk = ""
    if len(now_talk_data):
        talk_weight = value_handle.get_rand_value_for_value_region(
            list(now_talk_data.keys()))
        now_talk_id = random.choice(list(now_talk_data[talk_weight]))
        now_talk = game_config.config_talk[now_talk_id].context
    if now_talk != "":
        now_talk_text: str = now_talk
        scene_path = cache.character_data[0].position
        scene_path_str = map_handle.get_map_system_path_str_for_list(
            scene_path)
        scene_data = cache.scene_data[scene_path_str]
        scene_name = scene_data.scene_name
        player_data = cache.character_data[0]
        target_data = cache.character_data[character_data.target_character_id]
        now_talk_text = now_talk_text.format(
            NickName=character_data.nick_name,
            FoodName=character_data.behavior.food_name,
            Name=character_data.name,
            SceneName=scene_name,
            PlayerNickName=player_data.nick_name,
            TargetName=target_data.name,
        )
        now_draw = draw.LineFeedWaitDraw()
        now_draw.text = now_talk_text
        now_draw.width = normal_config.config_normal.text_width
        now_draw.draw()
Example #19
0
 def __init__(self, target_id: int, width: int):
     """ 初始化绘制对象 """
     self.target_id: int = target_id
     """ 查看属性的目标 """
     self.width: int = width
     """ 绘制宽度 """
     position = cache.character_data[0].position
     position_str = map_handle.get_map_system_path_str_for_list(position)
     scene_data: game_type.Scene = cache.scene_data[position_str]
     now_list = list(scene_data.character_list)
     now_list.remove(0)
     self.handle_panel = SeeCharacterInfoHandleInScene(
         target_id, width, now_list)
     """ 绘制控制面板 """
Example #20
0
def init_teacher_table():
    """ 初始化教师上课时间数据 """
    teacher_table = {}
    for school_id in cache.course_time_table_data:
        for phase in cache.course_time_table_data[school_id]:
            class_time_table = cache.course_time_table_data[school_id][phase]
            phase_room_id = 0
            if school_id == 0:
                phase_room_id = 1 + phase
            elif school_id == 1:
                phase_room_id = 7 + phase
            else:
                phase_room_id = 10 + phase
            if f"Classroom_{phase_room_id}" not in cache.classroom_teacher_data:
                continue
            classroom_list = constant.place_data[f"Classroom_{phase_room_id}"]
            for day in class_time_table:
                for classroom in classroom_list:
                    if classroom not in cache.classroom_teacher_data[
                            f"Classroom_{phase_room_id}"]:
                        continue
                    for i in class_time_table[day]:
                        now_course = class_time_table[day][i]
                        if (now_course not in cache.classroom_teacher_data[
                                f"Classroom_{phase_room_id}"][classroom]):
                            continue
                        for now_teacher in cache.classroom_teacher_data[
                                f"Classroom_{phase_room_id}"][classroom][
                                    now_course]:
                            if now_teacher not in teacher_table:
                                cache.character_data[
                                    now_teacher].officeroom = map_handle.get_map_system_path_str_for_list(
                                        constant.
                                        place_data[f"Office_{phase_room_id}"])
                            teacher_table.setdefault(now_teacher, 0)
                            if teacher_table[now_teacher] < 14:
                                teacher_table[now_teacher] += 1
                                cache.teacher_class_time_table.setdefault(
                                    day, {})
                                cache.teacher_class_time_table[day].setdefault(
                                    school_id, {})
                                cache.teacher_class_time_table[day][
                                    school_id].setdefault(phase, {})
                                cache.teacher_class_time_table[day][school_id][
                                    phase].setdefault(i, {})
                                cache.teacher_class_time_table[day][school_id][
                                    phase][i][now_teacher] = {
                                        classroom: now_course
                                    }
Example #21
0
def handle_in_classroom(character_id: int) -> int:
    """
    校验角色是否处于教室中
    Keyword arguments:
    character_id -- 角色id
    Return arguments:
    int -- 权重
    """
    character_data = cache.character_data[character_id]
    now_position = character_data.position
    now_scene_str = map_handle.get_map_system_path_str_for_list(now_position)
    now_scene_data = cache.scene_data[now_scene_str]
    if now_scene_data.scene_tag.startswith("Classroom"):
        return 1
    return 0
Example #22
0
def handle_in_cafeteria(character_id: int) -> int:
    """
    校验角色是否处于取餐区中
    Keyword arguments:
    character_id -- 角色id
    Return arguments:
    int -- 权重
    """
    character_data = cache.character_data[character_id]
    now_position = character_data.position
    now_scene_str = map_handle.get_map_system_path_str_for_list(now_position)
    now_scene_data = cache.scene_data[now_scene_str]
    if now_scene_data.scene_tag == "Cafeteria":
        return 1
    return 0
Example #23
0
def handle_in_restaurant(character_id: int) -> int:
    """
    校验角色是否处于就餐区中
    Keyword arguments:
    character_id -- 角色id
    Return arguments:
    int -- 权重
    """
    character_data = cache_contorl.character_data[character_id]
    now_position = character_data.position
    now_scene_str = map_handle.get_map_system_path_str_for_list(now_position)
    now_scene_data = cache_contorl.scene_data[now_scene_str]
    if now_scene_data["SceneTag"] == "Restaurant":
        return 1
    return 0
Example #24
0
def handle_in_swimming_pool(character_id: int) -> int:
    """
    校验角色是否在游泳池中
    Keyword arguments:
    character_id -- 角色id
    Return arguments:
    int -- 权重
    """
    character_data = cache_contorl.character_data[character_id]
    now_position = character_data.position
    now_scene_str = map_handle.get_map_system_path_str_for_list(now_position)
    now_scene_data = cache_contorl.scene_data[now_scene_str]
    if now_scene_data["SceneTag"] == "SwimmingPool":
        return 1
    return 0
Example #25
0
def character_play_piano_to_rand_character(character_id: int):
    """
    弹奏钢琴给房间里随机角色听
    Keyword arguments:
    character_id -- 角色id
    """
    character_data: game_type.Character = cache.character_data[character_id]
    character_list = list(
        cache.scene_data[map_handle.get_map_system_path_str_for_list(
            character_data.position)].character_list)
    character_list.remove(character_id)
    target_id = random.choice(character_list)
    character_data.behavior.behavior_id = constant.Behavior.PLAY_PIANO
    character_data.behavior.duration = 30
    character_data.target_character_id = target_id
    character_data.state = constant.CharacterStatus.STATUS_PLAY_PIANO
Example #26
0
def character_chat_rand_character(character_id: int):
    """
    角色和场景内随机角色聊天
    Keyword arguments:
    character_id -- 角色id
    """
    character_data: game_type.Character = cache.character_data[character_id]
    character_list = list(
        cache.scene_data[map_handle.get_map_system_path_str_for_list(
            character_data.position)].character_list)
    character_list.remove(character_id)
    target_id = random.choice(character_list)
    character_data.behavior.behavior_id = constant.Behavior.CHAT
    character_data.behavior.duration = 10
    character_data.target_character_id = target_id
    character_data.state = constant.CharacterStatus.STATUS_CHAT
Example #27
0
def judge_character_status(character_id: int, now_time: datetime.datetime) -> int:
    """
    校验并结算角色状态
    Keyword arguments:
    character_id -- 角色id
    Return arguments:
    bool -- 本次update时间切片内活动是否已完成
    """
    character_data: game_type.Character = cache.character_data[character_id]
    scene_path_str = map_handle.get_map_system_path_str_for_list(character_data.position)
    scene_data: game_type.Scene = cache.scene_data[scene_path_str]
    start_time = character_data.behavior.start_time
    end_time = game_time.get_sub_date(minute=character_data.behavior.duration, old_date=start_time)
    if (
        character_data.target_character_id != character_id
        and character_data.target_character_id not in scene_data.character_list
    ):
        end_time = now_time
    time_judge = game_time.judge_date_big_or_small(now_time, end_time)
    add_time = (end_time.timestamp() - start_time.timestamp()) / 60
    if not add_time:
        character_data.behavior = game_type.Behavior()
        character_data.behavior.start_time = end_time
        character_data.state = constant.CharacterStatus.STATUS_ARDER
        return 1
    last_hunger_time = start_time
    if character_data.last_hunger_time is not None:
        last_hunger_time = character_data.last_hunger_time
    hunger_time = int((now_time - last_hunger_time).seconds / 60)
    character_data.status.setdefault(27, 0)
    character_data.status.setdefault(28, 0)
    character_data.status[27] += hunger_time * 0.02
    character_data.status[28] += hunger_time * 0.02
    character_data.last_hunger_time = now_time
    if time_judge:
        settle_behavior.handle_settle_behavior(character_id, end_time)
        talk.handle_talk(character_id)
        character_data.behavior = game_type.Behavior()
        character_data.state = constant.CharacterStatus.STATUS_ARDER
    if time_judge == 1:
        character_data.behavior.start_time = end_time
        return 0
    elif time_judge == 2:
        character.init_character_behavior_start_time(character_id, now_time)
        return 0
    return 1
Example #28
0
def get_map_path_text(map_path: List[str]) -> str:
    """
    从地图路径获取地图地址描述文本
    例:主教学楼-1F
    Keyword arguments:
    map_path -- 地图路径
    Return arguments:
    str -- 地图地址描述文本
    """
    map_list = map_handle.get_map_hierarchy_list_for_scene_path(map_path, [])
    map_list.reverse()
    map_list.append(map_path)
    now_path_text = ""
    for now_map in map_list:
        now_map_map_system_str = map_handle.get_map_system_path_str_for_list(
            now_map)
        map_name = cache.map_data[now_map_map_system_str].map_name
        now_path_text += map_name + "-"
    return now_path_text.rstrip("-")
Example #29
0
 def draw(self):
     """ 绘制面板 """
     self.return_list = []
     map_path_str = map_handle.get_map_system_path_str_for_list(
         self.now_map)
     map_data: game_type.Map = cache.map_data[map_path_str]
     path_edge = map_data.path_edge
     scene_id_list = list(path_edge.keys())
     if len(scene_id_list):
         character_data: game_type.Character = cache.character_data[0]
         character_scene_id = map_handle.get_map_scene_id_for_scene_path(
             self.now_map, character_data.position)
         scene_path = path_edge[character_scene_id].copy()
         if character_scene_id in scene_path:
             del scene_path[character_scene_id]
         scene_path_list = list(scene_path.keys())
         draw_list = []
         for scene_id in scene_id_list:
             load_scene_data = map_handle.get_scene_data_for_map(
                 map_path_str, scene_id)
             now_scene_path = map_handle.get_map_system_path_for_str(
                 load_scene_data.scene_path)
             now_id_text = f"{scene_id}:{load_scene_data.scene_name}"
             now_draw = draw.LeftButton(now_id_text,
                                        now_id_text,
                                        self.width,
                                        cmd_func=self.move_now,
                                        args=(now_scene_path, ))
             self.return_list.append(now_draw.return_text)
             draw_list.append(now_draw)
         draw_group = value_handle.list_of_groups(draw_list, 4)
         now_width_index = 0
         for now_draw_list in draw_group:
             if len(now_draw_list) > now_width_index:
                 now_width_index = len(now_draw_list)
         now_width = self.width / now_width_index
         for now_draw_list in draw_group:
             for now_draw in now_draw_list:
                 now_draw.width = now_width
                 now_draw.draw()
             line_feed.draw()
     self.end_index = len(scene_id_list) - 1
Example #30
0
def character_move_to_rand_scene(character_id: int):
    """
    移动至随机场景
    Keyword arguments:
    character_id -- 角色id
    """
    character_data: game_type.Character = cache.character_data[character_id]
    scene_list = list(cache.scene_data.keys())
    now_scene_str = map_handle.get_map_system_path_str_for_list(
        character_data.position)
    scene_list.remove(now_scene_str)
    target_scene = random.choice(scene_list)
    _, _, move_path, move_time = character_move.character_move(
        character_id,
        map_handle.get_map_system_path_for_str(target_scene),
    )
    character_data.behavior.behavior_id = constant.Behavior.MOVE
    character_data.behavior.move_target = move_path
    character_data.behavior.duration = move_time
    character_data.state = constant.CharacterStatus.STATUS_MOVE