#2 v260322

Scalone
detopoi scala 15 commity/ów z detopoi/dev do detopoi/master 8 miesięcy temu

+ 1 - 0
.gitignore

@@ -35,6 +35,7 @@ Pipfile.lock
 *.rougedata
 *.zip
 *.bat
+*.txt
 
 # 废弃工程文件
 AndroidLauncher.py

+ 0 - 8
client_local/algo/aStar.py

@@ -2,7 +2,6 @@ from queue import PriorityQueue
 from client_local.level import level
 
 
-
 def r_block(x, y):
     return level.current_level.block[1][x + 1][y] > 0
 
@@ -70,9 +69,6 @@ def neighbors(current, npc_grid, limit1, limit2, is_ghost):
 
 
 # 原版优先级:右>下>上>左
-
-
-
 def heuristic(next, npc_grid):
     x1, y1 = next
     x2, y2 = npc_grid
@@ -100,12 +96,9 @@ def cal_path(npc_grid, hero_grid, limit1, limit2, is_ghost=False):
     cost_so_far[npc_grid] = 0
 
     while not frontier.empty():
-
         current = frontier.get()[1]
-
         if current == hero_grid:
             break
-
         for next in neighbors(current, npc_grid, limit1, limit2, is_ghost):
             new_cost = cost_so_far[current] + 1
             if next not in cost_so_far or new_cost < cost_so_far[next]:
@@ -115,4 +108,3 @@ def cal_path(npc_grid, hero_grid, limit1, limit2, is_ghost=False):
                 came_from[next] = current
 
     return reverse(came_from, hero_grid, npc_grid)
-

+ 8 - 5
client_local/const/game.py

@@ -54,6 +54,9 @@ WATER_DAMPING = 100
 PET = None
 ENVIRONMENT_EFFECT = []
 
+IS_CUSTOM_LEVEL = False
+CURRENT_MAP_NAME = ""  # 对于自定义关卡生效
+
 DISPLAY_NPC_NAME_CARD = False
 DISPLAY_NPC_BLOOD = False
 DISPLAY_FRAME_RATE = False
@@ -72,11 +75,11 @@ CAMERA = 1
 W_INCREMENT = 0
 H_INCREMENT = 0
 
-
-
-
-
-
+CUMULATION_INJURE = 0         # 一局游戏的累积受伤
+TRANSPORT_LEVEL_NUM = 0       # 经过了多少运输关
+TOTAL_TRANSPORT = 0           # 物资
+CUMULATION_RESOURCE_LEAK = 0  # 物资累积受损
+RESOUCE_NUM = 99
 
 
 

+ 40 - 34
client_local/control.py

@@ -20,7 +20,6 @@ from datetime import datetime
 # logging.basicConfig(filename='app.log', level=logging.INFO)
 
 
-
 class Control:
 
     def __init__(self):
@@ -60,6 +59,7 @@ class Control:
         self.cfg_reset = None  # 用户自定义重启0
         self.text_font = None
         self.description_shown = False
+        self.map_name_json = None
 
         self.wall_walking = True
 
@@ -172,14 +172,11 @@ class Control:
         self.screen = pygame.display.set_mode(W.WINDOW_SIZE, flags=self.display_flags)
         pygame.display.set_icon(pygame.image.load("res/img/ui/icon.png").convert_alpha())
 
-
         for i in range(10):
             file_name = "itemNum_0_" + str(i) + ".png"
             img = pygame.image.load("res/img/ui/number/" + file_name).convert_alpha()
             G.NUMBER_IMG.append(img)
 
-
-
     def init_keys(self, keys_root):
         # 加载自定义按键
         self.orientations[keys_root["RIGHT"]] = "R"
@@ -228,7 +225,13 @@ class Control:
             map_name = self.map_set_json["maps"][self.map_set_at]
             hero_name = self.cfg_json["your_hero"]
             character_color = self.cfg_json["your_character_color"]
-            self.set_level(self.your_name, map_name, hero_name, character_color, is_reset)
+            final_json = load_json(f"game/map/{self.map_set_json['maps'][-1]}.json")
+            if final_json["basic"].get("is_transport", True):
+                transport_amount = final_json["basic"].get("transport_amount", 0)
+                transport_remain = final_json["basic"].get("transport_remain", 0)
+                self.set_level(self.your_name, map_name, hero_name, character_color, is_reset, transport_amount, transport_remain)
+            else:
+                self.set_level(self.your_name, map_name, hero_name, character_color, is_reset)
         else:
             # 正常刷新
             if not self.description_shown:
@@ -241,10 +244,12 @@ class Control:
         hero_name = self.cfg_json["your_hero"]
         character_color = self.cfg_json["your_character_color"]
         G.TOTAL_LEVEL = G.CURRENT_LEVEL + 1
+        G.IS_CUSTOM_LEVEL = True
+        G.CURRENT_MAP_NAME = map_name
         self.set_level(self.your_name, map_name, hero_name, character_color)
         G.HAS_RECORD = False
 
-    def set_level(self, your_name, map_name, hero_name, character_color, is_reset=False):
+    def set_level(self, your_name, map_name, hero_name, character_color, is_reset=False, transport_amount=0, transport_remain=0):
         # 改变当前关卡
         character_colors = {
             "Red": C.CHARACTER_RED, "Blue": C.CHARACTER_BLUE, "SkyBlue": C.CHARACTER_SKYBLUE, "Yellow": C.CHARACTER_YELLOW, "Green": C.CHARACTER_GREEN,
@@ -259,8 +264,10 @@ class Control:
             me.skill_remains = self.me.skill_remains
         self.me = me
         # 设置新关卡
-        self.current_level = Level(your_name, map_name, self.me, self.music_volume, self.grid_damage_duration, self)
-
+        self.current_level = Level(
+            your_name, map_name, self.me, self.music_volume, self.grid_damage_duration, self,
+            transport_map_total=transport_amount, transport_map_remain=transport_remain
+        )
 
     def update(self):
         # 事件处理
@@ -294,7 +301,6 @@ class Control:
             pygame.time.Clock().tick(self.frame_rate)
 
 
-
     def key_pressed(self):
         # 键盘事件检测
         keys = pygame.key.get_pressed()
@@ -370,39 +376,37 @@ class Control:
         else:
             self.pause_old = False
 
-
     def player_reset(self, keys):
         if keys[self.cfg_reset]:
             if self.reset_old is True:
                 return
-            # print("C1:", G.CURRENT_LEVEL)
             G.CURRENT_LEVEL = 0
-            # print("C2:", G.CURRENT_LEVEL)
-            self.init_game()
-            self.proceed_game(is_reset=True)
             self.reset_old = True
             G.CHEAT = False
             G.HAS_RECORD = False
             G.LASTMAPTIME = G.TIME
             G.LAST_LEVEL_TIME = G.TIME
             G.ITEM = 0
+            G.SPECIAL_MAX_HP = 0
+            G.CUMULATION_INJURE = 0
+            G.TOTAL_TRANSPORT = 0
+            G.CUMULATION_RESOURCE_LEAK = 0
+            G.RESOUCE_NUM = 99
             G.MONSTER_RECORD_LIST = []
             G.HAS_RECORD_FULL = False
             G.HAS_GOLDEN = False
-
             self.cfg_json = load_json("config.json")
             self.map_set_json = load_json("game/map_set/" + self.cfg_json["map_set"] + ".json")
             G.TOTAL_LEVEL = len(self.map_set_json["maps"])
-            self.map_name_json = load_json("game/map/" + self.map_set_json["maps"][0] + ".json")
-
+            self.map_name_json = load_json(f"game/map/{self.map_set_json['maps'][0]}.json")
             if "environment_effect" in self.map_name_json["basic"].keys():
                 G.ENVIRONMENT_EFFECT = self.map_name_json["basic"]["environment_effect"]
             else:
                 G.ENVIRONMENT_EFFECT = []
-
             if "player_light" in self.map_name_json["basic"].keys():
                 self.me.light = self.map_name_json["basic"]["player_light"]
-
+            self.init_game()
+            self.proceed_game(is_reset=True)
         else:
             self.reset_old = False
 
@@ -429,21 +433,6 @@ class Control:
                 self.message_old[idx] = False
 
     def reset(self, map_set):
-        '''
-        with open("config.json", "r", encoding="utf-8") as json_file:
-            mapsetdata = json.load(json_file)
-        mapsetdata["map_set"] = map_set
-        with open("config.json", "w", encoding="utf-8") as json_file:
-            json.dump(mapsetdata, json_file, indent=4, ensure_ascii=False)
-        self.init_game()
-        '''
-        self.map_set_json = load_json("game/map_set/" + map_set + ".json")
-        self.map_set_at = 0
-        map_name = self.map_set_json["maps"][self.map_set_at]
-        hero_name = self.cfg_json["your_hero"]
-        character_color = self.cfg_json["your_character_color"]
-        self.set_level(self.your_name, map_name, hero_name, character_color, is_reset=True)
-
         self.reset_old = True
         G.CHEAT = False
         G.HAS_RECORD = False
@@ -452,6 +441,10 @@ class Control:
         G.LAST_LEVEL_TIME = G.TIME
         G.ITEM = 0
         G.SPECIAL_MAX_HP = 0
+        G.CUMULATION_INJURE = 0
+        G.TOTAL_TRANSPORT = 0
+        G.CUMULATION_RESOURCE_LEAK = 0
+        G.RESOUCE_NUM = 99
         # G.MONSTER_RECORD_LIST = []
         G.HAS_RECORD_FULL = False
         G.HAS_GOLDEN = False
@@ -465,3 +458,16 @@ class Control:
         if "player_light" in self.map_name_json["basic"].keys():
             self.me.light = self.map_name_json["basic"]["player_light"]
 
+        self.map_set_json = load_json("game/map_set/" + map_set + ".json")
+        self.map_set_at = 0
+        map_name = self.map_set_json["maps"][self.map_set_at]
+        hero_name = self.cfg_json["your_hero"]
+        character_color = self.cfg_json["your_character_color"]
+        final_json = load_json(f"game/map/{self.map_set_json['maps'][-1]}.json")
+        if final_json["basic"].get("is_transport", True):
+            transport_amount = final_json["basic"].get("transport_amount", 0)
+            transport_remain = final_json["basic"].get("transport_remain", 0)
+            self.set_level(self.your_name, map_name, hero_name, character_color, True, transport_amount, transport_remain)
+        else:
+            self.set_level(self.your_name, map_name, hero_name, character_color, is_reset=True)
+

+ 11 - 1
client_local/frame/obstacle.py

@@ -22,7 +22,7 @@ def load_obstacle(type, name):
 
     an_obstacle = {}
     # print(OBSTACLE_FRAME_ROOT + type + '/' + name + ".json")
-    obstacle_json = load_json(OBSTACLE_FRAME_ROOT + type + '/' + name + ".json")
+    obstacle_json = load_json(f"{OBSTACLE_FRAME_ROOT}{type}/{name}.json")
     an_obstacle["WIDTH"] = obstacle_json["WIDTH"]
     an_obstacle["HEIGHT"] = obstacle_json["HEIGHT"]
     an_obstacle["BLOCK"] = an_obstacle["BLOCK_FLAME"] = obstacle_json["BLOCK"]
@@ -32,6 +32,8 @@ def load_obstacle(type, name):
         an_obstacle["BLOCK_FLAME"] = obstacle_json["BLOCK_FLAME"]
     if "SLIDE" in obstacle_json.keys():
         an_obstacle["SLIDE"] = obstacle_json["SLIDE"]
+    if "BLOCK_SIGHT" in obstacle_json.keys():
+        an_obstacle["BLOCK_SIGHT"] = obstacle_json["BLOCK_SIGHT"]
     if "BACKGROUND" in obstacle_json.keys():
         an_obstacle["BACKGROUND"] = bool(obstacle_json["BACKGROUND"])
     if "CAN_PUSH" in obstacle_json.keys():
@@ -44,6 +46,14 @@ def load_obstacle(type, name):
         an_obstacle["SLOW"] = obstacle_json["SLOW"]
     if "EXPLODE" in obstacle_json.keys():
         an_obstacle["EXPLODE"] = obstacle_json["EXPLODE"]
+    if "TRANSPORT_AMOUNT" in obstacle_json.keys():
+        an_obstacle["TRANSPORT_AMOUNT"] = obstacle_json["TRANSPORT_AMOUNT"]
+    if "TRANSPORT_RANGE" in obstacle_json.keys():
+        an_obstacle["TRANSPORT_RANGE"] = obstacle_json["TRANSPORT_RANGE"]
+    if "TRANSPORT_DEBUFF" in obstacle_json.keys():
+        an_obstacle["TRANSPORT_DEBUFF"] = obstacle_json["TRANSPORT_DEBUFF"]
+    if "TRANSPORT_LEAK" in obstacle_json.keys():
+        an_obstacle["TRANSPORT_LEAK"] = obstacle_json["TRANSPORT_LEAK"]
     if "MULTI_TYPE" in obstacle_json.keys():
         an_obstacle["MULTI_TYPE"] = obstacle_json["MULTI_TYPE"]
     if "TYPE_LEN" in obstacle_json.keys():

+ 417 - 178
client_local/level/level.py

@@ -1,10 +1,13 @@
+import os
+import pygame
+import random
+import ast
 import json
 import math
+import time
 from json import JSONDecodeError
 import numpy as np
-import pygame
-import os
-import ast
+from collections import defaultdict
 
 from client_local.const import game as G
 from client_local.frame import floor
@@ -19,20 +22,24 @@ from client_local.sprite.item_instance import ItemState as IS
 from client_local.sprite.bomb_instance import BombInstance
 from client_local.effect.effect_instance import ReadyGo, DistrictAlarm, EnvironmentEffect, EffectState
 from client_local.sprite.npc import Npc
-from client_local.ui.game.blood_bar import BloodBar
+from client_local.ui.game.blood_bar import BloodBar, MapBloodBar, MapResouceBar, ResourceBloodBar
 from client_local.ui.game.dlg_pveFunc import DlgPveFunc
 from client_local.ui.game.game_top import GameTop
 from client_local.ui.game.misc_510 import Misc510
-from client_local.ui.game.player_icon import PlayerIcon
+from client_local.ui.game.player_icon import PlayerIcon, ResourceIcon
 from client_local.ui.game.score_board import ScoreBoard, Timer
 from client_local.ui.game.status_bar import StatusBar
 from client_local.ui.game.message_input import InputEntry, InputLevel
 from client_local.file_loader.fileLoader import load_json, load_png
+from client_local.skill.skill import WinEffect, TransportSuccessEffect
 from client_local.skill.level_skill import Level3x3RandomThunder, DebuffPoisonGrid
+from client_local.utils.json_saver import AsyncJsonSaver
 from datetime import datetime
 
 
 current_level = None
+level_font = pygame.font.Font("res/font/simsun.ttc", 16)
+Y_SCALE_FACTOR = 1  # 用于地震效果,画面会按比例以中间为基准进行上下偏移实现压缩效果
 
 max_alpha = 255  # 最大透明度
 circleMasks = {}
@@ -49,6 +56,7 @@ for i in range(1, 10):
         pygame.draw.circle(circleMask, (alpha, alpha, alpha, alpha), (circle_radius, circle_radius), R)
     circleMasks[i] = circleMask
 
+
 def get_player_coordinates():
     players = current_level.game.players
     coords = []
@@ -64,27 +72,95 @@ def get_light_npc_coordinates():
     return coords
 
 
+_last_light_states = None
+
+
+# def get_player_mask(mask_surface, bgl):
+#     """
+#     只在光源状态变化时才重绘遮罩;否则直接返回上次绘制结果。
+#     """
+#     global _last_light_states
+#     # 收集当前所有光源状态 (x, y, light)
+#     curr = []
+#     for p in [current_level.me] + current_level.npcs + list(current_level.obstacle_instances.values()):
+#         if p.light:
+#             curr.append((p.x_pos, p.y_pos, p.light))
+#     curr_key = tuple(curr)
+#     # 如果没变化,直接复用
+#     if curr_key == _last_light_states:
+#         return mask_surface
+#     # 状态变化:重绘
+#     _last_light_states = curr_key
+#     bgl = max(0, min(bgl, 255))
+#     fill = mask_surface.fill
+#     blit = mask_surface.blit
+#     masks = circleMasks
+#     fill((bgl, bgl, bgl, 0))
+#     for x, y, light in curr:
+#         # 叠加亮度
+#         cm = masks[light]
+#         r = light * MASK_STEP
+#         blit(cm, (x - r, y - r - 15),
+#              special_flags=pygame.BLEND_RGBA_ADD)
+#     return mask_surface
+
+
 def get_player_mask(mask_surface, bgl):
-    bgl = min(max(bgl,0),255)
-    mask_surface.fill((bgl, bgl, bgl, 0))  # 初始为完全透明
-    for player in [current_level.me] + current_level.npcs + list(current_level.obstacle_instances.values()):
-        x,y = player.x_pos,player.y_pos
-        if player.light==0: continue
-        circleMask = circleMasks[player.light]
-        circle_radius = player.light*MASK_STEP
+    global _last_light_states
+    # 收集当前所有光源状态 (x, y, light)
+    curr = []
+    for p in [current_level.me]:
+        if p.light and (not p.is_hide_sight()):
+            curr.append((p.x_pos, p.y_pos, p.light))
+    for p in current_level.npcs:
+        if p.light and (not p.is_hide_sight()):
+            curr.append((p.x_pos, p.y_pos, p.light))
+    for p in current_level.obstacle_instances.values():
+        if p.light:
+            curr.append((p.x_pos, p.y_pos, p.light))
+    curr_key = tuple(curr)
+    if curr_key == _last_light_states:
+        return mask_surface
+    _last_light_states = curr_key
+    bgl = max(0, min(bgl, 255))
+    fill = mask_surface.fill
+    blit = mask_surface.blit
+    masks = circleMasks
+    # 先把整表清空为 bgl 灰底
+    fill((bgl, bgl, bgl, 0))
+    # ---- 新增:计算屏幕视口,并在后面用 inflate 方式做相交测试 ----
+    from client_local.const import game as G
+    # world-space 下的视口矩形
+    view_rect = pygame.Rect(
+        current_level.scroll_x_pos,
+        current_level.scroll_y_pos,
+        G.MAIN_AREA_X_POS,
+        G.MAIN_AREA_Y_POS
+    )
+    # ---------------------------------------------------------
+    view_x, view_y = current_level.scroll_x_pos, current_level.scroll_y_pos
+    for x, y, light in curr:
+        r  = light * MASK_STEP
+        sx = x - view_x - r           # ← 世界 → 屏幕
+        sy = y - view_y - r - 15
+        cm = masks[light]
+        # 膨胀法:把视口向外各扩 r(水平方向)和 (r+15)(垂直方向)
+        if not view_rect.inflate(2*r, 2*(r+15)).collidepoint(x, y):
+            continue
         # 叠加亮度
-        mask_surface.blit(circleMask, (x-circle_radius, y-circle_radius-15),special_flags=pygame.BLEND_RGBA_ADD)    # 15是补偿值(大概是角色中心)
+        mask_surface.blit(cm, (sx, sy), special_flags=pygame.BLEND_RGBA_ADD)
     return mask_surface
 
 
 def special_colour_mask(mask_surface, rgb):
-    r = min(max(rgb[0],0),255)
-    g = min(max(rgb[1],0),255)
-    b = min(max(rgb[2],0),255)
+    r = min(max(rgb[0], 0), 255)
+    g = min(max(rgb[1], 0), 255)
+    b = min(max(rgb[2], 0), 255)
     mask_surface.fill((r, g, b, 0))  # 初始
     for player in [current_level.me] + current_level.npcs + list(current_level.obstacle_instances.values()):
-        x,y = player.x_pos,player.y_pos
-        if player.light==0: continue
+        x, y = player.x_pos, player.y_pos
+        if player.light == 0:
+            continue
         circleMask = circleMasks[player.light]
         circle_radius = player.light*MASK_STEP
         # 叠加亮度
@@ -115,9 +191,23 @@ def caesar_encrypt(text, k=3):
     return encrypted_text
 
 
+class MainArea(pygame.Surface):
+    def __init__(self, size, flags=0):
+        super().__init__(size, flags)
+
+    def blit(self, source, dest, area=None, special_flags=0):
+        relative_y = dest[1] - current_level.scroll_y_pos - G.MAIN_AREA_Y_POS//2
+        scale_bias_value = relative_y * (1 - Y_SCALE_FACTOR)
+        dest = (dest[0], int(dest[1] - scale_bias_value))
+        super().blit(source, dest, area, special_flags)
+
+
 class Level:
 
-    def __init__(self, your_name: str, map_name: str, me: Hero, music_volume, accumulation_time, game=None):
+    def __init__(
+            self, your_name: str, map_name: str, me: Hero, music_volume, accumulation_time, game=None,
+            transport_map_total=0, transport_map_remain=0
+    ):
 
         from client_local.control import Control
         self.game: Control = game
@@ -125,9 +215,9 @@ class Level:
         current_level = self
         self.times_num = 0  # 秒计数器,每秒累加
         self.frames_num = 0  # 帧计数器,每秒清空
-        self.frame_rate_text_font = pygame.font.Font("res/font/simsun.ttc", 16)
+        self.frame_rate_text_font = level_font
         self.me = me
-        self.pet = None
+        self.pets = []
         self.your_name = your_name
         self.map_name = map_name
         self.map_json = None
@@ -150,6 +240,18 @@ class Level:
         self.map_music_volume = music_volume  # 关卡背景音乐音量大小
         self.finish_at = None  # 地图过关点(x, y)
 
+        G.TOTAL_TRANSPORT = 0
+        self.transport_map_total = transport_map_total
+        self.transport_map_remain = transport_map_remain
+        self.transport_obstacle = []
+        self.transport_resource_init_points = []
+        self.earth_quake_direction = None
+        self.earth_quake_init_tick = 0  # 地震初始化tick
+        self.earth_quake_left_times = 0  # 地震剩余次数
+        self.earth_quake_strength = 0  # 地震强度
+        self.earth_quake_times = 0  # 地震次数
+        self.earth_quake_decrease = True  # 地震强度是否递减
+
         self.current_time = pygame.time.get_ticks()
         self.floor_image = None  # 游戏主区域的地板背景
         self.flame_instances = None  # FlameInstance对象列表
@@ -164,9 +266,11 @@ class Level:
         self.block_flame = None  # 三维NumPy对象,阻挡糖跑
         self.slide_orientation = dict()  # (x, y) --> (m, n) m网格传送带方向 0无 1右 2上 3左 4下 n速度
         self.grid_damage_blood = dict()  # 网格伤害血量
-        self.grid_damage_time = dict()  # 网格伤害时刻 只有糖泡爆炸时才会增加
+        self.grid_damage_time = defaultdict(None)  # 网格伤害时刻 只有糖泡爆炸时才会增加
         self.grid_damage_multiples = dict()  # 伤害次数(倍数)
-        self.grid_damage_orientations = dict()  # 网格伤害方向
+        # self.grid_damage_orientations = dict()  # 网格伤害方向
+        self.grid_damage_orientations = defaultdict(set)
+        self.path_map = dict()  # 缓存怪物追踪路径
         self.grid_damage_frame = False  # 用于判断糖泡伤害瞬间与玩家位置是否重合 只有爆炸帧才是True
         self.accumulation_time = accumulation_time  # 网格伤害延迟时间
         self.main_area = None  # 游戏主区域
@@ -178,6 +282,7 @@ class Level:
         self.left_black = None  # 屏幕右侧黑条
 
         self.grid_bomb_time_at = dict()  # 糖泡伤害时刻
+        self.level_variables = dict()
 
         self.blood_bar = None
         self.status_bar = None
@@ -185,6 +290,7 @@ class Level:
         self.time_board = None
         self.npcs = list()  # 存活npc列表
         self.ghosts = list()  # 存活僵尸列表
+        self.wanderers = list()
         self.recal_npc_paths = True  # 重新计算Npc路径的标志位 仅当玩家进入区域、糖泡施放与爆炸、玩家网格位置发生变化、障碍被摧毁时置为True
         self.recal_ghost_paths = True  # 重新计算Ghost路径的标志位 仅当玩家移动
         self.display_name_card = False  # 显示npc姓名牌
@@ -195,10 +301,19 @@ class Level:
         self.district_alarming = False  # 当前正在显示警戒
         self.district_all_finished = False  # 已完成全部区域的标志
         self.finish_flag = False  # 当前map结束的标志位
+        self.district_json = None
+        self.read_district_json = False
         self.custom_finish_flag = False
         self.custom_next_map = None
         self.portal = dict()
         self.portal_set = []
+        self.has_achievemeny_check = False
+
+        self.is_transport = False    # 是否为运输模式
+        self.map_blood_bar = None    # 地图血条
+        self.resource_bar = None     # 资源受损条
+        self.transport_buff_num = 0  # 资源buff
+        self.transport_destination = None
 
         self.special_music_volume = 1  # 若需放大音乐
 
@@ -207,28 +322,31 @@ class Level:
         self.load_floor()  # 加载地板
         self.load_obstacle()  # 加载障碍
         self.load_music()  # 加载音乐
+        if self.is_transport:
+            self.resource_bar.set_max_blood(G.TOTAL_TRANSPORT)
+
+        self.mask_surface = pygame.Surface((self.map_x_pos, self.map_y_pos), pygame.SRCALPHA).convert_alpha()
 
-        self.mask_surface = pygame.Surface((self.map_x_pos, self.map_y_pos), pygame.SRCALPHA)
         self.haunt_Mode = False
         self.bg_light = 0
         self.underwater = False
-        self.rgb_light = [0,0,0]
+        self.rgb_light = [0, 0, 0]
         self.special_rgb = False
 
         self.boss_blood_bar_dic = {1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0}  # boss血条显示
-
         self.dark_trap = set()  # debuff毒陷阱集合
         self.small_dark_trap = set()  # debuff毒陷阱集合
         self.poison_dic = dict()  # 改良版毒陷阱字典
+        self.async_json_saver = AsyncJsonSaver()
 
         ReadyGo(self.effects_screen)
 
-        self.map_json = load_json("game/map/" + self.map_name + ".json")
+        self.map_json = load_json(f"game/map/{self.map_name}.json")
         if "environment_effect" in self.map_json["basic"].keys():
             G.ENVIRONMENT_EFFECT = self.map_json["basic"]["environment_effect"]
         else:
             G.ENVIRONMENT_EFFECT = []
-        if len(G.ENVIRONMENT_EFFECT)>0:
+        if len(G.ENVIRONMENT_EFFECT) > 0:
             for en in G.ENVIRONMENT_EFFECT:
                 EnvironmentEffect(self.effects_screen, en)
 
@@ -249,7 +367,7 @@ class Level:
             self.rgb_light = self.map_json["basic"]["rgb_light"]
             self.special_rgb = True
         if G.PET is not None:
-            self.pet = Pet(G.PET, (self.me.x, self.me.y))
+            self.pets.append(Pet(G.PET, (self.me.x, self.me.y), owner=self.me, num=1))
 
         if "level_skill" in self.map_json["basic"].keys():
             for skills in self.map_json["basic"]["level_skill"]:
@@ -258,42 +376,24 @@ class Level:
                     Level3x3RandomThunder(self.me, self.npcs, skill_params+[skill_init, skill_interval], self.skill_instances)
         # 紫色毒陷阱判断
         DebuffPoisonGrid(self.me, self.npcs, self.skill_instances)
-        '''
-        with open("game/map/" + self.map_name + ".json") as map_file:
-            self.map_json = json.load(map_file)
-            if "environment_effect" in self.map_json["basic"].keys():
-                G.ENVIRONMENT_EFFECT = self.map_json["basic"]["environment_effect"]
-            else:
-                G.ENVIRONMENT_EFFECT = []
-            if len(G.ENVIRONMENT_EFFECT)>0:
-                for en in G.ENVIRONMENT_EFFECT:
-                    EnvironmentEffect(self.effects_screen, en)
-
-            if "haunted" in self.map_json["basic"].keys():
-                self.haunt_Mode = self.map_json["basic"]['haunted']
-            if "bg_light" in self.map_json["basic"].keys():
-                self.bg_light = self.map_json["basic"]["bg_light"]
-            if "underwater" in self.map_json["basic"].keys():
-                self.underwater = self.map_json["basic"]["underwater"]
-                G.UNDERWATER = self.underwater
-            else:
-                G.UNDERWATER = False
-            if "water_damping" in self.map_json["basic"].keys():
-                G.WATER_DAMPING = self.map_json["basic"]["water_damping"]
-            else:
-                G.WATER_DAMPING = 200
-            if "rgb_light" in self.map_json["basic"].keys():
-                self.rgb_light = self.map_json["basic"]["rgb_light"]
-                self.special_rgb = True
-        '''
+
+    def set_level_variables(self, name, value):
+        self.level_variables[name] = value
+
+    def get_level_variables(self, name, default_value):
+        return self.level_variables.get(name, default_value)
 
     def load_map_json(self):
         # 加载关卡json文件
         map_json = load_json("game/map/" + self.map_name + ".json")
         self.map_json = map_json
+        if not self.read_district_json:
+            self.read_district_json = True
+            self.district_json = self.map_json["districts"]
         self.me.set_xy(map_json["basic"]["begin"][0], map_json["basic"]["begin"][1])
-        if self.pet is not None:
-            self.pet.set_xy(map_json["basic"]["begin"][0], map_json["basic"]["begin"][1])
+        if len(self.pets) > 0:
+            for pet in self.pets:
+                pet.set_xy(map_json["basic"]["begin"][0], map_json["basic"]["begin"][1])
         # 地图大小-像素
         self.map_x = int(map_json["basic"]["width"])
         self.map_y = int(map_json["basic"]["height"])
@@ -325,20 +425,32 @@ class Level:
             for y in range(self.map_y):
                 self.grid_damage_blood[(x, y)] = 0
                 self.grid_damage_time[(x, y)] = 0
-                self.grid_damage_multiples[(x,y)] = 0
-                self.grid_damage_orientations[(x, y)] = set()
+                self.grid_damage_multiples[(x, y)] = 0
+                # self.grid_damage_orientations[(x, y)] = set()
                 self.grid_bomb_time_at[(x, y)] = 0
         self.district_square_grid = {"x1": 0, "x2": 0, "y1": 0, "y2": 0}
         self.district_square = {"x1": 0, "x2": 0, "y1": 0, "y2": 0}
         if "finish" in self.map_json["basic"].keys():
             self.finish_at = (self.map_json["basic"]["finish"][0], self.map_json["basic"]["finish"][1])
-        self.main_area = pygame.Surface((self.map_x_pos, self.map_y_pos))
+        self.main_area = MainArea((self.map_x_pos, self.map_y_pos)).convert()
         self.left_black = pygame.Surface((1, 600))
 
         if "haunted" in self.map_json["basic"].keys():
             self.haunt_Mode = self.map_json["basic"]['haunted']
         if "bg_light" in self.map_json["basic"].keys():
             self.bg_light = self.map_json["basic"]["bg_light"]
+        self.is_transport = self.map_json["basic"].get("is_transport", False)
+        if self.is_transport:
+            self.transport_resource_init_points = self.map_json["basic"].get("transport_resource_init", [])
+            self.transport_destination = self.map_json["basic"].get("transport_destination", None)
+            self.map_blood_bar = MapResouceBar(
+                self.transport_map_total,
+                self.transport_map_remain
+            )
+            self.ui_instances_top.append(self.map_blood_bar)
+            self.resource_bar = ResourceBloodBar(self.me)
+            self.ui_instances_top.append(self.resource_bar)
+            self.ui_instances_top.append(ResourceIcon())
 
         if "underwater" in self.map_json["basic"].keys():
             self.underwater = self.map_json["basic"]["underwater"]
@@ -366,14 +478,6 @@ class Level:
             self.portal = {}
             self.portal_set = []
 
-        '''
-        if "environment_effect" in self.map_json["basic"].keys():
-            G.ENVIRONMENT_EFFECT.append(self.map_json["basic"]["environment_effect"])
-        else:
-            G.ENVIRONMENT_EFFECT = []
-        if len(G.ENVIRONMENT_EFFECT)>0:
-            EnvironmentEffect(self.effects_screen, G.ENVIRONMENT_EFFECT)
-        '''
         G.CURRENT_LEVEL += 1
         G.KILLED_NPC = 0
         G.MAP_NAME = self.map_name
@@ -406,14 +510,49 @@ class Level:
         if not G.SHOW_INPUT:
             G.SHOW_INPUT = True
             self.message_entry = InputEntry()   # 聊天输入框
-            self.ui_instances_top.append(self.message_entry)
         else:
             self.message_entry = InputLevel()   # 聊天输入框
-            self.ui_instances_top.append(self.message_entry)
+        self.ui_instances_top.append(self.message_entry)
         self.blood_bar = BloodBar(self.me)
         self.blood_bar.set_name(self.your_name)
         self.ui_instances_top.append(self.blood_bar)
 
+    def earth_quake_effect(self, strength=0.1, times=3, duration_per_time=200, decrease=True, direction=None):
+        """屏幕震动效果,强度表示移动像素数量,times表示震动次数,duration_per_time表示每次震动持续时间"""
+        if direction is None:
+            direction = random.choice([0, 1])
+        self.earth_quake_direction = direction
+        if direction == 0:
+            self.earth_quake_duration_per_time = duration_per_time
+            strength *= 2
+        else:
+            self.earth_quake_duration_per_time = duration_per_time // 2
+        self.earth_quake_strength = strength
+        self.earth_quake_times = times
+        self.earth_quake_time = pygame.time.get_ticks()
+        self.earth_quake_decrease = decrease
+
+    def run_earth_quake_effect(self, screen: pygame.Surface = None):
+        """运行屏幕震动效果"""
+        global Y_SCALE_FACTOR
+        if self.earth_quake_strength <= 0 or self.earth_quake_times <= 0:
+            Y_SCALE_FACTOR = 1
+            return
+        now = pygame.time.get_ticks()
+        if now - self.earth_quake_time >= self.earth_quake_duration_per_time:
+            self.earth_quake_times -= 1
+            self.earth_quake_time = now
+            if self.earth_quake_decrease:
+                self.earth_quake_strength = self.earth_quake_strength * 0.5
+            if self.earth_quake_times <= 0:
+                self.earth_quake_strength = 0
+                return
+        # 计算偏移量(抛物线计算当前高度)
+        t = (now - self.earth_quake_time) / self.earth_quake_duration_per_time
+        Y_SCALE_FACTOR = 1 - self.earth_quake_strength * t * (1 - t)
+        MAX_BIAS = G.MAIN_AREA_Y_POS * (1-Y_SCALE_FACTOR)//2
+        screen.fill((0, 0, 0, 0), rect=(0, 21, G.MAIN_AREA_X_POS, MAX_BIAS))
+
     def load_floor(self):
         # 加载地板floor
         self.floor_image = pygame.Surface((self.map_x_pos, self.map_y_pos), flags=pygame.HWSURFACE)
@@ -439,12 +578,19 @@ class Level:
                 for x in range(square["x1"], square["x2"] + 1):
                     for y in range(square["y1"], square["y2"] + 1):
                         oi.ObstacleInstance(x, y, self.obstacle_instances, obs, obs_json)
-
         # 单个加载
         for o in self.map_json["obstacle"]:
             obs, obs_json = obstacle.get_obstacle(o["type"], o["name"])
             for point in o["points"]:
                 oi.ObstacleInstance(point["x"], point["y"], self.obstacle_instances, obs, obs_json)
+        if self.is_transport:
+            rs_num = 0
+            obs, obs_json = obstacle.get_obstacle("eden", "elem1")
+            for x, y in self.transport_resource_init_points:
+                if rs_num >= G.RESOUCE_NUM:
+                    break
+                oi.ObstacleInstance(x, y, self.obstacle_instances, obs, obs_json)
+                rs_num += 1
 
     def load_music(self):
         music_loader.play(self.map_music, self.map_music_volume * self.special_music_volume)
@@ -468,113 +614,161 @@ class Level:
     def record_achievement(self):
         pass
 
-    def load_district_and_enemies(self):
-        if len(self.npcs) > 0:  # npc还没有被杀光
-            return
-        self.me.district_locked = False  # 解除玩家区域锁
-        if self.district_idx >= len(self.map_json["districts"]):  # 已完成最后一个区域
-            self.district_square = {"x1": 0, "x2": 0, "y1": 0, "y2": 0}
-            self.district_square_grid = {"x1": 0, "x2": 0, "y1": 0, "y2": 0}
-            self.district_all_finished = True
-
-            if self.check_full_achievement() and not G.HAS_RECORD_FULL:
-                G.HAS_RECORD_FULL = True
-                # 构建保存文件的路径
-                user_documents_folder = os.path.expanduser("~\\Documents")  # 获取用户的"文档"文件夹路径
-                qqtpve_folder = os.path.join(user_documents_folder, "QQTPVE")  # 构建QQTPVE文件夹路径
-                os.makedirs(qqtpve_folder, exist_ok=True)  # 确保QQTPVE文件夹存在,如果不存在则创建
-                full_achievements_file_path = os.path.join(qqtpve_folder, "full_achievements.json")  # 构建full_achievements.json文件路径
+    def update_map_tranport_remain(self, new_remain):
+        path = f"game/map/{self.map_name}.json"
+        map_json = load_json(path)
+        map_json["basic"]["transport_remain"] = new_remain
+        self.async_json_saver.save(path, map_json)
+
+    def check_game_achievement(self):
+        if self.check_full_achievement() and not G.HAS_RECORD_FULL:
+            G.HAS_RECORD_FULL = True
+            # 构建保存文件的路径
+            user_documents_folder = os.path.expanduser("~\\Documents")  # 获取用户的"文档"文件夹路径
+            qqtpve_folder = os.path.join(user_documents_folder, "QQTPVE")  # 构建QQTPVE文件夹路径
+            os.makedirs(qqtpve_folder, exist_ok=True)  # 确保QQTPVE文件夹存在,如果不存在则创建
+            full_achievements_file_path = os.path.join(qqtpve_folder, "full_achievements.json")  # 构建full_achievements.json文件路径
+            try:
+                with open(full_achievements_file_path, encoding="utf-8") as file:
+                    encrypted_data = json.load(file)
+            except:
                 try:
-                    with open(full_achievements_file_path, encoding="utf-8") as file:
+                    with open(full_achievements_file_path, encoding="utf-8_sig") as file:
                         encrypted_data = json.load(file)
                 except:
-                    try:
-                        with open(full_achievements_file_path, encoding="utf-8_sig") as file:
-                            encrypted_data = json.load(file)
-                    except:
-                        # 如果文件不存在,创建新的空的achievements.json文件
-                        encrypted_data = {"STAT": []}
-                        with open(full_achievements_file_path, 'w', encoding="utf-8") as file:
-                            json.dump(encrypted_data, file, indent=2)
-                if encrypted_data == {}:
+                    # 如果文件不存在,创建新的空的achievements.json文件
                     encrypted_data = {"STAT": []}
-                # 新的数据
-                new_data = {caesar_encrypt("name"): caesar_encrypt(G.MAP_SET_NAME),
-                            caesar_encrypt("last_map_name"): caesar_encrypt(G.MAP_NAME),
-                            caesar_encrypt("map_order"): int(caesar_encrypt(str(G.CURRENT_LEVEL))),
-                            caesar_encrypt("LV"): int(caesar_encrypt(str(self.me.blood))),
-                            caesar_encrypt("time"): caesar_encrypt(datetime.now().strftime("%Y-%m-%d %H:%M:%S")),
-                            caesar_encrypt("game_time_min"): int(caesar_encrypt(str(self.map_time//60))),
-                            caesar_encrypt("game_time_sec"): int(caesar_encrypt(str(self.map_time%60)))}
-                # 添加新的加密数据
-                encrypted_data["STAT"].append(new_data)
-                with open(full_achievements_file_path, 'w') as file:
-                    json.dump(encrypted_data, file, indent=2)
-
-            if self.check_achievement() and G.CURRENT_LEVEL==G.TOTAL_LEVEL and not G.HAS_RECORD:
-                G.HAS_RECORD = True
-                sound_player.playWin("PlayerWin")
-                # 构建保存文件的路径
-                user_documents_folder = os.path.expanduser("~\\Documents")  # 获取用户的"文档"文件夹路径
-                qqtpve_folder = os.path.join(user_documents_folder, "QQTPVE")  # 构建QQTPVE文件夹路径
-                os.makedirs(qqtpve_folder, exist_ok=True)  # 确保QQTPVE文件夹存在,如果不存在则创建
-                achievements_file_path = os.path.join(qqtpve_folder, "achievements.json")  # 构建achievements.json文件路径
-                monster_stats_file_path = os.path.join(qqtpve_folder, "monster_stats.json")  # 构建json文件路径
+                    with open(full_achievements_file_path, 'w', encoding="utf-8") as file:
+                        json.dump(encrypted_data, file, indent=2)
+            if encrypted_data == {}:
+                encrypted_data = {"STAT": []}
+            # 新的数据
+            new_data = {
+                caesar_encrypt("name"): caesar_encrypt(G.MAP_SET_NAME),
+                caesar_encrypt("last_map_name"): caesar_encrypt(G.MAP_NAME),
+                caesar_encrypt("map_order"): int(caesar_encrypt(str(G.CURRENT_LEVEL))),
+                caesar_encrypt("LV"): int(caesar_encrypt(str(self.me.blood))),
+                caesar_encrypt("time"): caesar_encrypt(datetime.now().strftime("%Y-%m-%d %H:%M:%S")),
+                caesar_encrypt("game_time_min"): int(caesar_encrypt(str(self.map_time//60))),
+                caesar_encrypt("game_time_sec"): int(caesar_encrypt(str(self.map_time%60)))
+            }
+            # 添加新的加密数据
+            encrypted_data["STAT"].append(new_data)
+            with open(full_achievements_file_path, 'w') as file:
+                json.dump(encrypted_data, file, indent=2)
+        if G.CURRENT_LEVEL == G.TOTAL_LEVEL:
+            G.CUMULATION_INJURE += self.me.blood - self.me.remain_blood
+        if self.check_achievement() and G.CURRENT_LEVEL == G.TOTAL_LEVEL and not G.HAS_RECORD:
+            G.HAS_RECORD = True
+            sound_player.playWin("PlayerWin")
+            if self.is_transport:
+                if self.transport_map_remain > 0:
+                    TransportSuccessEffect(self.me, self.me, self.transport_map_remain, self.skill_instances)
+                    current_amount = max(G.TOTAL_TRANSPORT - G.CUMULATION_RESOURCE_LEAK + 50, 0) * (1 - G.CUMULATION_INJURE / (self.me.blood * G.TOTAL_LEVEL))
+                    new_remain = max(0, self.transport_map_remain - current_amount)
+                    current_amount = int(current_amount)
+                    new_remain = int(new_remain)
+                    if new_remain > 0:
+                        msg_txt = f"本次成功运输{current_amount}点资源,当前还剩余{new_remain}/{self.transport_map_total}"
+                    else:
+                        msg_txt = f"本次成功运输{current_amount}点资源,当前地图所有运输任务已完成!!!"
+                    self.message_entry.new_message(sender="运输助手", message=msg_txt, colour=[95, 191, 255])
+                    self.update_map_tranport_remain(new_remain)
+                    self.map_blood_bar.update_remain_blood(new_remain)
+                else:
+                    if G.CUMULATION_INJURE == 0:
+                        WinEffect(self.me, self.me, "super", self.skill_instances)
+                    elif G.CUMULATION_INJURE < min(4500, self.me.blood):
+                        WinEffect(self.me, self.me, "ultra", self.skill_instances)
+                    else:
+                        WinEffect(self.me, self.me, "big", self.skill_instances)
+                    current_amount = max(G.TOTAL_TRANSPORT - G.CUMULATION_RESOURCE_LEAK + 50, 0) * (1 - G.CUMULATION_INJURE / (self.me.blood * G.TOTAL_LEVEL))
+                    current_amount = int(current_amount)
+                    if current_amount > 0:
+                        msg_txt = f"当前区域运输目标已完成,本次额外运输{current_amount}点资源"
+                        self.message_entry.new_message(sender="运输助手", message=msg_txt, colour=[95, 191, 255])
+            else:
+                if G.CUMULATION_INJURE == 0:
+                    WinEffect(self.me, self.me, "super", self.skill_instances)
+                elif G.CUMULATION_INJURE < min(4500, self.me.blood):
+                    WinEffect(self.me, self.me, "ultra", self.skill_instances)
+                else:
+                    WinEffect(self.me, self.me, "big", self.skill_instances)
+            # 构建保存文件的路径
+            user_documents_folder = os.path.expanduser("~\\Documents")  # 获取用户的"文档"文件夹路径
+            qqtpve_folder = os.path.join(user_documents_folder, "QQTPVE")  # 构建QQTPVE文件夹路径
+            os.makedirs(qqtpve_folder, exist_ok=True)  # 确保QQTPVE文件夹存在,如果不存在则创建
+            achievements_file_path = os.path.join(qqtpve_folder, "achievements.json")  # 构建achievements.json文件路径
+            monster_stats_file_path = os.path.join(qqtpve_folder, "monster_stats.json")  # 构建json文件路径
 
+            try:
+                with open(achievements_file_path, encoding="utf-8") as file:
+                    encrypted_data = json.load(file)
+            except:
                 try:
-                    with open(achievements_file_path, encoding="utf-8") as file:
+                    with open(achievements_file_path, encoding="utf-8_sig") as file:
                         encrypted_data = json.load(file)
                 except:
-                    try:
-                        with open(achievements_file_path, encoding="utf-8_sig") as file:
-                            encrypted_data = json.load(file)
-                    except:
-                        # 如果文件不存在,创建新的空的achievements.json文件
-                        encrypted_data = {"STAT": []}
-                        with open(achievements_file_path, 'w', encoding="utf-8") as file:
-                            json.dump(encrypted_data, file, indent=2)
-                if encrypted_data == {}:
+                    # 如果文件不存在,创建新的空的achievements.json文件
                     encrypted_data = {"STAT": []}
-                # 新的数据
-                new_data = {caesar_encrypt("name"): caesar_encrypt(G.MAP_SET_NAME),
-                            caesar_encrypt("last_map_name"): caesar_encrypt(G.MAP_NAME),
-                            caesar_encrypt("LV"): int(caesar_encrypt(str(self.me.blood))),
-                            caesar_encrypt("time"): caesar_encrypt(datetime.now().strftime("%Y-%m-%d %H:%M:%S")),
-                            caesar_encrypt("game_time_min"): int(caesar_encrypt(str(self.map_time//60))),
-                            caesar_encrypt("game_time_sec"): int(caesar_encrypt(str(self.map_time%60))),
-                            caesar_encrypt("remain_blood"): int(caesar_encrypt(str(self.me.remain_blood)))}
-                try:
-                    # 添加新的加密数据
-                    encrypted_data["STAT"].append(new_data)
-                    with open(achievements_file_path, 'w') as file:
+                    with open(achievements_file_path, 'w', encoding="utf-8") as file:
                         json.dump(encrypted_data, file, indent=2)
-                except:
-                    pass
+            if encrypted_data == {}:
+                encrypted_data = {"STAT": []}
+            # 新的数据
+            new_data = {caesar_encrypt("name"): caesar_encrypt(G.MAP_SET_NAME),
+                        caesar_encrypt("last_map_name"): caesar_encrypt(G.MAP_NAME),
+                        caesar_encrypt("LV"): int(caesar_encrypt(str(self.me.blood))),
+                        caesar_encrypt("time"): caesar_encrypt(datetime.now().strftime("%Y-%m-%d %H:%M:%S")),
+                        caesar_encrypt("game_time_min"): int(caesar_encrypt(str(self.map_time//60))),
+                        caesar_encrypt("game_time_sec"): int(caesar_encrypt(str(self.map_time%60))),
+                        caesar_encrypt("remain_blood"): int(caesar_encrypt(str(self.me.remain_blood)))}
+            try:
+                # 添加新的加密数据
+                encrypted_data["STAT"].append(new_data)
+                with open(achievements_file_path, 'w') as file:
+                    json.dump(encrypted_data, file, indent=2)
+            except:
+                pass
 
+            try:
+                with open(monster_stats_file_path, encoding="utf-8") as file:
+                    self.encrypted_data_m = json.load(file)
+            except:
                 try:
-                    with open(monster_stats_file_path, encoding="utf-8") as file:
+                    with open(monster_stats_file_path, encoding="utf-8_sig") as file:
                         self.encrypted_data_m = json.load(file)
                 except:
-                    try:
-                        with open(monster_stats_file_path, encoding="utf-8_sig") as file:
-                            self.encrypted_data_m = json.load(file)
-                    except:
-                        # 如果文件不存在,创建新的空的json文件
-                        self.encrypted_data_m = {"STAT": []}
-                        with open(monster_stats_file_path, 'w', encoding="utf-8") as file:
-                            json.dump(self.encrypted_data_m, file, indent=2)
-                if self.encrypted_data_m == {}:
+                    # 如果文件不存在,创建新的空的json文件
                     self.encrypted_data_m = {"STAT": []}
-
-                try:
-                    for data in G.MONSTER_RECORD_LIST:
-                        self.encrypted_data_m["STAT"].append(data)
-                    with open(monster_stats_file_path, 'w') as file:
+                    with open(monster_stats_file_path, 'w', encoding="utf-8") as file:
                         json.dump(self.encrypted_data_m, file, indent=2)
-                    G.MONSTER_RECORD_LIST = []
-                except:
-                    G.MONSTER_RECORD_LIST = []
+            if self.encrypted_data_m == {}:
+                self.encrypted_data_m = {"STAT": []}
 
+            try:
+                for data in G.MONSTER_RECORD_LIST:
+                    self.encrypted_data_m["STAT"].append(data)
+                with open(monster_stats_file_path, 'w') as file:
+                    json.dump(self.encrypted_data_m, file, indent=2)
+                G.MONSTER_RECORD_LIST = []
+            except:
+                G.MONSTER_RECORD_LIST = []
+        else:
+            if G.CURRENT_LEVEL == G.TOTAL_LEVEL:
+                WinEffect(self.me, self.me, "normal", self.skill_instances)
+
+    def load_district_and_enemies(self):
+        if len(self.npcs) > 0:  # npc还没有被杀光
+            return
+        self.me.district_locked = False  # 解除玩家区域锁
+        if self.district_idx >= len(self.map_json["districts"]):  # 已完成最后一个区域
+            self.district_square = {"x1": 0, "x2": 0, "y1": 0, "y2": 0}
+            self.district_square_grid = {"x1": 0, "x2": 0, "y1": 0, "y2": 0}
+            self.district_all_finished = True
+            if not self.has_achievemeny_check:
+                self.has_achievemeny_check = True
+                self.check_game_achievement()
             return
         self.district_idx += 1
         a_district = self.map_json["districts"][self.district_idx - 1]
@@ -595,7 +789,11 @@ class Level:
                 self.ghosts.remove(g)
         for n in a_district["npcs"]:
             # 载入新区域的npc
-            self.npcs.append(Npc(n["name"], (n["x"], n["y"])))
+            patrol = n.get("patrol", None)
+            if patrol is not None:
+                self.npcs.append(Npc(n["name"], (n["x"], n["y"]), patrol_path=patrol))
+            else:
+                self.npcs.append(Npc(n["name"], (n["x"], n["y"])))
         for district in self.map_json["districts"][self.district_idx-1:]:
             x1, y1, x2, y2 = district["square"]["x1"], district["square"]["y1"], district["square"]["x2"], district["square"]["y2"]
             for point in self.poison_dic.keys():
@@ -611,9 +809,9 @@ class Level:
                 del self.poison_dic[point]
 
     def update(self, screen: pygame.Surface):
-
         # a = pygame.time.get_ticks()
         self.current_time = pygame.time.get_ticks()
+        self.run_earth_quake_effect(screen)  # 运行屏幕震动效果
 
         # 刷新帧率
         self.display_frame_rate(self.current_time, screen)
@@ -639,6 +837,13 @@ class Level:
         for b in self.bomb_instances:
             b.update()
 
+        # 刷新游荡者
+        for w in self.wanderers:
+            if w.remain_blood <= 0:
+                self.wanderers.remove(w)
+            else:
+                w.update()
+
         # 刷新npc
         for n in self.npcs:
             if n.remain_blood <= 0:
@@ -648,8 +853,9 @@ class Level:
         self.recal_npc_paths = False
 
         # 刷新宠物
-        if self.pet is not None:
-            self.pet.update()
+        if len(self.pets) > 0:
+            for pet in self.pets:
+                pet.update()
 
         # 刷新ghost
         for g in self.ghosts:
@@ -688,6 +894,12 @@ class Level:
             self.update_obstacles_update_list()
         for o in self.obstacle_instances_update:
             o.update()
+        self.transport_buff_num = 0
+        for o in self.transport_obstacle:
+            if o.transport_remain > 0:
+                o.update()
+                if o.in_safe_zone:
+                    self.transport_buff_num += 1
 
         # 刷新技能
         for s in self.skill_instances:
@@ -707,6 +919,11 @@ class Level:
         for u in self.ui_instances_bot:
             u.update()
 
+        if Y_SCALE_FACTOR != 1:
+            MAX_BIAS = G.MAIN_AREA_Y_POS * (1-Y_SCALE_FACTOR)//2
+            # 上下MAX_BIAS区域填充(0,0,0,0)
+            self.main_area.fill((255, 255, 255, 0), (self.scroll_x_pos, self.scroll_y_pos + 21, G.MAIN_AREA_X_POS, MAX_BIAS))
+
         # 显示地板
         self.main_area.blit(
             self.floor_image,
@@ -719,10 +936,11 @@ class Level:
             e.draw(self.main_area)
 
         # 显示人物和障碍
-        if self.pet is not None:
-            draw_seq = [self.pet] + \
+        if len(self.pets) > 0:
+            draw_seq = self.pets + \
                        [self.me] + \
                        self.npcs + \
+                       self.wanderers + \
                        self.ghosts + \
                        self.bomb_instances + \
                        self.obstacle_instances_update + \
@@ -731,6 +949,7 @@ class Level:
         else:
             draw_seq = [self.me] + \
                        self.npcs + \
+                       self.wanderers + \
                        self.ghosts + \
                        self.bomb_instances + \
                        self.obstacle_instances_update + \
@@ -745,9 +964,19 @@ class Level:
             self.mask_surface = special_colour_mask(self.mask_surface, self.rgb_light)
             self.main_area.blit(self.mask_surface, (0, 0), special_flags=pygame.BLEND_RGBA_MULT)
 
-        if self.haunt_Mode:   # 鬼屋模式下显示玩家
-            self.mask_surface = get_player_mask(self.mask_surface, self.bg_light)
-            self.main_area.blit(self.mask_surface, (0, 0), special_flags=pygame.BLEND_RGBA_MULT)
+        if self.haunt_Mode:
+            # 只在 get_player_mask 检测到状态变化时才重绘 mask_surface
+            get_player_mask(self.mask_surface, self.bg_light)
+            view_rect = pygame.Rect(
+                self.scroll_x_pos,
+                self.scroll_y_pos,
+                G.MAIN_AREA_X_POS,
+                G.MAIN_AREA_Y_POS
+            ).clip(self.main_area.get_rect())
+            # 取 main_area 的子 Surface(不拷贝像素,O(1))
+            sub_main = self.main_area.subsurface(view_rect)
+            # 将 mask_surface 乘进子 Surface,而不是整张 main_area
+            sub_main.blit(self.mask_surface, (0, 0), special_flags=pygame.BLEND_RGBA_MULT)
 
         # 显示顶层特效
         for e in self.effects_front:
@@ -768,8 +997,8 @@ class Level:
         for e in self.effects_screen:
             try:
                 e.draw(screen)
-            except:
-                pass
+            except Exception as e:
+                print(e)
 
         # 左侧黑条
         screen.blit(self.left_black, (0, 0))
@@ -778,9 +1007,7 @@ class Level:
         BombInstance.sound_played = False
 
         # 重置糖泡爆炸方向记录
-        for x in range(self.map_x):
-            for y in range(self.map_y):
-                self.grid_damage_orientations[(x, y)] = set()
+        self.grid_damage_orientations.clear()
 
         # print(pygame.time.get_ticks() - a)
 
@@ -816,6 +1043,18 @@ class Level:
             if self.me.x == self.finish_at[0] and self.me.y == self.finish_at[1]:
                 self.finish_flag = True
                 G.LAST_LEVEL_TIME = self.times_num
+                G.CUMULATION_INJURE += (self.me.blood - self.me.remain_blood)
+                if self.is_transport:
+                    resouce_next = 0
+                    injured = 0
+                    for o in self.transport_obstacle:
+                        if o.transport_remain > 0 and o.in_safe_zone:
+                            injured += o.transport_amount - o.transport_remain
+                            resouce_next += 1
+                    G.RESOUCE_NUM = resouce_next
+                    if G.CURRENT_LEVEL == 1:
+                        G.TOTAL_TRANSPORT = resouce_next
+                        G.CUMULATION_RESOURCE_LEAK = injured
 
     # 传送门,参数格式: {"[x1,y1]":{"type": "level", "target": [x2,y2]}, "[x3,y3]":{"type": "map", "target": 3}, "[x4,y4]":{"type": "map_set", "target": "Mo1"}}
     def portal_map(self):
@@ -878,7 +1117,7 @@ class Level:
                 self.scroll_y_pos = scroll_y_old - MAX_DIST
                 self.obstacle_instances_need_to_update = True
         # 限制滚动范围
-        if self.scroll_x_pos> self.scroll_x_pos_max:
+        if self.scroll_x_pos > self.scroll_x_pos_max:
             self.scroll_x_pos = self.scroll_x_pos_max
         if self.scroll_y_pos > self.scroll_y_pos_max:
             self.scroll_y_pos = self.scroll_y_pos_max

+ 20 - 11
client_local/music/music_loader.py

@@ -1,4 +1,5 @@
 import pygame
+import client_local.const.game as G
 
 current_music = ""
 current_ambience = ""
@@ -9,10 +10,14 @@ def play(name, volume):
     global current_music
     if current_music == name:
         return
-    pygame.mixer.music.load("res/music/" + name)
-    pygame.mixer.music.set_volume(volume)
-    pygame.mixer.music.play(loops=-1, fade_ms=1000)
-    current_music = name
+    try:
+        pygame.mixer.music.load(f"res/music/{name}")
+        pygame.mixer.music.set_volume(volume)
+        pygame.mixer.music.play(loops=-1, fade_ms=1000)
+        current_music = name
+    except Exception as e:
+        print(e)
+
 
 def play_ambience(name, volume):
     global current_ambience, ambience_sounds
@@ -21,13 +26,17 @@ def play_ambience(name, volume):
     # 停止当前正在播放的环境音效
     stop_ambience()
     # 加载并播放新的环境音效
-    sound_path = "res/ambience/" + name
-    ambience_sound = pygame.mixer.Sound(sound_path)
-    ambience_sound.set_volume(volume)
-    ambience_sound.play(loops=-1)
-    ambience_sounds[name] = ambience_sound  # 更新字典
-    current_ambience = name
-    # print(f"Playing ambience: {name}")
+    try:
+        sound_path = "res/ambience/" + name
+        ambience_sound = pygame.mixer.Sound(sound_path)
+        ambience_sound.set_volume(volume)
+        ambience_sound.play(loops=-1)
+        ambience_sounds[name] = ambience_sound  # 更新字典
+        current_ambience = name
+        # print(f"Playing ambience: {name}")
+    except Exception as e:
+        print(e)
+
 
 def stop_ambience():
     global current_ambience, ambience_sounds

+ 151 - 0
client_local/skill/cool_machine_skill.py

@@ -1043,10 +1043,161 @@ class PowerOFF(Skill):
 
 
 
+# 没电了(<1)就自杀
+class SuperPowerOFF(Skill):
+    def __init__(self, user, to, skill_instances):
+        self.charge = False
+        self.explode = False
+        self.yes_exp = False
+        self.trigger = False
+        self.trigger_time = 0
+        self.is_dying = False
+        self.flag_thunder_explode = True  # 400ms
+        self.target = None
+        self.explode = False
+        self.explode_time = 0
+        self.dmg = 500
+        super().__init__(user, to, skill_instances)
+
+    def load(self):
+        super().load()
+
+    def update(self):
+        super().update()
+        if not self.charge:
+            # if self.user.has_energy and self.user.energy_amount <= max(1,int(self.user.max_energy_amount/20)):
+            if self.user.has_energy and self.user.energy_amount < 1:
+                self.user.speed = 0
+                self.charge = True
+                self.explode = True
+                self.user.energy_amount = 0
+                self.user.remain_blood = 1
+                self.yes_exp = True
+                # DeadExplode(self.user, self.to, self.skill_instances)
+                # self.kill()
+
+        if self.yes_exp:
+            if not self.trigger:
+                self.trigger = True
+                self.trigger_time = self.current_time
+                sound_player.play("explode")
+                self.user.rooted_for(10000)
+
+            if self.trigger and self.trigger_time>0 and not self.is_dying:
+                self.is_dying = True
+                if self.flag_thunder_explode:
+                    self.flag_thunder_explode = False
+                    self.target = self.to
+                    NPC_Obstacle3x3Explode(level.current_level.me, self.user, level.current_level.skill_instances)
+                    for t in self.target:
+                        if abs(t.x-self.user.x) <= 1 and abs(t.y-self.user.y) <= 1:
+                            t.try_damage(10000)
+                            t.rooted_for(1000)
+                            try:
+                                if t.has_energy:
+                                    t.energy_amount -= min(max(10,int(t.max_energy_amount/10)), t.energy_amount)
+                            except:
+                                pass
+                    if abs(level.current_level.me.x-self.user.x)<=1 and abs(level.current_level.me.y-self.user.y)<=1:
+                        level.current_level.me.try_damage(300)
+                        level.current_level.me.rooted_for(500)
+                        sound_player.play("cry")
+                    self.explode = True
+                    self.explode_time = self.current_time
+                    self.user.try_damage(1000000000000000000000000000000000)
+                    self.user.die()
+                    self.user.remain_blood = 0
+                    self.kill()
+
+            if self.explode and self.current_time - self.explode_time >= 300:
+                self.kill()
+                return
+
+        if self.explode or not self.user.has_energy:
+            if self.user.remain_blood > 0:
+                self.user.energy_amount = 0
+                self.kill()
+
+
 
 
 
 
+# 没电了(<1)就自杀
+class SuperSuperPowerOFF(Skill):
+    def __init__(self, user, to, skill_instances):
+        self.charge = False
+        self.explode = False
+        self.yes_exp = False
+        self.trigger = False
+        self.trigger_time = 0
+        self.is_dying = False
+        self.flag_thunder_explode = True  # 400ms
+        self.target = None
+        self.explode = False
+        self.explode_time = 0
+        self.dmg = 500
+        super().__init__(user, to, skill_instances)
+
+    def load(self):
+        super().load()
+
+    def update(self):
+        super().update()
+        if not self.charge:
+            # if self.user.has_energy and self.user.energy_amount <= max(1,int(self.user.max_energy_amount/20)):
+            if self.user.has_energy and self.user.energy_amount < 1:
+                self.user.speed = 0
+                self.charge = True
+                self.explode = True
+                self.user.energy_amount = 0
+                self.user.remain_blood = 1
+                self.yes_exp = True
+
+        if self.yes_exp:
+            if not self.trigger:
+                self.trigger = True
+                self.trigger_time = self.current_time
+                sound_player.play("explode")
+                self.user.rooted_for(10000)
+
+            if self.trigger and self.trigger_time>0 and not self.is_dying:
+                self.is_dying = True
+                if self.flag_thunder_explode:
+                    self.flag_thunder_explode = False
+                    self.target = self.to
+                    NPC_Obstacle3x3Explode(level.current_level.me, self.user, level.current_level.skill_instances)
+                    for t in self.target:
+                        if abs(t.x-self.user.x) <= 1 and abs(t.y-self.user.y) <= 1:
+                            t.try_damage(10000)
+                            t.rooted_for(1000)
+                            try:
+                                if t.has_energy:
+                                    t.energy_amount -= min(max(15,int(t.max_energy_amount/5)), t.energy_amount)
+                            except:
+                                pass
+                    if abs(level.current_level.me.x-self.user.x)<=1 and abs(level.current_level.me.y-self.user.y)<=1:
+                        level.current_level.me.try_damage(300)
+                        level.current_level.me.rooted_for(500)
+                        sound_player.play("cry")
+                    self.explode = True
+                    self.explode_time = self.current_time
+                    self.user.try_damage(1000000000000000000000000000000000)
+                    self.user.die()
+                    self.user.remain_blood = 0
+                    self.kill()
+
+            if self.explode and self.current_time - self.explode_time >= 300:
+                self.kill()
+                return
+
+        if self.explode or not self.user.has_energy:
+            if self.user.remain_blood > 0:
+                self.user.energy_amount = 0
+                self.kill()
+
+
+
 
 
 

+ 27 - 6
client_local/skill/cool_skill.py

@@ -998,7 +998,8 @@ class AirFlow500(Skill):
             for e in self.effect_instances:
                 e.state = EffectState.DEAD
             self.kill()
-        if self.current_time - self.skill_time_init > 800 and self.launch:
+        dt = self.current_time - self.skill_time_init
+        if dt > 800 and self.launch:
             self.launch = False
             self.user.rooted -= 1
             if self.user.remain_blood == 0:
@@ -1010,7 +1011,7 @@ class AirFlow500(Skill):
             self.direction = self.user.orientation
             self.knife_effect = EffectInstance(self.eff_names[self.direction], self.user, False, level.current_level.effects_front)
             self.old_time = self.current_time
-        if self.current_time - self.skill_time_init > 800 and self.end:
+        if dt > 800 and self.end:
             delta_time = self.current_time - self.old_time  # 计算两次调用update的间隔
             self.knife_effect.set_xy_pos(
                 self.knife_effect.x_pos + delta_time * self.direction_to_adder[self.direction][0],
@@ -1026,7 +1027,7 @@ class AirFlow500(Skill):
                     self.to.try_damage(500)
                     self.end = False
             self.counter += 1
-            if self.counter > 400:
+            if self.counter > 2000 or dt >= 3000:
                 self.end = False
         if self.loaded:
             self.loaded = False
@@ -1066,7 +1067,8 @@ class FourSidedAirFlow500(Skill):
                 effect.state = EffectState.DEAD
             sound_player.play("explode")
             self.kill()
-        if self.current_time - self.skill_time_init > 800 and self.launch:
+        dt = self.current_time - self.skill_time_init
+        if dt > 800 and self.launch:
             self.launch = False
             self.user.rooted -= 1
             if self.user.remain_blood == 0:
@@ -1078,7 +1080,7 @@ class FourSidedAirFlow500(Skill):
             for i, direction in enumerate(self.directions):
                 self.knife_effect[i] = EffectInstance(self.eff_names[direction], self.user, False, level.current_level.effects_front)
                 self.old_time[i] = self.current_time
-        if self.current_time - self.skill_time_init > 800 and any(self.end):
+        if dt > 800 and any(self.end):
             for i, direction in enumerate(self.directions):
                 if not self.end[i]:
                     continue
@@ -1100,7 +1102,7 @@ class FourSidedAirFlow500(Skill):
                         self.to.try_damage(500)
                         self.end[i] = False
                 self.counter[i] += 1
-                if self.counter[i] > 400:
+                if self.counter[i] > 2000 or dt >= 3000:
                     self.end[i] = False
         if self.loaded:
             self.loaded = False
@@ -2882,6 +2884,25 @@ class KillSelf(Skill):
             return
 
 
+# 自杀
+class KillSelfQuietly(Skill):
+
+    def __init__(self, user, to, skill_instances):
+        super().__init__(user, to, skill_instances)
+        self.trigger = True
+
+    def load(self):
+        super().load()
+        self.trigger = True
+        self.user.die_quietly()
+
+    def update(self):
+        super().update()
+        if self.current_time - self.skill_time_init > 200:
+            self.kill()
+            return
+
+
 
 
 

+ 72 - 0
client_local/skill/machine_skill.py

@@ -406,6 +406,78 @@ class BigTimeStop(Skill):
                     self.effect_instances.append(an_effect)
 
 
+
+# 中时间静止500伤
+class MediumTimeStop(Skill):
+
+    def __init__(self, user, to, skill_instances):
+        super().__init__(user, to, skill_instances)
+        self.loaded = True
+        self.flag_thunder_down = True  # 300ms
+        self.flag_thunder_explode = True  # 400ms
+
+    def load(self):
+        super().load()
+        self.effect_instances.append(
+            EffectInstance("thunder_charge", self.user, False, self.user.effects_front)
+        )
+        sound_player.play("launch")
+        self.user.rooted_for(1600)
+        self.user.align_xy()
+
+    def update(self):
+        super().update()
+        if self.current_time - self.skill_time_init > 2000:
+            for e in self.effect_instances:
+                e.state = EffectState.DEAD
+            self.kill()
+
+        if self.current_time - self.skill_time_init > 1000 and self.flag_thunder_down:
+            self.flag_thunder_down = False
+            for x in range(self.user_x - 2, self.user_x + 3):
+                for y in range(self.user_y - 2, self.user_y + 3):
+                    an_effect = EffectInstance("thunder_down", self.user, False, self.user.effects_front)
+                    an_effect.x_pos = x * G.GAME_SQUARE + G.HALF_GAME_SQUARE
+                    an_effect.y_pos = y * G.GAME_SQUARE + G.HALF_GAME_SQUARE
+                    self.effect_instances.append(an_effect)
+
+        if self.current_time - self.skill_time_init > 1300 and self.flag_thunder_explode:
+            self.flag_thunder_explode = False
+            me = level.current_level.me
+            for x in range(self.user_x - 2, self.user_x + 3):
+                for y in range(self.user_y - 2, self.user_y + 3):
+                    an_effect = EffectInstance("thunder_explode", self.user, False, self.user.effects_front)
+                    an_effect.x_pos = x * G.GAME_SQUARE + G.HALF_GAME_SQUARE
+                    an_effect.y_pos = y * G.GAME_SQUARE + G.HALF_GAME_SQUARE
+                    self.effect_instances.append(an_effect)
+                    if me.x == x and me.y == y:
+                        self.dizzy_rooted_effect = EffectInstance("reverse", self.to, True, self.to.effects_front)
+                        self.to.try_damage(500)
+                        self.to.rooted_for(2500)
+                        sound_player.play("cry")
+            self.user.rooted -= 1
+            sound_player.play("crash")
+            sound_player.play("explode2")
+
+        if self.loaded:
+            # 显示火焰提示与npc施法阵
+            self.loaded = False
+            self.user.rooted += 1
+            self.user.align_xy()
+            self.effect_instances.append(
+                EffectInstance("violent", self.user, False, level.current_level.effects_behind)
+            )
+            self.effect_instances.append(
+                EffectInstance("violent", self.user, False, level.current_level.effects_behind)
+            )
+            for x in range(self.user_x - 2, self.user_x + 3):
+                for y in range(self.user_y - 2, self.user_y + 3):
+                    an_effect = EffectInstance("thunder_trap", self.user, False, level.current_level.effects_behind)
+                    an_effect.set_xy(x, y)
+                    self.effect_instances.append(an_effect)
+
+
+
 # 反向5s(非直接使用的技能)
 class Reverse5s(Skill):
 

+ 62 - 60
client_local/skill/obstacle_skill.py

@@ -1,51 +1,19 @@
 import random
-from client_local.algo import aStar
-from client_local.skill.skill import Skill
-from client_local.effect.effect_instance import EffectState, EffectInstance
-from client_local.frame import bomb
-from client_local.level import level
-from client_local.sound import sound_player
-from client_local.sprite.bomb_instance import BombInstance, BombInstanceBlack, BombInstanceGold
-
-
-
-from math import sqrt
-
+import logging
 import pygame.time
+from math import sqrt
+from datetime import datetime
 
 from client_local.const import game as G
 from client_local.effect.effect_instance import EffectInstance, EffectState
 from client_local.level import level
-from client_local.skill.skill import Skill, IceSlow, GotPoisonSmoke50x3, GotPoisonSmoke80x2
 from client_local.sound import sound_player
+from client_local.skill.skill import Skill, IceSlow, GotPoisonSmoke50x3, GotPoisonSmoke80x2
 
-from client_local.level import level
-
-import logging
-from datetime import datetime
 
 # 配置logging基础配置并设置日志级别为INFO
 # logging.basicConfig(filename='OBSTACLE_SKILL.log', level=logging.INFO)
 
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
 
 # 3*3(自爆)
 class Obstacle3x3Explode(Skill):
@@ -81,30 +49,6 @@ class Obstacle3x3Explode(Skill):
             self.kill()
 
 
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
 # 特效部分和引爆周围
 class NPC_Obstacle3x3Explode(Skill):
 
@@ -146,5 +90,63 @@ class NPC_Obstacle3x3Explode(Skill):
             self.loaded = False
 
 
+# 运输桶技能
+class ObstacleTransportResourceSkill(Skill):
+
+    def __init__(self, user, to, skill_instances, dmg):
+        super().__init__(user, to, skill_instances)
+        self.dmg = dmg
+        self.flag_thunder_explode = True  # 400ms
+        target = [level.current_level.me]
+        radius = self.user.transport_range + 0.5
+        is_out_of_monitored = [(abs(t.x - self.user.x) > radius or abs(t.y - self.user.y) > radius) for t in target]
+        out_destination = True
+        if level.current_level.finish_at is not None:
+            out_destination = abs(self.user.x - level.current_level.finish_at[0]) > 2 or abs(self.user.y - level.current_level.finish_at[1]) > 2
+        else:
+            if level.current_level.transport_destination is not None:
+                out_destination = abs(self.user.x - level.current_level.transport_destination[0]) > 2 or abs(self.user.y - level.current_level.transport_destination[1]) > 2
+        if all(is_out_of_monitored) and out_destination:
+            if self.user.in_safe_zone:
+                self.user.in_safe_zone = False
+                self.user.last_leave_time = self.current_time
+                # level.current_level.message_entry.new_message(sender="[警告]", message="距离过远! 三秒之后资源将开始受损!", colour=(255, 255, 255))
+            else:
+                if self.current_time - self.user.last_leave_time >= 5000:
+                    before = self.user.transport_remain
+                    self.user.transport_remain = max(0, self.user.transport_remain - self.user.transport_leak)
+                    G.CUMULATION_RESOURCE_LEAK += (before - self.user.transport_remain)
+                    if self.user.transport_remain <= 0:
+                        level.current_level.message_entry.new_message(sender="[警告]", message="资源已损毁!", colour=(255, 255, 255))
+                        sound_player.play("explode")
+                        try:
+                            if self.user in level.current_level.obstacle_instances_update:
+                                level.current_level.obstacle_instances_update.remove(self.user)
+                            level.current_level.transport_obstacle.remove(self.user)
+                        except Exception as e:
+                            print(e)
+                        self.user.uninstall()
+                        self.user.die(forced=True)
+        else:
+            self.user.in_safe_zone = True
+        self.kill()
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
 
 

+ 551 - 33
client_local/skill/parametric2_skill.py

@@ -1,41 +1,32 @@
 import random
-from client_local.algo import aStar
-from client_local.skill.skill import Skill
-from client_local.effect.effect_instance import EffectState, EffectInstance
-from client_local.frame import bomb
-from client_local.frame import obstacle
-from client_local.level import level
-from client_local.sound import sound_player
-from client_local.music import music_loader
-from client_local.sprite.bomb_instance import BombInstance, BombInstanceBlack, BombInstanceGold
-from client_local.sprite import obstacle_instance as oi
-
+import pygame.time
 from collections import deque, Counter
-
 from math import sqrt, pi, sin, cos
 
-import pygame.time
-
 from client_local.const import color as C
 from client_local.const import game as G
 from client_local.effect.effect_instance import EffectInstance, EffectState
 from client_local.level import level
 from client_local.skill.skill import Skill, IceSlow, GotPoisonSmoke50x3, GotPoisonSmoke80x2
 from client_local.sound import sound_player
-
+from client_local.algo import aStar
+from client_local.skill.skill import Skill
+from client_local.skill.skill import *
+from client_local.effect.effect_instance import EffectState, EffectInstance
+from client_local.frame import bomb
+from client_local.frame import obstacle
 from client_local.level import level
-
-import logging
-from datetime import datetime
-
-# 配置logging基础配置并设置日志级别为INFO
-# logging.basicConfig(filename='PSKILL.log', level=logging.INFO)
+from client_local.sound import sound_player
+from client_local.music import music_loader
+from client_local.sprite.bomb_instance import BombInstance, BombInstanceBlack, BombInstanceGold
+from client_local.sprite import obstacle_instance as oi
 
 
 def l1_distance(point, target):
     """计算点point到目标点target的L1距离"""
     return abs(point[0] - target[0]) + abs(point[1] - target[1])
 
+
 # 有向矩形线段碰撞整点格获取算法
 def get_integer_coordinates_with_custom_width(A, B, width):
     # 计算矩形的左上角和右下角坐标
@@ -135,7 +126,7 @@ class CustomMoveDirection(Skill):
 class CustomOnGridBasedSkill(Skill):
     def __init__(self, user, to, params, skill_instances):
         super().__init__(user, to, skill_instances)
-        self.last_time = 0
+        self.last_time = self.current_time
         self.skill_name, self.params, self.destination, self.interval = params[0], params[1], params[2], params[3]
 
     def update(self):
@@ -145,7 +136,7 @@ class CustomOnGridBasedSkill(Skill):
             return
         if (self.user.x, self.user.y) == tuple(self.destination) and self.current_time - self.last_time >= self.interval:
             self.last_time = self.current_time
-            self.user.handle_skill(self.skill_name, self.params, 0)
+            self.user.using_skill_map(self.skill_name, self.params, 0)
 
 
 
@@ -285,6 +276,29 @@ class CustomMessage(Skill):
 
 
 
+# 发送消息({"sender": "me", "text": "hello world", "colour": (r,g,b)})
+class CustomColourfulMessage(Skill):
+    def __init__(self, user, to, params, skill_instances):
+        super().__init__(user, to, skill_instances)
+        self.load = False
+        self.sender = params.get("sender", "??")
+        self.text = params.get("text", "??")
+        self.colour = tuple(params.get("colour", [255, 255, 255]))
+
+    def update(self):
+        super().update()
+        if not self.load:
+            self.load = True
+            level.current_level.message_entry.new_message(sender=self.sender, message=self.text, colour=self.colour)
+            self.kill()
+
+
+
+
+
+
+
+
 
 # 困在水泡里([输入哈希(如{"U":2, "D":2, "L":2, "R":2}), 破裂伤害])
 class CustomInBubble(Skill):
@@ -645,7 +659,7 @@ class CustomDirectionLaserFireBallEfect(Skill):
                 self.kill()
                 sound_player.play("crash")
 
-            if self.delta_len==0:
+            if self.delta_len == 0:
                 if (e.x_pos - self.to.x_pos)**2 + (e.y_pos - self.to.y_pos)**2 <= 20*20*1.5:
                     self.knife_end = False
                     self.to.try_damage(self.damage_blood)
@@ -666,9 +680,9 @@ class CustomDirectionLaserFireBallEfect(Skill):
             self.delta_y = 4 * round(sin(self.angle * pi / 180), 3)
             self.delta_len = sqrt(self.delta_x * self.delta_x + self.delta_y * self.delta_y)
             if self.delta_x > 0:
-                self.effect_fire = EffectInstance("fire_ball_laser", self.user, False, level.current_level.effects_front)
+                self.effect_fire = EffectInstance(self.effect, self.user, False, level.current_level.effects_front)
             else:
-                self.effect_fire = EffectInstance("fire_ball_laser", self.user, False, level.current_level.effects_front)
+                self.effect_fire = EffectInstance(self.effect, self.user, False, level.current_level.effects_front)
             self.effect_instances.append(self.effect_fire)
 
         if self.current_time - self.skill_time_init > 1000 and self.knife_charge:
@@ -718,7 +732,7 @@ class CustomGroupDirectionLaserFireBall(Skill):
             [self.damage_blood, self.angles, self.speed, self.energy] = params
             self.effect = "fire_ball_laser"
         self.path_points = []  # 新增:火苗经过的所有点
-        self.end_time = 8000/(max(0.01,self.speed/0.16))
+        self.end_time = 8000/(max(0.01, self.speed/0.16))
 
     def update(self):
         super().update()
@@ -1072,7 +1086,7 @@ class CustomTrackingDirectionLaserFireBallEffect(Skill):
         if not self.knife_begin and self.knife_end:
             e = self.effect_fire
             if self.delta_len != 0:
-                if self.current_time - self.skill_time_init <= 1000 + self.decay_init_time:
+                if self.current_time - self.skill_time_init <= 1000 + self.decay_init_time:  # 初始发射
                     delta_time = self.current_time - self.old_time  # 计算两次调用update的间隔: △t=t-t'
                     final_dx = self.delta_x
                     final_dy = self.delta_y
@@ -1082,10 +1096,10 @@ class CustomTrackingDirectionLaserFireBallEffect(Skill):
                     new_y = e.y_pos + self.speed * delta_time * (final_dy/final_sqrt_norm)
                     e.set_xy_pos(new_x, new_y)
                     self.old_time = self.current_time
-                elif 1000 + self.decay_init_time < self.current_time - self.skill_time_init <= 1000 + self.decay_init_time + self.stop_time:
+                elif 1000 + self.decay_init_time < self.current_time - self.skill_time_init <= 1000 + self.decay_init_time + self.stop_time:  # 停留
                     e.set_xy_pos(e.x_pos, e.y_pos)
                     self.old_time = self.current_time
-                else:
+                else:  # 开始追踪
                     total_time = self.current_time - self.skill_time_init - self.decay_init_time - 1000 - self.stop_time
                     delta_time = self.current_time - self.old_time  # 计算两次调用update的间隔: △t=t-t'
                     self.rho = max(0, 1-total_time/(self.decay_rate*self.end_time))
@@ -1134,7 +1148,7 @@ class CustomTrackingDirectionLaserFireBallEffect(Skill):
             self.delta_x = round(cos(self.last_angle * pi / 180), 3)
             self.delta_y = round(sin(self.last_angle * pi / 180), 3)
             self.delta_len = sqrt(self.delta_x * self.delta_x + self.delta_y * self.delta_y)
-            self.effect_fire = EffectInstance("fire_ball_laser", self.user, False, level.current_level.effects_front)
+            self.effect_fire = EffectInstance(self.effect, self.user, False, level.current_level.effects_front)
             self.effect_instances.append(self.effect_fire)
 
         if self.current_time - self.skill_time_init > 1000 and self.knife_charge:
@@ -1311,7 +1325,7 @@ class CustomFixedDirectionLaserFireBallEffect(Skill):
                 self.kill()
                 sound_player.play("crash")
 
-            if self.delta_len==0:
+            if self.delta_len == 0:
                 if (e.x_pos - self.to.x_pos)**2 + (e.y_pos - self.to.y_pos)**2 <= 20*20*1.5:
                     self.knife_end = False
                     self.to.try_damage(self.damage_blood)
@@ -1332,7 +1346,7 @@ class CustomFixedDirectionLaserFireBallEffect(Skill):
             self.delta_x = round(cos(self.last_angle * pi / 180), 3)
             self.delta_y = round(sin(self.last_angle * pi / 180), 3)
             self.delta_len = sqrt(self.delta_x * self.delta_x + self.delta_y * self.delta_y)
-            self.effect_fire = EffectInstance("fire_ball_laser", self.user, False, level.current_level.effects_front)
+            self.effect_fire = EffectInstance(self.effect, self.user, False, level.current_level.effects_front)
             self.effect_instances.append(self.effect_fire)
 
         if self.current_time - self.skill_time_init > 1000 and self.knife_charge:
@@ -1642,6 +1656,510 @@ class CustomHydroGunFireSkew5x5(Skill):
 
 
 
+
+# 自定义光系远程攻击([玩家中心1/怪物中心2, [攻击点列[x1,y1]](如果只填[[n]]则为(2n+1)*(2n+1)), 伤害, 变天使时长(不能放泡)
+class CustomLightDistanceAttack(Skill):
+
+    def __init__(self, user, to, params, skill_instances):
+        super().__init__(user, to, skill_instances)
+        self.params = params
+        self.centre_type = self.params.get("type", 1)
+        self.points = self.params.get("point", [[0]])
+        self.damage = self.params.get("damage", 500)
+        self.mute_time = self.params.get("mute_time", 0)
+        if len(self.points[0]) == 1:
+            n = self.points[0][0]
+            # tmp = []
+            # for i in range(-n, n+1):
+            #     for j in range(-n, n+1):
+            #         tmp.append([i, j])
+            # self.points = None
+            # self.points = tmp[:]
+            self.points = [[i, j] for j in range(-n, n+1) for i in range(-n, n+1)]
+        self.loaded = True
+        self.hint_cancel = True
+        self.poison_explode = True
+        self.poison_rooted_effect = None
+        self.px = 0
+        self.py = 0
+        self.time = 720
+
+    def update(self):
+        super().update()
+        if self.user.remain_blood <= 0:
+            for e in self.effect_instances:
+                e.state = EffectState.DEAD
+            self.kill()
+        if self.current_time - self.skill_time_init > self.time + 1500:
+            for e in self.effect_instances:
+                e.state = EffectState.DEAD
+            self.kill()
+        if self.current_time - self.skill_time_init > self.time + 5 and self.poison_explode:
+            # 眩晕爆炸
+            self.poison_explode = False
+            self.user.rooted -= 1
+            # 检查死亡
+            if self.user.remain_blood == 0:
+                for e in self.effect_instances:
+                    e.state = EffectState.DEAD
+                self.kill()
+                return
+            for i in range(len(self.points)):
+                x, y = self.points[i]
+                px, py = self.px + x, self.py + y
+                an_effect = EffectInstance("light_explode", self.user, False, level.current_level.effects_front)
+                an_effect.set_xy(px, py)
+                self.effect_instances.append(an_effect)
+                # 伤害类
+                if self.to.x == px and self.to.y == py:
+                    sound_player.play("cry")
+                    self.to.try_damage(self.damage)
+                    self.to.polymorph_for(self.mute_time, character="Angel")
+                    self.effect_instances.append(
+                        EffectInstance("dizzy_explode", self.to, False, self.to.effects_front)
+                    )
+
+        if self.current_time - self.skill_time_init > max(0, self.time - 100) and self.hint_cancel:
+            self.hint_cancel = False
+            for e in self.effect_instances:
+                e.state = EffectState.DEAD
+
+        if self.loaded:
+            # npc施法阵与眩晕范围提示
+            self.loaded = False
+            self.user.rooted += 1
+            self.user.align_xy()
+            if self.centre_type == 1:
+                self.px = self.to.x
+                self.py = self.to.y
+            else:
+                self.px = self.user.x
+                self.py = self.user.y
+            self.effect_instances.append(EffectInstance("launch", self.user, True, self.user.effects_front))
+            # 眩晕范围提示
+            for i in range(len(self.points)):
+                x, y = self.points[i]
+                an_effect = EffectInstance("light_hint", self.user, False, level.current_level.effects_behind)
+                an_effect.set_xy(self.px + x, self.py + y)
+                self.effect_instances.append(an_effect)
+            sound_player.play("trap")
+
+
+
+
+# 天降光柱 + 地火
+class CustomSkyLightClean(Skill):
+
+    def __int__(self):
+        pass
+
+
+
+# 隐潮珍壳专属(被动) "params": {"distance": 3, "in_character": "Ocean8_2", "out_character": "Ocean8_1", "defense_add": 10000}
+class CustomShellSkill(Skill):
+    def __init__(self, user, to, params, skill_instances):
+        super().__init__(user, to, skill_instances)
+        self.last_time = 0
+        self.params = params
+        self.distance = self.params.get("distance", 3)
+        self.in_character = self.params.get("in_character", "Ocean8_2")    # 闭合
+        self.out_character = self.params.get("out_character", "Ocean8_1")  # 张开
+        self.defense_add = self.params.get("defense_add", 10000)
+        self.is_defense_mode = False  # 张开
+
+    def update(self):
+        super().update()
+        if self.user.remain_blood <= 0:
+            self.kill()
+            return
+
+        if self.is_defense_mode:
+            if abs(self.user.x-self.to.x) > self.distance or abs(self.user.y-self.to.y) > self.distance:
+                # 张开
+                self.is_defense_mode = False
+                self.user.using_skill_map("CustomModeSwitch", [self.out_character], 0)
+                self.user.defense -= self.defense_add
+        else:
+            if abs(self.user.x-self.to.x) <= self.distance and abs(self.user.y-self.to.y) <= self.distance:
+                # 闭合
+                self.is_defense_mode = True
+                self.user.using_skill_map("CustomModeSwitch", [self.in_character], 0)
+                self.user.defense += self.defense_add
+
+
+
+
+# 光陷阱 "params": {"damage": 500, "mute_time": 3000, "trap_time": 30000}
+class CustomLightTrap(Skill):
+
+    def __init__(self, user, to, params, skill_instances):
+        super().__init__(user, to, skill_instances)
+        self.params = params
+        self.damage = self.params.get("damage", 500)
+        self.mute_time = self.params.get("mute_time", 0)
+        self.trap_time = self.params.get("trap_time", 30000)
+        self.ice_trap = True
+        self.to_already_on = False
+
+    def load(self):
+        super().load()
+        sound_player.play("trap")
+        self.effect_instances.append(
+            EffectInstance("ice_charge", self.user, False, self.user.effects_front)
+        )
+        self.user.rooted += 1
+        self.user.align_xy()
+
+    def update(self):
+        super().update()
+        if self.current_time - self.skill_time_init > 21000:
+            for e in self.effect_instances:
+                e.state = EffectState.DEAD
+            self.kill()
+        if self.current_time - self.skill_time_init > 950 and self.ice_trap:
+            self.ice_trap = False
+            self.effect_instances.append(
+                EffectInstance("light_trap", self.user, False, level.current_level.effects_behind)
+            )
+            self.user.rooted -= 1
+            if self.to.x == self.user_x and self.to.y == self.user_y:
+                self.to_already_on = True
+            if self.user.remain_blood == 0:
+                self.kill()
+        if self.current_time - self.skill_time_init > 950:
+            # 判断玩家是否踩中陷阱
+            if self.to.x == self.user_x and self.to.y == self.user_y:
+                if not self.to_already_on:
+                    sound_player.play("cry")
+                    self.to.try_damage(self.damage)
+                    self.to.polymorph_for(self.mute_time, character="Angel")
+                    self.effect_instances.append(
+                        EffectInstance("dizzy_explode", self.to, False, self.to.effects_front)
+                    )
+                    self.kill()
+            else:
+                self.to_already_on = False
+
+
+# 自定义范围内治疗敌方  "params": {"radius": 3, "heal_amount": 3000}
+class CustomLightRangeRecovery(Skill):
+
+    def __init__(self, user, to, params, skill_instances):
+        super().__init__(user, to, skill_instances)
+        self.params = params
+        self.radius = self.params.get("radius", 3)
+        self.heal_amount = self.params.get("heal_amount", 0)
+        self.trigger = True
+        self.assistance_list = []
+        self.loaded = False
+
+    def load(self):
+        super().load()
+        self.assistance_list = []
+        self.trigger = True
+
+    def update(self):
+        super().update()
+        if not self.loaded:
+            self.loaded = True
+            for npc in self.to:
+                if abs(self.user.x - npc.x) <= self.radius and abs(self.user.y - npc.y) <= self.radius:
+                    self.assistance_list.append(npc)
+            if len(self.assistance_list) > 0:
+                self.effect_instances.append(EffectInstance("blue_dots", self.user, True, self.user.effects_behind))
+                for npc in self.assistance_list:
+                    self.effect_instances.append(
+                        EffectInstance("recovery", npc, True, npc.effects_front)
+                    )
+                    npc.heal(self.heal_amount)
+
+        if self.current_time - self.skill_time_init > 500:
+            for e in self.effect_instances:
+                e.state = EffectState.DEAD
+            self.kill()
+            return
+
+
+# 自定义移动到玩家最近的实体  "params": {"target": "npc_name"}
+class CustomMoveToTarget(Skill):
+
+    def __init__(self, user, to, params, skill_instances):
+        super().__init__(user, to, skill_instances)
+        self.params = params
+        self.target = self.params.get("target", "LumenChurchLightGate")
+        self.final_target = None
+        self.final_dist = 9999
+        self.trigger = True
+        self.loaded = False
+
+    def load(self):
+        super().load()
+        self.trigger = True
+
+    def update(self):
+        super().update()
+        if not self.loaded:
+            self.loaded = True
+            for npc in self.to:
+                if npc.stats_name == self.target:
+                    dist = abs(npc.x - level.current_level.me.x) + abs(npc.y - level.current_level.me.y)
+                    if dist < self.final_dist:
+                        self.final_target = npc
+                        self.final_dist = dist
+            if self.final_target is not None:
+                self.effect_instances.append(EffectInstance("blue_dots", self.user, True, self.user.effects_behind))
+                self.effect_instances.append(EffectInstance("blue_dots", self.final_target, True, self.final_target.effects_behind))
+                self.user.set_xy(self.final_target.x, self.final_target.y)
+                level.current_level.scroll_map()
+                level.current_level.recal_npc_paths = True
+                self.final_target.die_quietly()
+                sound_player.play("X08_01")
+
+        if self.current_time - self.skill_time_init > 500:
+            for e in self.effect_instances:
+                e.state = EffectState.DEAD
+            self.kill()
+            return
+
+
+# 自定义光盾  "params": {"break_times": 1, "recover_time": 1000}
+class CustomLightShield(Skill):
+
+    def __init__(self, user, to, params, skill_instances):
+        super().__init__(user, to, skill_instances)
+        self.params = params
+        self.break_times = self.params.get("break_times", 1)
+        self.recover_time = self.params.get("recover_time", 1000)
+        self.cumulation = 0
+        self.cumulation_time = deque()
+        self.defend = False
+        self.last_break_time = 0
+        self.last_trigger_time = 0
+        self.effect_shield = None  # 盾动画
+        self.defense_add = 99999999999999
+
+    def update(self):
+        super().update()
+        # 受伤则刷新队列
+        if self.defend:
+            if self.user.last_get_damage_multiple > 0 and self.current_time - self.last_trigger_time > 20:
+                self.user.last_get_damage_multiple = 0
+                self.last_trigger_time = self.current_time
+                latest = self.current_time
+                while self.cumulation_time:
+                    if latest - self.cumulation_time[0] > self.recover_time:
+                        self.cumulation_time.popleft()
+                    else:
+                        break
+                self.cumulation_time.append(latest)
+                self.cumulation = len(self.cumulation_time)
+                if self.cumulation > self.break_times:  # 击破
+                    self.defend = False
+                    self.last_break_time = self.current_time
+                    self.user.defense -= self.defense_add
+                    if self.effect_shield is not None:
+                        self.effect_shield.state = EffectState.DEAD
+                    sound_player.play("kick")
+                else:
+                    Protect30ms(self.user, self.user.skill_instances)
+
+        if not self.defend:
+            if self.current_time - self.last_break_time >= self.recover_time:
+                self.defend = True
+                self.user.defense += self.defense_add
+                self.effect_shield = EffectInstance("light_shield", self.user, True, self.user.effects_front)
+
+        if self.user.remain_blood == 0:
+            if self.effect_shield is not None:
+                self.effect_shield.state = EffectState.DEAD
+            self.kill()
+
+
+
+
+# 地震特效, "params": {"strength": 0.1, "duration_per_time": 200, "times": 3, "decrease": true, "direction": 0}
+class CustomMapEarthQuake(Skill):
+
+    def __init__(self, user, to, params=None, skill_instances=None):
+        super().__init__(user, to, skill_instances)
+        if params is None:
+            params = dict()
+        strength = params.get("strength", 0.1)
+        duration_per_time = params.get("duration_per_time", 200)
+        times = params.get("times", 3)
+        decrease = params.get("decrease", True)
+        direction = params.get("direction", 0)
+        level.current_level.earth_quake_effect(
+            strength=strength, duration_per_time=duration_per_time, times=times, decrease=decrease, direction=direction
+        )
+
+
+
+
+
+
+# 耗电原地召唤怪, "params": {"spawn_list": [充电召唤列表], "energy_cost": 3}
+class CustomPointSpawnWithNameAndCharge(Skill):
+
+    def __init__(self, user, to, params, skill_instances):
+        super().__init__(user, to, skill_instances)
+        self.spawns = params.get("spawn_list", ["JourneyBatMinion"])
+        self.energy_cost = params.get("energy_cost", 0)
+        self.loaded = True
+        self.loaded_eff = None
+        self.spawned = False
+        self.spawn_time = 0
+        self.enough_energy = False
+
+    def load(self):
+        super().load()
+
+    def update(self):
+        super().update()
+        if self.loaded:
+            self.loaded = False
+
+            if self.user.has_energy:
+                if self.user.energy_amount < self.energy_cost:
+                    for e in self.effect_instances:
+                        e.state = EffectState.DEAD
+                    self.kill()
+                    return
+                else:
+                    self.user.energy_amount -= self.energy_cost
+                    self.enough_energy = True
+
+        if not self.loaded and self.enough_energy and self.spawn_time == 0:
+            self.spawn_time = self.current_time
+            self.loaded_eff = EffectInstance("launch2", self.user, False, self.user.effects_behind)
+            self.user.rooted += 1
+            sound_player.play("launch")
+            self.spawned = True
+
+        if self.current_time - self.spawn_time > 800 and self.spawned:
+            self.spawned = False
+            self.user.rooted -= 1
+            self.loaded_eff.state = EffectState.DEAD
+            cl = level.current_level
+            for monster in self.spawns:
+                an_npc = cl.get_an_npc(monster, (self.user.x, self.user.y))
+                cl.npcs.append(an_npc)
+            self.kill()
+
+
+
+
+# 闪现附近
+# "params": {"range": 1}
+class CustomTeleportEscape(Skill):
+
+    def __init__(self, user, to, params, skill_instances):
+        super().__init__(user, to, skill_instances)
+        self.range = params.get("range", 1)
+        cl = level.current_level
+        # npc传送
+        safe_grids = self.cal_to_available(cl)  # 计算全部安全格子
+        if len(safe_grids) == 0:
+            return
+        safe_point = random.choice(safe_grids)  # 随机抽取安全格子
+        self.effect_instances.append(
+            EffectInstance("blue_dots_reverse", self.user, False, self.user.effects_front)
+        )
+        self.user.set_xy(*safe_point)
+        self.effect_instances.append(
+            EffectInstance("blue_dots", self.user, False, self.user.effects_front)
+        )
+        sound_player.play("X08_01")
+
+    def cal_to_available(self, cl):
+        safe_grids = []
+        for dx in range(-self.range, self.range + 1):
+            for dy in range(-self.range, self.range + 1):
+                if 0 <= self.to.y + dy < cl.map_y and 0 <= self.to.x + dx < cl.map_x:
+                    if dx == 0 and dy == 0:
+                        continue
+                    if not cl.block[1][self.to.x + dx][self.to.y + dy] and len(cl.get_bomb_instance(self.to.x + dx, self.to.y + dy)) == 0:
+                        safe_grids.append((self.to.x + dx, self.to.y + dy))
+        return safe_grids
+
+
+
+
+# "params": {"cast_time": 2500, "land_quake_range": 2, "dizz_time": 5000, "do_earth_quake": true}
+class CustomMinionChaseWithCastTimeAndEarthQuake(Skill):
+
+    def __init__(self, user, to, params, skill_instances):
+        super().__init__(user, to, skill_instances)
+        self.to_xy = None
+        self.recording = True
+        self.jumping = False
+        self.has_landing = False
+        self.landing_time = 0
+        self.cast_time = params.get("cast_time", 2500)
+        self.land_quake_range = params.get("land_quake_range", 2)
+        self.dizz_time = params.get("dizz_time", 5000)
+        self.do_earth_quake = params.get("do_earth_quake", True)
+        self.user.rooted_for(self.cast_time)
+        sound_player.play("launch")
+
+    def update(self):
+        super().update()
+        dt = self.current_time - self.skill_time_init
+        if dt > 0 and self.recording:
+            self.recording = False
+            self.to_xy = (self.to.x, self.to.y)
+            for x in range(-self.land_quake_range, self.land_quake_range+1):
+                for y in range(-self.land_quake_range, self.land_quake_range+1):
+                    an_effect = EffectInstance("time_stop_hint", self.user, False, level.current_level.effects_behind)
+                    an_effect.set_xy(self.to_xy[0] + x, self.to_xy[1] + y)
+                    self.effect_instances.append(an_effect)
+        if dt > self.cast_time and not self.jumping:
+            self.jumping = True
+            try:
+                self.user.throw_to(self.to_xy[0], self.to_xy[1], self.get_directions(), True)
+            except Exception as e:
+                print(e)
+        if self.jumping and not self.has_landing:
+            if not self.user.throwing:
+                self.has_landing = True
+        if self.has_landing:
+            if self.landing_time == 0:
+                self.landing_time = self.current_time
+                if abs(self.to_xy[0] - self.to.x) <= self.land_quake_range and abs(self.to_xy[1] - self.to.y) <= self.land_quake_range:
+                    for e in self.effect_instances:
+                        e.state = EffectState.DEAD
+                    self.effect_instances.append(
+                        EffectInstance("reverse", self.to, True, self.to.effects_front)
+                    )
+                    self.to.rooted_for(self.dizz_time)
+                    sound_player.play("cry")
+                for x in range(-self.land_quake_range, self.land_quake_range+1):
+                    for y in range(-self.land_quake_range, self.land_quake_range+1):
+                        an_effect = EffectInstance("dizzy_explode", self.user, False, level.current_level.effects_front)
+                        an_effect.set_xy(self.to_xy[0] + x, self.to_xy[1] + y)
+                        self.effect_instances.append(an_effect)
+                if self.do_earth_quake:
+                    level.current_level.earth_quake_effect(
+                        strength=0.1, duration_per_time=200, times=3, decrease=True, direction=0
+                    )
+                level.current_level.recal_npc_paths = True
+            else:
+                if self.current_time > self.landing_time + self.dizz_time:
+                    for e in self.effect_instances:
+                        e.state = EffectState.DEAD
+                    self.kill()
+
+    def get_directions(self):
+        user_p = [self.user.x, self.user.y]
+        if user_p[0] == self.to_xy[0]:
+            if user_p[1] > self.to_xy[1]:
+                return "U"
+            else:
+                return "D"
+        if self.to_xy[0] > user_p[0]:
+            return "R"
+        else:
+            return "L"
 
 
 

+ 215 - 0
client_local/skill/parametric3_skill.py

@@ -0,0 +1,215 @@
+import random
+import pygame.time
+from collections import deque, Counter
+from math import sqrt, pi, sin, cos
+
+from client_local.const import color as C
+from client_local.const import game as G
+from client_local.effect.effect_instance import EffectInstance, EffectState
+from client_local.level import level
+from client_local.skill.skill import Skill, IceSlow, GotPoisonSmoke50x3, GotPoisonSmoke80x2
+from client_local.sound import sound_player
+from client_local.algo import aStar
+from client_local.skill.skill import Skill
+from client_local.skill.skill import *
+from client_local.effect.effect_instance import EffectState, EffectInstance
+from client_local.frame import bomb
+from client_local.frame import obstacle
+from client_local.level import level
+from client_local.sound import sound_player
+from client_local.music import music_loader
+from client_local.sprite.bomb_instance import BombInstance, BombInstanceBlack, BombInstanceGold
+from client_local.sprite import obstacle_instance as oi
+
+
+def custom_operator(x, operation, y):
+    if operation == "+":
+        return x + y
+    elif operation == "-":
+        return x - y
+    elif operation == "*":
+        return x * y
+    elif operation == r"//":
+        return x // y
+    elif operation == "%":
+        return x % y
+
+
+def custom_condition(x, condition, y):
+    if condition == "=":
+        return x == y
+    elif condition == ">":
+        return x > y
+    elif condition == "<":
+        return x < y
+
+
+# 自定义关卡全局变量操作   "params": {"variable_name": "hello", "operation": "+", "amount": 1}
+# 支持 "=" "+" "-" "*" "//" "%"
+class CustomLevelVariableOperation(Skill):
+
+    def __init__(self, user, to, params, skill_instances):
+        super().__init__(user, to, skill_instances)
+        self.params = params
+        self.variable = params.get("variable_name", "")
+        self.operation = params.get("operation", "*")
+        self.amount = params.get("amount", 1)
+
+    def update(self):
+        super().update()
+        if self.user.remain_blood <= 0:
+            self.kill()
+            return
+        if self.operation == "=":
+            level.current_level.set_level_variables(self.variable, self.amount)
+        else:
+            value = level.current_level.get_level_variables(self.variable, None)
+            if value is None:
+                value = 0
+            level.current_level.set_level_variables(
+                self.variable, custom_operator(value, self.operation, self.amount)
+            )
+        self.kill()
+
+
+# 自定义满足一定条件就放技能   "params": {"skill_name": "Skill1", "params": [], "variable": "v1", "operation": ">", "amount": 1}
+# 支持 "=" ">" "<"
+# "amount" 为 string 则为变量, 否则为数值
+class CustomConditionBasedSkill(Skill):
+
+    def __init__(self, user, to, params, skill_instances):
+        super().__init__(user, to, skill_instances)
+        self.skill_name = params.get("skill_name", "")
+        self.params = params.get("params", [])
+        self.variable = params.get("variable", "")
+        self.variable_amount = level.current_level.get_level_variables(self.variable, 1)
+        self.operation = params.get("operation", "")
+        self.amount = params.get("amount", 1)
+        if isinstance(self.amount, str):
+            self.amount = level.current_level.get_level_variables(self.amount, 1)
+
+    def update(self):
+        super().update()
+        if self.user.remain_blood <= 0:
+            self.kill()
+            return
+        if custom_condition(self.variable_amount, self.operation, self.amount):
+            self.user.using_skill_map(self.skill_name, self.params, 0)
+        self.kill()
+
+
+# 自定义满足一定条件就放的一次性被动技能   "params": {"skill_name": "Skill1", "params": [], "variable": "v1", "operation": ">", "amount": 1}
+# 支持 "=" ">" "<"
+# "amount" 为 string 则为变量, 否则为数值
+class CustomSingleTriggeredConditionBasedSkill(Skill):
+
+    def __init__(self, user, to, params, skill_instances):
+        super().__init__(user, to, skill_instances)
+        self.skill_name = params.get("skill_name", "")
+        self.params = params.get("params", [])
+        self.variable = params.get("variable", "")
+        self.variable_amount = level.current_level.get_level_variables(self.variable, 1)
+        self.operation = params.get("operation", "")
+        self.amount = params.get("amount", 1)
+        if isinstance(self.amount, str):
+            self.amount = level.current_level.get_level_variables(self.amount, 1)
+
+    def update(self):
+        super().update()
+        if self.user.remain_blood <= 0:
+            self.kill()
+            return
+        if custom_condition(self.variable_amount, self.operation, self.amount):
+            self.user.using_skill_map(self.skill_name, self.params, 0)
+            self.kill()
+
+
+# 自定义第一次小于等于一定百分比血量就放技能   "params": {"skill_name": "Skill1", "params": [], "percent": 0.1}
+class CustomMonsterBloodBasedSkill(Skill):
+
+    def __init__(self, user, to, params, skill_instances):
+        super().__init__(user, to, skill_instances)
+        self.skill_name = params.get("skill_name", "")
+        self.params = params.get("params", [])
+        self.percent = params.get("percent", 0.5)
+        self.threshold = (self.user.remain_blood - self.user.fake_blood) * self.percent
+
+    def update(self):
+        super().update()
+        if self.user.remain_blood <= 0:
+            self.kill()
+            return
+        if self.user.remain_blood <= self.threshold:
+            self.user.using_skill_map(self.skill_name, self.params, 0)
+            self.kill()
+
+
+# 自定义满足一定百分比血量就放技能   "params": {"skill_name": "Skill1", "params": [], "percent": 0.1, "operation": ">"}
+class CustomAnyTimeMonsterBloodBasedSkill(Skill):
+
+    def __init__(self, user, to, params, skill_instances):
+        super().__init__(user, to, skill_instances)
+        self.skill_name = params.get("skill_name", "")
+        self.params = params.get("params", [])
+        self.percent = params.get("percent", 0.5)
+        self.operation = params.get("operation", ">")
+        self.threshold = (self.user.remain_blood - self.user.fake_blood) * self.percent
+
+    def update(self):
+        super().update()
+        if self.user.remain_blood <= 0:
+            self.kill()
+            return
+        if custom_condition(self.user.remain_blood, self.operation, self.threshold):
+            self.user.using_skill_map(self.skill_name, self.params, 0)
+        self.kill()
+        return
+
+
+# 一串技能  "params": {"skill_names": ["Skill1","Skill2"], "params": [[],[]], "times": [0, 0]}
+# 其中必须按时间顺序来L t1 <= t2 <= ...
+class CustomSequentialSkill(Skill):
+
+    def __init__(self, user, to, params, skill_instances):
+        super().__init__(user, to, skill_instances)
+        self.skill_names = params.get("skill_names", [])
+        self.params = params.get("params", [])
+        self.times = params.get("times", [])
+        self.skill_num = len(self.skill_names)
+        self.current_skill_idx = 0
+
+    def update(self):
+        super().update()
+        if self.user.remain_blood <= 0:
+            self.kill()
+            return
+        if self.current_skill_idx >= self.skill_num:
+            self.kill()
+            return
+        if self.current_time - self.skill_time_init > self.times[self.current_skill_idx]:
+            self.user.using_skill_map(self.skill_names[self.current_skill_idx], self.params[self.current_skill_idx], 0)
+            self.current_skill_idx += 1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

+ 181 - 17
client_local/skill/parametric_skill.py

@@ -331,7 +331,95 @@ class PointSpawnWithNameAndCharge(Skill):
 
 
 
+# 原地召唤随机怪
+class PointRandomSpawnWithName(Skill):
 
+    def __init__(self, user, to, spawns, spawn_order, skill_instances):
+        super().__init__(user, to, skill_instances)
+        self.spawns = spawns
+        self.spawn_order = spawn_order
+        self.loaded = True
+        self.loaded_eff = None
+        self.spawned = True
+        self.monster = None
+        self.an_npc = None
+
+    def load(self):
+        super().load()
+
+    def update(self):
+        super().update()
+        if self.loaded:
+            self.loaded = False
+            if self.spawn_order < 1:
+                self.spawn_order = 0
+            if self.spawn_order >= 1:
+                self.spawn_order = self.spawn_order - 1
+
+            if len(self.spawns) == 0:
+                self.spanw_list = ["JourneyBatMinion"]
+            else:
+                self.spanw_list = self.spawns[self.spawn_order]
+            self.loaded_eff = EffectInstance("launch2", self.user, False, self.user.effects_behind)
+            self.user.rooted += 1
+            sound_player.play("launch")
+        if self.current_time - self.skill_time_init > 800 and self.spawned:
+            self.spawned = False
+            self.user.rooted -= 1
+            self.loaded_eff.state = EffectState.DEAD
+            cl = level.current_level
+
+            self.monster = random.choice(self.spanw_list)
+            self.an_npc = cl.get_an_npc(self.monster, (self.user.x, self.user.y))
+            cl.npcs.append(self.an_npc)
+            self.kill()
+
+
+
+
+# 原地召唤随机怪
+class PointRandomSpawnWithProtect(Skill):
+
+    def __init__(self, user, to, spawns, spawn_order, skill_instances):
+        super().__init__(user, to, skill_instances)
+        self.spawns = spawns
+        self.spawn_order = spawn_order
+        self.loaded = True
+        self.loaded_eff = None
+        self.spawned = True
+        self.monster = None
+        self.an_npc = None
+
+    def load(self):
+        super().load()
+
+    def update(self):
+        super().update()
+        if self.loaded:
+            self.loaded = False
+            if self.spawn_order < 1:
+                self.spawn_order = 0
+            if self.spawn_order >= 1:
+                self.spawn_order = self.spawn_order - 1
+
+            if len(self.spawns) == 0:
+                self.spanw_list = ["JourneyBatMinion"]
+            else:
+                self.spanw_list = self.spawns[self.spawn_order]
+            self.loaded_eff = EffectInstance("launch2", self.user, False, self.user.effects_behind)
+            self.user.rooted += 1
+            sound_player.play("launch")
+        if self.current_time - self.skill_time_init > 800 and self.spawned:
+            self.spawned = False
+            self.user.rooted -= 1
+            self.loaded_eff.state = EffectState.DEAD
+            cl = level.current_level
+
+            self.monster = random.choice(self.spanw_list)
+            self.an_npc = cl.get_an_npc(self.monster, (self.user.x, self.user.y))
+            Protect3s(self.an_npc, self.an_npc.skill_instances)
+            cl.npcs.append(self.an_npc)
+            self.kill()
 
 
 
@@ -835,7 +923,11 @@ class CustomLaserFireBall(Skill):
         self.delta_len = 0  # 火苗运行长度
         self.old_time = pygame.time.get_ticks()
         self.effect_fire = None
-        [self.damage_blood, self.speed, self.energy] = params
+        self.fire_ball_effect = "fire_ball_laser"
+        if len(params) == 3:
+            [self.damage_blood, self.speed, self.energy] = params
+        else:
+            [self.damage_blood, self.speed, self.energy, self.fire_ball_effect] = params
         self.path_points = []  # 新增:火苗经过的所有点
         self.end_time = 8000/(max(0.01,self.speed/0.16))
 
@@ -862,7 +954,7 @@ class CustomLaserFireBall(Skill):
                 self.kill()
                 sound_player.play("crash")
 
-            if self.delta_len==0:
+            if self.delta_len == 0:
                 if (e.x_pos - self.to.x_pos)**2 + (e.y_pos - self.to.y_pos)**2 <= 20*20*1.5:
                     self.knife_end = False
                     self.to.try_damage(self.damage_blood)
@@ -883,9 +975,9 @@ class CustomLaserFireBall(Skill):
             self.delta_y = self.to_xy[1] - self.user_y
             self.delta_len = sqrt(self.delta_x * self.delta_x + self.delta_y * self.delta_y)
             if self.delta_x > 0:
-                self.effect_fire = EffectInstance("fire_ball_laser", self.user, False, level.current_level.effects_front)
+                self.effect_fire = EffectInstance(self.fire_ball_effect, self.user, False, level.current_level.effects_front)
             else:
-                self.effect_fire = EffectInstance("fire_ball_laser", self.user, False, level.current_level.effects_front)
+                self.effect_fire = EffectInstance(self.fire_ball_effect, self.user, False, level.current_level.effects_front)
             self.effect_instances.append(self.effect_fire)
 
         if self.current_time - self.skill_time_init > 1000 and self.knife_charge:
@@ -1715,6 +1807,52 @@ class CustomSummonObstacle(Skill):
 
 
 
+# 召唤障碍({"type": "类", "elem": "障碍名", "time": 吟唱时间, "coordinates": [(x1,y1), (x2,y2)]})
+class CustomSummonObstacleWithXY(Skill):
+
+    def __init__(self, user, to, params, skill_instances):
+        self.grid_list = list()
+        super().__init__(user, to, skill_instances)
+        self.params = params
+        self.type = self.params.get("type", "common")
+        self.name = self.params.get("elem", "elem43")
+        self.time = self.params.get("time", 0)
+        self.coordinates = self.params.get("coordinates", [])
+        self.loaded = False
+        self.summoned = False
+
+    def update(self):
+        super().update()
+        if self.user.remain_blood <= 0:
+            for e in self.effect_instances:
+                e.state = EffectState.DEAD
+            self.kill()
+
+        if self.current_time - self.skill_time_init > max(0, self.time-1000) and not self.loaded:
+            self.loaded = True
+            sound_player.play("trap")
+            for x, y in self.coordinates:
+                an_effect = EffectInstance("ice_hint_canyon", self.user, False, level.current_level.effects_behind)
+                an_effect.set_xy(x, y)
+                self.effect_instances.append(an_effect)
+            self.effect_instances.append(EffectInstance("launch", self.user, False, self.user.effects_behind))
+
+        if self.current_time - self.skill_time_init > self.time + 1 and not self.summoned:
+            self.summoned = True
+            for x, y in self.coordinates:
+                if (x, y) not in level.current_level.obstacle_instances.keys():  # 障碍
+                    an_effect = EffectInstance("ice_explode_canyon", self.user, False, level.current_level.effects_front)
+                    an_effect.set_xy(x, y)
+                    self.effect_instances.append(an_effect)
+                    obs, obs_json = obstacle.get_obstacle(self.type, self.name)
+                    oi.ObstacleInstance(x, y, level.current_level.obstacle_instances, obs, obs_json)
+                    sound_player.play("explode")
+                level.current_level.obstacle_instances_need_to_update = True
+
+        if self.current_time - self.skill_time_init > self.time + 400:
+            for e in self.effect_instances:
+                e.state = EffectState.DEAD
+            self.kill()
 
 
 
@@ -1747,7 +1885,7 @@ class CustomDirectionLaserFireBall(Skill):
             [self.damage_blood, self.angle, self.speed, self.energy] = params
             self.effect = "fire_ball_laser"
         self.path_points = []  # 新增:火苗经过的所有点
-        self.end_time = 8000/(max(0.01,self.speed/0.16))
+        self.end_time = 8000/(max(0.01, self.speed/0.16))
 
     def update(self):
         super().update()
@@ -1793,9 +1931,9 @@ class CustomDirectionLaserFireBall(Skill):
             self.delta_y = 4 * round(sin(self.angle * pi / 180), 3)
             self.delta_len = sqrt(self.delta_x * self.delta_x + self.delta_y * self.delta_y)
             if self.delta_x > 0:
-                self.effect_fire = EffectInstance("fire_ball_laser", self.user, False, level.current_level.effects_front)
+                self.effect_fire = EffectInstance(self.effect, self.user, False, level.current_level.effects_front)
             else:
-                self.effect_fire = EffectInstance("fire_ball_laser", self.user, False, level.current_level.effects_front)
+                self.effect_fire = EffectInstance(self.effect, self.user, False, level.current_level.effects_front)
             self.effect_instances.append(self.effect_fire)
 
         if self.current_time - self.skill_time_init > 1000 and self.knife_charge:
@@ -1988,6 +2126,7 @@ class CustomGeneralTrap(Skill):
         self.debuff_damage = - self.debuff_damage
         self.fire_trap = True
         self.to_already_on = False
+        self.trap_effect_instance = None
         if self.pre_effect != "none":
             self.effect_instances.append(EffectInstance(self.pre_effect, self.user, False, self.user.effects_front))
         if self.pre_sound != "none":
@@ -1997,7 +2136,8 @@ class CustomGeneralTrap(Skill):
         if self.align:
             self.user.align_xy()
         if self.trap_effect != "none":
-            self.effect_instances.append(EffectInstance(self.trap_effect, self.user, False, level.current_level.effects_behind))
+            self.trap_effect_instance = EffectInstance(self.trap_effect, self.user, False, level.current_level.effects_behind)
+            self.effect_instances.append(self.trap_effect_instance)
         self.hit = 0
 
     def load(self):
@@ -2044,7 +2184,8 @@ class CustomGeneralTrap(Skill):
                     if self.reverse > 0:
                         self.effect_instances.append(EffectInstance("reverse", self.to, True, level.current_level.effects_front))
                         self.to.reverse_for(self.reverse)
-                    self.kill()
+                    if self.trap_effect_instance is not None:
+                        self.trap_effect_instance.state = EffectState.DEAD
             else:
                 self.to_already_on = False
 
@@ -2746,7 +2887,7 @@ class CustomDevilSmokeMagic(Skill):
                 G.SPECIAL_MAX_HP -= min(max(0,level.current_level.me.blood-self.damages[0]), self.damages[0])
                 level.current_level.blood_bar.max_blood = min(max(0, level.current_level.me.blood), 999999)
                 sound_player.play("cry")
-            for (x,y) in self.grids:
+            for (x, y) in self.grids:
                 an_effect = EffectInstance("devil_dizzy_explode", self.user, False, level.current_level.effects_front)
                 an_effect.set_xy(x, y)
                 self.effect_instances.append(an_effect)
@@ -3013,8 +3154,7 @@ class CustomDamageFrameSkill(Skill):
             self.kill()
             return
         if self.user.get_damage_frame:
-            self.user.handle_skill(self.skill_name, self.params, 0)
-
+            self.user.using_skill_map(self.skill_name, self.params, 0)
 
 
 # (被动)血量每减少时放技能(不支持大部分召唤技能)("params": ["技能名", [此技能参数(非参数化技能的话随便填个0都行)]])
@@ -3031,11 +3171,10 @@ class CustomHPDropSkill(Skill):
             return
         if self.user.remain_blood != self.last_hp:
             if self.user.remain_blood < self.last_hp:
-                self.user.handle_skill(self.skill_name, self.params, 0)
+                self.user.using_skill_map(self.skill_name, self.params, 0)
             self.last_hp = self.user.remain_blood
 
 
-
 # (被动)一定距离内放技能(["技能名", [参数], 正方形格子L1距离, 冷却])(不支持大部分召唤技能)
 class CustomInDistanceBasedSkill(Skill):
     def __init__(self, user, to, params, skill_instances):
@@ -3050,7 +3189,7 @@ class CustomInDistanceBasedSkill(Skill):
             return
         if abs(self.user.x-self.to.x) <= self.distance and abs(self.user.y-self.to.y) <= self.distance and self.current_time - self.last_time >= self.interval:
             self.last_time = self.current_time
-            self.user.handle_skill(self.skill_name, self.params, 0)
+            self.user.using_skill_map(self.skill_name, self.params, 0)
 
 
 # (被动)一定距离外放技能(["技能名", [参数], 正方形格子距离, 冷却])(不支持大部分召唤技能)
@@ -3067,7 +3206,7 @@ class CustomOutDistanceBasedSkill(Skill):
             return
         if (abs(self.user.x-self.to.x) >= self.distance or abs(self.user.y-self.to.y) >= self.distance) and self.current_time - self.last_time >= self.interval:
             self.last_time = self.current_time
-            self.user.handle_skill(self.skill_name, self.params, 0)
+            self.user.using_skill_map(self.skill_name, self.params, 0)
 
 
 # 一定时间后放技能(["技能名", [参数], 延时])(不支持大部分召唤技能)
@@ -3086,7 +3225,7 @@ class CustomDelayedSkill(Skill):
         if self.current_time - self.last_time >= self.time and not self.triggerd:
             self.triggerd = True
             self.last_time = self.current_time
-            self.user.handle_skill(self.skill_name, self.params, 0)
+            self.user.using_skill_map(self.skill_name, self.params, 0)
         if self.current_time - self.last_time >= 3000:
             self.kill()
 
@@ -3183,5 +3322,30 @@ class KillAllExcept(Skill):
 
 
 
+# 杀掉指定地点怪物
+class KillMonsterInCustomPosition(Skill):
+
+    def __init__(self, user, to, params, skill_instances):
+        super().__init__(user, to, skill_instances)
+        self.trigger = True
+        self.point = (params.get("x", 0), params.get("y", 0))
+
+    def load(self):
+        super().load()
+
+    def update(self):
+        super().update()
+        if self.trigger:
+            self.trigger = False
+            for npc in self.to:
+                if (npc.x, npc.y) == self.point:
+                    npc.remain_blood = -1
+                    npc.die()
+
+        if self.current_time - self.skill_time_init > 200:
+            self.kill()
+            return
+
+
 
 

+ 93 - 4
client_local/skill/skill.py

@@ -1,14 +1,13 @@
-from math import sqrt
-
+import weakref
 import pygame
-
+from math import sqrt
 from client_local.const import game as G
 from client_local.effect.effect_instance import EffectState, EffectInstance
 from client_local.level import level
 from client_local.sound import sound_player
 from client_local.sprite.updatable import Updatable
 
-import weakref
+
 class Skill:
 
     def __init__(self, user, to, skill_instances):
@@ -76,6 +75,25 @@ class Protect3s(Skill):
         self.user.protected -= 1
 
 
+class Protect30ms(Skill):
+
+    def __init__(self, user, skill_instances):
+        super(Protect30ms, self).__init__(user, None, skill_instances)
+
+    def load(self):
+        super().load()
+        self.user.protected += 1
+
+    def update(self):
+        super().update()
+        if self.current_time - self.skill_time_init >= 50:
+            self.kill()
+
+    def kill(self):
+        super().kill()
+        self.user.protected -= 1
+
+
 
 class Protect005s(Skill):
 
@@ -1580,4 +1598,75 @@ class PlayerDistantFire5x5(Skill):
             sound_player.play("launch")
 
 
+class WinEffect(Skill):
+
+    def __init__(self, user, to, params, skill_instances):
+        super().__init__(user, to, skill_instances)
+        if params == "super":
+            effect = 'winEffectSuper'
+        elif params == "big":
+            effect = 'winEffectBig'
+        elif params == "ultra":
+            effect = 'winEffectUltra'
+        else:
+            effect = 'winEffect'
+        self.effectObj = EffectInstance(effect, self.user, False, level.current_level.effects_screen)
+        self.effect_instances.append(self.effectObj)
+        self.speed = 0.2  # 15格/s
+        self.init_x_pos = min(G.MAIN_AREA_X_POS, level.current_level.map_x_pos + 20)//2
+        self.init_y_pos = 100
+        self.running = True
+
+    def update(self):
+        super().update()
+        if self.current_time - self.skill_time_init >= 9000:
+            for e in self.effect_instances:
+                e.state = EffectState.DEAD
+            self.kill()
+
+        if self.running:
+            time_passed = self.current_time - self.skill_time_init
+            self.effectObj.set_xy_pos(self.init_x_pos, self.init_y_pos + time_passed * self.speed)
+            if self.effectObj.y_pos >= G.MAIN_AREA_Y_POS//2:
+                self.running = False
+
+
+class TransportSuccessEffect(Skill):
+
+    def __init__(self, user, to, params, skill_instances):
+        super().__init__(user, to, skill_instances)
+        total_remain = params
+        me = level.current_level.me
+        transport_amount = max(G.TOTAL_TRANSPORT - G.CUMULATION_RESOURCE_LEAK + 50, 0) * (1 - G.CUMULATION_INJURE / (me.blood * G.TOTAL_LEVEL))
+        if total_remain <= 0 or transport_amount >= total_remain:
+            effect = 'transportBigSuccessEffect'
+        else:
+            if transport_amount > 0:
+                effect = 'transportSuccessEffect'
+            else:
+                effect = 'transportFailEffect'
+        self.effectObj = EffectInstance(effect, self.user, False, level.current_level.effects_screen)
+        self.effect_instances.append(self.effectObj)
+        self.speed = 0.2  # 15格/s
+        self.init_x_pos = min(G.MAIN_AREA_X_POS, level.current_level.map_x_pos + 20)//2
+        self.init_y_pos = 100
+        self.running = True
+
+    def update(self):
+        super().update()
+        if self.current_time - self.skill_time_init >= 9000:
+            for e in self.effect_instances:
+                e.state = EffectState.DEAD
+            self.kill()
+
+        if self.running:
+            time_passed = self.current_time - self.skill_time_init
+            self.effectObj.set_xy_pos(self.init_x_pos, self.init_y_pos + time_passed * self.speed)
+            if self.effectObj.y_pos >= G.MAIN_AREA_Y_POS//2:
+                self.running = False
+
+
+
+
+
 

+ 342 - 0
client_local/skill/skill_map.py

@@ -0,0 +1,342 @@
+from client_local.skill.jidi_skill import *
+from client_local.skill.mizhidi_skill import *
+from client_local.skill.npc_skill import *
+from client_local.skill.new_skill import *
+from client_local.skill.skill import *
+from client_local.skill.cool_skill import *
+from client_local.skill.parametric_skill import *
+from client_local.skill.special_magic_skill import *
+from client_local.skill.machine_skill import *
+from client_local.skill.cool_machine_skill import *
+from client_local.skill.parametric2_skill import *
+from client_local.skill.parametric3_skill import *
+
+
+skill_map = {
+    "Skill21000": {"skill": Skill21000, "target": "me", "param": None, "effect": "cl"},
+    "Skill21002": {"skill": Skill21002, "target": "me", "param": None, "effect": "cl"},
+    "Skill21003": {"skill": Skill21003, "target": "me", "param": None, "effect": "cl"},
+    "Skill21004": {"skill": Skill21004, "target": "me", "param": None, "effect": "cl"},
+    "Skill21005": {"skill": Skill21005, "target": "me", "param": None, "effect": "cl"},
+    "Skill21006": {"skill": Skill21006, "target": "me", "param": None, "effect": "cl"},
+    "Skill21007": {"skill": Skill21007, "target": "me", "param": None, "effect": "cl"},
+    "Skill21008": {"skill": Skill21008, "target": "me", "param": None, "effect": "cl"},
+    "Skill21011": {"skill": Skill21011, "target": "me", "param": None, "effect": "cl"},
+    "Skill21012": {"skill": Skill21012, "target": "me", "param": None, "effect": "cl"},
+    "Skill21014": {"skill": Skill21014, "target": "me", "param": None, "effect": "cl"},
+    "Skill21017": {"skill": Skill21017, "target": None, "param": None, "effect": "self"},
+    "Skill21017New": {"skill": Skill21017New, "target": None, "param": None, "effect": "self"},
+    "Skill21018": {"skill": Skill21018, "target": "me", "param": None, "effect": "cl"},
+    "Skill21019": {"skill": Skill21019, "target": "me", "param": None, "effect": "cl"},
+    "Skill21020": {"skill": Skill21020, "target": "me", "param": None, "effect": "cl"},
+    "Skill21022": {"skill": Skill21022, "target": "me", "param": None, "effect": "cl"},
+    "Skill21025": {"skill": Skill21025, "target": "me", "param": None, "effect": "cl"},
+    "Skill21027": {"skill": Skill21027, "target": "me", "param": None, "effect": "cl"},
+    "Skill21044": {"skill": Skill21044, "target": "me", "param": None, "effect": "self"},
+    "Skill21049": {"skill": Skill21049, "target": "me", "param": None, "effect": "self"},
+    "Skill21054": {"skill": Skill21054, "target": "npcs", "param": None, "effect": "self"},
+    "Skill21065": {"skill": Skill21065, "target": "me", "param": None, "effect": "self"},
+    "Skill21066": {"skill": Skill21066, "target": "me", "param": None, "effect": "cl"},
+    "Skill21067": {"skill": Skill21067, "target": "me", "param": None, "effect": "cl"},
+    "Skill21069": {"skill": Skill21069, "target": "me", "param": None, "effect": "self"},
+    "Skill21072": {"skill": Skill21072, "target": "me", "param": None, "effect": "cl"},
+    "Skill21073": {"skill": Skill21073, "target": "me", "param": None, "effect": "cl"},
+    "Skill21074": {"skill": Skill21074, "target": "me", "param": None, "effect": "cl"},
+    "Skill21082": {"skill": Skill21082, "target": "me", "param": None, "effect": "self"},
+    "Skill21087": {"skill": Skill21087, "target": "me", "param": None, "effect": "self"},
+    "ThunderAttack": {"skill": ThunderAttack, "target": None, "param": None, "effect": "self"},
+    "BloodElixirMiddle": {"skill": BloodElixirMiddle, "target": None, "param": None, "effect": "self"},
+    "HeiLongReverse": {"skill": HeiLongReverse, "target": "me", "param": None, "effect": "cl"},
+    "HeiLongBlackWizardPutIceTrap": {"skill": HeiLongBlackWizardPutIceTrap, "target": "me", "param": None, "effect": "cl"},
+    "HeiLongBlackWizardPutFireTrap": {"skill": HeiLongBlackWizardPutFireTrap, "target": "me", "param": None, "effect": "cl"},
+    "HeiLongAbyssDragonDistantFire": {"skill": HeiLongAbyssDragonDistantFire, "target": "me", "param": None, "effect": "cl"},
+    "HeiLongAbyssDragonCharge": {"skill": HeiLongAbyssDragonCharge, "target": None, "param": None, "effect": "self"},
+    "HeiLongAbyssDragonSword": {"skill": HeiLongAbyssDragonSword, "target": "listed_me", "param": None, "effect": "self"},
+    "HeiLongAbyssDragonRecovery": {"skill": HeiLongAbyssDragonRecovery, "target": None, "param": None, "effect": "self"},
+    "HeiLongPutFireTrap": {"skill": HeiLongPutFireTrap, "target": "me", "param": None, "effect": "cl"},
+    "HeiLongPutIceTrap": {"skill": HeiLongPutIceTrap, "target": "me", "param": None, "effect": "cl"},
+    "HeiLongDistantFire5x5": {"skill": HeiLongDistantFire5x5, "target": "listed_me", "param": None, "effect": "cl"},
+    "HeiLongDistantFire3x3": {"skill": HeiLongDistantFire3x3, "target": "listed_me", "param": None, "effect": "cl"},
+    "HeiLongDizzy9x9": {"skill": HeiLongDizzy9x9, "target": "me", "param": None, "effect": "cl"},
+    "HeiLongThunder3x3HP800": {"skill": HeiLongThunder3x3HP800, "target": "me", "param": None, "effect": "cl"},
+    "HeiLongSkeletonKnightPutThunderTrap": {"skill": HeiLongSkeletonKnightPutThunderTrap, "target": "me", "param": None, "effect": "cl"},
+    "HeiLongSkeletonKnightEnhance": {"skill": HeiLongSkeletonKnightEnhance, "target": None, "param": None, "effect": "cl"},
+    "HeiLongRedWizardPutFireTrap": {"skill": HeiLongRedWizardPutFireTrap, "target": "me", "param": None, "effect": "cl"},
+    "HeiLongFloatingFire": {"skill": HeiLongFloatingFire, "target": "me", "param": None, "effect": "self"},
+    "HeiLongHellDragonDistantFire": {"skill": HeiLongHellDragonDistantFire, "target": "me", "param": None, "effect": "cl"},
+    "HeiLongHellDragonCharge": {"skill": HeiLongHellDragonCharge, "target": None, "param": None, "effect": "self"},
+    "HeiLongHellDragonScope": {"skill": HeiLongHellDragonScope, "target": "me", "param": None, "effect": "self"},
+    "MiZhiDiSword500": {"skill": MiZhiDiSword500, "target": "listed_me", "param": None, "effect": "self"},
+    "MiZhiDiSword800": {"skill": MiZhiDiSword800, "target": "listed_me", "param": None, "effect": "self"},
+    "MonsterReverse": {"skill": MonsterReverse, "target": "me", "param": None, "effect": "cl"},
+    "MiZhiDiThunder1x1HP800": {"skill": MiZhiDiThunder1x1HP800, "target": "me", "param": None, "effect": "cl"},
+    "FengBaoIceSlow1x1": {"skill": FengBaoIceSlow1x1, "target": "me", "param": None, "effect": "cl"},
+    "FengBaoSword100": {"skill": FengBaoSword100, "target": "listed_me", "param": None, "effect": "self"},
+    "RevengeDash": {"skill": RevengeDash, "target": None, "param": None, "effect": "self"},
+    "RevengeDash3s": {"skill": RevengeDash3s, "target": None, "param": None, "effect": "self"},
+    "TemporaryHidden": {"skill": TemporaryHidden, "target": "me", "param": None, "effect": "self"},
+    "PermanentlyHidden": {"skill": PermanentlyHidden, "target": "me", "param": None, "effect": "self"},
+    "PutBomb": {"skill": PutBomb, "target": None, "param": None, "effect": "self"},
+    "BombJail": {"skill": BombJail, "target": "me", "param": None, "effect": "self"},
+    "BombThrowGold": {"skill": BombThrowGold, "target": "me", "param": None, "effect": "self"},
+    "BombThrowBlack": {"skill": BombThrowBlack, "target": "me", "param": None, "effect": "self"},
+    "BombEscape": {"skill": BombEscape, "target": "me", "param": None, "effect": "self"},
+    "ContactStun": {"skill": ContactStun, "target": "me", "param": None, "effect": "self"},
+    "LandQuake": {"skill": LandQuake, "target": "me", "param": None, "effect": "self"},
+    "ColorfulSmoke": {"skill": ColorfulSmoke, "target": "me", "param": None, "effect": "self"},
+    "DistantIce5x5": {"skill": DistantIce5x5, "target": "me", "param": None, "effect": "self"},
+    "SlowSword": {"skill": SlowSword, "target": "me", "param": None, "effect": "self"},
+    "DirtyPath": {"skill": DirtyPath, "target": "me", "param": None, "effect": "cl"},
+    "NearSlow": {"skill": NearSlow, "target": "me", "param": None, "effect": "self"},
+    "NearAccelerate": {"skill": NearAccelerate, "target": "me", "param": None, "effect": "self"},
+    "SlowSmoke7x7": {"skill": SlowSmoke7x7, "target": "me", "param": None, "effect": "self"},
+    "BombThrowRainPlayer": {"skill": BombThrowRainPlayer, "target": "me", "param": None, "effect": "self"},
+    "BombThrowRainRandom": {"skill": BombThrowRainRandom, "target": "me", "param": None, "effect": "self"},
+    "IceFireSwitch": {"skill": IceFireSwitch, "target": "me", "param": None, "effect": "self"},
+    "SpawnMinions": {"skill": SpawnMinions, "target": "me", "param": True, "effect": "self"},
+    "BloodAccelerate": {"skill": BloodAccelerate, "target": "me", "param": None, "effect": "self"},
+    "LoomingFire": {"skill": LoomingFire, "target": "me", "param": None, "effect": "cl"},
+    "MinionChase": {"skill": MinionChase, "target": "me", "param": None, "effect": "self"},
+    "EnergyEgg": {"skill": EnergyEgg, "target": "me", "param": None, "effect": "cl"},
+    "BigEnergyEgg": {"skill": BigEnergyEgg, "target": "me", "param": None, "effect": "cl"},
+    "EnergyShield": {"skill": EnergyShield, "target": None, "param": None, "effect": "cl"},
+    "TimeStop": {"skill": TimeStop, "target": "me", "param": None, "effect": "cl"},
+    "BigTimeStop": {"skill": BigTimeStop, "target": "me", "param": None, "effect": "cl"},
+    "MediumTimeStop": {"skill": MediumTimeStop, "target": "me", "param": None, "effect": "cl"},
+    "TimeExplode": {"skill": TimeExplode, "target": "me", "param": None, "effect": "cl"},
+    "ReversePoisonFogExplode": {"skill": ReversePoisonFogExplode, "target": "me", "param": None, "effect": "cl"},
+    "PoisonFog1000x5": {"skill": PoisonFog1000x5, "target": "me", "param": None, "effect": "cl"},
+    "InvisibleSlowTrap": {"skill": InvisibleSlowTrap, "target": "me", "param": None, "effect": "cl"},
+    "SelfNuclearExplode": {"skill": SelfNuclearExplode, "target": "me", "param": None, "effect": "cl"},
+    "RobotScope": {"skill": RobotScope, "target": "me", "param": None, "effect": "self"},
+    "SelfRepair70": {"skill": SelfRepair70, "target": None, "param": None, "effect": "self"},
+    "FreedomBless": {"skill": FreedomBless, "target": "npcs", "param": None, "effect": "self"},
+    "BigFreedomBless": {"skill": BigFreedomBless, "target": "npcs", "param": None, "effect": "self"},
+    "Self5x5Explode": {"skill": Self5x5Explode, "target": "me", "param": None, "effect": "cl"},
+    "SelfRepair100": {"skill": SelfRepair100, "target": None, "param": None, "effect": "self"},
+    "Thunder1x1HP200": {"skill": Thunder1x1HP200, "target": "me", "param": None, "effect": "cl"},
+    "Thunder3x3HP200": {"skill": Thunder3x3HP200, "target": "me", "param": None, "effect": "cl"},
+    "SelfThunder3x3HP200": {"skill": SelfThunder3x3HP200, "target": "me", "param": None, "effect": "cl"},
+    "AttackModeContact500": {"skill": AttackModeContact500, "target": None, "param": None, "effect": "cl"},
+    "DefenseMode1000": {"skill": DefenseMode1000, "target": None, "param": None, "effect": "cl"},
+    "FastDistantFire1x1": {"skill": FastDistantFire1x1, "target": "listed_me", "param": None, "effect": "cl"},
+    "DeathBombFire1000": {"skill": DeathBombFire1000, "target": "me", "param": None, "effect": "cl"},
+    "FastSlideToHell": {"skill": FastSlideToHell, "target": "me", "param": None, "effect": "cl"},
+    "FastSlideToHellNew": {"skill": FastSlideToHellNew, "target": "me", "param": None, "effect": "cl"},
+    "WitchRiceModeSwitch": {"skill": WitchRiceModeSwitch, "target": None, "param": None, "effect": "cl"},
+    "ImmobilizedThunder1x1HP800": {"skill": ImmobilizedThunder1x1HP800, "target": "me", "param": None, "effect": "cl"},
+    "Thunder3x3HP500WithStun": {"skill": Thunder3x3HP500WithStun, "target": "me", "param": None, "effect": "cl"},
+    "HenshinIceSkeleton3s": {"skill": HenshinIceSkeleton3s, "target": "me", "param": None, "effect": "cl"},
+    "HenshinFireSkeleton3s": {"skill": HenshinFireSkeleton3s, "target": "me", "param": None, "effect": "cl"},
+    "HenshinThunderSkeleton3s": {"skill": HenshinThunderSkeleton3s, "target": "me", "param": None, "effect": "cl"},
+    "HenshinIceSkeleton5s": {"skill": HenshinIceSkeleton5s, "target": "me", "param": None, "effect": "cl"},
+    "HenshinFireSkeleton5s": {"skill": HenshinFireSkeleton5s, "target": "me", "param": None, "effect": "cl"},
+    "HenshinThunderSkeleton5s": {"skill": HenshinThunderSkeleton5s, "target": "me", "param": None, "effect": "cl"},
+    "HenshinIceSkeleton9s": {"skill": HenshinIceSkeleton9s, "target": "me", "param": None, "effect": "cl"},
+    "HenshinFireSkeleton9s": {"skill": HenshinFireSkeleton9s, "target": "me", "param": None, "effect": "cl"},
+    "HenshinThunderSkeleton9s": {"skill": HenshinThunderSkeleton9s, "target": "me", "param": None, "effect": "cl"},
+    "SuperLandQuake": {"skill": SuperLandQuake, "target": "me", "param": None, "effect": "self"},
+    "DistantIce3x3": {"skill": DistantIce3x3, "target": "me", "param": None, "effect": "self"},
+    "NearStop": {"skill": NearStop, "target": "me", "param": None, "effect": "self"},
+    "PreloadPoison3x3": {"skill": PreloadPoison3x3, "target": "me", "param": None, "effect": "cl"},
+    "DevilPoisonx3": {"skill": DevilPoisonx3, "target": "me", "param": None, "effect": "cl"},
+    "Fire400": {"skill": Fire400, "target": "me", "param": None, "effect": "cl"},
+    "SpeedUp": {"skill": SpeedUp, "target": "me", "param": None, "effect": "self"},
+    "SpeedDown": {"skill": SpeedDown, "target": "me", "param": None, "effect": "self"},
+    "JumpForward": {"skill": JumpForward, "target": "me", "param": None, "effect": "self"},
+    "RandomSpawn1": {"skill": RandomSpawn1, "target": "me", "param": True, "effect": "self"},
+    "PointSpawn1": {"skill": PointSpawn1, "target": "me", "param": True, "effect": "self"},
+    "PointSpawn2": {"skill": PointSpawn2, "target": "me", "param": True, "effect": "self"},
+    "AllDizzy7x7": {"skill": AllDizzy7x7, "target": "me", "param": None, "effect": "cl"},
+    "AllDizzy9x9": {"skill": AllDizzy9x9, "target": "me", "param": None, "effect": "cl"},
+    "AirFlow500": {"skill": AirFlow500, "target": "me", "param": None, "effect": "cl"},
+    "Smoke1x7": {"skill": Smoke1x7, "target": "me", "param": None, "effect": "cl"},
+    "Smoke1x7Reverse": {"skill": Smoke1x7Reverse, "target": "me", "param": None, "effect": "cl"},
+    "Skill21019Test": {"skill": Skill21019Test, "target": "me", "param": None, "effect": "cl"},
+    "FourSidedAirFlow500": {"skill": FourSidedAirFlow500, "target": "me", "param": None, "effect": "self"},
+    "RealAirKnife": {"skill": RealAirKnife, "target": "me", "param": None, "effect": "self"},
+    "RealAirKnifePlus": {"skill": RealAirKnifePlus, "target": "me", "param": None, "effect": "self"},
+    "CuteAirKnife": {"skill": CuteAirKnife, "target": "me", "param": None, "effect": "self"},
+    "Thunder1x1HP500": {"skill": Thunder1x1HP500, "target": "me", "param": None, "effect": "cl"},
+    "DefenseEnhance5K": {"skill": DefenseEnhance5K, "target": None, "param": None, "effect": "cl"},
+    "DistantFire5x5Pro": {"skill": DistantFire5x5Pro, "target": "listed_me", "param": None, "effect": "cl"},
+    "DistantFire3x3": {"skill": DistantFire3x3, "target": "listed_me", "param": None, "effect": "cl"},
+    "SpawnMinions2": {"skill": SpawnMinions2, "target": "me", "param": True, "effect": "self"},
+    "SpawnMinions3": {"skill": SpawnMinions3, "target": "me", "param": True, "effect": "self"},
+    "SpawnMinions4": {"skill": SpawnMinions4, "target": "me", "param": True, "effect": "self"},
+    "SpawnMinions5": {"skill": SpawnMinions5, "target": "me", "param": True, "effect": "self"},
+    "RushB": {"skill": RushB, "target": None, "param": None, "effect": "cl"},
+    "DevilPoisonBlood80": {"skill": DevilPoisonBlood80, "target": "me", "param": None, "effect": "cl"},
+    "DebuffPoisonBlood": {"skill": DebuffPoisonBlood, "target": "me", "param": None, "effect": "cl"},
+    "DevilPoisonSmoke50xHPx10": {"skill": DevilPoisonSmoke50xHPx10, "target": "me", "param": None, "effect": "cl"},
+    "SolomoniciShieldBless": {"skill": SolomoniciShieldBless, "target": "npcs", "param": None, "effect": "self"},
+    "WarningOrder": {"skill": WarningOrder, "target": "npcs", "param": None, "effect": "self"},
+    "DirectWarningOrder": {"skill": DirectWarningOrder, "target": "npcs", "param": None, "effect": "self"},
+    "SelfPoison5x5Damage10HPx3": {"skill": SelfPoison5x5Damage10HPx3, "target": "me", "param": None, "effect": "cl"},
+    "SelfPoison3x3Damage10HPx3": {"skill": SelfPoison3x3Damage10HPx3, "target": "me", "param": None, "effect": "cl"},
+    "SelfPoison7x7Damage10HPx3": {"skill": SelfPoison7x7Damage10HPx3, "target": "me", "param": None, "effect": "cl"},
+    "PlayerPoison3x3Damage10HPx3": {"skill": PlayerPoison3x3Damage10HPx3, "target": "me", "param": None, "effect": "cl"},
+    "SelfBombEscape": {"skill": SelfBombEscape, "target": "me", "param": None, "effect": "self"},
+    "SuperBombEscape": {"skill": SuperBombEscape, "target": "me", "param": None, "effect": "self"},
+    "SuperBombDefense": {"skill": SuperBombDefense, "target": "me", "param": None, "effect": "self"},
+    "PutSmallBomb_P1_Dn200": {"skill": PutSmallBomb_P1_Dn200, "target": None, "param": None, "effect": "self"},
+    "KillAll": {"skill": KillAll, "target": "npcs", "param": None, "effect": "self"},
+    "FakeKillAll": {"skill": FakeKillAll, "target": "npcs", "param": None, "effect": "self"},
+    "KillSelf": {"skill": KillSelf, "target": "npcs", "param": None, "effect": "self"},
+    "KillSelfQuietly": {"skill": KillSelfQuietly, "target": "npcs", "param": None, "effect": "self"},
+    "Self5x5Explode600": {"skill": Self5x5Explode600, "target": "me", "param": None, "effect": "cl"},
+    "VeryNearStop": {"skill": VeryNearStop, "target": "me", "param": None, "effect": "cl"},
+    "MainGunFire3x3": {"skill": MainGunFire3x3, "target": "me", "param": None, "effect": "cl"},
+    "MainGunFire3x3Charge15s": {"skill": MainGunFire3x3Charge15s, "target": "me", "param": None, "effect": "cl"},
+    "ChargeAssistance": {"skill": ChargeAssistance, "target": "npcs", "param": None, "effect": "self"},
+    "ChargeAssistance3s": {"skill": ChargeAssistance3s, "target": "npcs", "param": None, "effect": "self"},
+    "SpreadingThunder600": {"skill": SpreadingThunder600, "target": "me", "param": None, "effect": "cl"},
+    "FastHeal5000": {"skill": FastHeal5000, "target": "npcs", "param": None, "effect": "self"},
+    "Smoke1x7Pro": {"skill": Smoke1x7Pro, "target": "me", "param": None, "effect": "cl"},
+    "Smoke1x7ReversePro": {"skill": Smoke1x7ReversePro, "target": "me", "param": None, "effect": "cl"},
+    "GhostChase": {"skill": GhostChase, "target": "me", "param": None, "effect": "self"},
+    "ChasingThunder700": {"skill": ChasingThunder700, "target": "me", "param": None, "effect": "cl"},
+    "ColumnThunder700": {"skill": ColumnThunder700, "target": "me", "param": None, "effect": "cl"},
+    "RowThunder700": {"skill": RowThunder700, "target": "me", "param": None, "effect": "cl"},
+    "SpeedZero": {"skill": SpeedZero, "target": "me", "param": None, "effect": "self"},
+    "Energy_Charge_1": {"skill": Energy_Charge_1, "target": "me", "param": None, "effect": "self"},
+    "Energy_Discharge_1": {"skill": Energy_Discharge_1, "target": "me", "param": None, "effect": "self"},
+    "SlowFireBall": {"skill": SlowFireBall, "target": "me", "param": None, "effect": "cl"},
+    "RandomSlowFireBall": {"skill": RandomSlowFireBall, "target": "me", "param": None, "effect": "cl"},
+    "EnergyEgg300": {"skill": EnergyEgg300, "target": "me", "param": None, "effect": "cl"},
+    "TimeExplodePlus": {"skill": TimeExplodePlus, "target": "me", "param": None, "effect": "cl"},
+    "Energy5x5Charge1": {"skill": Energy5x5Charge1, "target": "npcs", "param": None, "effect": "self"},
+    "Energy5x5Charge5": {"skill": Energy5x5Charge5, "target": "npcs", "param": None, "effect": "self"},
+    "Energy7x7Charge5": {"skill": Energy7x7Charge5, "target": "npcs", "param": None, "effect": "self"},
+    "PowerOFF": {"skill": PowerOFF, "target": "npcs", "param": None, "effect": "self"},
+    "SuperPowerOFF": {"skill": SuperPowerOFF, "target": "npcs", "param": None, "effect": "self"},
+    "SuperSuperPowerOFF": {"skill": SuperSuperPowerOFF, "target": "npcs", "param": None, "effect": "self"},
+    "DeadExplode": {"skill": DeadExplode, "target": "npcs", "param": None, "effect": "self"},
+    "LaserSword5x5": {"skill": LaserSword5x5, "target": "listed_me", "param": None, "effect": "self"},
+    "PowerShield2": {"skill": PowerShield2, "target": "me", "param": None, "effect": "cl"},
+    "RemoveProtect": {"skill": RemoveProtect, "target": None, "param": None, "effect": "cl"},
+    "ShortRush": {"skill": ShortRush, "target": None, "param": None, "effect": "cl"},
+    "VeryShortRush": {"skill": VeryShortRush, "target": None, "param": None, "effect": "cl"},
+    "Energy5x5Absorb3": {"skill": Energy5x5Absorb3, "target": "npcs", "param": None, "effect": "self"},
+    "Energy_Clear": {"skill": Energy_Clear, "target": "me", "param": None, "effect": "self"},
+    "RevengeSmoke7x7D600": {"skill": RevengeSmoke7x7D600, "target": "me", "param": None, "effect": "self"},
+    "RevengePoison1x1": {"skill": RevengePoison1x1, "target": "me", "param": None, "effect": "cl"},
+    "MinionChase2sLater": {"skill": MinionChase2sLater, "target": "me", "param": None, "effect": "self"},
+    "DebuffPoisonBlood3x3": {"skill": DebuffPoisonBlood3x3, "target": "me", "param": None, "effect": "cl"},
+    "PoisonTrap1x1DHPx5x5": {"skill": PoisonTrap1x1DHPx5x5, "target": "me", "param": None, "effect": "cl"},
+    "LifeLongReverse": {"skill": LifeLongReverse, "target": "me", "param": None, "effect": "self"},
+    "SlowRecoveryWeak": {"skill": SlowRecoveryWeak, "target": "me", "param": None, "effect": "self"},
+    "ClearReverse": {"skill": ClearReverse, "target": "me", "param": None, "effect": "self"},
+    "RunBack": {"skill": RunBack, "target": "me", "param": None, "effect": "self"},
+    "RunBackShort": {"skill": RunBackShort, "target": "me", "param": None, "effect": "self"},
+    "RunPlayerBack": {"skill": RunPlayerBack, "target": "me", "param": None, "effect": "self"},
+    "PermanentlyHiddenWithPower": {"skill": PermanentlyHiddenWithPower, "target": "me", "param": None, "effect": "self"},
+    "KillPlayer": {"skill": KillPlayer, "target": "me", "param": None, "effect": "self"},
+    "KillContact": {"skill": KillContact, "target": "me", "param": None, "effect": "self"},
+    "SwapPosition": {"skill": SwapPosition, "target": "me", "param": None, "effect": "self"},
+    "CustomTeleportEscape": {"skill": CustomTeleportEscape, "target": "me", "param": True, "effect": "self"},
+
+    "SpawnMinionsWithName": {"skill": SpawnMinionsWithName, "target": "me", "old_spawn": True, "param": None, "effect": "self"},
+    "PointSpawnWithName": {"skill": PointSpawnWithName, "target": "me", "old_spawn": True, "param": None, "effect": "self"},
+    "RemakeWithNameAfterCharge": {"skill": RemakeWithNameAfterCharge, "target": "me", "old_spawn": True, "param": None, "effect": "self"},
+    "PointSpawnWithNameAndCharge": {"skill": PointSpawnWithNameAndCharge, "target": "me", "old_spawn": True, "param": None, "effect": "self"},
+    "PointRandomSpawnWithName": {"skill": PointRandomSpawnWithName, "target": "me", "old_spawn": True, "param": None, "effect": "self"},
+    "PointRandomSpawnWithProtect": {"skill": PointRandomSpawnWithProtect, "target": "me", "old_spawn": True, "param": None, "effect": "self"},
+    "CustomSword5x5": {"skill": CustomSword5x5, "target": "listed_me", "param": True, "effect": "self"},
+    "CustomPutBomb": {"skill": CustomPutBomb, "target": None, "param": True, "effect": "self"},
+    "CustomMinionChase": {"skill": CustomMinionChase, "target": "me", "param": True, "effect": "self"},
+    "CustomLocationSpawnMinionsWithName": {"skill": CustomLocationSpawnMinionsWithName, "target": "me", "param": True, "effect": "self"},
+    "CustomMonsterCombo": {"skill": CustomMonsterCombo, "target": "npcs", "param": True, "effect": "self"},
+    "CustomBombShield": {"skill": CustomBombShield, "target": "me", "param": True, "effect": "self"},
+    "CustomGunFireSkew3x3": {"skill": CustomGunFireSkew3x3, "target": "npcs", "param": True, "effect": "self"},
+    "CustomLaserFireBall": {"skill": CustomLaserFireBall, "target": "me", "param": True, "effect": "cl"},
+    "CustomShieldBless": {"skill": CustomShieldBless, "target": "npcs", "param": True, "effect": "self"},
+    "CustomBombJail": {"skill": CustomBombJail, "target": "me", "param": True, "effect": "self"},
+    "CustomDirectSlow": {"skill": CustomDirectSlow, "target": "me", "param": True, "effect": "self"},
+    "EscapeFromBomb": {"skill": EscapeFromBomb, "target": "me", "param": True, "effect": "self"},
+    "SafelyEscapeFromBomb": {"skill": SafelyEscapeFromBomb, "target": "me", "param": True, "effect": "self"},
+    "EscapeFromBombOld": {"skill": EscapeFromBombOld, "target": "me", "param": True, "effect": "self"},
+    "EscapeRandom": {"skill": EscapeRandom, "target": "me", "param": True, "effect": "self"},
+    "CustomCleverSpawnMinionsWithName": {"skill": CustomCleverSpawnMinionsWithName, "target": "me", "param": True, "effect": "self"},
+    "CustomBombThrowRainRandom": {"skill": CustomBombThrowRainRandom, "target": "me", "param": True, "effect": "self"},
+    "CustomSummonObstacle": {"skill": CustomSummonObstacle, "target": "me", "param": True, "effect": "cl"},
+    "CustomSummonObstacleWithXY": {"skill": CustomSummonObstacleWithXY, "target": "me", "param": True, "effect": "cl"},
+    "CustomDirectionLaserFireBall": {"skill": CustomDirectionLaserFireBall, "target": "me", "param": True, "effect": "cl"},
+    "CustomGeneralDistanceAttack": {"skill": CustomGeneralDistanceAttack, "target": "me", "param": True, "effect": "cl"},
+    "ShareDamage": {"skill": ShareDamage, "target": "me", "param": True, "effect": "self"},
+    "CustomGeneralTrap": {"skill": CustomGeneralTrap, "target": "me", "param": True, "effect": "cl"},
+    "CustomMovePoint": {"skill": CustomMovePoint, "target": "me", "param": True, "effect": "self"},
+    "CustomBGM": {"skill": CustomBGM, "target": "me", "param": True, "effect": "self"},
+    "CustomLevel": {"skill": CustomLevel, "target": "me", "param": True, "effect": "self"},
+    "CustomFourSidedWaterFlow": {"skill": CustomFourSidedWaterFlow, "target": "me", "param": True, "effect": "cl"},
+    "CustomWaterFlow": {"skill": CustomWaterFlow, "target": "me", "param": True, "effect": "cl"},
+    "CustomSourceWaterFlow": {"skill": CustomSourceWaterFlow, "target": "me", "param": True, "effect": "cl"},
+    "CustomCrabWalk": {"skill": CustomCrabWalk, "target": "me", "param": True, "effect": "self"},
+    "CustomRangeBuff": {"skill": CustomRangeBuff, "target": "npcs", "param": True, "effect": "cl"},
+    "CustomRecovery": {"skill": CustomRecovery, "target": None, "param": True, "effect": "cl"},
+    "CustomRandomGunFireSkew1x1": {"skill": CustomRandomGunFireSkew1x1, "target": "me", "param": True, "effect": "cl"},
+    "CustomDevilSmokeMagic": {"skill": CustomDevilSmokeMagic, "target": "me", "param": True, "effect": "cl"},
+    "AbsorbAlly": {"skill": AbsorbAlly, "target": "npcs", "param": True, "effect": "self"},
+    "CustomDevilAirKnife": {"skill": CustomDevilAirKnife, "target": "me", "param": True, "effect": "self"},
+    "CustomDamageFrameSkill": {"skill": CustomDamageFrameSkill, "target": "me", "param": True, "effect": "self"},
+    "CustomHPDropSkill": {"skill": CustomHPDropSkill, "target": "me", "param": True, "effect": "self"},
+    "CustomInDistanceBasedSkill": {"skill": CustomInDistanceBasedSkill, "target": "me", "param": True, "effect": "self"},
+    "CustomOutDistanceBasedSkill": {"skill": CustomOutDistanceBasedSkill, "target": "me", "param": True, "effect": "self"},
+    "CustomDelayedSkill": {"skill": CustomDelayedSkill, "target": "me", "param": True, "effect": "self"},
+    "CustomModeSwitch": {"skill": CustomModeSwitch, "target": None, "param": True, "effect": "self"},
+    "DirectPointSpawn": {"skill": DirectPointSpawn, "target": "me", "param": True, "effect": "self"},
+    "KillAllExcept": {"skill": KillAllExcept, "target": "npcs", "param": True, "effect": "self"},
+    "KillMonsterInCustomPosition": {"skill": KillMonsterInCustomPosition, "target": "npcs", "param": True, "effect": "self"},
+    "CustomMoveDirection": {"skill": CustomMoveDirection, "target": "npcs", "param": True, "effect": "self"},
+    "CustomOnGridBasedSkill": {"skill": CustomOnGridBasedSkill, "target": "me", "param": True, "effect": "self"},
+    "CustomChaseMonster": {"skill": CustomChaseMonster, "target": "npcs", "param": True, "effect": "self"},
+    "CustomMonsterTargetedSword5x5": {"skill": CustomMonsterTargetedSword5x5, "target": "npcs", "param": True, "effect": "self"},
+    "CustomMessage": {"skill": CustomMessage, "target": "me", "param": True, "effect": "self"},
+    "CustomColourfulMessage": {"skill": CustomColourfulMessage, "target": "me", "param": True, "effect": "self"},
+    "CustomWaterBubbleDistanceAttack": {"skill": CustomWaterBubbleDistanceAttack, "target": "me", "param": True, "effect": "self"},
+    "CustomGroupSourceWaterFlow": {"skill": CustomGroupSourceWaterFlow, "target": "me", "param": True, "effect": "cl"},
+    "CustomGroupDirectionLaserFireBall": {"skill": CustomGroupDirectionLaserFireBall, "target": "me", "param": True, "effect": "cl"},
+    "CustomSelfDefenseEnhance": {"skill": CustomSelfDefenseEnhance, "target": None, "param": True, "effect": "self"},
+    "CustomWaterDamageHeal": {"skill": CustomWaterDamageHeal, "target": None, "param": True, "effect": "self"},
+    "CustomVortex": {"skill": CustomVortex, "target": "me", "param": True, "effect": "cl"},
+    "CustomBubbleContact": {"skill": CustomBubbleContact, "target": "me", "param": True, "effect": "self"},
+    "CustomSelfDamage": {"skill": CustomSelfDamage, "target": "me", "param": True, "effect": "self"},
+    "CustomTrackingDirectionLaserFireBallEffect": {"skill": CustomTrackingDirectionLaserFireBallEffect, "target": None, "param": True, "effect": "cl"},
+    "CustomTrackingDirectionLaserFireBallArithmeticStream": {"skill": CustomTrackingDirectionLaserFireBallArithmeticStream, "target": "me", "param": True, "effect": "cl"},
+    "CustomFixedDirectionLaserFireBallArithmeticStream": {"skill": CustomFixedDirectionLaserFireBallArithmeticStream, "target": "me", "param": True, "effect": "cl"},
+    "CustomAssassinHide": {"skill": CustomAssassinHide, "target": "me", "param": True, "effect": "self"},
+    "CustomHydroGunFireSkew5x5": {"skill": CustomHydroGunFireSkew5x5, "target": "npcs", "param": True, "effect": "self"},
+    "CustomLightDistanceAttack": {"skill": CustomLightDistanceAttack, "target": "me", "param": True, "effect": "self"},
+    "CustomShellSkill": {"skill": CustomShellSkill, "target": "me", "param": True, "effect": "self"},
+    "CustomLightTrap": {"skill": CustomLightTrap, "target": "me", "param": True, "effect": "cl"},
+    "CustomLightRangeRecovery": {"skill": CustomLightRangeRecovery, "target": "npcs", "param": True, "effect": "cl"},
+    "CustomMoveToTarget": {"skill": CustomMoveToTarget, "target": "npcs", "param": True, "effect": "cl"},
+    "CustomLightShield": {"skill": CustomLightShield, "target": "me", "param": True, "effect": "cl"},
+    "CustomMapEarthQuake": {"skill": CustomMapEarthQuake, "target": "me", "param": True, "effect": "cl"},
+    "CustomPointSpawnWithNameAndCharge": {"skill": CustomPointSpawnWithNameAndCharge, "target": "me", "param": True, "effect": "cl"},
+    "CustomMinionChaseWithCastTimeAndEarthQuake": {"skill": CustomMinionChaseWithCastTimeAndEarthQuake, "target": "me", "param": True, "effect": "self"},
+
+    "CustomLevelVariableOperation": {"skill": CustomLevelVariableOperation, "target": "me", "param": True, "effect": "self"},
+    "CustomConditionBasedSkill": {"skill": CustomConditionBasedSkill, "target": "me", "param": True, "effect": "self"},
+    "CustomSingleTriggeredConditionBasedSkill": {"skill": CustomSingleTriggeredConditionBasedSkill, "target": "me", "param": True, "effect": "self"},
+    "CustomMonsterBloodBasedSkill": {"skill": CustomMonsterBloodBasedSkill, "target": "me", "param": True, "effect": "self"},
+    "CustomAnyTimeMonsterBloodBasedSkill": {"skill": CustomAnyTimeMonsterBloodBasedSkill, "target": "me", "param": True, "effect": "self"},
+    "CustomSequentialSkill": {"skill": CustomSequentialSkill, "target": "me", "param": True, "effect": "self"},
+
+    "Canyon_RevengeDash": {"skill": Canyon_RevengeDash, "target": None, "param": None, "effect": "self"},
+    "Canyon_Skill21044": {"skill": Canyon_Skill21044, "target": "me", "param": None, "effect": "self"},
+    "Canyon_Skill21065": {"skill": Canyon_Skill21065, "target": "me", "param": None, "effect": "self"},
+    "Canyon_HeiLongAbyssDragonSword": {"skill": Canyon_HeiLongAbyssDragonSword, "target": "me", "param": None, "effect": "self"},
+    "Canyon_DistantIce5x5": {"skill": Canyon_DistantIce5x5, "target": "me", "param": None, "effect": "self"},
+    "Canyon_HeiLongBlackWizardPutIceTrap": {"skill": Canyon_HeiLongBlackWizardPutIceTrap, "target": "me", "param": None, "effect": "cl"},
+    "Canyon_HeiLongPutIceTrap": {"skill": Canyon_HeiLongPutIceTrap, "target": "me", "param": None, "effect": "cl"},
+    "Canyon_Skill21000": {"skill": Canyon_Skill21000, "target": "me", "param": None, "effect": "self"},
+    "Canyon_Skill21017": {"skill": Canyon_Skill21017, "target": None, "param": None, "effect": "self"},
+    "Tundra_Skill21011": {"skill": Tundra_Skill21011, "target": "me", "param": None, "effect": "self"},
+    "Tundra_Skill21002": {"skill": Tundra_Skill21002, "target": "me", "param": None, "effect": "self"},
+    "Tundra_Skill21002Promax": {"skill": Tundra_Skill21002Promax, "target": "me", "param": True, "effect": "self"},
+    "Tundra_HeiLongDistantFire5x5": {"skill": Tundra_HeiLongDistantFire5x5, "target": "listed_me", "param": None, "effect": "cl"},
+    "Tundra_HeiLongFloatingFire": {"skill": Tundra_HeiLongFloatingFire, "target": "me", "param": None, "effect": "self"},
+    "Tundra_Skill21018": {"skill": Tundra_Skill21018, "target": "me", "param": None, "effect": "self"},
+    "Tundra_MinionChase": {"skill": Tundra_MinionChase, "target": "me", "param": None, "effect": "self"}
+}

+ 21 - 10
client_local/sound/sound_player.py

@@ -1,9 +1,13 @@
 import pygame
+import time
 from client_local.const import game as G
 from collections import defaultdict
 from datetime import timedelta
 
-pygame.mixer.init()
+try:
+    pygame.mixer.init()
+except Exception as e:
+    print(e)
 PATH = "res/sound"
 
 # 用于记录每种音效的上一次播放时间
@@ -11,19 +15,26 @@ last_play_time = defaultdict(lambda: -1)
 # 时间间隔阈值(毫秒)
 TIME_THRESHOLD = 100
 
+
 def play(name):
     global last_play_time
     current_time = pygame.time.get_ticks()
-    # 检查是否超过时间间隔阈值
-    if current_time - last_play_time[name] > TIME_THRESHOLD:
-        sound = pygame.mixer.Sound(PATH + '/' + name + ".wav")
-        sound.set_volume(G.SOUND_VOLUME)
-        sound.play()
-        last_play_time[name] = current_time
+    try:
+        # 检查是否超过时间间隔阈值
+        if current_time - last_play_time[name] > TIME_THRESHOLD or name in {"bomb", "flame"}:
+            sound = pygame.mixer.Sound(f"{PATH}/{name}.wav")
+            sound.set_volume(G.SOUND_VOLUME)
+            sound.play()
+            last_play_time[name] = current_time
+    except Exception as e:
+        print(e)
 
 
 def playWin(name):
-    sound = pygame.mixer.Sound("res/music" + '/' + name + ".ogg")
-    sound.set_volume(G.SOUND_VOLUME)
-    sound.play()
+    try:
+        sound = pygame.mixer.Sound(f"res/music/{name}.ogg")
+        sound.set_volume(G.SOUND_VOLUME)
+        sound.play()
+    except Exception as e:
+        print(e)
 

+ 13 - 10
client_local/sprite/hero.py

@@ -57,9 +57,13 @@ class Hero(Player):
         Indicator(self, self.skill_instances)
 
         self.cfg_json = load_json("config.json")
-        self.map_file = load_json("game/map_set/" + self.cfg_json["map_set"] + ".json")
+        self.map_file = load_json(f"game/map_set/{self.cfg_json['map_set']}.json")
         # print("here:", G.CURRENT_LEVEL)
-        self.map_json = load_json("game/map/" + self.map_file["maps"][G.CURRENT_LEVEL-1] + ".json")
+        if not G.IS_CUSTOM_LEVEL:
+            self.map_json = load_json(f"game/map/{self.map_file['maps'][G.CURRENT_LEVEL]}.json")
+        else:
+            G.IS_CUSTOM_LEVEL = False
+            self.map_json = load_json(f"game/map/{G.CURRENT_MAP_NAME}.json")
         try:
             # 特殊亮度
             if "player_light" in self.map_json["basic"].keys():
@@ -92,8 +96,8 @@ class Hero(Player):
                 G.SPECIAL_SPEED = 1
                 G.SPECIAL_POWER = 0
                 G.SPECIAL_BOMB = 0
-        except:
-            pass
+        except Exception as e:
+            print(e)
 
         self.hero_json = load_json("game/hero/" + hero_name + ".json")
         self.standard_speed = ((self.hero_json["speed"]*G.SPECIAL_SPEED) * G.GAME_SQUARE) / 1000
@@ -110,8 +114,6 @@ class Hero(Player):
         self.delta_defense = 0
         self.delta_power = 0
 
-
-
     def load_hero(self, hero_name):
         # 加载人物hero的json文件
         if hero_name == "random":
@@ -122,6 +124,7 @@ class Hero(Player):
         self.bomb_skin = bomb.get_bomb(self.hero_json["decorations"]["bomb_skin"])
         self.icon_img = self.hero_json["icon_img"]
         self.blood = self.hero_json["blood"] + G.SPECIAL_MAX_HP
+        print(self.blood, G.SPECIAL_MAX_HP)
         self.speed = (self.hero_json["speed"] * G.SPECIAL_SPEED * G.GAME_SQUARE) / 1000
         self.bomb = self.hero_json["bomb"] + G.SPECIAL_BOMB
         self.power = self.hero_json["power"] + G.SPECIAL_POWER
@@ -193,7 +196,7 @@ class Hero(Player):
         if len(bs) > 0:  # 当前位置有糖泡
             return
         sound_player.play("bomb")
-        b = BombInstance(self.x, self.y, bis, self.bomb_skin, self.power, self.damage, self)
+        b = BombInstance(self.x, self.y, bis, self.bomb_skin, self.power, self.damage + 200 * level.current_level.transport_buff_num, self)
         if self.bomb_decoration is not None:
             EffectInstance(self.bomb_decoration, b, True, b.effects_front)
         self.remain_bombs -= 1
@@ -255,13 +258,13 @@ class Hero(Player):
                 is_safe = True
         return is_safe
 
-    def polymorph_for(self, duration):
-        if self.polymorph_begin != 0:
+    def polymorph_for(self, duration, character="Character15701"):
+        if self.polymorph_begin != 0 or self.remain_blood <= 0:
             return
         self.polymorph += 1
         self.polymorph_begin = pygame.time.get_ticks()
         self.polymorph_duration = duration
-        self.character = self.load_character("Character15701", "Red", dict())
+        self.character = self.load_character(character, "Red", dict())
 
     def check_polymorph_time(self, current_time):
         if self.polymorph_begin != 0 and current_time - self.polymorph_begin > self.polymorph_duration:

Plik diff jest za duży
+ 203 - 792
client_local/sprite/npc.py


+ 91 - 40
client_local/sprite/obstacle_instance.py

@@ -9,8 +9,9 @@ from client_local.sprite.updatable import Updatable
 from client_local.sprite.item_instance import ItemInstance
 import client_local.frame.item as item
 
-from client_local.skill.obstacle_skill import Obstacle3x3Explode
+from client_local.skill.obstacle_skill import Obstacle3x3Explode, ObstacleTransportResourceSkill
 from client_local.frame.obstacle import switch_type
+from client_local.ui.game.blood_bar import ResourceObstacleBloodBar
 
 import logging
 from datetime import datetime
@@ -18,24 +19,26 @@ from datetime import datetime
 # 配置logging基础配置并设置日志级别为INFO
 # logging.basicConfig(filename='OBSTACLE_SKILL.log', level=logging.INFO)
 
-giftsDefault = {'item_blue_gem': 0.05,
-                     'item_book': 0.6,
-                     'item_bottle': 0.7,
-                     'item_cabbage': 0.8,
-                     'item_cucumber': 0.8,
-                     'item_drop': 0.6,
-                     'item_grape': 0.6,
-                     'item_green_gem': 0.05,
-                     'item_herb': 0.6,
-                     'item_knife': 0.5,
-                     'item_paper': 0.5,
-                     'item_pearl': 0.4,
-                     'item_plume': 0.6,
-                     'item_red_gem': 0.1,
-                     'item_rice_paper': 0.5,
-                     'item_wood': 0.5,
-                     'item_yellow_gem': 0.05,
-                     'item_yellow_vegetable': 0.7}
+giftsDefault = {
+    'item_blue_gem': 0.05,
+    'item_book': 0.6,
+    'item_bottle': 0.7,
+    'item_cabbage': 0.8,
+    'item_cucumber': 0.8,
+    'item_drop': 0.6,
+    'item_grape': 0.6,
+    'item_green_gem': 0.05,
+    'item_herb': 0.6,
+    'item_knife': 0.5,
+    'item_paper': 0.5,
+    'item_pearl': 0.4,
+    'item_plume': 0.6,
+    'item_red_gem': 0.1,
+    'item_rice_paper': 0.5,
+    'item_wood': 0.5,
+    'item_yellow_gem': 0.05,
+    'item_yellow_vegetable': 0.7
+}
 
 
 def custom_deepcopy(item):
@@ -57,7 +60,6 @@ def custom_deepcopy(item):
             return item
 
 
-
 class ObstacleInstance(Updatable):
 
     def __init__(self, x, y, obstacle_instances_dict: dict, obstacle, obstacle_json):
@@ -75,7 +77,10 @@ class ObstacleInstance(Updatable):
         self.has_drawn = False  # 当前帧已经draw过了,避免长宽大于1的障碍在1帧中多次draw,在update中复原
         self.has_updated = False  # 当前帧已经update过了,避免长宽大于1的障碍在1帧中多次update,在draw中复原
 
-        self.is_pushing = 0  # 当前是否正在推?每帧先False一次,如果正在推就再True,这样push方法就觉得“推”是连续的
+        # self.is_pushing = 0  # 当前是否正在推?每帧先False一次,如果正在推就再True,这样push方法就觉得“推”是连续的
+        self.is_pushing = False
+        self.is_last_pushing = False
+        self.last_push_time = 0
         self.push_begin = 0
         self.push_time = 500
         self.contact_damage = 0  # 接触伤害
@@ -86,8 +91,20 @@ class ObstacleInstance(Updatable):
         self.type_num = 0
         self.current_type = -1
         self.last_type_switch_time = 0
-
-        self.setup()
+        self.block_sight = False
+
+        self.last_transport_check_time = 0
+        self.last_leave_time = 0            # 上一次玩家离开安全范围的时间
+        self.in_safe_zone = True            # 是否在安全区内
+        self.transport_leak = 0
+        self.transport_debuff = None
+        self.transport_range = 4
+        self.transport_amount = 100
+        self.transport_remain = 100
+        self.is_transport_resource = False
+        self.transport_blood_bar = None
+
+        self.setup(first_time=True)
         self.effects_behind = list()
         self.effects_front = list()
 
@@ -99,8 +116,7 @@ class ObstacleInstance(Updatable):
         self.rect = self.image.get_rect()
         self.update()
 
-    def setup(self):
-
+    def setup(self, first_time=False):
         # 添加obstacle_instances字典映射
         for x in range(self.obstacle["WIDTH"]):
             for y in range(self.obstacle["HEIGHT"]):
@@ -130,6 +146,9 @@ class ObstacleInstance(Updatable):
             if "PUSH_TIME" in self.obstacle.keys():
                 self.push_time = int(self.obstacle["PUSH_TIME"])
 
+        if "BLOCK_SIGHT" in self.obstacle.keys():
+            self.block_sight = int(self.obstacle["BLOCK_SIGHT"])
+
         if "CONTACT" in self.obstacle.keys():
             self.contact_damage = int(self.obstacle["CONTACT"])
 
@@ -139,6 +158,20 @@ class ObstacleInstance(Updatable):
         if "EXPLODE" in self.obstacle.keys():
             self.explode_damage = int(self.obstacle["EXPLODE"])
 
+        if "TRANSPORT_AMOUNT" in self.obstacle.keys():
+            self.is_transport_resource = True
+            self.transport_amount = int(self.obstacle["TRANSPORT_AMOUNT"])
+            if first_time:
+                G.TOTAL_TRANSPORT += self.transport_amount
+                self.transport_remain = self.transport_amount
+            self.transport_range = int(self.obstacle["TRANSPORT_RANGE"])
+            self.transport_debuff = self.obstacle.get("TRANSPORT_DEBUFF", {"damage": 0, "defense": 0, "bomb": 0})
+            self.transport_leak = self.obstacle["TRANSPORT_LEAK"]
+            if first_time:
+                level.current_level.transport_obstacle.append(self)
+                self.transport_blood_bar = ResourceObstacleBloodBar(self)  # 血条
+                self.transport_blood_bar.set_max_blood(self.transport_amount)
+
         if "MULTI_TYPE" in self.obstacle.keys():
             self.multi_type = self.obstacle["MULTI_TYPE"]
             self.obstacle = custom_deepcopy(self.obstacle)
@@ -158,11 +191,12 @@ class ObstacleInstance(Updatable):
     def update(self):
         if self.state == ObstacleState.DEAD:
             return
-        if not self.has_updated:
+        if not self.has_updated or self.is_transport_resource:
             current_time = level.current_level.current_time
             self.update_frame(current_time)
             self.update_push()
             self.update_contact_damage()
+            self.update_transport(current_time)
             self.has_updated = True
             self.has_drawn = False
 
@@ -183,6 +217,14 @@ class ObstacleInstance(Updatable):
             self.rect.x = self.x * G.GAME_SQUARE + self.obstacle[category][self.obstacle_frame_idx].cx
             self.rect.y = self.y * G.GAME_SQUARE + self.obstacle[category][self.obstacle_frame_idx].cy
 
+    def update_transport(self, current_time):
+        if not self.is_transport_resource:
+            return
+        if current_time - self.last_transport_check_time < 1000:
+            return
+        self.last_transport_check_time = current_time
+        ObstacleTransportResourceSkill(self, level.current_level.npcs, level.current_level.skill_instances, self.explode_damage)
+
     def push(self, direction):
         if self.state == ObstacleState.DYING or self.state == ObstacleState.DEAD:
             return
@@ -191,47 +233,53 @@ class ObstacleInstance(Updatable):
             return
         # 障碍物接触伤害
         # level.current_level.me.try_damage(self.contact_damage)
-        if self.is_pushing == 0:
-            self.is_pushing = 1  # 防止下面的update_push方法将push_begin归零
-            self.push_begin = pygame.time.get_ticks()  # 开始计时
+        if not self.is_last_pushing:
+            self.is_last_pushing = True
+            self.push_begin = pygame.time.get_ticks()
             self.switch_state(ObstacleState.PUSHING)
-        self.is_pushing += 1
+        self.is_pushing = True
         if pygame.time.get_ticks() - self.push_begin >= self.push_time:
             # 达到阈值时间
             if direction == 'R':
                 if (self.x + 1, self.y) not in self.obstacle_instances_dict and len(level.current_level.get_bomb_instance(self.x + 1, self.y)) == 0:
-                    if self.x+1<G.CURRENT_MAP_WIDTH:
+                    if self.x+1 < G.CURRENT_MAP_WIDTH:
                         self.uninstall()
                         self.x += 1
                         self.setup()
             elif direction == 'U':
                 if (self.x, self.y - 1) not in self.obstacle_instances_dict and len(level.current_level.get_bomb_instance(self.x, self.y - 1)) == 0:
-                    if self.y-1>=0:
+                    if self.y-1 >= 0:
                         self.uninstall()
                         self.y -= 1
                         self.setup()
             elif direction == 'L':
                 if (self.x - 1, self.y) not in self.obstacle_instances_dict and len(level.current_level.get_bomb_instance(self.x - 1, self.y)) == 0:
-                    if self.x-1>=0:
+                    if self.x-1 >= 0:
                         self.uninstall()
                         self.x -= 1
                         self.setup()
             elif direction == 'D':
                 if (self.x, self.y + 1) not in self.obstacle_instances_dict and len(level.current_level.get_bomb_instance(self.x, self.y + 1)) == 0:
-                    if self.y+1<G.CURRENT_MAP_HEIGHT:
+                    if self.y+1 < G.CURRENT_MAP_HEIGHT:
                         self.uninstall()
                         self.y += 1
                         self.setup()
             level.current_level.obstacle_instances_need_to_update = True
+            self.push_begin = pygame.time.get_ticks()
+            self.is_pushing = False
 
     def update_push(self):
         if not self.obstacle_can_push:
             return
-        if self.is_pushing == 0:
-            self.push_begin = 0
-            self.switch_state(ObstacleState.NORMAL)
+        if self.is_pushing:
+            self.is_pushing = False
+            self.is_last_pushing = True
+            self.last_push_time = pygame.time.get_ticks()
         else:
-            self.is_pushing -= 1
+            if pygame.time.get_ticks() - self.last_push_time >= 20:
+                self.is_last_pushing = False
+                self.push_begin = pygame.time.get_ticks()
+                self.switch_state(ObstacleState.NORMAL)
 
     def update_contact_damage(self):
         if self.state == ObstacleState.DYING or self.state == ObstacleState.DEAD:
@@ -296,11 +344,11 @@ class ObstacleInstance(Updatable):
         for e in self.effects_front:
             e.update()
 
-    def die(self):
+    def die(self, forced=False):
         # 摧毁障碍 尝试进入DYING状态
         if self.state == ObstacleState.DEAD or self.state == ObstacleState.DYING:
             return
-        if self.obstacle["BREAKABLE"] is False:
+        if self.obstacle["BREAKABLE"] is False and not forced:
             return
         if self.multi_type:
             if level.current_level.current_time - self.last_type_switch_time <= 50:
@@ -334,6 +382,9 @@ class ObstacleInstance(Updatable):
             super().draw(screen)
             self.has_updated = False
             self.has_drawn = True
+            if self.is_transport_resource:
+                if abs(self.x-level.current_level.me.x) <= self.transport_range and abs(self.y-level.current_level.me.y) <= self.transport_range:
+                    self.transport_blood_bar.update(screen)
 
     def get_y(self):
         if not self.obstacle_is_background:

+ 254 - 171
client_local/sprite/pet.py

@@ -1,34 +1,66 @@
-import json
-import random
-import os
 import pygame
-
-from client_local.algo import aStar
+import random
 from client_local.const import color as C
-from client_local.const import game as G
-from client_local.frame import bomb, item
-from client_local.level import level
-from client_local.sound import sound_player
-from client_local.sprite.bomb_instance import BombInstance
-from client_local.sprite.ghost import Ghost
-from client_local.sprite.hero import Hero
 from client_local.sprite.item_instance import ItemInstance
 from client_local.sprite.player import Player, PlayerState
 from client_local.sprite.throwable import Throwable
+from client_local.sprite import updatable
+from client_local.skill.skill import *
 from client_local.file_loader.fileLoader import load_json, load_png
-import logging
-from datetime import datetime
 
+pet_name_map = {}
+for petID in range(1, 125):
+    pet_name_map[f'pet{petID}'] = {'character': f'pet{petID}'}
 
+pet_name_map_ex = {
+    '酷比': {'character':'pet1'},
+    '酷比(大)': {'character':'pet2'},
+    '米多': {'character':'pet3'},
+    '米多(大)': {'character':'pet4'},
+    '恶魔': {'character':'pet5'},
+    '恶魔(大)': {'character':'pet6'},
+    '布鲁斯': {'character':'pet7'},
+    '布鲁斯(大)': {'character':'pet8'},
+    '小菜娃': {'chs_name':'小菜娃','character':'pet14'},
+    '龙猫': {'chs_name':'龙猫','character':'pet94'},
+    '神龙': {'chs_name':'神龙','character':'pet48'},
+    '流光龙': {'chs_name':'流光龙','character':'pet16'},
+    '帝黑星': {'chs_name':'帝黑星','character':'pet106'},
+    '九尾狐(粉)': {'chs_name':'九尾狐','character':'pet112'},
+    '九尾狐(蓝)': {'chs_name':'九尾狐','character':'pet113'},
+    '彩雀': {'chs_name':'彩雀','character':'pet63'},
+    '彩雀(大)': {'chs_name': '彩雀', 'character': 'pet64'},
+    '嫦娥': {'chs_name':'嫦娥','character':'pet61'},
+    '嫦娥玉兔': {'chs_name':'嫦娥玉兔','character':'pet62'},
+    '树苗': {'chs_name':'树苗','character':'pet103'},
+    '大树': {'chs_name':'大树','character':'pet104'},
+    '乖乖虎': {'chs_name':'乖乖虎','character':'pet70'},
+    '新年兔子': {'chs_name':'新年兔子','character':'pet92'},
+    '哆来咪海豚': {'chs_name':'哆来咪海豚','character':'pet108'},
+    '小萝莉': {'chs_name':'小萝莉','character':'pet79'},
+    '小萝莉(大)': {'chs_name':'小萝莉','character':'pet80'},
+    '暗夜使者': {'chs_name':'暗夜使者','character':'pet58b'},
+    '飞骷髅': {'chs_name':'飞骷髅','character':'pet77'},
+}
+
+for pet_name in pet_name_map_ex:
+    petID = pet_name_map_ex[pet_name]['character']
+    if petID in pet_name_map:
+        pet_name_map.pop(petID)
+pet_name_map_ex.update(pet_name_map)  # 合并两个字典
+pet_name_map = pet_name_map_ex  # 使用合并后的字典
 
 
 class Pet(Player, Throwable):
 
-    def __init__(self, npc_name, xy, color=C.CHARACTER_RED):
-        super(Pet, self).__init__(npc_name, xy, color)
+    def __init__(self, pet_name, xy, color=C.CHARACTER_RED, owner=None, num=1):
+        super(Pet, self).__init__(pet_name, xy, color)
+        from client_local.sprite.hero import Hero
+        self.npc_time_init = None
+        self.owner: Hero = owner
         self.npc_json = None
         self.chs_name = None  # Npc中文名
-        self.stats_name = npc_name
+        self.pet_name = pet_name
         self.idx_motion = {0: "R", 1: "U", 2: "L", 3: "D"}
         self.contact = 0  # Npc接触伤害
         self.resent_dist = None  # Npc仇恨范围(几格以内)
@@ -36,180 +68,231 @@ class Pet(Player, Throwable):
         self.mocking = False  # Npc受到嘲笑药水的作用暂时仇恨
         self.friendly = False  # Npc受到玫瑰药水的作用暂时解除仇恨
         self.refresh = 0
-
-        self.is_ghost = True  # 幽灵模式
-        self.fake_blood = 0
-        self.energy_amount = 0  # 充能格数
-        self.max_energy_amount = 0
-        self.has_energy = False
         self.wall_walking = True  # 穿墙
-        self.flying = True  # 飞行(免疫墙体减速)
-        self.sliding = False  # 踩技能滑行中
-        self.sliding_direction = None  # 踩技能后滑的方向
-        self.witch_protected_remove = False  # 巫师无防护状态
-        self.fire_load_time = 0
-        self.slime = False
-        self.last_in_water = 0
-        self.slime_time = 0
-        self.free_chasing = False
-        self.chasing_point = (1,1)
-        self.imitating = False
-        self.combo_num = 1
-        self.is_combo_target = False
-        self.bomb_shield_num = 0  # 防糖泡电磁护盾
-        self.bomb_shield_protect = False
-        self.is_target = False
-        self.light = 0  # 鬼屋模式发光大小 0不发光,1发光20像素,2发光40像素 最大9
-        self.sharing_damage = False
-
-        self.obstacle_can_push = False
-        self.npc_time_init = None  # Npc初始化时刻
-        self.wander_random = 10  # Npc在无仇恨时的闲逛时间
-        self.district_locked = True
-        self.chase_path = None  # Npc追踪路径
-        self.npc_skill_time = pygame.time.get_ticks()  # npc施放技能时的时刻 设为成员变量是为了统一多个技能的时间
-        self.chs_name_bg = load_png("res/img/ui/game/misc172.png")  # Npc姓名牌背景
-        self.blood_bar = None
-        self.blood_bar_pos = 0
-        self.profile = None
-        self.chain = False
-        self.chase_rad = 2
-
-        self.chs_name_font = pygame.font.Font("res/font/simsun.ttc", 13)  # Npc姓名牌字体
-        self.chs_name_text = None  # Npc姓名牌前景文字
-        self.chs_name_text_shadow = None  # Npc姓名牌背景文字
-        self.chs_name_text_half_width = None  # Npc姓名牌文字的半宽 用于居中显示文字
-        self.chs_name_show = True  # 是否显示名牌
-        self.bomb_skin = bomb.get_bomb("bomb1")
-        self.gifts = None  # 爆装备
-        self.death = None  # 死亡状态
-        self.last_motion = 0
-        self.last_random = 10
-        self.energy_num = None
-        self.load_npc(npc_name, color)
-
-    def load_npc(self, npc_name, color):
-        # 加载npc的json文件
-        self.npc_json = load_json("game/pet/" + npc_name + ".json")
-        self.chs_name = self.npc_json["chs_name"]
-        self.blood = self.npc_json["blood"]
-        self.light = self.npc_json.get("light",self.light)
-        if "self_damage_blood" in self.npc_json.keys():
-            self.self_damage_blood = self.npc_json["self_damage_blood"]
-        self.speed = (max(2.5, self.npc_json["speed"]) * G.GAME_SQUARE) / 1000
-        self.contact = self.npc_json["contact"]
-        self.defense = self.npc_json["defense"]
-
-        if "slime" in self.npc_json.keys():
-            self.slime = self.npc_json["slime"]
-        if "gifts" in self.npc_json.keys():
-            self.gifts = self.npc_json["gifts"]
-        if "death" in self.npc_json.keys():
-            self.death = self.npc_json["death"]
-        if "show_name" in self.npc_json.keys():
-            self.chs_name_show = self.npc_json["show_name"]
-        if "light" in self.npc_json.keys():
-            self.light = self.npc_json["light"]
-        if "chain" in self.npc_json.keys():
-            self.chain = self.npc_json["chain"]
-        if "chase_rad" in self.npc_json.keys():
-            self.chase_rad = self.npc_json["chase_rad"]
-
-        self.resent_dist = self.npc_json["resent_dist"] * G.GAME_SQUARE  # 仇恨距离(像素)
-        for n, s in enumerate(self.npc_json["skills"]):
-            self.skill_names.append(s["name"])
-            self.skill_init_times.append(s["init"])
-            self.skill_intervals.append(s["interval"])
-            self.skill_remains.append(s["max"])
-            self.skill_params.append(s["params"] if "params" in s else [])
-            self.skill_params_order.append(n)
-            self.skill_spawns.append(s["spawns"] if "spawns" in s else [])
-            self.skill_spawn_order.append(s["spawn_order"] if "spawn_order" in s else n)
-
-        self.remain_blood = self.blood
-        self.chase_path = dict()
-        self.chs_name_text = self.chs_name_font.render(self.chs_name, True, (255, 128, 192))
-        self.chs_name_text_shadow = self.chs_name_font.render(self.chs_name, True, (0, 0, 0))
-        self.chs_name_text_half_width = self.chs_name_text.get_width() // 2
-        self.character = self.load_character(self.npc_json["character"], color, dict())
-        self.npc_time_init = pygame.time.get_ticks()
+        self.force_moving = False   # 联机强制移动
+        self.force_move_init_time = 0   # 联机强制移动开始时间
+        self.force_move_pos = (0, 0)   # 联机强制移动目标位置
+        self.force_move_duration = 0   # 联机强制移动持续时间
+        self.force_move_init_xy_pos = (0, 0)   # 联机强制移动开始位置
+        self.light = 1  # 鬼屋模式发光大小 0不发光,1发光20像素,2发光40像素 最大9
+        if owner is not None:
+            self.x_pos = owner.x_pos
+            self.y_pos = owner.y_pos
+            self.random_move()
+        else:
+            self.x_pos = xy[0] * 40 + 20
+            self.y_pos = xy[1] * 40 + 20
+        self.force_move_pos = (self.x_pos, self.y_pos)
+        self.load_pet(pet_name, color)
+        self.create_time = pygame.time.get_ticks()
+        if num > 1:
+            self.petObj = Pet(self.pet_name, xy, color, owner=self, num=num-1)
+        else:
+            self.petObj = None
 
+    def __repr__(self):
+        return f'PET {self.chs_name}'
 
-    def update(self):
-        super().update()
-        current_time = pygame.time.get_ticks()
-        # self.update_npc_blood_display(current_time)
-        self.chase_hero()
-        # self.try_using_skills()
+    def __str__(self):
+        return f'PET {self.chs_name}'
 
-    def update_npc_blood_display(self, current_time):
-        if G.DISPLAY_NPC_NAME_CARD and G.DISPLAY_NPC_BLOOD:
-            self.chs_name_text = self.chs_name_font.render(str(self.remain_blood-self.fake_blood), True, (255, 128, 192))
-            self.chs_name_text_shadow = self.chs_name_font.render(str(self.remain_blood-self.fake_blood), True, (0, 0, 0))
-            self.chs_name_text_half_width = self.chs_name_text.get_width() // 2
+    def update_orientation_online(self, orientation):
+        return
+
+    def add_one(self):
+        if self.petObj:
+            self.petObj.add_one()
         else:
-            self.chs_name_text = self.chs_name_font.render(self.chs_name, True, (255, 128, 192))
-            self.chs_name_text_shadow = self.chs_name_font.render(self.chs_name, True, (0, 0, 0))
-            self.chs_name_text_half_width = self.chs_name_text.get_width() // 2
-
-    def chase_hero(self):
-        me = (level.current_level.me.x, level.current_level.me.y)
-        if abs(self.x - me[0]) + abs(self.y - me[1]) <= self.chase_rad:
-            self.set_motion()
+            self.petObj = Pet(self.pet_name, (self.x, self.y), self.color, owner=self)
+
+    def set_num(self, num=5):
+        current_num = self.get_num()
+        if current_num < num:
+            for i in range(num-current_num):
+                self.add_one()
+        elif current_num > num:
+            petObj = self
+            for i in range(num-1):
+                petObj = petObj.petObj
+            petObj.petObj = None
+
+    def get_num(self):
+        if self.petObj:
+            return 1 + self.petObj.get_num()
+        else:
+            return 1
+
+    def load_pet(self, pet_name, color):
+        # 加载npc的json文件
+        try:
+            self.blood = 1000
+            self.remain_blood = self.blood
+            character_name = pet_name_map.get(pet_name, {}).get('character', pet_name)
+            self.chs_name = pet_name
+            self.character = self.load_character(character_name, color, dict())
+            self.npc_time_init = pygame.time.get_ticks()
+        except Exception as e:
+            print(e)
+
+    def random_move(self):
+        if self.owner is None:
+            return
+        if self.owner.state == PlayerState.LOSE:
+            return
+        new_x = self.owner.x_pos + random.randint(-20, 20)
+        new_y = self.owner.y_pos + random.randint(-20, 20)
+        if self.owner.walking:
+            if self.owner.orientation == 'D':
+                new_y -= 20
+            elif self.owner.orientation == 'U':
+                new_y += 20
+            elif self.owner.orientation == 'L':
+                new_x += 20
+            elif self.owner.orientation == 'R':
+                new_x -= 20
+
+        delta_x = new_x - self.x_pos
+        delta_y = new_y - self.y_pos
+        # 根据delta设定移动方向 LDRU
+        if abs(delta_x) > abs(delta_y):
+            if delta_x > 0:
+                self.orientation = 'R'
+            else:
+                self.orientation = 'L'
+        else:
+            if delta_y > 0:
+                self.orientation = 'D'
+            else:
+                self.orientation = 'U'
+        self.set_motion(self.orientation)
+
+        self.move_to(new_x, new_y, duration=300)
+
+    def move_to(self, x_pos, y_pos, duration=None):
+        # 强制移动到指定位置, duration为持续时间(ms)
+        self.force_movement()   # 先处理强制移动
+        if self.force_move_pos == (x_pos, y_pos):
+            # 未改变目标位置
+            if not self.force_moving:
+                self.force_moving = True
+            return
+        self.force_moving = True
+        self.force_move_init_time = pygame.time.get_ticks()
+        self.force_move_duration = duration
+        self.force_move_init_xy_pos = (self.x_pos, self.y_pos)
+        self.force_move_pos = (x_pos, y_pos)
+
+    def force_movement(self):
+        if not self.force_moving:
+            return
+        current_time = pygame.time.get_ticks()
+        if current_time - self.force_move_init_time > self.force_move_duration:
+            self.force_moving = False
+            self.x_pos, self.y_pos = self.force_move_pos
+            self.x, self.y = updatable.current_grid(self.x_pos, self.y_pos)
             return
-        now = (self.x, self.y)
-        # 追踪玩家
-        self.chase_path = aStar.cal_path(
-            now, me,
-            (level.current_level.district_square_grid["x1"], level.current_level.district_square_grid["y1"]),
-            (level.current_level.district_square_grid["x2"], level.current_level.district_square_grid["y2"]),
-            is_ghost=self.is_ghost
-        )
-        if now in self.chase_path.keys():
-            next = self.chase_path[now]
-            if next is None:
-                self.set_motion()
-            elif next[0] > self.x:
-                self.set_motion("R")
-            elif next[1] < self.y:
-                self.set_motion("U")
-            elif next[0] < self.x:
-                self.set_motion("L")
-            elif next[1] > self.y:
-                self.set_motion("D")
         else:
-            self.set_motion()
+            # 计算距离
+            x1, y1 = self.force_move_init_xy_pos
+            x2, y2 = self.force_move_pos
+            dx = x2-x1
+            dy = y2-y1
+            # 计算速度
+            speed_x = dx/self.force_move_duration
+            speed_y = dy/self.force_move_duration
+            # 计算当前位置
+            self.x_pos = x1+speed_x*(current_time-self.force_move_init_time)
+            self.y_pos = y1+speed_y*(current_time-self.force_move_init_time)
+            self.x, self.y = updatable.current_grid(self.x_pos, self.y_pos)
+            return
+
+    def update(self):
+        try:
+            from client_local.level.level import current_level
+            if self.owner is not None:
+                x_pos, y_pos = self.force_move_pos
+                dist_to_owner = abs(x_pos - self.owner.x_pos) + abs(y_pos - self.owner.y_pos)
+                import random
+                if dist_to_owner > 60:
+                    self.random_move()
+                self.temporary_alpha = self.owner.temporary_alpha
+                if self.force_moving:
+                    self.walking = True
+                else:
+                    self.walking = False
+
+            # 检查的是否在砖块里
+            xy = self.x, self.y
+            if current_level is not None and current_level.obstacle_instances.get(xy):
+                self.temporary_alpha = min(128, self.temporary_alpha)  # 砖块内透明度为128
+
+            current_time = pygame.time.get_ticks()
+            if self.state == PlayerState.NORMAL:
+                self.update_footprints(current_time)
+                self.stimulate_x_y_changed_trigger()
+                self.update_frame(current_time)
+                self.force_movement()  # 处理强制移动
+                self.if_obstacle_trigger()
+
+            if self.state == PlayerState.LOSE:
+                self.update_frame_dead(current_time)
+            self.update_skills()
+            self.update_effects()
+            self.get_damage_frame = False  # 复原伤害帧
+            self.get_damage_amount = 0
+            self.grid_damage(current_time)
+            self.stimulate_character_frame_trigger()
+            self.update_time_old = current_time
+            if self.petObj:
+                current_level.pets.append(self.petObj)
+                self.petObj.update()
+        except Exception as e:
+            print(e)
+
+    def update_npc_blood_display(self, current_time):
+        return
 
     def half_body_damage(self, point, cl, current_time):
-        self.try_damage(cl.grid_damage_blood[point])
+        return
+
+    def contact_damage(self):
+        return
 
     def die(self):
-        super().die()
-        sound_player.play("npc_dead")
+        return
+
+    def gene_gifts(self):
+        return  # 客户端不控制掉落
+
+    def gene_ghost(self):
+        return
+
+    def collide_wall(self):
+        return
 
     def try_push(self, direction, offset=(0, 0)):
         pass
 
     def try_using_skills(self):
-        pass
+        return
 
-    def use_skill(self, idx: int):
-        cl = level.current_level
-        if self.npc_skill_time < self.skill_init_times[idx] or self.skill_remains[idx] == 0:
-            # 未到初始时间 或技能冷却中 或次数已用完(-1则可以无限使用)
-            return
+    def use_skill(self, idx: int, fake=False):
+        return True
+
+    def set_bomb(self):
+        return
+
+    def set_general_bomb(self, power, damage):
+        return
+
+    def set_custom_bomb(self, x, y, power, damage):
+        return
 
     def set_restoration(self, to_x, to_y):
         self.x = to_x
         self.y = to_y
 
     def draw(self, screen: pygame.Surface):
-        super().draw(screen)
-        if G.DISPLAY_NPC_NAME_CARD and self.chs_name_show:
-            self.chs_name_text_shadow.set_alpha(self.temporary_alpha)
-            screen.blit(self.chs_name_text_shadow, (self.x_pos + 3 - self.chs_name_text_half_width, self.y_pos - 75))
-            self.chs_name_text.set_alpha(self.temporary_alpha)
-            screen.blit(self.chs_name_text, (self.x_pos + 2 - self.chs_name_text_half_width, self.y_pos - 75))
-        if self.chain:
-            pygame.draw.line(screen, (155, 155, 155), (level.current_level.me.x_pos, level.current_level.me.y_pos), (self.x_pos, self.y_pos), 1)
-
+        display = super().draw(screen)
+        # if display and self.temporary_alpha > 200:
+        #     self.speech_bubble.draw(screen)

+ 18 - 13
client_local/sprite/player.py

@@ -2,7 +2,8 @@ import enum
 import json
 import pygame
 import os
-
+import logging
+from datetime import datetime
 from client_local.const import game as G
 from client_local.const import color as C
 from client_local.frame import character
@@ -11,9 +12,6 @@ from client_local.skill.skill import Protect3s, Protect005s, Protect500ms
 from client_local.sprite import updatable
 from client_local.file_loader.fileLoader import load_json, load_png
 
-import logging
-from datetime import datetime
-
 # 配置logging基础配置并设置日志级别为INFO
 user_documents_folder = os.path.expanduser("~\\Documents")  # 获取用户的"文档"文件夹路径
 qqtpve_folder = os.path.join(user_documents_folder, "QQTPVE")  # 构建QQTPVE文件夹路径
@@ -213,7 +211,7 @@ class Player(updatable.Updatable):
     def load_character(self, character_name, color, decorations: dict, is_ghost=False):
         # 加载角色character
 
-        character_json = load_json("game/frame/character/" + character_name + ".json")
+        character_json = load_json(f"game/frame/character/{character_name}.json")
         if "HEAD_POS" in character_json.keys():
             self.head_cx, self.head_cy = character_json["HEAD_POS"][0], character_json["HEAD_POS"][1]
         # self.light = character_json.get("LIGHT", self.light)
@@ -569,6 +567,8 @@ class Player(updatable.Updatable):
             self.set_text("HP-" + str(damage_blood), 500)
 
     def shares_damage(self, damage_blood: int):
+        if self.remain_blood <= 0:
+            return
         # 真实对玩家扣减damage_blood血量
         self.remain_blood -= max(damage_blood, self.self_damage_blood)
         if self.remain_blood <= 0:
@@ -639,6 +639,11 @@ class Player(updatable.Updatable):
     def heal(self, heal_blood: int):
         if self.state != PlayerState.NORMAL:
             return
+        if hasattr(self, 'power'):
+            remain_blood = min(self.blood, self.remain_blood + heal_blood)
+            G.CUMULATION_INJURE += max(remain_blood - self.remain_blood, 0)
+            self.remain_blood = remain_blood
+            return
         # 血量恢复
         self.remain_blood = min(self.blood, self.remain_blood + heal_blood)
         # 破临界值
@@ -745,7 +750,7 @@ class Player(updatable.Updatable):
         self.last_pos = (self.x_pos, self.y_pos)
         self.last_slide_time = pygame.time.get_ticks()
         try:
-            if self.power>0:
+            if hasattr(self, 'power'):
                 G.LAST_MOVE_CORRECTION = G.MOVE_CORRECTION
                 updatable.move_correction = 0
         except:
@@ -753,7 +758,7 @@ class Player(updatable.Updatable):
 
     def check_slide_time(self, current_time):
         try:
-            if self.power > 0:
+            if hasattr(self, 'power'):
                 if self.fast_slide_begin != 0 and current_time-self.last_slide_time>=800:
                     self.last_slide_time = current_time
                     self.last_pos = (self.x_pos, self.y_pos)
@@ -761,7 +766,7 @@ class Player(updatable.Updatable):
                         self.fast_slide -= 1
                         self.fast_slide_begin = 0
                         try:
-                            if self.power>0:
+                            if hasattr(self, 'power'):
                                 updatable.move_correction = G.LAST_MOVE_CORRECTION
                         except:
                             pass
@@ -771,7 +776,7 @@ class Player(updatable.Updatable):
             self.fast_slide -= 1
             self.fast_slide_begin = 0
             try:
-                if self.power>0:
+                if hasattr(self, 'power'):
                     updatable.move_correction = G.LAST_MOVE_CORRECTION
             except:
                 pass
@@ -817,15 +822,14 @@ class Player(updatable.Updatable):
             for s in self.skill_instances:
                 self.skill_instances.remove(s)
 
-
     def get_y(self):
         # return self.y + 0.1
         return self.y_pos/40
 
     def draw(self, screen: pygame.Surface):
+        from client_local.sprite.pet import Pet
         # 如果人物隐藏,则不绘图
         display = not super().if_hide()
-
         if display:
             # 显示背景特效
             for s in self.effects_behind:
@@ -835,8 +839,9 @@ class Player(updatable.Updatable):
                     frame = self.character["STAND_" + a_footprint.orient]["Footprint"][a_footprint.frame_idx]
                     screen.blit(frame.image, (frame.cx + a_footprint.x_pos, frame.cy + a_footprint.y_pos))
             # 显示阴影
-            Player.shadow.set_alpha(self.temporary_alpha)
-            screen.blit(Player.shadow, (self.x_pos - 17, self.y_pos - 7))
+            if not isinstance(self, Pet):
+                Player.shadow.set_alpha(self.temporary_alpha)
+                screen.blit(Player.shadow, (self.x_pos - 17, self.y_pos - 7))
             if self.state == PlayerState.NORMAL:
                 for component in character.CHARACTER_COMPONENTS[self.orientation]:
                     if component not in self.character[self.STAND + self.orientation]:

+ 1 - 0
client_local/sprite/throwable.py

@@ -35,6 +35,7 @@ class Throwable(updatable.Updatable):
         if self.throwing is True:
             return  # 正在投掷的对象 不能再投掷
         if to_x == self.x and to_y == self.y:
+            self.throwing = False
             return  # 目标点与当前点重叠 不能再投掷
         cl = level.current_level
         real_x = (to_x + cl.map_x) % cl.map_x

+ 17 - 2
client_local/sprite/updatable.py

@@ -18,6 +18,7 @@ try:
 except JSONDecodeError:
     with open("config.json", encoding="utf-8_sig") as f:
         cfg_json = json.load(f)
+
 def move_correction_param(x):
     if x <= 0:
         return 0
@@ -25,6 +26,7 @@ def move_correction_param(x):
         return 19
     else:
         return round(x, 3)
+
 # 半身滑墙校正
 G.MOVE_CORRECTION = cfg_json.get("move_correction", 8)
 move_correction = move_correction_param(G.MOVE_CORRECTION)
@@ -44,14 +46,14 @@ class Updatable(pygame.sprite.Sprite):
         self.y = y
         self.x_pos = x * G.GAME_SQUARE + G.HALF_GAME_SQUARE  # 中心点x坐标
         self.y_pos = y * G.GAME_SQUARE + G.HALF_GAME_SQUARE  # 中心点y坐标
+        self.z_pos = 0  # z轴坐标
 
         if hasattr(self, 'is_ghost'):
-            if self.is_ghost != True:
+            if not self.is_ghost:
                 self.wall_walking = True  # 允许穿墙
         else:
             self.wall_walking = False  # 允许穿墙
 
-
     def if_hide(self):
         ret = False
         ois = level.current_level.obstacle_instances
@@ -62,6 +64,19 @@ class Updatable(pygame.sprite.Sprite):
                 ret = True
         return ret
 
+    def is_hide_sight(self):
+        ret = False
+        ois = level.current_level.obstacle_instances
+        # if (self.x, self.y) in ois.keys():
+        #     an_obstacle = ois[(self.x, self.y)]
+        #     if an_obstacle.block_sight:
+        #         self.blank_img()
+        #         ret = True
+        if (self.x, self.y) in ois.keys():
+            if ois[(self.x, self.y)].block_sight:
+                ret = True
+        return ret
+
     def blank_img(self):
         # 清空image
         self.image = pygame.Surface((1, 1), pygame.SRCALPHA, 32)

+ 127 - 0
client_local/sprite/wanderer.py

@@ -0,0 +1,127 @@
+import json
+import pygame
+import random
+from client_local.algo import aStar
+from client_local.const import game as G
+from client_local.const import color as C
+from client_local.level import level
+from client_local.sound import sound_player
+from client_local.sprite.npc import Npc
+from client_local.sprite.player import Player, PlayerState
+from client_local.file_loader.fileLoader import load_json, load_png
+
+
+# 常驻地图的怪
+class Wanderer(Npc):
+
+    def __init__(self, npc_name, xy, color=C.CHARACTER_RED, patrol_path=None):
+        super(Wanderer, self).__init__(npc_name, xy, color)
+
+    def update(self):
+        super(Npc, self).update()
+        if not self.is_dead:
+            current_time = pygame.time.get_ticks()
+            self.update_npc_blood_display(current_time)
+            self.wander_and_detect(current_time)
+            self.chase_hero()
+            self.contact_damage()
+            self.try_using_skills()
+            self.throw()
+
+    def wander_and_detect(self, current_time):
+        if (self.resentful or self.mocking) and not self.friendly:
+            return
+        if current_time - self.npc_time_init < 300:
+            return
+        if (current_time - self.last_motion) >= 50 * self.last_random:
+            if self.speed >= (5.8 * G.GAME_SQUARE) / 1000:
+                self.last_random = random.randint(5, 15)
+            if 0 <= (current_time % 1200) <= 300 or (random.randint(1, 100) >= 85):
+                self.last_motion = current_time
+                if random.randint(1, 100) >= 25:
+                    motion = self.idx_motion[random.randint(0, 3)]
+                    self.set_motion(motion)
+                else:
+                    self.set_motion(self.orientation)
+            else:
+                self.set_motion(self.orientation)
+        else:
+            self.set_motion(self.orientation)
+        # 技能初始时间更新
+        for i in range(len(self.skill_names)):
+            # 游荡状态下,技能初始时间永远等于当前时刻加init值
+            self.skill_init_times[i] = self.npc_json["skills"][i]["init"] + current_time
+        self.is_skill_init = True
+        me = level.current_level.me
+        if me.state == PlayerState.NORMAL:
+            if abs(me.x_pos - self.x_pos) < self.resent_dist and abs(me.y_pos - self.y_pos) < self.resent_dist and not me.is_hide_sight():
+                # 如果玩家活着且距离小于临界值 且不被障碍阻碍视野 则产生玩家仇恨
+                self.resentful = True
+                level.current_level.recal_npc_paths = True
+
+    def chase_hero(self):
+        if (not self.resentful and not self.mocking) or self.friendly or self.imitating or (self.speed == 0 and self.original_speed == 0):
+            return
+        me = (level.current_level.me.x, level.current_level.me.y)
+        if self.free_chasing:
+            me = self.chasing_point
+        if self.chasing_monster and self.chasing_monster_target is not None:
+            me = (self.chasing_monster_target.x, self.chasing_monster_target.y)
+        # 玩家在糖泡中 定身Npc
+        if len(level.current_level.get_bomb_instance(*me)) > 0 and not self.is_ghost and not self.free_chasing and not self.chasing_monster:
+            self.set_motion()
+            return
+        now = (self.x, self.y)
+        # 如果重新计算路径标志为True则重新追踪玩家
+        if level.current_level.recal_npc_paths:
+            self.chase_path = aStar.cal_path(
+                now, me,
+                (level.current_level.me.x - 15, level.current_level.me.y - 15),
+                (level.current_level.me.x + 15, level.current_level.me.y + 15),
+                is_ghost=self.is_ghost
+            )
+        if now in self.chase_path.keys():
+            _next = self.chase_path[now]
+            if _next is None:
+                self.set_motion()
+            elif _next[0] > self.x:
+                self.set_motion("R")
+            elif _next[1] < self.y:
+                self.set_motion("U")
+            elif _next[0] < self.x:
+                self.set_motion("L")
+            elif _next[1] > self.y:
+                self.set_motion("D")
+        else:
+            self.set_motion()
+
+    def die(self):
+        super(Npc, self).die()
+        sound_player.play("npc_dead")
+        if self.blood_bar_pos != 0:
+            try:
+                level.current_level.ui_instances_top.remove(self.blood_bar)
+                level.current_level.ui_instances_top.remove(self.profile)
+                level.current_level.boss_blood_bar_dic[self.blood_bar_pos] = 0
+            except Exception as e:
+                print(e)
+                try:
+                    print("血条错误", self.chs_name, self.blood_bar_pos)
+                except Exception as e:
+                    print(f"npc.py: die(): {e}")
+        self.is_dead = True
+
+    def die_quietly(self):
+        super(Npc, self).die()
+        if self.blood_bar_pos != 0:
+            try:
+                level.current_level.ui_instances_top.remove(self.blood_bar)
+                level.current_level.ui_instances_top.remove(self.profile)
+                level.current_level.boss_blood_bar_dic[self.blood_bar_pos] = 0
+            except:
+                try:
+                    print("血条错误", self.chs_name, self.blood_bar_pos)
+                except:
+                    pass
+        self.is_dead = True
+        self.remain_blood = -1

+ 193 - 0
client_local/ui/game/blood_bar.py

@@ -1,6 +1,7 @@
 import math
 import pygame.font
 
+from client_local.const import game as G
 from client_local.sprite.player import Player
 from client_local.ui.ui import UIInstance
 from client_local.frame import character
@@ -70,14 +71,108 @@ class BloodBar(UIInstance):
         self.sheet.blit(text_img, (26, 24))
 
 
+class ResourceObstacleBloodBar(UIInstance):
+
+    UI_IMG_GAME_ROOT = "res/img/ui/game/"
+
+    def __init__(self, me):
+        super(ResourceObstacleBloodBar, self).__init__("game", "mask_player")
+        # self.rect.x = 0
+        # self.rect.y = 120
+        self.blood_bar_len = 61
+        self.me = me
+        self.screen = None
+        self.current_blood = 0
+        self.max_blood = 1
+        self.blood_slice_img = pygame.image.load(f"{BloodBar.UI_IMG_GAME_ROOT}/img_playerLife.png").convert_alpha()
+        self.blood_slice_idx = self.blood_bar_len  # 0~100 决定血条的长度
+        # self.blood_slice_last_update_time = pygame.time.get_ticks()
+        self.init()
+
+    def init(self):
+        self.set_max_blood(self.me.transport_amount)
+
+    def update(self, screen=None):
+        self.redraw_trigger = True
+        if not self.screen:
+            self.screen = screen
+        self.current_blood = self.me.transport_remain
+        self.set_blood(self.current_blood)
+        # 动画改变血条长度
+        idx = math.ceil(self.current_blood * self.blood_bar_len / self.max_blood)
+        if idx == self.blood_slice_idx:
+            return
+        if idx < self.blood_slice_idx:
+            self.blood_slice_idx -= 1
+        elif idx > self.blood_slice_idx:
+            self.blood_slice_idx += 1
+
+    def set_max_blood(self, max_blood):
+        self.max_blood = min(max(0, max_blood), 999999)
+        self.current_blood = self.max_blood
+        self.set_blood(self.current_blood)
+
+    def set_blood(self, blood: int):
+        # blood = min(max(0, blood), self.max_blood)
+        if self.screen:
+            for i in range(self.blood_slice_idx):
+                self.screen.blit(self.blood_slice_img, (self.me.x*40-12+i, self.me.y*40-32))
 
 
+class ResourceBloodBar(UIInstance):
 
+    UI_IMG_GAME_ROOT = "res/img/ui/game/"
+
+    def __init__(self, me: Player):
+        super(ResourceBloodBar, self).__init__("game", "mask_resource")
+        self.rect.x = 0
+        self.rect.y = 205
+        self.me = me
+        self.current_blood = 0
+        self.max_blood = 1
+        self.blood_font = pygame.font.Font("res/font/century.ttf", 11)
+        self.blood_font.set_bold(True)
+        self.blood_slice_img = pygame.image.load(f"{BloodBar.UI_IMG_GAME_ROOT}/img_playerLife.png").convert_alpha()
+        self.blood_slice_idx = 90  # 0~90 决定血条的长度
+        self.blood_slice_last_update_time = pygame.time.get_ticks()
+        self.init()
 
+    def init(self):
+        self.set_max_blood(G.TOTAL_TRANSPORT)
 
+    def update_max_blood(self, max_blood):
+        self.max_blood = min(max(1, max_blood), 999999)
+        self.current_blood = self.max_blood
+        self.set_blood(self.current_blood)
 
+    def update(self):
+        self.redraw_trigger = True
+        current_time = pygame.time.get_ticks()
+        if current_time - self.blood_slice_last_update_time > 100:  # 每100ms刷新一次动画
+            self.blood_slice_last_update_time = current_time
+            self.sheet = pygame.Surface(self.rect.size, pygame.SRCALPHA, 32)
+            self.current_blood = max(G.TOTAL_TRANSPORT - G.CUMULATION_RESOURCE_LEAK, 0) * (1 - G.CUMULATION_INJURE / (self.me.blood * G.TOTAL_LEVEL))
+            self.set_blood(self.current_blood)
+            # 动画改变血条长度
+            idx = math.ceil(self.current_blood * 90 / self.max_blood)
+            if idx == self.blood_slice_idx:
+                return
+            if idx < self.blood_slice_idx:
+                self.blood_slice_idx -= 1
+            elif idx > self.blood_slice_idx:
+                self.blood_slice_idx += 1
 
+    def set_max_blood(self, max_blood):
+        self.max_blood = min(max(1, max_blood), 999999)
+        self.current_blood = self.max_blood
+        self.set_blood(self.current_blood)
 
+    def set_blood(self, blood: int):
+        # blood = min(max(0, blood), self.max_blood)
+        # text_img = self.blood_font.render(str(blood), False, (0, 255, 255))
+        # self.sheet.blit(text_img, (2, 2))
+        for i in range(self.blood_slice_idx):
+            self.sheet.blit(self.blood_slice_img, (i, 6))
 
 
 class BossBloodBar(UIInstance):
@@ -129,7 +224,105 @@ class BossBloodBar(UIInstance):
             self.sheet.blit(self.blood_slice_img, (i+2, 4))
 
 
+class MapBloodBar(UIInstance):
+
+    UI_IMG_GAME_ROOT = "res/img/ui/game/"
+
+    def __init__(self, max_blood, remain_blood):
+        super(MapBloodBar, self).__init__("game", "map_blood_bar")
+        self.rect.x = 570
+        self.rect.y = 510
+        self.current_blood = 0
+        self.max_blood = 1
+        self.max_map_blood = max_blood
+        self.remain_map_blood = remain_blood
+        self.blood_slice_img = pygame.image.load(f"{BloodBar.UI_IMG_GAME_ROOT}/img_mapBlood.png").convert_alpha()
+        self.bar_len = 180
+        self.blood_slice_idx = self.bar_len  # 0~90 决定血条的长度
+        self.blood_slice_last_update_time = pygame.time.get_ticks()
+        self.init()
+
+    def init(self):
+        self.set_max_blood(self.max_map_blood)
+
+    def update(self):
+        self.redraw_trigger = True
+        current_time = pygame.time.get_ticks()
+        if current_time - self.blood_slice_last_update_time > 50:  # 每1000ms刷新一次动画
+            self.blood_slice_last_update_time = current_time
+            self.sheet = pygame.Surface(self.rect.size, pygame.SRCALPHA, 32)
+            self.current_blood = self.remain_map_blood
+            self.set_blood(self.current_blood)
+            # 动画改变血条长度
+            idx = math.ceil(self.current_blood * self.bar_len / self.max_blood)
+            if idx == self.blood_slice_idx:
+                return
+            if idx < self.blood_slice_idx:
+                self.blood_slice_idx -= 1
+            elif idx > self.blood_slice_idx:
+                self.blood_slice_idx += 1
+
+    def set_max_blood(self, max_blood):
+        self.max_blood = max(0, max_blood)
+        self.current_blood = self.max_blood
+        self.set_blood(self.current_blood)
+
+    def set_blood(self, blood: int):
+        blood = min(max(0, blood), self.max_blood)
+        for i in range(self.blood_slice_idx):
+            self.sheet.blit(self.blood_slice_img, (i+16, 4))
+
+
+class MapResouceBar(UIInstance):
+
+    UI_IMG_GAME_ROOT = "res/img/ui/game/"
+
+    def __init__(self, max_blood, remain_blood):
+        super(MapResouceBar, self).__init__("game", "map_resource_bar")
+        self.rect.x = 570
+        self.rect.y = 510
+        self.current_blood = 0
+        self.max_blood = 1
+        self.max_map_blood = max_blood
+        self.remain_map_blood = remain_blood
+        self.blood_slice_img = pygame.image.load(f"{BloodBar.UI_IMG_GAME_ROOT}/img_mapResource.png").convert_alpha()
+        self.bar_len = 180
+        self.blood_slice_idx = self.bar_len  # 0~90 决定血条的长度
+        self.blood_slice_last_update_time = pygame.time.get_ticks()
+        self.init()
+
+    def init(self):
+        self.set_max_blood(self.max_map_blood)
+
+    def update(self):
+        self.redraw_trigger = True
+        current_time = pygame.time.get_ticks()
+        if current_time - self.blood_slice_last_update_time > 50:  # 每1000ms刷新一次动画
+            self.blood_slice_last_update_time = current_time
+            self.sheet = pygame.Surface(self.rect.size, pygame.SRCALPHA, 32)
+            self.current_blood = self.remain_map_blood
+            self.set_blood(self.current_blood)
+            # 动画改变血条长度
+            idx = math.ceil(self.current_blood * self.bar_len / self.max_blood)
+            if idx == self.blood_slice_idx:
+                return
+            if idx < self.blood_slice_idx:
+                self.blood_slice_idx -= 1
+            elif idx > self.blood_slice_idx:
+                self.blood_slice_idx += 1
+
+    def set_max_blood(self, max_blood):
+        self.max_blood = max(0, max_blood)
+        self.current_blood = self.max_blood
+        self.set_blood(self.current_blood)
+
+    def set_blood(self, blood: int):
+        blood = min(max(0, blood), self.max_blood)
+        for i in range(self.blood_slice_idx):
+            self.sheet.blit(self.blood_slice_img, (i+16, 4))
 
+    def update_remain_blood(self, remain_amount):
+        self.remain_map_blood = remain_amount
 
 
 

+ 10 - 2
client_local/ui/game/game_top.py

@@ -1,13 +1,21 @@
+import os
 import pygame
+import pygame.freetype as freetype
 from client_local.ui.ui import UIInstance
 
+Current_Path = os.getcwd()
+FONT_PATH = Current_Path + r"\res\font\simsun.ttc"
+# FONT_PATH = Current_Path + r"\res\font\hk4e_zh-cn.ttf"
+# FONT_PATH = Current_Path + r"\res\font\SourceHanSerif-VF.ttc"
+# FONT_PATH = "Arial"
+
 
 class GameTop(UIInstance):
 
     def __init__(self):
         super().__init__("game", "gameTop")
-        self.font = pygame.font.Font("res/font/simsun.ttc", 16)
-        self.rend = self.font.render("v20240802", True, (0, 196, 255))
+        self.font = pygame.font.Font(FONT_PATH, 16)
+        self.rend = self.font.render("v20260322", True, (0, 196, 255))
 
     def draw(self, screen: pygame.Surface):
         super().draw(screen)

+ 136 - 200
client_local/ui/game/message_input.py

@@ -1,257 +1,193 @@
+import os
+import time
 import pygame
-import pygame as pg
 import pygame.freetype as freetype
 from typing import List
-import time
-history_messages = []
-message_upload_index = 0    # 上传消息的序号
 
 
-class TextInput:
-    """
-    A simple TextInput class that allows you to receive inputs in pygame.
-    """
+# Initialize Pygame and Clock
+pygame.init()
+screen = pygame.display.set_mode((800, 600))
+pygame.display.set_caption("Chat Optimization Demo")
+clock = pygame.time.Clock()
 
-    # Add font name for each language,
-    # otherwise some text can't be correctly displayed.
-    FONT_NAMES = ",".join(
-        str(x)
-        for x in [
-            r'res\font\simsun.ttc',
-            "notosanscjktcregular",
-            "notosansmonocjktcregular",
-            "notosansregular,",
-            "microsoftjhengheimicrosoftjhengheiuilight",
-            "microsoftyaheimicrosoftyaheiuilight",
-            "msgothicmsuigothicmspgothic",
-            "msmincho",
-            "Arial",
-        ]
-    )
+# Preload font once
+Current_Path = os.getcwd()
+# FONT_PATH = r"\res\font\simsun.ttc"
+# FONT_PATH = r"\res\font\SourceHanSerifCN-Bold.otf"
+FONT_PATH = Current_Path + r"\res\font\hk4e_zh-cn.ttf"
+# FONT_PATH = r"\res\font\SourceHanSerif-VF.ttc"
+_font = freetype.Font(FONT_PATH, 14)
+_font_small = freetype.Font(FONT_PATH, 12)
+
+
+class Message:
+    def __init__(self, sender: str, text: str, duration_ms: int = 20000, colour: tuple = (255, 255, 255)):
+        self.sender = sender
+        self.text = text
+        self.start = pygame.time.get_ticks()
+        self.duration = duration_ms
+        content = f"{sender}:{text}" if text else sender
+        self.shadow_surf, _ = _font_small.render(content, fgcolor=(0, 0, 0))
+        self.text_surf, _ = _font_small.render(content, fgcolor=colour)
 
-    def __init__(
-        self, prompt: str, pos, screen_dimensions, print_event: bool, text_color="white",entryObj=None
-    ) -> None:
+    def expired(self) -> bool:
+        return pygame.time.get_ticks() - self.start > self.duration
+
+
+class TextInput:
+    FONT_NAMES = ",".join([
+        r'res\font\simsun.ttc',
+        "notosanscjktcregular",
+        "notosansmonocjktcregular",
+        "notosansregular,",
+        "microsoftjhengheimicrosoftjhengheiuilight",
+        "microsoftyaheimicrosoftyaheiuilight",
+        "msgothicmsuigothicmspgothic",
+        "msmincho",
+        "Arial",
+    ])
+
+    def __init__(self, prompt: str, pos, screen_dimensions, print_event: bool, text_color="white", entryObj=None) -> None:
         self.prompt = prompt
         self.print_event = print_event
-        # position of chatlist and chatbox
-        self.CHAT_LIST_POS = pg.Rect((pos[0], pos[1] + 50), (screen_dimensions[0], 400))
-        self.CHAT_BOX_POS = pg.Rect(pos, (screen_dimensions[1], 40))
-        self.CHAT_LIST_MAXSIZE = 20
-        self.entryObj:InputEntry = entryObj
-
+        self.CHAT_BOX_POS = pygame.Rect(pos, (screen_dimensions[1], 40))
+        self.entryObj = entryObj
         self._ime_editing = False
         self._ime_text = ""
         self._ime_text_pos = 0
         self._ime_editing_text = ""
         self._ime_editing_pos = 0
-        self.chat_list: List[str] = []
-
-        # Freetype
-        # The font name can be a comma separated list
-        # of font names to search for.
-        self.font = freetype.Font(r'res\font\simsun.ttc', 13)
-        self.font_small = freetype.Font(r'res\font\simsun.ttc', 13)
+        self.font = _font
+        self.font_small = _font_small
         self.text_color = text_color
 
-    def update(self, events) -> None:
-        """
-        Updates the text input widget
-        """
-        if not self.entryObj.show:
+    def update(self, events=None) -> None:
+        if events is None:
+            events = []
+        if self.entryObj and not self.entryObj.show:
             return
         for event in events:
-            if event.type == pg.KEYDOWN:
+            if event.type == pygame.KEYDOWN:
                 if self.print_event:
                     print(event)
-
                 if self._ime_editing:
-                    if len(self._ime_editing_text) == 0:
+                    if not self._ime_editing_text:
                         self._ime_editing = False
                     continue
-
-                if event.key == pg.K_BACKSPACE:
-                    if len(self._ime_text) > 0 and self._ime_text_pos > 0:
-                        self._ime_text = (
-                            self._ime_text[0 : self._ime_text_pos - 1]
-                            + self._ime_text[self._ime_text_pos :]
-                        )
-                        self._ime_text_pos = max(0, self._ime_text_pos - 1)
-
-                elif event.key == pg.K_DELETE:
-                    self._ime_text = (
-                        self._ime_text[0 : self._ime_text_pos]
-                        + self._ime_text[self._ime_text_pos + 1 :]
-                    )
-                elif event.key == pg.K_LEFT:
+                key = event.key
+                if key == pygame.K_BACKSPACE and self._ime_text_pos > 0:
+                    self._ime_text = self._ime_text[:self._ime_text_pos - 1] + self._ime_text[self._ime_text_pos:]
+                    self._ime_text_pos -= 1
+                elif key == pygame.K_DELETE:
+                    self._ime_text = self._ime_text[:self._ime_text_pos] + self._ime_text[self._ime_text_pos + 1:]
+                elif key == pygame.K_LEFT:
                     self._ime_text_pos = max(0, self._ime_text_pos - 1)
-                elif event.key == pg.K_RIGHT:
-                    self._ime_text_pos = min(
-                        len(self._ime_text), self._ime_text_pos + 1
-                    )
-                # Handle ENTER key
-                elif event.key in [pg.K_RETURN, pg.K_KP_ENTER]:
-                    # Block if we have no text to append
-                    if len(self._ime_text) == 0:
-                        continue
-                    # Append chat list
-                    # self.chat_list.append(self._ime_text)
-                    # if len(self.chat_list) > self.CHAT_LIST_MAXSIZE:
-                    #     self.chat_list.pop(0)
+                elif key == pygame.K_RIGHT:
+                    self._ime_text_pos = min(len(self._ime_text), self._ime_text_pos + 1)
+                elif key in (pygame.K_RETURN, pygame.K_KP_ENTER) and self._ime_text:
+                    if self.entryObj:
+                        self.entryObj.new_message(sender="玩家", message=self._ime_text)
                     self._ime_text = ""
                     self._ime_text_pos = 0
-
-            elif event.type == pg.TEXTEDITING:
-                if self.print_event:
-                    print(event)
+            elif event.type == pygame.TEXTEDITING:
                 self._ime_editing = True
                 self._ime_editing_text = event.text
                 self._ime_editing_pos = event.start
-
-            elif event.type == pg.TEXTINPUT:
-                if self.print_event:
-                    print(event)
+            elif event.type == pygame.TEXTINPUT:
                 self._ime_editing = False
-                self._ime_editing_text = ""
-                self._ime_text = (
-                    self._ime_text[0 : self._ime_text_pos]
-                    + event.text
-                    + self._ime_text[self._ime_text_pos :]
-                )
+                self._ime_text = self._ime_text[:self._ime_text_pos] + event.text + self._ime_text[self._ime_text_pos:]
                 self._ime_text_pos += len(event.text)
 
     def draw(self, screen: pygame.Surface) -> None:
-        """
-        Draws the text input widget onto the provided surface
-        """
-        # Chat List updates
-        # chat_height = self.CHAT_LIST_POS.height / self.CHAT_LIST_MAXSIZE
-        # for i, chat in enumerate(self.chat_list):
-        #     self.font_small.render_to(
-        #         screen,
-        #         (self.CHAT_LIST_POS.x, self.CHAT_LIST_POS.y + i * chat_height),
-        #         chat,
-        #         self.text_color,
-        #     )
-        # Chat box updates
-        start_pos = self.CHAT_BOX_POS.copy()
-        ime_text_l = self.prompt + self._ime_text[0 : self._ime_text_pos]
-        ime_text_m = (
-            self._ime_editing_text[0 : self._ime_editing_pos]
-            + "|"
-            + self._ime_editing_text[self._ime_editing_pos :]
-        )
-        ime_text_r = self._ime_text[self._ime_text_pos :]
-
-        rect_text_l = self.font.render_to(
-            screen, start_pos, ime_text_l, self.text_color
-        )
-        start_pos.x += rect_text_l.width
-
-        # Editing texts should be underlined
-        rect_text_m = self.font.render_to(
-            screen,
-            start_pos,
-            ime_text_m,
-            self.text_color,
-            None,
-            freetype.STYLE_UNDERLINE,
-        )
-        start_pos.x += rect_text_m.width
-        self.font.render_to(screen, start_pos, ime_text_r, self.text_color)
+        start = self.CHAT_BOX_POS.copy()
+        left = self.prompt + self._ime_text[:self._ime_text_pos]
+        mid = self._ime_editing_text[:self._ime_editing_pos] + "|" + self._ime_editing_text[self._ime_editing_pos:]
+        right = self._ime_text[self._ime_text_pos:]
+        surf_l, _ = self.font.render(left, fgcolor=self.text_color)
+        screen.blit(surf_l, (start.x, start.y)); start.x += surf_l.get_width()
+        surf_m, _ = self.font.render(mid, fgcolor=self.text_color, style=freetype.STYLE_UNDERLINE)
+        screen.blit(surf_m, (start.x, start.y)); start.x += surf_m.get_width()
+        surf_r, _ = self.font.render(right, fgcolor=self.text_color)
+        screen.blit(surf_r, (start.x, start.y))
 
 
 class InputEntry(pygame.sprite.Sprite):
-
     def __init__(self):
-        self.image = pygame.image.load("res/img/ui/common/chat_entry.png").convert_alpha()
+        super().__init__()
+        self.image = pygame.image.load(f"{Current_Path}/res/img/ui/common/chat_entry.png").convert_alpha()
+        self.rect = self.image.get_rect(topleft=(250, 500))
         self.show = False
-        self.x = 250
-        self.y = 500
-        self.size = self.image.get_size()
-        self.textEntry = TextInput("", (self.x+20, self.y+5), self.size, False, "black",self)
-        #  {'sender': 'xxx', 'message': 'xxx', 'time': 'xxx'}
-        self.messages = [{'sender': 'QQTPVE制作组', 'message': '重开游戏按0,更多设置详见主菜单之游戏设置', 'time': time.time()+8},
-                         {'sender': 'QQTPVE制作组', 'message': '单机作者: 永恒,运营: 100の雨女,KY', 'time': time.time()+4},
-                         {'sender': 'QQTPVE制作组', 'message': '欢迎使用单机版探险!本项目完全免费,任何售卖渠道均为剽窃!官方群号756422783', 'time': time.time()}]
-        self.Y_DIST = 20    # 每条消息的间隔
+        self.text_input = TextInput("", (self.rect.x + 20, self.rect.y + 5), self.rect.size, False, "black", self)
+        self.messages: List[Message] = [
+            Message("QQTPVE制作组", "重开游戏按0, 更多设置详见主菜单之游戏设置", duration_ms=20000),
+            Message("QQTPVE制作组", "单机作者: 永恒, 联机作者: KY, 运营: 100の雨女", duration_ms=20000),
+            Message("QQTPVE制作组", "欢迎使用单机版探险! 本项目完全免费,任何售卖渠道均为剽窃! 最新官方群号956553296!", duration_ms=20000),
+        ]
+        self.max_msgs = 10
+        self.y_gap = 20
         self.last_msg_time = time.time()
 
-    def draw(self, screen: pygame.Surface):
+    def update(self, events=None):
+        if events is None:
+            events = []
         if self.show:
-            screen.blit(self.image, (self.x, self.y))
-            self.textEntry.draw(screen)
-        # 在 100,450 处显示消息,把最新的消息放在最下面
-        for i in range(len(self.messages)):
-            msg = self.messages[i]
-            
-            if time.time() - msg['time'] > 20:
-                continue
-            if len(msg['message']) > 0:
-                text = msg['sender'] + ':' + msg['message']
-            else:
-                text = msg['sender']
-            # self.textEntry.font_small.render_to(screen, ( 99, 479 - i * self.Y_DIST), text, fgcolor='black')
-            self.textEntry.font_small.render_to(screen, (101, 481 - i * self.Y_DIST), text, fgcolor='black')
-            self.textEntry.font_small.render_to(screen, (100, 480 - i * self.Y_DIST), text, fgcolor='white')
-            # screen.blit(self.entry.font_small.render(msg['sender'] + ': ' + msg['message'], fgcolor='black'), (100, 450 + i * self.Y_DIST))
-        if time.time() - self.last_msg_time > 4:  # 每4秒上移一行
+            self.text_input.update(events)
+        # 清理过期消息
+        self.messages = [m for m in self.messages if not m.expired()]
+        if time.time() - self.last_msg_time > 5:  # 每5秒上移一行
             self.new_message()
 
-    def new_message(self, sender='', message=''):
-        self.messages.insert(0,{'sender': sender, 'message': message, 'time': time.time()})
-        if len(self.messages) > 10:
+    def draw(self, screen: pygame.Surface):
+        if self.show:
+            screen.blit(self.image, self.rect.topleft)
+            self.text_input.draw(screen)
+        x0, y0 = 100, 480
+        for i, msg in enumerate(self.messages):
+            dy = i * self.y_gap
+            screen.blit(msg.shadow_surf, (x0 + 1, y0 - dy + 1))
+            screen.blit(msg.text_surf, (x0, y0 - dy))
+
+    def new_message(self, sender='', message='', colour=(255, 255, 255)):
+        self.messages.insert(0, Message(sender, message, colour=colour))
+        if len(self.messages) > self.max_msgs:
             self.messages.pop()
         self.last_msg_time = time.time()
 
 
-
-
-
-
-
-
-
-
-
-
 class InputLevel(pygame.sprite.Sprite):
-
     def __init__(self):
-        self.image = pygame.image.load("res/img/ui/common/chat_entry.png").convert_alpha()
+        super().__init__()
+        self.image = pygame.image.load(f"{Current_Path}/res/img/ui/common/chat_entry.png").convert_alpha()
+        self.rect = self.image.get_rect(topleft=(250, 500))
         self.show = False
-        self.x = 250
-        self.y = 500
-        self.size = self.image.get_size()
-        self.textEntry = TextInput("", (self.x+20, self.y+5), self.size, False, "black", self)
-        #  {'sender': 'xxx', 'message': 'xxx', 'time': 'xxx'}
-        self.messages = []
-        self.Y_DIST = 20    # 每条消息的间隔
+        self.text_input = TextInput("", (self.rect.x + 20, self.rect.y + 5), self.rect.size, False, "black", self)
+        self.messages: List[Message] = []
+        self.max_msgs = 10
+        self.y_gap = 20
         self.last_msg_time = time.time()
 
-    def draw(self, screen: pygame.Surface):
+    def update(self, events=None):
+        if events is None:
+            events = []
         if self.show:
-            screen.blit(self.image, (self.x, self.y))
-            self.textEntry.draw(screen)
-        # 在 100,450 处显示消息,把最新的消息放在最下面
-        for i in range(len(self.messages)):
-            msg = self.messages[i]
-
-            if time.time() - msg['time'] > 40:
-                continue
-            if len(msg['message']) > 0:
-                text = msg['sender'] + ':' + msg['message']
-            else:
-                text = msg['sender']
-            # self.textEntry.font_small.render_to(screen, ( 99, 479 - i * self.Y_DIST), text, fgcolor='black')
-            self.textEntry.font_small.render_to(screen, (101, 481 - i * self.Y_DIST), text, fgcolor='black')
-            self.textEntry.font_small.render_to(screen, (100, 480 - i * self.Y_DIST), text, fgcolor='white')
-            # screen.blit(self.entry.font_small.render(msg['sender'] + ': ' + msg['message'], fgcolor='black'), (100, 450 + i * self.Y_DIST))
-        if time.time() - self.last_msg_time > 10:  # 每10秒上移一行
+            self.text_input.update(events)
+        self.messages = [m for m in self.messages if not m.expired()]
+        if time.time() - self.last_msg_time > 5:  # 每5秒上移一行
             self.new_message()
 
-    def new_message(self, sender='', message=''):
-        self.messages.insert(0,{'sender': sender, 'message': message, 'time': time.time()})
-        if len(self.messages) > 10:
+    def draw(self, screen: pygame.Surface):
+        if self.show:
+            screen.blit(self.image, self.rect.topleft)
+            self.text_input.draw(screen)
+        x0, y0 = 100, 480
+        for i, msg in enumerate(self.messages):
+            dy = i * self.y_gap
+            screen.blit(msg.shadow_surf, (x0 + 1, y0 - dy + 1))
+            screen.blit(msg.text_surf, (x0, y0 - dy))
+
+    def new_message(self, sender='', message='', colour=(255, 255, 255)):
+        self.messages.insert(0, Message(sender, message, colour=colour))
+        if len(self.messages) > self.max_msgs:
             self.messages.pop()
         self.last_msg_time = time.time()

+ 11 - 0
client_local/ui/game/player_icon.py

@@ -10,3 +10,14 @@ class PlayerIcon(pygame.sprite.Sprite):
 
     def draw(self, screen: pygame.Surface):
         screen.blit(self.image, self.rect)
+
+
+class ResourceIcon(pygame.sprite.Sprite):
+
+    def __init__(self):
+        self.image = pygame.image.load(f"res/img/ui/game/icon_resource.png").convert_alpha()
+        self.rect = self.image.get_rect()
+        self.rect.y = 168
+
+    def draw(self, screen: pygame.Surface):
+        screen.blit(self.image, self.rect)

+ 100 - 0
client_local/utils/json_saver.py

@@ -0,0 +1,100 @@
+import json
+import os
+import shutil
+import tempfile
+import threading
+import time
+
+
+class AsyncJsonSaver:
+
+    def __init__(self, merge_delay=0.05):
+        self.merge_delay = merge_delay
+        self._lock = threading.Lock()
+        self._event = threading.Event()
+        self._stop_event = threading.Event()
+        self._pending = {}
+        self._path_locks = {}
+
+        self._worker = threading.Thread(target=self._worker_loop, daemon=True)
+        self._worker.start()
+
+    def save(self, path, data):
+        with self._lock:
+            self._pending[path] = data
+            if path not in self._path_locks:
+                self._path_locks[path] = threading.Lock()
+        self._event.set()
+
+    def flush(self, timeout=None):
+        start = time.time()
+        while True:
+            with self._lock:
+                empty = not self._pending
+            if empty:
+                return True
+            if timeout is not None and time.time() - start > timeout:
+                return False
+            time.sleep(0.01)
+
+    def shutdown(self, timeout=2.0):
+        self.flush(timeout=timeout)
+        self._stop_event.set()
+        self._event.set()
+        self._worker.join(timeout=timeout)
+
+    def _worker_loop(self):
+        while not self._stop_event.is_set():
+            self._event.wait(timeout=0.1)
+            if self._stop_event.is_set():
+                break
+
+            time.sleep(self.merge_delay)
+
+            with self._lock:
+                if not self._pending:
+                    self._event.clear()
+                    continue
+                tasks = self._pending
+                self._pending = {}
+                self._event.clear()
+
+            for path, data in tasks.items():
+                try:
+                    self._save_json_atomic(path, data)
+                except Exception as e:
+                    print(f"[AsyncJsonSaver] save failed: {path}, error: {e}")
+
+    def _save_json_atomic(self, path, data):
+        os.makedirs(os.path.dirname(path) or ".", exist_ok=True)
+
+        with self._path_locks[path]:
+            backup_path = path + ".bak"
+            dir_name = os.path.dirname(path) or "."
+            base_name = os.path.basename(path)
+
+            fd, temp_path = tempfile.mkstemp(
+                prefix=base_name + ".",
+                suffix=".tmp",
+                dir=dir_name,
+                text=True
+            )
+
+            try:
+                with os.fdopen(fd, "w", encoding="utf-8") as f:
+                    json.dump(data, f, indent=4, ensure_ascii=False)
+                    f.flush()
+                    os.fsync(f.fileno())
+
+                if os.path.exists(path):
+                    shutil.copy2(path, backup_path)
+
+                os.replace(temp_path, path)
+
+            except Exception:
+                try:
+                    if os.path.exists(temp_path):
+                        os.remove(temp_path)
+                except Exception:
+                    pass
+                raise

+ 2 - 2
menulauncher.py

@@ -3,11 +3,11 @@ import os
 import subprocess
 
 current_folder_path = os.getcwd()
-app_name = current_folder_path + "\游戏文件\测试主菜单.exe"
+app_name = f"{current_folder_path}\游戏文件\测试主菜单.exe"
 
 try:
     # 改变当前工作目录
-    os.chdir(current_folder_path+"\游戏文件")
+    os.chdir(f"{current_folder_path}\游戏文件")
     # 替换为launcher.exe的路径
     launcher_path = app_name
     # 启动launcher.exe

+ 2 - 3
test.py

@@ -1,9 +1,8 @@
 from client_local import control
 import os
-# import cProfile
-
 
 current_folder_path = os.getcwd()
+
+
 if __name__ == "__main__":
-    # cProfile.runctx("control.Control()", globals(), locals())
     control.Control()

+ 1837 - 0
test_menu.py

@@ -0,0 +1,1837 @@
+import pygame
+import json
+import subprocess
+import os
+import sys
+import pygame_gui
+from pygame_gui.ui_manager import UIManager
+from pygame_gui.elements.ui_text_entry_line import UITextEntryLine
+import tkinter as tk
+from tkinter import ttk
+from datetime import datetime
+import hashlib
+
+
+# 处理过长的成就
+def generate_verification_code(timestamp):
+    """基于时间戳生成一个长度为6的验证字符串"""
+    hash_object = hashlib.sha256(timestamp.encode())
+    # 取SHA256哈希值的前6位作为验证字符串
+    return hash_object.hexdigest()[:6]
+
+
+def handle_long_achievements():
+    user_documents_folder = os.path.expanduser("~\\Documents")
+    qqtpve_folder = os.path.join(user_documents_folder, "QQTPVE")
+    os.makedirs(qqtpve_folder, exist_ok=True)
+    def process_file(file_path, file_key="STAT"):
+        try:
+            with open(file_path, encoding="utf-8") as file:
+                data = json.load(file)
+        except FileNotFoundError:
+            data = {file_key: []}
+            with open(file_path, 'w', encoding="utf-8") as file:
+                json.dump(data, file, indent=2)
+        except Exception as e:
+            print(f"读取{file_path}错误: {e}")
+            return
+        if len(data[file_key]) > 5000:
+            extracted_data = data[file_key][:]
+            data[file_key] = []
+            with open(file_path, 'w', encoding="utf-8") as file:
+                json.dump(data, file, indent=2)
+            timestamp = datetime.now().strftime('%Y%m%d%H%M%S')
+            verification_code = generate_verification_code(timestamp)
+            base_name = os.path.basename(file_path)
+            name, ext = os.path.splitext(base_name)
+            new_name = f"{name}_{timestamp}_{verification_code}{ext}"
+            new_file_path = os.path.join(os.path.dirname(file_path), new_name)
+            with open(new_file_path, 'w', encoding="utf-8") as file:
+                json.dump({file_key: extracted_data}, file, indent=2)
+            print(f"已保存到{new_file_path}")
+    # achievements_file_path = os.path.join(qqtpve_folder, "achievements.json")
+    monster_stats_file_path = os.path.join(qqtpve_folder, "monster_stats.json")
+    # process_file(achievements_file_path)
+    process_file(monster_stats_file_path)
+    # 读取时需要解析文件名,提取时间戳和验证字符串,然后使用generate_verification_code函数来验证这个字符串是否匹配。
+
+try:
+    handle_long_achievements()
+except Exception as e:
+    print(e)
+
+
+
+# 初始化pygame
+pygame.init()
+
+# 屏幕大小
+SCREEN_WIDTH, SCREEN_HEIGHT = 960, 680
+screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
+pygame.display.set_caption("游戏主菜单(游戏作者:永恒,菜单作者:100の雨女),讨论群:756422783,官方wiki网址:qqtwiki.free.nf")
+
+# 颜色定义
+PAPER = (255, 235, 205)
+WHITE = (255, 255, 255)
+BLACK = (0, 0, 0)
+LIGHT_GRAY = (168, 168, 168)
+BROWN = (127, 70, 44)
+DARK_BROWN = (100, 50, 30)
+ORANGE_PINK = (127, 82, 93)
+LAVENDER_BLUE = (227, 228, 250)
+
+bg_music = "res/music/M09.ogg"
+# 播放背景音乐
+# pygame.mixer.music.load(bg_music)
+# pygame.mixer.music.play(-1)
+
+# 全局变量,用于保存launcher进程对象
+launcher_process = None
+app_process = None
+achievement_process = None
+# 在全局定义一个变量来保存鼠标左键是否按下的状态
+mouse_left_button_down = False
+mouse_left_button_up = True
+is_click_setting = False
+settings_changed = False
+show_map_info = False
+show_map_name = None
+show_custom_map_name = None
+leave_map_info = True
+current_page = 1
+
+
+try:
+    with open("config.json", encoding="utf-8") as f:
+        cfg_json = json.load(f)
+except:
+    with open("config.json", encoding="utf-8_sig") as f:
+        cfg_json = json.load(f)
+
+
+# 初始化一个空字典来存储合并后的数据
+map_name_en = {}
+# 遍历指定目录中的所有文件
+for filename in os.listdir("game/menu_list/menu_map_set"):
+    # 检查文件是否是 JSON 文件
+    if filename.endswith('.json'):
+        # 构造文件的完整路径
+        file_path = os.path.join("game/menu_list/menu_map_set", filename)
+        # 读取 JSON 数据并合并
+        with open(file_path, 'r', encoding='utf-8') as file:
+            # 文件名(不包括扩展名)作为键
+            key = filename[:-5]
+            tmp_file = json.load(file)
+            if len(tmp_file) == 0:
+                continue
+            if key == '0Official':
+                for mname in tmp_file[0].keys():
+                    map_name_en[mname] = tmp_file[0][mname]["map_name"]
+            else:
+                for thame in tmp_file:
+                    for thame_name in thame.keys():
+                        for mname_dic in thame[thame_name]["selections"]:
+                            map_name_en[mname_dic["map_name"]] = mname_dic["difficulty"]
+
+
+# 读取地图信息
+def read_map_selection():
+    # 初始化一个空字典来存储合并后的数据
+    merged_data = {}
+    # 遍历指定目录中的所有文件
+    for filename in os.listdir("game/menu_list/menu_map_set"):
+        # 检查文件是否是 JSON 文件
+        if filename.endswith('.json'):
+            # 构造文件的完整路径
+            file_path = os.path.join("game/menu_list/menu_map_set", filename)
+            # 读取 JSON 数据并合并
+            with open(file_path, 'r', encoding='utf-8') as file:
+                # 文件名(不包括扩展名)作为键
+                key = filename[:-5]
+                # 读取文件内容并添加到字典
+                # print(filename)
+                # print(json.load(file))
+                merged_data[key] = json.load(file)
+    return merged_data
+
+
+
+
+
+
+# 初始化一个空字典来存储合并后的数据
+app_name = {}
+# 遍历指定目录中的所有文件
+for filename in os.listdir("game/menu_list/menu_app"):
+    # 检查文件是否是 JSON 文件
+    if filename.endswith('.json'):
+        # 构造文件的完整路径
+        file_path = os.path.join("game/menu_list/menu_app", filename)
+        # 读取 JSON 数据并合并
+        with open(file_path, 'r', encoding='utf-8') as file:
+            # 文件名(不包括扩展名)作为键
+            key = filename[:-5]
+            tmp_file = json.load(file)
+            app_name[key] = tmp_file[0]
+
+
+def stars_string(n):
+    if n <= 0:
+        raise ValueError("输入必须为正整数")
+
+    num_stars = n // 10
+    num_dots = n % 10
+
+    stars_string = "★" * num_stars + "☆" * num_dots
+    return stars_string
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+# 绘制主菜单界面
+def draw_menu():
+    screen.fill(PAPER)
+
+    # 加载自定义字体文件
+    font = pygame.font.Font("res/font/simsun.ttc", 24)
+
+    # 定义按钮的外观
+    button_width, button_height = 600, 100
+    button_margin = 20
+
+    # 定义按钮的文本和位置
+    buttons = [
+        ("直接开始(当前关卡:" + show_official_map_name(cfg_json["map_set"]) + ")", (SCREEN_WIDTH // 2 - button_width // 2, 100)),
+        ("选择关卡", (SCREEN_WIDTH // 2 - button_width // 2, 100 + button_height + button_margin)),
+        # ("游戏设置", (SCREEN_WIDTH // 2 - button_width // 2, 100 + (button_height + button_margin) * 2)),
+        ("关于作者", (SCREEN_WIDTH // 2 - button_width // 2, 100 + (button_height + button_margin) * 3)),
+    ]
+
+    # 绘制按钮
+    for button_text, (x, y) in buttons:
+        button_rect = pygame.Rect(x, y, button_width, button_height)
+
+        if button_rect.collidepoint(pygame.mouse.get_pos()):
+            pygame.draw.rect(screen, DARK_BROWN, button_rect)
+        else:
+            pygame.draw.rect(screen, BROWN, button_rect)
+
+        # pygame.draw.rect(screen, BROWN, button_rect)
+        text = font.render(button_text, True, WHITE)
+        text_rect = text.get_rect(center=button_rect.center)
+        screen.blit(text, text_rect)
+
+    # 定义按钮的文本和位置
+    buttons2 = [
+        ("游戏设置", (SCREEN_WIDTH // 2 - button_width // 2, 100 + (button_height + button_margin) * 2)),
+        ("成就记录", (SCREEN_WIDTH // 2 - button_width // 2 + 210, 100 + (button_height + button_margin) * 2)),
+        ("操作帮助", (SCREEN_WIDTH // 2 - button_width // 2 + 210 * 2, 100 + (button_height + button_margin) * 2))
+    ]
+
+    # 绘制按钮
+    for button_text, (x, y) in buttons2:
+        button_rect = pygame.Rect(x, y, 180, 100)
+
+        if button_rect.collidepoint(pygame.mouse.get_pos()):
+            pygame.draw.rect(screen, DARK_BROWN, button_rect)
+        else:
+            pygame.draw.rect(screen, BROWN, button_rect)
+
+        # pygame.draw.rect(screen, BROWN, button_rect)
+        text = font.render(button_text, True, WHITE)
+        text_rect = text.get_rect(center=button_rect.center)
+        screen.blit(text, text_rect)
+
+    # 更新屏幕显示
+    pygame.display.flip()
+
+
+# 绘制作者信息界面
+def draw_author_info():
+    screen.fill(PAPER)
+
+    # 加载自定义字体文件
+    font = pygame.font.Font("res/font/simsun.ttc", 24)
+
+    # 作者信息文本
+    author_info_text = "关于作者:\n\n QQTPVE作者: 永恒 B站曾用id: QQTPVE-永恒(已注销) \n\n 联机作者: KY B站id: Zageku" + \
+                       "\n\n 菜单作者与后续单机运营: 100の雨女 B站id同名 \n\n 链接: https://space.bilibili.com/12132334" + \
+                       "\n\n 感谢悠闲人生,疾风等改图作者与根号十三,冰神等老玩家与Null等技术人员的支持" + \
+                       "\n\n 官方探险群:756422783,老群:133753304 \n\n 官方wiki网站: qqtwiki.free.nf"
+
+    # 将文本按换行符拆分成多行
+    lines = author_info_text.split("\n")
+
+    # 绘制每一行文本
+    line_height = 30
+    y_offset = 120
+    for line in lines:
+        text_surface = font.render(line, True, BLACK)
+        text_rect = text_surface.get_rect(center=(SCREEN_WIDTH // 2, y_offset))
+        screen.blit(text_surface, text_rect)
+        y_offset += line_height
+
+    # 绘制返回按钮
+    return_button_text = "返回主菜单"
+    return_button_width, return_button_height = 200, 60
+    return_button_rect = pygame.Rect(50, SCREEN_HEIGHT - 50 - return_button_height, return_button_width,
+                                     return_button_height)
+    if return_button_rect.collidepoint(pygame.mouse.get_pos()):
+        pygame.draw.rect(screen, DARK_BROWN, return_button_rect)
+    else:
+        pygame.draw.rect(screen, BROWN, return_button_rect)
+    # pygame.draw.rect(screen, BROWN, return_button_rect)
+    return_text_surface = font.render(return_button_text, True, WHITE)
+    return_text_rect = return_text_surface.get_rect(center=return_button_rect.center)
+    screen.blit(return_text_surface, return_text_rect)
+
+    # 更新屏幕显示
+    pygame.display.flip()
+
+
+# 绘制操作帮助
+def draw_helper_info():
+    screen.fill(PAPER)
+
+    # 加载自定义字体文件
+    font = pygame.font.Font("res/font/simsun.ttc", 24)
+
+    # 作者信息文本
+    author_info_text = "操作帮助:\n\n 开关怪物姓名牌快捷键:F6(部分机型F6+Fn) \n\n 怪物姓名与血量切换显示快捷键:F7(部分机型F7+Fn)" + \
+                       "\n\n 重新开始本地图快捷键: 0(主键盘数字) \n\n 上下左右移动,空格放置糖泡,数字123使用道具 \n\n 修改特殊键位置请使用其他辅助程序或参阅config修改手册" + \
+                       "\n\n 换衣服换糖泡请参阅永恒大佬B站视频教学 \n\n 此为单机探险不可联机不可进入商城更不可能恢复原账号数据 \n\n 打不过原图就去打新手教程!!能过教程基本能过所有原图(黑龙除外)!!"
+
+    # 将文本按换行符拆分成多行
+    lines = author_info_text.split("\n")
+
+    # 绘制每一行文本
+    line_height = 30
+    y_offset = 50
+    for line in lines:
+        text_surface = font.render(line, True, BLACK)
+        text_rect = text_surface.get_rect(center=(SCREEN_WIDTH // 2, y_offset))
+        screen.blit(text_surface, text_rect)
+        y_offset += line_height
+
+    # 绘制返回按钮
+    return_button_text = "返回主菜单"
+    return_button_width, return_button_height = 200, 60
+    return_button_rect = pygame.Rect(50, SCREEN_HEIGHT - 50 - return_button_height, return_button_width,
+                                     return_button_height)
+    if return_button_rect.collidepoint(pygame.mouse.get_pos()):
+        pygame.draw.rect(screen, DARK_BROWN, return_button_rect)
+    else:
+        pygame.draw.rect(screen, BROWN, return_button_rect)
+    # pygame.draw.rect(screen, BROWN, return_button_rect)
+    return_text_surface = font.render(return_button_text, True, WHITE)
+    return_text_rect = return_text_surface.get_rect(center=return_button_rect.center)
+    screen.blit(return_text_surface, return_text_rect)
+
+    # 更新屏幕显示
+    pygame.display.flip()
+
+
+# 运行游戏launcher
+def launch_game():
+    global launcher_process
+    print("PVE, Launch!!!")
+
+    try:
+        # 替换为launcher.exe的路径
+        launcher_path = "launcher.exe"
+        # 启动launcher.exe并隐藏窗口
+        launcher_process = subprocess.Popen([launcher_path], shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
+                                            stderr=subprocess.PIPE, creationflags=subprocess.DETACHED_PROCESS)
+        # 隐藏主菜单窗口
+        pygame.display.iconify()
+
+        # 等待launcher.exe结束
+        # launcher_process.communicate()
+
+        # 当launcher.exe关闭后,关闭主菜单窗口并退出程序
+        # pygame.display.quit()
+        # sys.exit()
+
+    except FileNotFoundError:
+        print("找不到launcher.exe,请确保它与Python脚本在同一目录下。")
+    except Exception as e:
+        print("运行launcher.exe时出现错误:", e)
+    finally:
+        launcher_process = None
+
+
+
+# 运行app
+def launch_app(app_name):
+    global app_process
+    print(app_name + ", Launch!!!")
+    try:
+        # 替换为launcher.exe的路径
+        launcher_path = app_name + ".exe"
+        # 启动launcher.exe
+        app_process = subprocess.Popen([launcher_path])
+
+    except FileNotFoundError:
+        print("找不到" + app_name + ".exe,请确保它与Python脚本在同一目录下。")
+    except Exception as e:
+        print("运行" + app_name + "时出现错误:", e)
+    finally:
+        app_process = None
+
+
+# 运行成就
+def achievement():
+    global achievement_process
+
+    try:
+        # 替换为launcher.exe的路径
+        achievement_path = "点亮式成就.exe"
+        # 启动launcher.exe并隐藏窗口
+        achievement_process = subprocess.Popen([achievement_path], shell=True, stdin=subprocess.PIPE,
+                                               stdout=subprocess.PIPE, stderr=subprocess.PIPE,
+                                               creationflags=subprocess.DETACHED_PROCESS)
+        # 隐藏主菜单窗口
+        # pygame.display.iconify()
+
+        # 等待launcher.exe结束
+        # achievement_process.communicate()
+
+        # 当launcher.exe关闭后,关闭主菜单窗口并退出程序
+        # pygame.display.quit()
+        # sys.exit()
+
+    except FileNotFoundError:
+        print("找不到点亮式成就.exe,请确保它与Python脚本在同一目录下。")
+    except Exception as e:
+        print("运行点亮式成就.exe时出现错误:", e)
+    finally:
+        achievement_process = None
+
+
+# 地图选择菜单中的按钮
+map_buttons = []
+map_button_width, map_button_height = 300, 60
+map_button_margin = 20
+
+
+# 处理地图选择按钮的点击事件
+def handle_map_selection_click(map):
+    # 在这里处理地图选择,例如更新config.json中的选定地图
+    cfg_json["map_set"] = map
+    # 返回到上一个界面(地图选择菜单)
+    current_screen = "main_menu"
+    draw_menu()
+    # map_selection_loop(map_selection_data, map_info["author"])
+
+
+# 绘制地图选择菜单
+def draw_map_selection_menu():
+    # 清空屏幕
+    screen.fill(PAPER)
+
+    # 绘制"原图"按钮
+    original_maps_button_rect = pygame.Rect(250, 150, map_button_width, map_button_height)
+
+    if original_maps_button_rect.collidepoint(pygame.mouse.get_pos()):
+        pygame.draw.rect(screen, DARK_BROWN, original_maps_button_rect)
+    else:
+        pygame.draw.rect(screen, BROWN, original_maps_button_rect)
+
+    # pygame.draw.rect(screen, BROWN, original_maps_button_rect)
+    pygame.draw.rect(screen, PAPER, original_maps_button_rect, 3)
+    font = pygame.font.Font("res/font/simsun.ttc", 24)
+    text = font.render("官方原图与教程", True, WHITE)
+    text_rect = text.get_rect(center=original_maps_button_rect.center)
+    screen.blit(text, text_rect)
+
+    # 绘制"其他作者的地图"按钮
+    other_authors_button_rect = pygame.Rect(250, 150 + map_button_height + map_button_margin, map_button_width,
+                                            map_button_height)
+
+    if other_authors_button_rect.collidepoint(pygame.mouse.get_pos()):
+        pygame.draw.rect(screen, DARK_BROWN, other_authors_button_rect)
+    else:
+        pygame.draw.rect(screen, BROWN, other_authors_button_rect)
+
+    # pygame.draw.rect(screen, BROWN, other_authors_button_rect)
+    pygame.draw.rect(screen, PAPER, other_authors_button_rect, 3)
+    text = font.render("改图(玩家自创)", True, WHITE)
+    text_rect = text.get_rect(center=other_authors_button_rect.center)
+    screen.blit(text, text_rect)
+
+    # 绘制"其他地图生成工具"按钮
+    other_apps_button_rect = pygame.Rect(250, 150 + 2*map_button_height + 2*map_button_margin, map_button_width,
+                                            map_button_height)
+
+    if other_apps_button_rect.collidepoint(pygame.mouse.get_pos()):
+        pygame.draw.rect(screen, DARK_BROWN, other_apps_button_rect)
+    else:
+        pygame.draw.rect(screen, BROWN, other_apps_button_rect)
+    pygame.draw.rect(screen, PAPER, other_apps_button_rect, 3)
+    text = font.render("其他(地图生成/辅助)", True, WHITE)
+    text_rect = text.get_rect(center=other_apps_button_rect.center)
+    screen.blit(text, text_rect)
+
+
+    # 绘制"返回"按钮
+    return_button_rect = pygame.Rect(250, SCREEN_HEIGHT - 150 - map_button_height, map_button_width, map_button_height)
+
+    if return_button_rect.collidepoint(pygame.mouse.get_pos()):
+        pygame.draw.rect(screen, DARK_BROWN, return_button_rect)
+    else:
+        pygame.draw.rect(screen, BROWN, return_button_rect)
+
+    # pygame.draw.rect(screen, BROWN, return_button_rect)
+    pygame.draw.rect(screen, PAPER, return_button_rect, 3)
+    text = font.render("返回主菜单", True, WHITE)
+    text_rect = text.get_rect(center=return_button_rect.center)
+    screen.blit(text, text_rect)
+
+    # 更新屏幕显示
+    pygame.display.flip()
+
+random_map_type = ""
+
+def show_official_map_name(map):
+    if map in list(map_name_en.keys()):
+        return map_name_en[map]
+    else:
+        if map == "randomMapSet":
+            if random_map_type != "":
+                return "随机地图("+random_map_type+")"
+            else: return "随机地图(未知)"
+        else: return map
+
+
+# 地图信息显示框
+map_info_box_width, map_info_box_height = 300, 100
+map_info_box_margin = 10
+map_info_box_rect = None
+map_info_text = ""
+
+original_map_button_width = 200
+
+# 绘制原图子菜单
+def draw_original_maps_submenu():
+    global map_info_box_rect, map_info_text
+    # 清空屏幕
+    screen.fill(PAPER)
+
+    # 绘制"返回"按钮
+    return_button_rect = pygame.Rect(50, SCREEN_HEIGHT - 50 - map_button_height, original_map_button_width, map_button_height)
+    if return_button_rect.collidepoint(pygame.mouse.get_pos()):
+        pygame.draw.rect(screen, DARK_BROWN, return_button_rect)
+    else:
+        pygame.draw.rect(screen, BROWN, return_button_rect)
+    # pygame.draw.rect(screen, BROWN, return_button_rect)
+    pygame.draw.rect(screen, PAPER, return_button_rect, 3)
+    font = pygame.font.Font("res/font/simsun.ttc", 24)
+    text = font.render("返回", True, WHITE)
+    text_rect = text.get_rect(center=return_button_rect.center)
+    screen.blit(text, text_rect)
+
+    # 绘制所有原图按钮
+    x, y = 200, 50
+    # for map_info in map_selection_data[author]:
+    # print(list(map_selection_data["Official"][0].keys()))
+    for k, map_info in enumerate(list(map_selection_data["0Official"][0].keys())):
+        # print(map_info)
+        map_button_rect = pygame.Rect(x, y, original_map_button_width, map_button_height)
+
+        if map_button_rect.collidepoint(pygame.mouse.get_pos()):
+            pygame.draw.rect(screen, DARK_BROWN, map_button_rect)
+        else:
+            pygame.draw.rect(screen, BROWN, map_button_rect)
+
+        # pygame.draw.rect(screen, BROWN, map_button_rect)
+        pygame.draw.rect(screen, PAPER, map_button_rect, 3)
+        font = pygame.font.Font("res/font/simsun.ttc", 24)
+        # text = font.render(map_info[list(map_info.keys())[0]]["map_name"], True, WHITE)
+        text = font.render(show_official_map_name(map_info), True, WHITE)
+        text_rect = text.get_rect(center=map_button_rect.center)
+        screen.blit(text, text_rect)
+        # 添加地图按钮到列表中以备后续处理事件
+        map_buttons.append((map_button_rect, map_info))
+        if y + map_button_height + map_button_margin <= SCREEN_HEIGHT - 3 * map_button_height:
+            y += map_button_height + map_button_margin
+        else:
+            x += original_map_button_width + map_button_margin
+            y = 50
+
+    map_info_box_width, map_info_box_height = 600, 120
+    map_info_box_rect = pygame.Rect((SCREEN_WIDTH - map_info_box_width) // 2 + 100, SCREEN_HEIGHT - 150, map_info_box_width, map_info_box_height)
+    pygame.draw.rect(screen, ORANGE_PINK, map_info_box_rect)
+    pygame.draw.rect(screen, PAPER, map_info_box_rect, 3)
+
+    if show_map_info and show_map_name is not None:
+            font = pygame.font.Font("res/font/simsun.ttc", 24)
+            lines = show_map_name.split("\n")
+            for i, line in enumerate(lines):
+                text_surface = font.render(line, True, WHITE)
+                text_rect = text_surface.get_rect(center=(SCREEN_WIDTH // 2 + 100, SCREEN_HEIGHT - 120 + i * 20))
+                screen.blit(text_surface, text_rect)
+            # pygame.display.flip()
+
+    # 更新屏幕显示
+    pygame.display.flip()
+
+
+
+
+
+
+
+
+def show_author_name(author):
+    if author == 'AmeOnna': return '100の雨女'
+    elif author == '0YouXian0': return '0悠闲人生0'
+    elif author == 'MingGui': return '冥の归'
+    elif author == 'JiFeng': return '疾风'
+    elif author == 'CanBing': return '残冰'
+    elif author == 'Null': return '闹神'
+    elif author == 'YongHeng': return '永恒'
+    elif author == 'PBGuangYing': return '光影'
+    elif author == 'TaXue': return '踏雪无痕'
+    elif author == 'XiaoLieQuan': return '小猎犬'
+    elif author == 'u7iui': return 'u7iui'
+    elif author == 'z_Unknown': return '敬请期待更多'
+    else: return author
+
+
+# 改图子菜单的按钮宽高和间距
+custom_map_button_width, custom_map_button_height = 200, 60
+custom_map_button_margin = 10
+
+def draw_custom_maps_submenu():
+    global map_info_box_rect, map_info_text
+
+    # 清空屏幕
+    screen.fill(PAPER)
+
+    # 绘制"返回"按钮
+    return_button_rect = pygame.Rect(50, SCREEN_HEIGHT - 50 - custom_map_button_height, custom_map_button_width, custom_map_button_height)
+    if return_button_rect.collidepoint(pygame.mouse.get_pos()):
+        pygame.draw.rect(screen, DARK_BROWN, return_button_rect)
+    else:
+        pygame.draw.rect(screen, BROWN, return_button_rect)
+    # pygame.draw.rect(screen, BROWN, return_button_rect)
+    pygame.draw.rect(screen, PAPER, return_button_rect, 3)
+    font = pygame.font.Font("res/font/simsun.ttc", 24)
+    text = font.render("返回", True, WHITE)
+    text_rect = text.get_rect(center=return_button_rect.center)
+    screen.blit(text, text_rect)
+
+    # 获取所有改图作者的名字
+    caremove = list(map_selection_data.keys())
+    caremove.remove('0Official')
+    custom_authors = caremove
+    # 计算可以显示的改图作者的数量
+    max_custom_authors = (SCREEN_HEIGHT - 2 * custom_map_button_height) // (custom_map_button_height + custom_map_button_margin)
+    # 计算总页数
+    total_pages = (len(custom_authors) + max_custom_authors - 1) // max_custom_authors
+
+    # 绘制改图作者按钮
+    x, y = SCREEN_WIDTH // 2 - custom_map_button_width // 2, 50
+    custom_map_buttons = []  # 存储改图作者按钮的位置和对应作者名
+    # print(custom_authors[(current_page - 1) * max_custom_authors : min(len(custom_authors),(current_page * max_custom_authors))])
+    # print(current_page)
+    # print((current_page - 1) * max_custom_authors , min(len(custom_authors),(current_page * max_custom_authors)))
+    for author in custom_authors[(current_page - 1) * max_custom_authors : min(len(custom_authors),(current_page * max_custom_authors))]:
+        author_button_rect = pygame.Rect(x, y, custom_map_button_width, custom_map_button_height)
+        if author_button_rect.collidepoint(pygame.mouse.get_pos()):
+            pygame.draw.rect(screen, DARK_BROWN, author_button_rect)
+        else:
+            pygame.draw.rect(screen, BROWN, author_button_rect)
+        # pygame.draw.rect(screen, BROWN, author_button_rect)
+        pygame.draw.rect(screen, PAPER, author_button_rect, 3)
+        font = pygame.font.Font("res/font/simsun.ttc", 18)
+        text = font.render(show_author_name(author)+'改图', True, WHITE)
+        text_rect = text.get_rect(center=author_button_rect.center)
+        screen.blit(text, text_rect)
+        custom_map_buttons.append((author_button_rect, author))
+        y += custom_map_button_height + custom_map_button_margin
+
+
+    # 绘制滚动条或下一页按钮
+    if total_pages > 1:
+        scroll_button_width, scroll_button_height = 80, 120
+        scroll_button_margin = 10
+        next_button_rect = pygame.Rect(SCREEN_WIDTH - scroll_button_width - scroll_button_margin*20, SCREEN_HEIGHT - custom_map_button_height*7 - scroll_button_margin, scroll_button_width, scroll_button_height)
+        prev_button_rect = pygame.Rect(scroll_button_margin*20, SCREEN_HEIGHT - custom_map_button_height*7 - scroll_button_margin, scroll_button_width, scroll_button_height)
+        if next_button_rect.collidepoint(pygame.mouse.get_pos()):
+            pygame.draw.rect(screen, LIGHT_GRAY, next_button_rect)
+        else:
+            pygame.draw.rect(screen, ORANGE_PINK, next_button_rect)
+        if prev_button_rect.collidepoint(pygame.mouse.get_pos()):
+            pygame.draw.rect(screen, LIGHT_GRAY, prev_button_rect)
+        else:
+            pygame.draw.rect(screen, ORANGE_PINK, prev_button_rect)
+        # pygame.draw.rect(screen, BROWN, next_button_rect)
+        # pygame.draw.rect(screen, BROWN, prev_button_rect)
+        pygame.draw.polygon(screen, WHITE, [(next_button_rect.centerx, next_button_rect.centery - 10), (next_button_rect.centerx, next_button_rect.centery + 10), (next_button_rect.centerx + 10, next_button_rect.centery)])
+        pygame.draw.polygon(screen, WHITE, [(prev_button_rect.centerx, prev_button_rect.centery - 10), (prev_button_rect.centerx, prev_button_rect.centery + 10), (prev_button_rect.centerx - 10, prev_button_rect.centery)])
+        pygame.display.flip()
+        return custom_map_buttons, total_pages, next_button_rect, prev_button_rect
+
+    # 更新屏幕显示
+    pygame.display.flip()
+    return custom_map_buttons, total_pages, None, None
+
+
+
+
+# 选大关界面
+def draw_custom_maps(author):
+    global map_info_box_rect, map_info_text, custom_map_buttons
+
+    # 清空屏幕
+    screen.fill(PAPER)
+
+    # 绘制"返回"按钮
+    return_button_rect = pygame.Rect(50, SCREEN_HEIGHT - 50 - custom_map_button_height, custom_map_button_width, custom_map_button_height)
+    if return_button_rect.collidepoint(pygame.mouse.get_pos()):
+        pygame.draw.rect(screen, DARK_BROWN, return_button_rect)
+    else:
+        pygame.draw.rect(screen, BROWN, return_button_rect)
+    # pygame.draw.rect(screen, BROWN, return_button_rect)
+    pygame.draw.rect(screen, PAPER, return_button_rect, 3)
+    font = pygame.font.Font("res/font/simsun.ttc", 24)
+    text = font.render("返回作者菜单", True, WHITE)
+    text_rect = text.get_rect(center=return_button_rect.center)
+    screen.blit(text, text_rect)
+
+    # 获取所有改图的名字
+    custom_maps = [list(item.keys())[0] for item in map_selection_data[author]]
+    # 计算可以显示的改图的数量
+    max_custom_maps = (SCREEN_HEIGHT - 2 * custom_map_button_height) // (custom_map_button_height + custom_map_button_margin) - 1
+    # 计算总页数
+    total_pages = (len(custom_maps) + max_custom_maps - 1) // max_custom_maps
+    # print(custom_maps, max_custom_maps, total_pages)
+
+    # 绘制改图作者按钮
+    x, y = SCREEN_WIDTH // 4 - custom_map_button_width // 2, 50
+    custom_map_buttons = []  # 存储改图作者按钮的位置和对应作者名
+    for map in custom_maps[(current_page - 1) * max_custom_maps : min(len(custom_maps),(current_page * max_custom_maps))]:
+        map_button_rect = pygame.Rect(x, y, custom_map_button_width, custom_map_button_height)
+        if map_button_rect.collidepoint(pygame.mouse.get_pos()):
+            pygame.draw.rect(screen, DARK_BROWN, map_button_rect)
+        else:
+            pygame.draw.rect(screen, BROWN, map_button_rect)
+        pygame.draw.rect(screen, PAPER, map_button_rect, 3)
+        font = pygame.font.Font("res/font/simsun.ttc", 18)
+        text = font.render(next(item[map]['full_name'] for item in map_selection_data[author] if map in item), True, WHITE)
+        text_rect = text.get_rect(center=map_button_rect.center)
+        screen.blit(text, text_rect)
+        custom_map_buttons.append((map_button_rect, map))
+        y += custom_map_button_height + custom_map_button_margin
+
+    map_info_box_width, map_info_box_height = 450, 620
+    map_info_box_rect = pygame.Rect((SCREEN_WIDTH - map_info_box_width) // 2 + 215, 30, map_info_box_width, map_info_box_height)
+    pygame.draw.rect(screen, ORANGE_PINK, map_info_box_rect)
+    pygame.draw.rect(screen, PAPER, map_info_box_rect, 3)
+
+    if show_map_info and show_map_name is not None:
+        font = pygame.font.Font("res/font/simsun.ttc", 18)
+        lines = show_map_name.split("\n")
+        for i, line in enumerate(lines):
+            text_surface = font.render(line, True, WHITE)
+            text_rect = text_surface.get_rect(center=(SCREEN_WIDTH // 2 + 220, 80 + i * 15))
+            screen.blit(text_surface, text_rect)
+
+    # 绘制滚动条或下一页按钮
+    if total_pages > 1:
+        scroll_button_width, scroll_button_height = 80, 120
+        scroll_button_margin = 10
+        next_button_rect = pygame.Rect(360, SCREEN_HEIGHT - custom_map_button_height*7 - scroll_button_margin, scroll_button_width, scroll_button_height)
+        prev_button_rect = pygame.Rect(40, SCREEN_HEIGHT - custom_map_button_height*7 - scroll_button_margin, scroll_button_width, scroll_button_height)
+        if next_button_rect.collidepoint(pygame.mouse.get_pos()):
+            pygame.draw.rect(screen, LIGHT_GRAY, next_button_rect)
+        else:
+            pygame.draw.rect(screen, ORANGE_PINK, next_button_rect)
+        if prev_button_rect.collidepoint(pygame.mouse.get_pos()):
+            pygame.draw.rect(screen, LIGHT_GRAY, prev_button_rect)
+        else:
+            pygame.draw.rect(screen, ORANGE_PINK, prev_button_rect)
+        pygame.draw.polygon(screen, WHITE, [(next_button_rect.centerx, next_button_rect.centery - 10), (next_button_rect.centerx, next_button_rect.centery + 10), (next_button_rect.centerx + 10, next_button_rect.centery)])
+        pygame.draw.polygon(screen, WHITE, [(prev_button_rect.centerx, prev_button_rect.centery - 10), (prev_button_rect.centerx, prev_button_rect.centery + 10), (prev_button_rect.centerx - 10, prev_button_rect.centery)])
+        pygame.display.flip()
+        return custom_map_buttons, total_pages, next_button_rect, prev_button_rect
+
+    # 更新屏幕显示
+    pygame.display.flip()
+    return custom_map_buttons, total_pages, None, None
+
+
+
+
+
+
+
+
+
+
+difficulty_button_width, difficulty_button_height = 280, 70
+difficulty_button_margin = 10
+
+def draw_custom_difficulty(author, map):
+    global map_info_box_rect, map_info_text, difficulty_buttons
+
+    # 清空屏幕
+    screen.fill(PAPER)
+
+    # 绘制"返回"按钮
+    return_button_rect = pygame.Rect(50, SCREEN_HEIGHT - 50 - difficulty_button_height, difficulty_button_width, difficulty_button_height)
+    if return_button_rect.collidepoint(pygame.mouse.get_pos()):
+        pygame.draw.rect(screen, DARK_BROWN, return_button_rect)
+    else:
+        pygame.draw.rect(screen, BROWN, return_button_rect)
+    # pygame.draw.rect(screen, BROWN, return_button_rect)
+    pygame.draw.rect(screen, PAPER, return_button_rect, 3)
+    font = pygame.font.Font("res/font/simsun.ttc", 24)
+    text = font.render("返回"+show_author_name(author)+"改图", True, WHITE)
+    text_rect = text.get_rect(center=return_button_rect.center)
+    screen.blit(text, text_rect)
+
+    # 获取所有难度
+    difficulty = next(item[map]['selections'] for item in map_selection_data[author] if map in item)
+    # 计算可以显示的难度数量
+    max_difficulty = (SCREEN_HEIGHT - 2 * difficulty_button_height) // (difficulty_button_height + difficulty_button_margin)
+    # 计算总页数
+    total_pages = (len(difficulty) + max_difficulty - 1) // max_difficulty
+
+    # 绘制改图作者按钮
+    x, y = SCREEN_WIDTH // 2 - difficulty_button_width // 2, 50
+    difficulty_buttons = []  # 存储改图作者按钮的位置和对应作者名
+    for diff in difficulty[(current_page - 1) * max_difficulty : min(len(difficulty),(current_page * max_difficulty))]:
+        map_button_rect = pygame.Rect(x, y, difficulty_button_width, difficulty_button_height)
+        if map_button_rect.collidepoint(pygame.mouse.get_pos()):
+            pygame.draw.rect(screen, DARK_BROWN, map_button_rect)
+        else:
+            pygame.draw.rect(screen, BROWN, map_button_rect)
+        pygame.draw.rect(screen, PAPER, map_button_rect, 3)
+        font = pygame.font.Font("res/font/simsun.ttc", 18)
+        text = font.render(diff['difficulty'], True, WHITE)
+        text_rect = text.get_rect(center=map_button_rect.center)
+        screen.blit(text, text_rect)
+        difficulty_buttons.append((map_button_rect, diff))
+        y += difficulty_button_height + difficulty_button_margin
+
+    # 绘制滚动条或下一页按钮
+    if total_pages > 1:
+        scroll_button_width, scroll_button_height = 80, 120
+        scroll_button_margin = 10
+        next_button_rect = pygame.Rect(SCREEN_WIDTH - scroll_button_width - scroll_button_margin*20, SCREEN_HEIGHT - custom_map_button_height*7 - scroll_button_margin, scroll_button_width, scroll_button_height)
+        prev_button_rect = pygame.Rect(scroll_button_margin*20, SCREEN_HEIGHT - custom_map_button_height*7 - scroll_button_margin, scroll_button_width, scroll_button_height)
+        if next_button_rect.collidepoint(pygame.mouse.get_pos()):
+            pygame.draw.rect(screen, LIGHT_GRAY, next_button_rect)
+        else:
+            pygame.draw.rect(screen, ORANGE_PINK, next_button_rect)
+        if prev_button_rect.collidepoint(pygame.mouse.get_pos()):
+            pygame.draw.rect(screen, LIGHT_GRAY, prev_button_rect)
+        else:
+            pygame.draw.rect(screen, ORANGE_PINK, prev_button_rect)
+        pygame.draw.polygon(screen, WHITE, [(next_button_rect.centerx, next_button_rect.centery - 10), (next_button_rect.centerx, next_button_rect.centery + 10), (next_button_rect.centerx + 10, next_button_rect.centery)])
+        pygame.draw.polygon(screen, WHITE, [(prev_button_rect.centerx, prev_button_rect.centery - 10), (prev_button_rect.centerx, prev_button_rect.centery + 10), (prev_button_rect.centerx - 10, prev_button_rect.centery)])
+        pygame.display.flip()
+        return difficulty_buttons, total_pages, next_button_rect, prev_button_rect
+
+    # 更新屏幕显示
+    pygame.display.flip()
+    return difficulty_buttons, total_pages, None, None
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+def draw_custom_apps():
+    global map_info_box_rect, map_info_text, app_buttons
+
+    # 清空屏幕
+    screen.fill(PAPER)
+
+    # 绘制"返回"按钮
+    return_button_rect = pygame.Rect(50, SCREEN_HEIGHT - 50 - difficulty_button_height, 200, difficulty_button_height)
+    if return_button_rect.collidepoint(pygame.mouse.get_pos()):
+        pygame.draw.rect(screen, DARK_BROWN, return_button_rect)
+    else:
+        pygame.draw.rect(screen, BROWN, return_button_rect)
+    # pygame.draw.rect(screen, BROWN, return_button_rect)
+    pygame.draw.rect(screen, PAPER, return_button_rect, 3)
+    font = pygame.font.Font("res/font/simsun.ttc", 24)
+    text = font.render("返回", True, WHITE)
+    text_rect = text.get_rect(center=return_button_rect.center)
+    screen.blit(text, text_rect)
+
+    # 获取所有难度
+    difficulty = list(app_name.keys())
+    # 计算可以显示的难度数量
+    max_difficulty = (SCREEN_HEIGHT - 2 * difficulty_button_height) // (difficulty_button_height + difficulty_button_margin)
+    # 计算总页数
+    total_pages = (len(difficulty) + max_difficulty - 1) // max_difficulty
+
+    # 绘制按钮
+    x, y = SCREEN_WIDTH // 2 - difficulty_button_width // 2, 50
+    app_buttons = []  # 存储改图作者按钮的位置和对应作者名
+    for diff in difficulty[(current_page - 1) * max_difficulty : min(len(difficulty),(current_page * max_difficulty))]:
+        map_button_rect = pygame.Rect(x, y, difficulty_button_width, difficulty_button_height)
+        if map_button_rect.collidepoint(pygame.mouse.get_pos()):
+            pygame.draw.rect(screen, DARK_BROWN, map_button_rect)
+        else:
+            pygame.draw.rect(screen, BROWN, map_button_rect)
+        pygame.draw.rect(screen, PAPER, map_button_rect, 3)
+        font = pygame.font.Font("res/font/simsun.ttc", 18)
+        text = font.render(app_name[diff], True, WHITE)
+        text_rect = text.get_rect(center=map_button_rect.center)
+        screen.blit(text, text_rect)
+        app_buttons.append((map_button_rect, diff))
+        y += difficulty_button_height + difficulty_button_margin
+
+    # 绘制滚动条或下一页按钮
+    if total_pages > 1:
+        scroll_button_width, scroll_button_height = 80, 120
+        scroll_button_margin = 10
+        next_button_rect = pygame.Rect(SCREEN_WIDTH - scroll_button_width - scroll_button_margin*20, SCREEN_HEIGHT - custom_map_button_height*7 - scroll_button_margin, scroll_button_width, scroll_button_height)
+        prev_button_rect = pygame.Rect(scroll_button_margin*20, SCREEN_HEIGHT - custom_map_button_height*7 - scroll_button_margin, scroll_button_width, scroll_button_height)
+        if next_button_rect.collidepoint(pygame.mouse.get_pos()):
+            pygame.draw.rect(screen, LIGHT_GRAY, next_button_rect)
+        else:
+            pygame.draw.rect(screen, ORANGE_PINK, next_button_rect)
+        if prev_button_rect.collidepoint(pygame.mouse.get_pos()):
+            pygame.draw.rect(screen, LIGHT_GRAY, prev_button_rect)
+        else:
+            pygame.draw.rect(screen, ORANGE_PINK, prev_button_rect)
+        pygame.draw.polygon(screen, WHITE, [(next_button_rect.centerx, next_button_rect.centery - 10), (next_button_rect.centerx, next_button_rect.centery + 10), (next_button_rect.centerx + 10, next_button_rect.centery)])
+        pygame.draw.polygon(screen, WHITE, [(prev_button_rect.centerx, prev_button_rect.centery - 10), (prev_button_rect.centerx, prev_button_rect.centery + 10), (prev_button_rect.centerx - 10, prev_button_rect.centery)])
+        pygame.display.flip()
+        return app_buttons, total_pages, next_button_rect, prev_button_rect
+
+    # 更新屏幕显示
+    pygame.display.flip()
+    return app_buttons, total_pages, None, None
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+def get_map_info_text(map_info):
+    # 从map_info字典中提取地图信息
+    # 这里假设map_info字典中包含地图信息的字段
+    return "难度:" + stars_string(map_selection_data["0Official"][0][map_info]["difficulty"]) + "\n\n" + map_selection_data["0Official"][0][map_info]["info"]
+
+def get_custom_map_info_text(author, map):
+    # 从map_info字典中提取地图信息
+    # 这里假设map_info字典中包含地图信息的字段
+    for i, m in enumerate(map_selection_data[author]):
+        if map == next(iter(m.keys())):
+            return map_selection_data[author][i][map]['info']
+
+# 新增变量用于保存信息框矩形
+map_info_box_rect = None
+custom_map_info_box_rect = None
+
+# 绘制信息文本框的函数
+def draw_map_info_box():
+    global map_info_box_rect
+
+    if map_info_box_rect is not None:
+        # 绘制带颜色的矩形背景
+        pygame.draw.rect(screen, BROWN, map_info_box_rect)
+        pygame.draw.rect(screen, PAPER, map_info_box_rect, 3)
+
+        # 绘制信息文本
+        font = pygame.font.Font("res/font/simsun.ttc", 18)
+        lines = map_info_text.split("\n")
+        for i, line in enumerate(lines):
+            text = font.render(line, True, WHITE)
+            text_rect = text.get_rect(x=map_info_box_rect.x + 10, y=map_info_box_rect.y + 10 + i * 20)
+            screen.blit(text, text_rect)
+
+
+# 在绘制函数之外添加一个字典用于保存勾选框的状态
+checkbox_states = {
+    "full_screen": cfg_json["full_screen"],
+    "low_config_mode": cfg_json["low_config_mode"],
+    "display_stat": cfg_json["display_stat"],
+    "monster_records": cfg_json["monster_records"],
+    "v_sync": cfg_json["v_sync"],
+    "show_time": cfg_json["show_time"],
+    "drop_item": cfg_json["drop_item"]
+}
+
+# 增加一个变量来表示下拉菜单是否处于显示状态
+dropdown_menu_active = False
+
+drop_hero_choices = False
+drop_colour_choices = False
+
+music_slider_x = 0
+sound_slider_x = 0
+music_dragging = False
+sound_dragging = False
+music_slider_rect = pygame.Rect(0, 0, 0, 0)
+sound_slider_rect = pygame.Rect(0, 0, 0, 0)
+
+
+def show_hero_name(hero):
+    if hero == "Maomao": return "毛毛"
+    if hero == "Asha": return "阿莎"
+    if hero == "Monkey": return "小悟空"
+    if hero == "Titan": return "泰坦"
+    if hero == "Fox": return "小倩"
+    if hero == "FoxPlus": return "小倩(很多道具)"
+    if hero == "Maria": return "玛丽亚"
+    if hero == "CaiBaozi": return "菜包子(幻制)"
+    if hero == "Xiami": return "小虾米(悠制)"
+    if hero == "Chunli": return "春丽(悠制)"
+    if hero == "Boboli": return "波波丽(悠制)"
+    if hero == "XingZai": return "星仔(悠制)"
+    if hero == "SeaPrince": return "海王子(光影制)"
+    if hero == "SeaPrince_old": return "海王子(旧)(悠制)"
+    if hero == "Naruto": return "火影(光影制)"
+    if hero == "Naruto_old": return "火影(旧)(悠制)"
+    if hero == "Cola": return "可乐(悠制)"
+    if hero == "Nezha": return "哪吒(悠制)"
+    if hero == "Chris": return "克莉丝(悠制)"
+    if hero == "mxfc": return "梦小繁(残冰制)"
+    if hero == "Flandre": return "芙兰朵露(雨制)"
+    if hero == "Remilia": return "蕾米莉亚(雨制)"
+
+    if hero == "Red": return "红色"
+    if hero == "Blue": return "蓝色"
+    if hero == "Yellow": return "黄色"
+    if hero == "Green": return "绿色"
+    if hero == "Pink": return "粉色"
+    if hero == "Orange": return "橙色"
+    if hero == "Purple": return "紫色"
+    if hero == "Black": return "黑色"
+    if hero == "SkyBlue": return "蓝灰色"
+    if hero == "SakuraPink": return "香芋紫"
+    if hero == "ForestGreen": return "森绿色"
+    if hero == "GrassGreen": return "若草色"
+    if hero == "Withered":
+        return "枯叶色"
+    else:
+        return hero
+
+
+def draw_slider(setting_value, slider_x, setting_y):
+    slider_width = 150
+    slider_height = 10
+    slider_rect = pygame.Rect(slider_x, setting_y, slider_width, slider_height)
+
+    # Draw the slider track
+    pygame.draw.rect(screen, LIGHT_GRAY, slider_rect, border_radius=5)
+
+    # Calculate the position of the slider button based on the setting value
+    slider_button_width = 15
+    slider_button_x = slider_x + int((slider_width - slider_button_width) * setting_value)
+    slider_button_rect = pygame.Rect(slider_button_x, setting_y - 5, slider_button_width, slider_height + 10)
+
+    # Draw the slider button
+    pygame.draw.rect(screen, BLACK, slider_button_rect, border_radius=5)
+
+    return slider_button_rect
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+# 设置界面代码
+def draw_game_settings():
+    global cfg_json, is_click_setting, settings_changed, dropdown_menu_active, drop_hero_choices, drop_colour_choices, music_slider_x, sound_slider_x, music_dragging, sound_dragging, music_slider_rect, sound_slider_rect
+
+    screen.fill(PAPER)
+
+    # 加载自定义字体文件
+    font = pygame.font.Font("res/font/simsun.ttc", 24)
+
+    # 标题
+    title_text = "游戏设置"
+    title_surface = font.render(title_text, True, BLACK)
+    title_rect = title_surface.get_rect(center=(SCREEN_WIDTH // 2, 50))
+    screen.blit(title_surface, title_rect)
+
+    # 绘制返回按钮
+    return_button_text = "返回主菜单"
+    return_button_width, return_button_height = 160, 50
+    return_button_rect = pygame.Rect(50, SCREEN_HEIGHT - 50 - return_button_height, return_button_width,
+                                     return_button_height)
+    if return_button_rect.collidepoint(pygame.mouse.get_pos()):
+        pygame.draw.rect(screen, DARK_BROWN, return_button_rect)
+    else:
+        pygame.draw.rect(screen, BROWN, return_button_rect)
+    # pygame.draw.rect(screen, BROWN, return_button_rect)
+    return_text_surface = font.render(return_button_text, True, WHITE)
+    return_text_rect = return_text_surface.get_rect(center=return_button_rect.center)
+    screen.blit(return_text_surface, return_text_rect)
+
+    # 绘制保存设置按钮
+    save_button_text = "保存设置"
+    save_button_width, save_button_height = 150, 50
+    save_button_rect = pygame.Rect(SCREEN_WIDTH - 50 - save_button_width, SCREEN_HEIGHT - 50 - save_button_height,
+                                   save_button_width, save_button_height)
+    if save_button_rect.collidepoint(pygame.mouse.get_pos()):
+        pygame.draw.rect(screen, DARK_BROWN, save_button_rect)
+    else:
+        pygame.draw.rect(screen, BROWN, save_button_rect)
+    # pygame.draw.rect(screen, BROWN, save_button_rect)
+    save_text_surface = font.render(save_button_text, True, WHITE)
+    save_text_rect = save_text_surface.get_rect(center=save_button_rect.center)
+    screen.blit(save_text_surface, save_text_rect)
+
+    # 绘制设置项
+    setting_margin = 50
+    setting_y = 120
+    setting_height = 30
+
+    # 设置项的名称和取值范围
+    settings = [
+        {"name": "your_hero", "label": "角色:",
+         "choices": [
+             "Maomao", "Asha", "Monkey", "Titan", "Fox", "FoxPlus", "Maria", "CaiBaozi", "Xiami", "Chunli", "Boboli",
+             "XingZai", "SeaPrince_old", "Naruto_old", "Cola", "SeaPrince", "Naruto", "Nezha", "Chris",
+             "mxfc", "Flandre", "Remilia"
+         ]},
+        {"name": "your_character_color", "label": "角色颜色:",
+         "choices": [
+             "Red", "Blue", "Yellow", "Green", "Pink", "Orange", "Purple", "Black", "SkyBlue", "SakuraPink",
+             "ForestGreen", "GrassGreen", "Withered"
+         ]},
+        {"name": "music_volume", "label": "音乐音量:", "min_value": 0, "max_value": 1},
+        {"name": "sound_volume", "label": "音效音量:", "min_value": 0, "max_value": 1},
+        {"name": "full_screen", "label": "全屏模式(有颜色表示ON/空白表示OFF):", "type": "checkbox"},
+        {"name": "low_config_mode", "label": "低配模式(推荐打开):", "type": "checkbox"},
+        {"name": "display_stat", "label": "显示数据(推荐打开):", "type": "checkbox"},
+        {"name": "monster_records", "label": "怪物统计(只有玩家死亡和通关时会保存记录):", "type": "checkbox"},
+        {"name": "v_sync", "label": "垂直同步(除低配机外推荐打开):", "type": "checkbox"},
+        {"name": "show_time", "label": "显示时间特效(电脑不卡就开):", "type": "checkbox"},
+        {"name": "drop_item", "label": "炸砖掉道具(电脑不卡可选择开):", "type": "checkbox"}
+    ]
+
+    # 绘制每个设置项
+    for setting in settings:
+        setting_name = setting["name"]
+        setting_label = setting["label"]
+        setting_value = cfg_json[setting_name]
+
+        # 绘制标签
+        label_surface = font.render(setting_label, True, BLACK)
+        label_rect = label_surface.get_rect(topleft=(setting_margin, setting_y))
+        screen.blit(label_surface, label_rect)
+
+        # 绘制输入框或下拉列表或勾选框
+
+        if setting["name"] == "music_volume":
+            music_slider_x = SCREEN_WIDTH - setting_margin - 150
+            music_slider_rect = draw_slider(setting_value, music_slider_x, setting_y)
+        if setting["name"] == "sound_volume":
+            sound_slider_x = SCREEN_WIDTH - setting_margin - 150
+            sound_slider_rect = draw_slider(setting_value, sound_slider_x, setting_y)
+
+        if "choices" in setting:
+            choices = setting["choices"]
+            dropdown_width = 150
+            dropdown_height = 30
+            dropdown_rect = pygame.Rect(SCREEN_WIDTH - setting_margin - dropdown_width, setting_y, dropdown_width,
+                                        dropdown_height)
+            pygame.draw.rect(screen, PAPER, dropdown_rect, border_radius=5)
+            pygame.draw.rect(screen, BLACK, dropdown_rect, 2)
+
+            # 绘制当前值
+            value_surface = font.render(show_hero_name(setting_value), True, BLACK)
+            value_rect = value_surface.get_rect(center=dropdown_rect.center)
+            screen.blit(value_surface, value_rect)
+
+            # 绘制下拉箭头
+            arrow_surface = font.render("▼", True, BLACK)
+            arrow_rect = arrow_surface.get_rect(midright=(dropdown_rect.right - 5, dropdown_rect.centery))
+            screen.blit(arrow_surface, arrow_rect)
+
+            # 处理下拉按钮点击事件
+            if dropdown_rect.collidepoint(pygame.mouse.get_pos()):
+                if pygame.mouse.get_pressed()[0] and not is_click_setting:  # Left mouse button clicked
+
+                    # dropdown_menu_active = not dropdown_menu_active
+                    if setting["name"] == "your_hero":
+                        if drop_colour_choices:
+                            dropdown_menu_active = True
+                            drop_colour_choices = False
+                        else:
+                            dropdown_menu_active = not dropdown_menu_active
+                        drop_hero_choices = not drop_hero_choices
+                    if setting["name"] == "your_character_color":
+                        if drop_hero_choices:
+                            dropdown_menu_active = True
+                            drop_hero_choices = False
+                        else:
+                            dropdown_menu_active = not dropdown_menu_active
+                        drop_colour_choices = not drop_colour_choices
+                    is_click_setting = True
+
+
+        elif setting.get("type") == "checkbox":
+            checkbox_size = 25
+            checkbox_rect = pygame.Rect(SCREEN_WIDTH - setting_margin - checkbox_size, setting_y, checkbox_size,
+                                        checkbox_size)
+            pygame.draw.rect(screen, WHITE, checkbox_rect, border_radius=5)
+            pygame.draw.rect(screen, BLACK, checkbox_rect, 2)
+
+            # 修改勾选状态的绘制
+            if checkbox_states[setting_name]:
+                checkbox_rect = pygame.Rect(SCREEN_WIDTH - setting_margin - checkbox_size, setting_y, checkbox_size,
+                                            checkbox_size)
+                pygame.draw.rect(screen, BLACK, checkbox_rect, 2)
+
+                # 绘制实心正方形,使其与勾选框大小相同且在其中居中
+                pygame.draw.rect(screen, BROWN, checkbox_rect)  # 绘制实心正方形
+
+            # 处理勾选框的点击事件
+            if checkbox_rect.collidepoint(pygame.mouse.get_pos()):
+                if pygame.mouse.get_pressed()[0] and not is_click_setting:  # Left mouse button clicked
+                    settings_changed = True
+                    is_click_setting = True
+                    checkbox_states[setting_name] = not checkbox_states[setting_name]
+                    cfg_json[setting_name] = not cfg_json[setting_name]
+
+        setting_y += setting_height + 10
+
+    # 在绘制下拉选项的循环之外定义一个变量来追踪选中的选项
+    selected_choice = None
+
+    # 绘制下拉选项(只有在下拉菜单处于显示状态时才进行绘制)
+    if dropdown_menu_active:
+        for setting in settings:
+            if "choices" in setting:
+                if (setting["name"] == "your_hero" and drop_hero_choices) or (setting["name"] == "your_character_color" and drop_colour_choices):
+
+                    choices = setting["choices"]
+                    dropdown_width = 180
+                    dropdown_height = 30
+                    num_per_col = 10
+                    dropdown_menu_height = len(choices) * dropdown_height + 10
+
+                    if setting["name"] == "your_hero":
+                        setting_y = 110
+                    if setting["name"] == "your_character_color":
+                        setting_y = 150
+
+                    dropdown_menu_y = setting_y + dropdown_height
+                    for i in range(len(choices)):
+                        choice_rect = pygame.Rect(
+                            SCREEN_WIDTH - setting_margin - (2 + i//num_per_col) * dropdown_width - 2 * (i//num_per_col) + 20,
+                            dropdown_menu_y + (i % num_per_col - 1) * dropdown_height + 10,
+                            dropdown_width,
+                            dropdown_height
+                        )
+
+                        # Change the color of the option when the mouse hovers over it
+                        if choice_rect.collidepoint(pygame.mouse.get_pos()):
+                            pygame.draw.rect(screen, LIGHT_GRAY, choice_rect, border_radius=5)
+                        else:
+                            pygame.draw.rect(screen, LAVENDER_BLUE, choice_rect, border_radius=5)
+
+                        pygame.draw.rect(screen, BLACK, choice_rect, 2)
+
+                        # 绘制选项文本
+                        choice_text = font.render(show_hero_name(choices[i]), True, BLACK)
+                        choice_text_rect = choice_text.get_rect(center=choice_rect.center)
+                        screen.blit(choice_text, choice_text_rect)
+
+                        # 处理选项列表的点击事件
+                        if choice_rect.collidepoint(pygame.mouse.get_pos()):
+                            if pygame.mouse.get_pressed()[0] and not is_click_setting:  # Left mouse button clicked
+                                # 更新选中的选项
+                                selected_choice = choices[i]
+                                is_click_setting = True
+                                break
+
+                    if selected_choice is not None:
+                        cfg_json[setting["name"]] = selected_choice
+                        dropdown_menu_active = False
+                        drop_hero_choices = False
+                        drop_colour_choices = False
+                        settings_changed = True
+                        break
+    # 更新屏幕显示
+    pygame.display.flip()
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+# 主菜单循环
+def main_menu_loop():
+    global buttons, current_screen, mouse_left_button_down, mouse_left_button_up, is_click_setting, settings_changed, cfg_json, music_slider_x, sound_slider_x, music_dragging, sound_dragging, music_slider_rect, sound_slider_rect, achievement_process, \
+        show_map_info, show_map_name, leave_map_info, custom_map_buttons, current_page, difficulty_buttons, app_buttons, random_map_type, app_process, launcher_process
+
+    current_screen = "main_menu"
+
+    running = True
+    while running:
+        for event in pygame.event.get():
+            if event.type == pygame.QUIT:
+                running = False
+            elif event.type == pygame.KEYDOWN:
+                if event.key == pygame.K_ESCAPE:
+                    running = False
+
+            if event.type == pygame.MOUSEMOTION and mouse_left_button_down and not mouse_left_button_up and current_screen == "game_settings":
+                setting_margin = 50
+                if music_dragging:
+                    # Update the music volume setting based on the slider position
+                    # print(event.pos[0], SCREEN_WIDTH - setting_margin - 150)
+                    music_slider_x = round(max(min(event.pos[0], SCREEN_WIDTH - setting_margin),
+                                               SCREEN_WIDTH - setting_margin - 150) / 15) * 15
+                    setting_value = round((max(min(event.pos[0], SCREEN_WIDTH - setting_margin),
+                                               SCREEN_WIDTH - setting_margin - 150) - (
+                                                       SCREEN_WIDTH - setting_margin - 150)) / 150, 1)
+                    cfg_json["music_volume"] = max(0.0, min(1.0, setting_value))
+                    settings_changed = True
+                    # print("music=",setting_value)
+                if sound_dragging:
+                    # Update the sound volume setting based on the slider position
+                    music_slider_x = round(max(min(event.pos[0], SCREEN_WIDTH - setting_margin),
+                                               SCREEN_WIDTH - setting_margin - 150) / 15) * 15
+                    setting_value = round((max(min(event.pos[0], SCREEN_WIDTH - setting_margin),
+                                               SCREEN_WIDTH - setting_margin - 150) - (
+                                                       SCREEN_WIDTH - setting_margin - 150)) / 150, 1)
+                    cfg_json["sound_volume"] = max(0.0, min(1.0, setting_value))
+                    settings_changed = True
+                    # print("sound=",setting_value)
+
+            if event.type == pygame.MOUSEMOTION and current_screen == "original_maps_submenu":
+                for button_rect, map_info in map_buttons:
+                    if button_rect.collidepoint(event.pos):
+                        map_info_text = get_map_info_text(map_info)  # 获取信息文本
+                        # print("collode button", map_info, map_info_text)
+                        if leave_map_info:
+                            show_map_info = True
+                        leave_map_info = False
+                        show_map_name = map_info_text
+
+                # 如果鼠标不在按钮上方,则隐藏信息框
+                if not any(button_rect.collidepoint(event.pos) for button_rect, _ in map_buttons):
+                    if show_map_info:
+                        # print("hide")
+                        map_info_box_rect = None
+                        map_info_text = ""
+                        show_map_info = False
+                        show_map_name = None
+                        leave_map_info = True
+
+
+            if event.type == pygame.MOUSEMOTION and current_screen == "custom_maps":
+                for button_rect, map in custom_map_buttons:
+                    if button_rect.collidepoint(event.pos):
+                        map_info_text = get_custom_map_info_text(author_chosen, map)  # 获取信息文本
+                        # print(map, map_info_text)
+                        if leave_map_info:
+                            show_map_info = True
+                        leave_map_info = False
+                        show_map_name = map_info_text
+                # 如果鼠标不在按钮上方,则隐藏信息框
+                if not any(button_rect.collidepoint(event.pos) for button_rect, _ in custom_map_buttons):
+                    if show_map_info:
+                        map_info_box_rect = None
+                        map_info_text = ""
+                        show_map_info = False
+                        show_map_name = None
+                        leave_map_info = True
+
+
+            elif event.type == pygame.MOUSEBUTTONDOWN:
+                # 更新鼠标左键按下的状态
+                if event.button == 1:
+                    mouse_left_button_down = True
+                    mouse_left_button_up = False
+                    if music_slider_rect.collidepoint(event.pos):
+                        music_dragging = True
+                    if sound_slider_rect.collidepoint(event.pos):
+                        sound_dragging = True
+                    # print("down", mouse_left_button_down, mouse_left_button_up)
+                    effect_sound = "res/sound/uiLeave.wav"
+                    try:
+                        pygame.mixer.Sound(effect_sound).play()
+                    except Exception as e:
+                        print(e)
+            elif event.type == pygame.MOUSEBUTTONUP:
+                # 更新鼠标左键按下的状态
+                if event.button == 1:
+                    mouse_left_button_down = False
+                    mouse_left_button_up = True
+                    is_click_setting = False
+                    # Stop dragging when the user releases the mouse button
+                    music_dragging = False
+                    sound_dragging = False
+                    # print("up", mouse_left_button_down, mouse_left_button_up)
+
+                # 在这里处理按钮点击事件
+                if current_screen == "main_menu":
+                    for button_text, (x, y) in buttons:
+                        button_rect = pygame.Rect(x, y, button_width, button_height)
+                        if button_rect.collidepoint(event.pos):
+                            try:
+                                pygame.mixer.music.stop()
+                            except Exception as e:
+                                print(e)
+                            print(button_text, "直接开始(当前关卡:" + show_official_map_name(cfg_json["map_set"]) + ")")
+                            if button_text == "直接开始(当前关卡:" + show_official_map_name(cfg_json["map_set"]) + ")":
+                                # 处理直接开始按钮点击事件
+                                print("ready_launch")
+                                if launcher_process is None:
+                                    launch_game()
+                            elif button_text == "选择关卡":
+                                # 处理选择关卡按钮点击事件
+                                current_screen = "map_selection_menu"
+                                draw_map_selection_menu()
+                            # elif button_text == "游戏设置":
+                            # 处理游戏设置按钮点击事件
+                            # current_screen = "game_settings"
+                            # draw_game_settings()
+                            elif button_text == "关于作者":
+                                # 处理作者信息按钮点击事件
+                                current_screen = "author_info"
+                                draw_author_info()
+                    for button_text, (x, y) in buttons2:
+                        button_rect = pygame.Rect(x, y, 180, 100)
+                        if button_rect.collidepoint(event.pos):
+                            if button_text == "成就记录":
+                                # 处理直接开始按钮点击事件
+                                if achievement_process is None:
+                                    achievement()
+                            elif button_text == "游戏设置":
+                                # 处理游戏设置按钮点击事件
+                                current_screen = "game_settings"
+                                draw_game_settings()
+                            elif button_text == "操作帮助":
+                                # 处理作者信息按钮点击事件
+                                current_screen = "helper_info"
+                                draw_helper_info()
+
+
+
+                elif current_screen == "author_info":
+                    # 在作者信息界面点击返回按钮
+                    return_button_width, return_button_height = 200, 60
+                    return_button_rect = pygame.Rect(50, SCREEN_HEIGHT - 50 - return_button_height, return_button_width,
+                                                     return_button_height)
+                    if return_button_rect.collidepoint(event.pos):
+                        current_screen = "main_menu"
+                        draw_menu()
+
+
+                elif current_screen == "helper_info":
+                    # 在作者信息界面点击返回按钮
+                    return_button_width, return_button_height = 200, 60
+                    return_button_rect = pygame.Rect(50, SCREEN_HEIGHT - 50 - return_button_height, return_button_width,
+                                                     return_button_height)
+                    if return_button_rect.collidepoint(event.pos):
+                        current_screen = "main_menu"
+                        draw_menu()
+
+
+                elif current_screen == "game_settings":
+                    # 在游戏设置界面点击返回按钮
+                    return_button_width, return_button_height = 160, 50
+                    return_button_rect = pygame.Rect(50, SCREEN_HEIGHT - 50 - return_button_height, return_button_width,
+                                                     return_button_height)
+                    if return_button_rect.collidepoint(event.pos):
+                        current_screen = "main_menu"
+                        draw_menu()
+                    # 处理保存设置按钮点击事件
+                    save_button_width, save_button_height = 150, 50
+                    save_button_rect = pygame.Rect(SCREEN_WIDTH - 50 - save_button_width,
+                                                   SCREEN_HEIGHT - 50 - save_button_height, save_button_width,
+                                                   save_button_height)
+                    if save_button_rect.collidepoint(event.pos) and settings_changed:
+                        # 保存设置到config.json文件中
+                        try:
+                            with open("config.json", "w", encoding="utf-8") as f:
+                                json.dump(cfg_json, f, indent=4, ensure_ascii=False)
+                        except:
+                            with open("config.json", "w", encoding="utf-8_sig") as f:
+                                json.dump(cfg_json, f, indent=4, ensure_ascii=False)
+                        # 重置设置改变的标记
+                        settings_changed = False
+                        # 返回主菜单
+                        current_screen = "main_menu"
+                        draw_menu()
+
+
+
+                elif current_screen == "map_selection_menu":
+                    # 在作者信息界面点击返回按钮
+                    return_button_width, return_button_height = 300, 60
+                    return_button_rect = pygame.Rect(250, SCREEN_HEIGHT - 150 - return_button_height,
+                                                     return_button_width, return_button_height)
+                    if return_button_rect.collidepoint(event.pos):
+                        current_screen = "main_menu"
+                        draw_menu()
+
+                    original_maps_button_rect = pygame.Rect(250, 150, return_button_width, return_button_height)
+                    if original_maps_button_rect.collidepoint(event.pos):
+                        current_screen = "original_maps_submenu"
+                        draw_original_maps_submenu()
+
+                    custom_maps_button_rect = pygame.Rect(250, 150 + map_button_height + map_button_margin, return_button_width, return_button_height)
+                    if custom_maps_button_rect.collidepoint(event.pos):
+                        current_screen = "custom_maps_submenu"
+                        current_page = 1
+                        draw_custom_maps_submenu()
+
+                    custom_apps_button_rect = pygame.Rect(250, 150 + 2*map_button_height + 2*map_button_margin, return_button_width, return_button_height)
+                    if custom_apps_button_rect.collidepoint(event.pos):
+                        current_screen = "apps"
+                        current_page = 1
+                        draw_custom_apps()
+
+
+
+                elif current_screen == "original_maps_submenu":
+                    # 在作者信息界面点击返回按钮
+                    return_button_width, return_button_height = 200, 60
+                    return_button_rect = pygame.Rect(50, SCREEN_HEIGHT - 50 - return_button_height, return_button_width,
+                                                     return_button_height)
+                    if return_button_rect.collidepoint(event.pos):
+                        current_screen = "map_selection_menu"
+                        draw_map_selection_menu()
+                    # 绘制信息文本框
+                    draw_map_info_box()
+                    for button_rect, map_info in map_buttons:
+                        if button_rect.collidepoint(event.pos):
+                            handle_map_selection_click(map_info)
+                            try:
+                                with open("config.json", "w", encoding="utf-8") as f:
+                                    json.dump(cfg_json, f, indent=4, ensure_ascii=False)
+                            except:
+                                with open("config.json", "w", encoding="utf-8_sig") as f:
+                                    json.dump(cfg_json, f, indent=4, ensure_ascii=False)
+                            buttons = [("直接开始(当前关卡:" + show_official_map_name(cfg_json["map_set"]) + ")", (SCREEN_WIDTH // 2 - button_width // 2, 100)),("选择关卡", (SCREEN_WIDTH // 2 - button_width // 2, 100 + button_height + button_margin)),("关于作者", (SCREEN_WIDTH // 2 - button_width // 2, 100 + (button_height + button_margin) * 3)),]
+                            current_screen = "main_menu"
+                            draw_menu()
+                            break
+
+
+
+
+                elif current_screen == "custom_maps_submenu":
+                    custom_map_buttons, total_pages, next_button_rect, prev_button_rect = draw_custom_maps_submenu()
+                    # 在作者信息界面点击返回按钮
+                    return_button_width, return_button_height = 200, 60
+                    return_button_rect = pygame.Rect(50, SCREEN_HEIGHT - 50 - return_button_height, return_button_width,
+                                                     return_button_height)
+                    if return_button_rect.collidepoint(event.pos):
+                        current_screen = "map_selection_menu"
+                        draw_map_selection_menu()
+                        break
+
+                    # 检查是否点击了改图作者按钮
+                    # custom_authors[(current_page - 1) * max_custom_authors : min(len(custom_authors),(current_page * max_custom_authors))]
+                    for author_button_rect, author in custom_map_buttons:
+                        if author_button_rect.collidepoint(event.pos):
+                            total_pages = 1
+                            show_map_name = None
+                            author_chosen = author
+                            draw_custom_maps(author_chosen)
+                            current_screen = "custom_maps"
+                            current_page = 1
+                            break
+                            # return  # 退出改图子菜单循环
+
+                    # 检查是否点击了下一页按钮
+                    if total_pages > 1 and next_button_rect.collidepoint(event.pos):
+                        current_page = (current_page % total_pages) + 1
+                        # print(current_page)
+                        draw_custom_maps_submenu()  # 重新绘制改图子菜单以显示下一页
+
+                    # 检查是否点击了上一页按钮
+                    if total_pages > 1 and prev_button_rect.collidepoint(event.pos):
+                        current_page = (current_page - 2 + total_pages) % total_pages + 1
+                        # print(current_page)
+                        draw_custom_maps_submenu()  # 重新绘制改图子菜单以显示上一页
+
+
+
+
+                elif current_screen == "custom_maps":
+                    custom_map_buttons, total_pages, next_button_rect, prev_button_rect = draw_custom_maps(author_chosen)
+                    # 在作者信息界面点击返回按钮
+                    return_button_width, return_button_height = 200, 60
+                    return_button_rect = pygame.Rect(50, SCREEN_HEIGHT - 50 - return_button_height, return_button_width,
+                                                     return_button_height)
+                    if return_button_rect.collidepoint(event.pos):
+                        current_page = 1
+                        current_screen = "custom_maps_submenu"
+                        draw_custom_maps_submenu()
+                        break
+
+                    # 检查是否点击了改图作者按钮
+                    # custom_authors[(current_page - 1) * max_custom_authors : min(len(custom_authors),(current_page * max_custom_authors))]
+                    for map_button_rect, map in custom_map_buttons:
+                        if map_button_rect.collidepoint(event.pos):
+                            current_page = 1
+                            current_screen = "difficulties"
+                            map_chosen = map
+                            draw_custom_difficulty(author_chosen, map_chosen)
+                            break
+                            # current_screen = "custom_maps"
+                            # draw_custom_maps(author)  # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!下一步写这个函数以打开每个改图作者的子界面
+                            # return  # 退出改图子菜单循环
+
+                    # 检查是否点击了下一页按钮
+                    if total_pages > 1 and next_button_rect.collidepoint(event.pos):
+                        current_page = (current_page % total_pages) + 1
+                        # print(current_page)
+                        draw_custom_maps(author_chosen)  # 重新绘制改图子菜单以显示下一页
+
+                    # 检查是否点击了上一页按钮
+                    if total_pages > 1 and prev_button_rect.collidepoint(event.pos):
+                        current_page = (current_page - 2 + total_pages) % total_pages + 1
+                        # print(current_page)
+                        draw_custom_maps(author_chosen)  # 重新绘制改图子菜单以显示上一页
+
+
+
+
+                elif current_screen == "difficulties":
+                    difficulty_buttons, total_pages, next_button_rect, prev_button_rect = draw_custom_difficulty(author_chosen, map_chosen)
+                    # 在作者信息界面点击返回按钮
+                    return_button_width, return_button_height = 280, 70
+                    return_button_rect = pygame.Rect(50, SCREEN_HEIGHT - 50 - return_button_height, return_button_width,
+                                                     return_button_height)
+                    if return_button_rect.collidepoint(event.pos):
+                        # print("碰撞返回按钮"+datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
+                        current_page = 1
+                        current_screen = "custom_maps"
+                        # print("切屏幕名"+datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
+                        draw_custom_maps(author_chosen)
+                        # print("显示新屏幕"+datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
+                        break
+
+                    # 检查是否点击了改图作者按钮
+                    # custom_authors[(current_page - 1) * max_custom_authors : min(len(custom_authors),(current_page * max_custom_authors))]
+                    for map_button_rect, diff in difficulty_buttons:
+                        if map_button_rect.collidepoint(event.pos):
+                            handle_map_selection_click(diff['map_name'])
+                            try:
+                                with open("config.json", "w", encoding="utf-8") as f:
+                                    json.dump(cfg_json, f, indent=4, ensure_ascii=False)
+                            except:
+                                with open("config.json", "w", encoding="utf-8_sig") as f:
+                                    json.dump(cfg_json, f, indent=4, ensure_ascii=False)
+                            buttons = [("直接开始(当前关卡:" + diff['difficulty'] + ")", (SCREEN_WIDTH // 2 - button_width // 2, 100)),("选择关卡", (SCREEN_WIDTH // 2 - button_width // 2, 100 + button_height + button_margin)),("关于作者", (SCREEN_WIDTH // 2 - button_width // 2, 100 + (button_height + button_margin) * 3))]
+                            current_screen = "main_menu"
+                            draw_menu()
+                            break
+
+
+                    # 检查是否点击了下一页按钮
+                    if total_pages > 1 and next_button_rect.collidepoint(event.pos):
+                        current_page = (current_page % total_pages) + 1
+                        # print(current_page)
+                        draw_custom_difficulty(author_chosen, map_chosen)  # 重新绘制改图子菜单以显示下一页
+
+                    # 检查是否点击了上一页按钮
+                    if total_pages > 1 and prev_button_rect.collidepoint(event.pos):
+                        current_page = (current_page - 2 + total_pages) % total_pages + 1
+                        # print(current_page)
+                        draw_custom_difficulty(author_chosen, map_chosen)  # 重新绘制改图子菜单以显示上一页
+
+
+
+                elif current_screen == "apps":
+                    app_buttons, total_pages, next_button_rect, prev_button_rect = draw_custom_apps()
+                    # 在作者信息界面点击返回按钮
+                    return_button_width, return_button_height = 200, 70
+                    return_button_rect = pygame.Rect(50, SCREEN_HEIGHT - 50 - return_button_height, return_button_width,
+                                                     return_button_height)
+                    if return_button_rect.collidepoint(event.pos):
+                        # print("碰撞返回按钮"+datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
+                        current_page = 1
+                        current_screen = "map_selection_menu"
+                        # print("切屏幕名"+datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
+                        draw_map_selection_menu()
+                        launcher_process = None
+                        app_process = None
+                        try:
+                            with open("config.json", encoding="utf-8") as f:
+                                cfg_json = json.load(f)
+                        except:
+                            with open("config.json", encoding="utf-8_sig") as f:
+                                cfg_json = json.load(f)
+                        buttons = [("直接开始(当前关卡:" + show_official_map_name(cfg_json["map_set"]) + ")", (SCREEN_WIDTH // 2 - button_width // 2, 100)),("选择关卡", (SCREEN_WIDTH // 2 - button_width // 2, 100 + button_height + button_margin)),("关于作者", (SCREEN_WIDTH // 2 - button_width // 2, 100 + (button_height + button_margin) * 3))]
+                        # print("显示新屏幕"+datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
+                        break
+
+                    # 检查是否点击了改图作者按钮
+                    # custom_authors[(current_page - 1) * max_custom_authors : min(len(custom_authors),(current_page * max_custom_authors))]
+                    for map_button_rect, diff in app_buttons:
+                        if map_button_rect.collidepoint(event.pos):
+                            random_map_type = diff
+                            launch_app(diff)
+                            break
+
+                    # 检查是否点击了下一页按钮
+                    if total_pages > 1 and next_button_rect.collidepoint(event.pos):
+                        current_page = (current_page % total_pages) + 1
+                        draw_custom_apps()
+
+                    # 检查是否点击了上一页按钮
+                    if total_pages > 1 and prev_button_rect.collidepoint(event.pos):
+                        current_page = (current_page - 2 + total_pages) % total_pages + 1
+                        draw_custom_apps()
+
+
+        if current_screen == "main_menu":
+            # 绘制主菜单界面
+            draw_menu()
+        elif current_screen == "game_settings":
+            # 绘制游戏设置界面
+            draw_game_settings()
+        elif current_screen == "author_info":
+            # 绘制作者信息界面
+            draw_author_info()
+        elif current_screen == "map_selection_menu":
+            # 处理选图菜单
+            draw_map_selection_menu()
+        elif current_screen == "original_maps_submenu":
+            # 处理原图子菜单
+            draw_original_maps_submenu()
+        elif current_screen == "custom_maps_submenu":
+            # 处理改图子菜单
+            custom_map_buttons, total_pages, next_button_rect, prev_button_rect = draw_custom_maps_submenu()
+            draw_custom_maps_submenu()
+        elif current_screen == "custom_maps":
+            # 处理具体作者改图
+            custom_map_buttons, total_pages, next_button_rect, prev_button_rect = draw_custom_maps(author_chosen)
+            draw_custom_maps(author_chosen)
+        elif current_screen == "difficulties":
+            # 处理具体改图具体难度
+            difficulty_buttons, total_pages, next_button_rect, prev_button_rect = draw_custom_difficulty(author_chosen, map_chosen)
+            draw_custom_difficulty(author_chosen, map_chosen)
+        elif current_screen == "apps":
+            # 处理具体改图具体难度
+            app_buttons, total_pages, next_button_rect, prev_button_rect = draw_custom_apps()
+            draw_custom_apps()
+
+        # 更新屏幕显示
+        pygame.display.flip()
+
+
+    pygame.quit()
+
+
+# 地图选择循环
+def map_selection_loop(map_selection, selected_author):
+    running = True
+    selected_map = None
+    while running:
+        for event in pygame.event.get():
+            if event.type == pygame.QUIT:
+                running = False
+            elif event.type == pygame.KEYDOWN:
+                if event.key == pygame.K_ESCAPE:
+                    running = False
+            elif event.type == pygame.MOUSEBUTTONDOWN:
+                # 检查是否点击了任意一个地图按钮
+                for button_rect, map_info in map_buttons:
+                    if button_rect.collidepoint(event.pos):
+                        handle_map_selection_click(map_info)
+                        return  # 返回到上一个界面(主菜单或原图子菜单)
+
+        # draw_map_selection(map_selection, selected_author, selected_map)
+        pygame.display.flip()
+
+    pygame.quit()
+
+
+if __name__ == "__main__":
+    # 读取地图选择数据
+    map_selection_data = read_map_selection()
+
+    # 运行主菜单循环
+    # 定义按钮的外观
+    button_width, button_height = 600, 100
+    button_margin = 20
+
+    # 定义按钮的文本和位置
+    buttons = [
+        ("直接开始(当前关卡:" + show_official_map_name(cfg_json["map_set"]) + ")", (SCREEN_WIDTH // 2 - button_width // 2, 100)),
+        ("选择关卡", (SCREEN_WIDTH // 2 - button_width // 2, 100 + button_height + button_margin)),
+        # ("游戏设置", (SCREEN_WIDTH // 2 - button_width // 2, 100 + (button_height + button_margin) * 2)),
+        ("关于作者", (SCREEN_WIDTH // 2 - button_width // 2, 100 + (button_height + button_margin) * 3)),
+    ]
+
+    buttons2 = [
+        ("游戏设置", (SCREEN_WIDTH // 2 - button_width // 2, 100 + (button_height + button_margin) * 2)),
+        ("成就记录", (SCREEN_WIDTH // 2 - button_width // 2 + 210, 100 + (button_height + button_margin) * 2)),
+        ("操作帮助", (SCREEN_WIDTH // 2 - button_width // 2 + 210 * 2, 100 + (button_height + button_margin) * 2))
+    ]
+    main_menu_loop()

Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików