🚑 修复无法正常铲除荒废作物的BUG
This commit is contained in:
parent
564d9858f5
commit
69ddbe4669
@ -273,7 +273,7 @@ class CUserSignDB(CSqlManager):
|
||||
sql = "SELECT signDate FROM userSignLog WHERE uid=? AND signDate LIKE ?"
|
||||
async with cls.m_pDB.execute(sql, (uid, f"{monthStr}-%")) as cursor:
|
||||
rows = await cursor.fetchall()
|
||||
signedDays = set(int(r[0][-2:]) for r in rows if r[0][-2:].isdigit())
|
||||
signedDays = {int(r[0][-2:]) for r in rows if r[0][-2:].isdigit()}
|
||||
except Exception as e:
|
||||
logger.warning("绘制签到图时数据库查询失败", e=e)
|
||||
signedDays = set()
|
||||
|
||||
@ -24,6 +24,7 @@ class CUserSoilDB(CSqlManager):
|
||||
"weedStatus": "INTEGER DEFAULT 0", # 杂草状态 0=无杂草,1=有杂草
|
||||
"waterStatus": "INTEGER DEFAULT 0", # 缺水状态 0=不缺水,1=缺水
|
||||
"harvestCount": "INTEGER DEFAULT 0", # 收获次数
|
||||
"isSoilPlanted": "INTEGER DEFAULT 0", # 是否种植作物
|
||||
"PRIMARY KEY": "(uid, soilIndex)",
|
||||
}
|
||||
|
||||
@ -182,8 +183,8 @@ class CUserSoilDB(CSqlManager):
|
||||
INSERT INTO userSoil
|
||||
(uid, soilIndex, plantName, plantTime, matureTime,
|
||||
soilLevel, wiltStatus, fertilizerStatus, bugStatus,
|
||||
weedStatus, waterStatus, harvestCount)
|
||||
VALUES (?,?,?,?,?,?,?,?,?,?,?,?)
|
||||
weedStatus, waterStatus, harvestCount, isSoilPlanted)
|
||||
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)
|
||||
""",
|
||||
(
|
||||
soilInfo["uid"],
|
||||
@ -198,6 +199,7 @@ class CUserSoilDB(CSqlManager):
|
||||
soilInfo.get("weedStatus", 0),
|
||||
soilInfo.get("waterStatus", 0),
|
||||
soilInfo.get("harvestCount", 0),
|
||||
soilInfo.get("isSoilPlanted", 0),
|
||||
),
|
||||
)
|
||||
|
||||
@ -216,8 +218,8 @@ class CUserSoilDB(CSqlManager):
|
||||
INSERT INTO userSoil
|
||||
(uid, soilIndex, plantName, plantTime, matureTime,
|
||||
soilLevel, wiltStatus, fertilizerStatus, bugStatus,
|
||||
weedStatus, waterStatus, harvestCount)
|
||||
VALUES (?,?,?,?,?,?,?,?,?,?,?,?)
|
||||
weedStatus, waterStatus, harvestCount, isSoilPlanted)
|
||||
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)
|
||||
""",
|
||||
(
|
||||
soilInfo["uid"],
|
||||
@ -232,6 +234,7 @@ class CUserSoilDB(CSqlManager):
|
||||
soilInfo.get("weedStatus", 0),
|
||||
soilInfo.get("waterStatus", 0),
|
||||
soilInfo.get("harvestCount", 0),
|
||||
soilInfo.get("isSoilPlanted", 0),
|
||||
),
|
||||
)
|
||||
|
||||
@ -360,6 +363,7 @@ class CUserSoilDB(CSqlManager):
|
||||
"weedStatus",
|
||||
"waterStatus",
|
||||
"harvestCount",
|
||||
"isSoilPlanted",
|
||||
}
|
||||
setClauses = []
|
||||
values = []
|
||||
@ -413,23 +417,6 @@ class CUserSoilDB(CSqlManager):
|
||||
"DELETE FROM userSoil WHERE uid = ? AND soilIndex = ?", (uid, soilIndex)
|
||||
)
|
||||
|
||||
@classmethod
|
||||
async def isSoilPlanted(cls, uid: str, soilIndex: int) -> bool:
|
||||
"""判断指定用户的指定土地是否已种植
|
||||
|
||||
Args:
|
||||
uid (str): 用户ID
|
||||
soilIndex (int): 土地索引
|
||||
|
||||
Returns:
|
||||
bool: 如果 plantName 不为空且 plantTime 大于 0,则视为已种植,返回 True;否则 False
|
||||
"""
|
||||
soilInfo = await cls.getUserSoil(uid, soilIndex)
|
||||
if not soilInfo:
|
||||
return False
|
||||
|
||||
return bool(soilInfo.get("plantName")) and soilInfo.get("plantTime", 0) > 0
|
||||
|
||||
@classmethod
|
||||
async def sowingByPlantName(cls, uid: str, soilIndex: int, plantName: str) -> bool:
|
||||
"""播种指定作物到用户土地区
|
||||
@ -481,6 +468,7 @@ class CUserSoilDB(CSqlManager):
|
||||
"weedStatus": 0,
|
||||
"waterStatus": 0,
|
||||
"harvestCount": 0,
|
||||
"isSoilPlanted": 1,
|
||||
}
|
||||
)
|
||||
return True
|
||||
|
||||
25
farm/farm.py
25
farm/farm.py
@ -552,14 +552,14 @@ class CFarmManager:
|
||||
harvestCount = 0 # 成功收获数量
|
||||
|
||||
for i in range(1, soilNumber + 1):
|
||||
# 如果没有种植
|
||||
if not await g_pDBService.userSoil.isSoilPlanted(uid, i):
|
||||
continue
|
||||
|
||||
soilInfo = await g_pDBService.userSoil.getUserSoil(uid, i)
|
||||
if not soilInfo:
|
||||
continue
|
||||
|
||||
# 如果没有种植
|
||||
if soilInfo.get("isSoilPlanted", 0):
|
||||
continue
|
||||
|
||||
level = soilInfo.get("soilLevel", 0)
|
||||
|
||||
# 如果是枯萎状态
|
||||
@ -676,14 +676,14 @@ class CFarmManager:
|
||||
|
||||
experience = 0
|
||||
for i in range(1, soilNumber + 1):
|
||||
# 如果没有种植
|
||||
if not await g_pDBService.userSoil.isSoilPlanted(uid, i):
|
||||
continue
|
||||
|
||||
soilInfo = await g_pDBService.userSoil.getUserSoil(uid, i)
|
||||
if not soilInfo:
|
||||
continue
|
||||
|
||||
# 如果没有种植
|
||||
if soilInfo.get("isSoilPlanted", 0):
|
||||
continue
|
||||
|
||||
# 如果不是枯萎状态
|
||||
if soilInfo.get("wiltStatus", 0) == 0:
|
||||
continue
|
||||
@ -704,6 +704,7 @@ class CFarmManager:
|
||||
"plantTime": 0,
|
||||
"matureTime": 0,
|
||||
"wiltStatus": 0,
|
||||
"isSoilPlanted": 0,
|
||||
},
|
||||
)
|
||||
|
||||
@ -810,14 +811,14 @@ class CFarmManager:
|
||||
isStealingPlant = 0
|
||||
|
||||
for i in range(1, soilNumber + 1):
|
||||
# 如果没有种植
|
||||
if not await g_pDBService.userSoil.isSoilPlanted(target, i):
|
||||
continue
|
||||
|
||||
soilInfo = await g_pDBService.userSoil.getUserSoil(target, i)
|
||||
if not soilInfo:
|
||||
continue
|
||||
|
||||
# 如果没有种植
|
||||
if soilInfo.get("isSoilPlanted", 0):
|
||||
continue
|
||||
|
||||
# 如果是枯萎状态
|
||||
if soilInfo.get("wiltStatus", 1) == 1:
|
||||
continue
|
||||
|
||||
@ -10,7 +10,6 @@ from rich.progress import (
|
||||
TimeRemainingColumn,
|
||||
TransferSpeedColumn,
|
||||
)
|
||||
|
||||
from zhenxun.configs.config import Config
|
||||
from zhenxun.services.log import logger
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user