🐛 修复金币更新异常BUG
This commit is contained in:
parent
46fecc7684
commit
43b2184597
10
database.py
10
database.py
@ -221,13 +221,7 @@ class CSqlManager:
|
||||
return -1
|
||||
|
||||
try:
|
||||
async with cls.m_pDB.execute(
|
||||
"""UPDATE user
|
||||
SET point = ?
|
||||
WHERE uid = ?
|
||||
RETURNING point""",
|
||||
(point, uid)
|
||||
) as cursor:
|
||||
async with cls.m_pDB.execute(f"UPDATE user SET point = {point} WHERE uid = '{uid}'") as cursor:
|
||||
async for row in cursor:
|
||||
return int(row[0])
|
||||
|
||||
@ -235,7 +229,7 @@ class CSqlManager:
|
||||
return -1
|
||||
except Exception as e:
|
||||
# 记录详细错误日志(建议记录堆栈)
|
||||
logger.error(f"更新失败: {e}")
|
||||
logger.error(f"金币更新失败: {e}")
|
||||
return -1
|
||||
|
||||
@classmethod
|
||||
|
||||
10
farm/farm.py
10
farm/farm.py
@ -374,7 +374,7 @@ class CFarmManager:
|
||||
|
||||
experience = 0
|
||||
for (soil_name, (status, info)) in zip(soilNames, soilStatuses):
|
||||
if not status:
|
||||
if not info:
|
||||
soilInfo = info.split(',')
|
||||
if int(soilInfo[3]) == 4:
|
||||
experience += 3
|
||||
@ -508,8 +508,11 @@ class CFarmManager:
|
||||
for (soilName, (status, info)) in zip(soilNames, soilStatuses):
|
||||
isStealing = False
|
||||
|
||||
if not status:
|
||||
if not info:
|
||||
soilInfo = info.split(',')
|
||||
if soilInfo[3] == 4:
|
||||
continue
|
||||
|
||||
plantId = soilInfo[0]
|
||||
plantInfo = g_pJsonManager.m_pPlant['plant'][plantId] # type: ignore
|
||||
|
||||
@ -542,7 +545,8 @@ class CFarmManager:
|
||||
plant[plantId] = plant.get(plantId, 0) + randomNumber
|
||||
harvestRecords.append(f"成功偷到作物:{plantId},数量为:{randomNumber}")
|
||||
|
||||
stealingStatus += f"|{uid}-{randomNumber}"
|
||||
newElement = f"|{uid}-{randomNumber}"
|
||||
stealingStatus.append(newElement)
|
||||
|
||||
#如果将作物偷完,就直接更新状态 并记录用户偷取过
|
||||
if plantInfo['harvest'] - randomNumber + stealingNumber == 0:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user