增加别名查找资源点的功能

This commit is contained in:
KimgiaiiWuyi 2022-11-06 22:51:08 +08:00
parent 886d0ba362
commit 61d61dee09
3 changed files with 24 additions and 1 deletions

2
.gitmodules vendored
View File

@ -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

View File

@ -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))

View File

@ -305,8 +305,13 @@
劫波莲:
- 劫波莲
- 多莉突破材料
- 纳西妲突破材料
- 草神突破材料
- 羽毛球突破材料
- 财迷突破材料
树王圣体菇:
- 树王圣体菇
- 树菇
- 科莱突破材料
帕蒂沙兰:
- 帕蒂沙兰