From 61d61dee0905aa19008674ee98f7ba3e02455a61 Mon Sep 17 00:00:00 2001 From: KimgiaiiWuyi <444835641@qq.com> Date: Sun, 6 Nov 2022 22:51:08 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20=E5=A2=9E=E5=8A=A0=E5=88=AB?= =?UTF-8?q?=E5=90=8D=E6=9F=A5=E6=89=BE=E8=B5=84=E6=BA=90=E7=82=B9=E7=9A=84?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitmodules | 2 +- .../GetMapImage/get_map_image.py | 18 ++++++++++++++++++ .../GetMapImage/map.yaml | 5 +++++ 3 files changed, 24 insertions(+), 1 deletion(-) rename map.yaml => fastapi_genshin_map/GetMapImage/map.yaml (99%) diff --git a/.gitmodules b/.gitmodules index 9571502..6610a2b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ -[submodule "fastapi_genshin_map/GenshinMap"] +[submodule "fastapi_genshin_map/GetMapImage/GenshinMap"] path = fastapi_genshin_map/GetMapImage/GenshinMap url = https://github.com/MingxuanGame/GenshinMap.git diff --git a/fastapi_genshin_map/GetMapImage/get_map_image.py b/fastapi_genshin_map/GetMapImage/get_map_image.py index 7941933..e88a4a0 100644 --- a/fastapi_genshin_map/GetMapImage/get_map_image.py +++ b/fastapi_genshin_map/GetMapImage/get_map_image.py @@ -4,6 +4,8 @@ from pathlib import Path from time import time from typing import Optional, Union +import yaml + from fastapi import APIRouter, HTTPException, Query from fastapi.responses import FileResponse, StreamingResponse from PIL import Image @@ -21,6 +23,8 @@ CHASM_PATH = MAP / 'chasm.png' ENKANOMIYA_PATH = MAP / 'enkanomiya.png' TEYVAT_PATH = MAP / 'teyvat.png' +with open(Path(__file__).parent / 'map.yaml', 'r', encoding='utf-8') as ymlfile: + resource_aliases = yaml.load(ymlfile, Loader=yaml.SafeLoader) MAP_ID_DICT = { '2': models.MapID.teyvat, # 提瓦特 @@ -75,6 +79,13 @@ async def get_map_by_point( is_cluster: bool = False, ): req_id = random.randint(10000, 99999) + # 判断别名 + for m in resource_aliases: + for a in resource_aliases[m]: + for r in resource_aliases[m][a]: + if resource_name == r: + resource_name = a + prefix = f'>> [请求序列:{req_id}]' logger.info(f'{prefix} 收到资源点访问请求! [资源名称] {resource_name} [地图ID] {map_id}') ERROR = { @@ -168,6 +179,13 @@ async def get_map_by_point( lt_point = group_point[0][0] rb_point = group_point[0][1] + # 增加裁切长宽 + x = rb_point[0] - lt_point[0] + y = rb_point[1] - lt_point[1] + if x < 500 or y < 500: + lt_point = models.XYPoint(lt_point.x - 400, lt_point.y - 400) + rb_point = models.XYPoint(rb_point.x + 400, rb_point.y + 400) + # 开始裁切 genshin_map = genshin_map.crop( (int(lt_point.x), int(lt_point.y), int(rb_point.x), int(rb_point.y)) diff --git a/map.yaml b/fastapi_genshin_map/GetMapImage/map.yaml similarity index 99% rename from map.yaml rename to fastapi_genshin_map/GetMapImage/map.yaml index d3a3a61..2f5f282 100644 --- a/map.yaml +++ b/fastapi_genshin_map/GetMapImage/map.yaml @@ -305,8 +305,13 @@ 劫波莲: - 劫波莲 - 多莉突破材料 + - 纳西妲突破材料 + - 草神突破材料 + - 羽毛球突破材料 + - 财迷突破材料 树王圣体菇: - 树王圣体菇 + - 树菇 - 科莱突破材料 帕蒂沙兰: - 帕蒂沙兰