🚑 修复土地等级绘制出错的BUG

This commit is contained in:
Art_Sakura 2025-06-29 22:38:51 +08:00
parent f4e192ff27
commit e48bdf03da
5 changed files with 18 additions and 10 deletions

View File

@ -8,6 +8,9 @@
<a href="https://www.python.org"> <a href="https://www.python.org">
<img src="https://img.shields.io/badge/Python-3.10%2B-blue" alt="Python"> <img src="https://img.shields.io/badge/Python-3.10%2B-blue" alt="Python">
</a> </a>
<a href="https://github.com/astral-sh/ruff">
<img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json" alt="ruff">
</a>
<a href="https://nonebot.dev/"> <a href="https://nonebot.dev/">
<img src="https://img.shields.io/badge/Nonebot-2.0.0%2B-black" alt="Nonebot"> <img src="https://img.shields.io/badge/Nonebot-2.0.0%2B-black" alt="Nonebot">
</a> </a>

View File

@ -35,7 +35,7 @@ class CUserDB(CSqlManager):
point (int): 农场币 point (int): 农场币
Returns: Returns:
Union[bool, str]: False 表示失败字符串表示成功信息 bool | str: False 表示失败字符串表示成功信息
""" """
nowStr = g_pToolManager.dateTime().date().today().strftime("%Y-%m-%d") nowStr = g_pToolManager.dateTime().date().today().strftime("%Y-%m-%d")
sql = ( sql = (
@ -55,7 +55,7 @@ class CUserDB(CSqlManager):
"""获取所有用户UID列表 """获取所有用户UID列表
Returns: Returns:
List[str]: 用户UID列表 list[str]: 用户UID列表
""" """
cursor = await cls.m_pDB.execute("SELECT uid FROM user") cursor = await cls.m_pDB.execute("SELECT uid FROM user")
rows = await cursor.fetchall() rows = await cursor.fetchall()

View File

@ -244,7 +244,7 @@ class CUserSoilDB(CSqlManager):
soilIndex (int): 土地索引 soilIndex (int): 土地索引
Returns: Returns:
Optional[dict]: 记录存在返回字段-值字典否则返回 None dict: 记录存在返回字段-值字典否则返回 None
""" """
async with cls._transaction(): async with cls._transaction():
cursor = await cls.m_pDB.execute( cursor = await cls.m_pDB.execute(
@ -266,7 +266,7 @@ class CUserSoilDB(CSqlManager):
soilIndex (int): 土地索引 soilIndex (int): 土地索引
Returns: Returns:
Optional[dict]: 记录存在返回字段-值字典否则返回 None dict | None: 记录存在返回字段-值字典否则返回 None
""" """
cursor = await cls.m_pDB.execute( cursor = await cls.m_pDB.execute(
"SELECT * FROM userSoil WHERE uid = ? AND soilIndex = ?", "SELECT * FROM userSoil WHERE uid = ? AND soilIndex = ?",

View File

@ -243,10 +243,16 @@ class CFarmManager:
soilInfo = await g_pDBService.userSoil.getUserSoil(uid, i) soilInfo = await g_pDBService.userSoil.getUserSoil(uid, i)
if soilInfo: if soilInfo:
if soilInfo["soilLevel"] == 1: match soilInfo.get("soilLevel", 0):
iconPath = g_sResourcePath / "soil/红土地.png" case 1:
else: name = "红土地.png"
iconPath = g_sResourcePath / "soil/普通土地.png" case 2:
name = "黑土地.png"
case 3:
name = "金土地.png"
case _:
name = "普通土地.png"
iconPath = g_sResourcePath / "soil" / name
if iconPath.exists(): if iconPath.exists():
icon = (iconPath, 33, 33) icon = (iconPath, 33, 33)

View File

@ -31,7 +31,7 @@ class CRequestManager:
params: dict | None = None, params: dict | None = None,
jsonData: dict | None = None, jsonData: dict | None = None,
) -> bool: ) -> bool:
"""下载文件到指定路径并覆盖已存在的文件,并显示下载进度条 """下载文件到指定路径并覆盖已存在的文件
Args: Args:
url (str): 文件的下载链接 url (str): 文件的下载链接
@ -210,7 +210,6 @@ class CRequestManager:
# 重命名为 sign_in.json # 重命名为 sign_in.json
g_pToolManager.renameFile(f"{path}/signTemp.json", "sign_in.json") g_pToolManager.renameFile(f"{path}/signTemp.json", "sign_in.json")
return True return True
except Exception as e: except Exception as e:
logger.error("下载签到文件失败", e=e) logger.error("下载签到文件失败", e=e)
return False return False