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