完善显示用户农场图片,优化部分JSON

This commit is contained in:
2025-03-19 01:16:08 +08:00
parent 2bf5ab8052
commit ca6eb3343f
9 changed files with 335 additions and 112 deletions
+9 -9
View File
@@ -1,5 +1,3 @@
from ast import arg
from zhenxun.services.log import logger
from zhenxun.utils._build_image import BuildImage
@@ -19,24 +17,26 @@ class CDrawImageManager:
Returns:
bytes: 返回绘制结果
"""
# soilNumber = await self.m_pSql.getUserLevelByUid(uid)
soilNumber = 1
soilNumber = await g_pSqlManager.getUserLevelByUid(uid)
img = BuildImage(background=g_sResourcePath / "background/background.jpg")
soilSize = g_pJsonManager.m_pSoil['size'] # type: ignore
#TODO 缺少判断用户土地资源状况
soil = BuildImage(background=g_sResourcePath / "soil/普通土地.png")
await soil.resize(0, 229, 112)
await soil.resize(0, soilSize[0], soilSize[1])
grass = BuildImage(background=g_sResourcePath / "soil/草土地.png")
await grass.resize(0, 229, 112)
await grass.resize(0, soilSize[0], soilSize[1])
soilPos = g_pJsonManager.m_pSoil['soil']
soilPos = g_pJsonManager.m_pSoil['soil'] # type: ignore
for key, value in soilPos.items():
if soilNumber >= int(key):
await img.paste(soil, (value['x'], value['y']), center_type="center")
await img.paste(soil, (value['x'], value['y']))
else:
await img.paste(grass, (value['x'], value['y']), center_type="center")
await img.paste(grass, (value['x'], value['y']))
return img.pic2bytes()