From 43b2184597639d421c4bb9e333a06e1ab057d448 Mon Sep 17 00:00:00 2001 From: Art_Sakura <1754798088@qq.com> Date: Sat, 22 Mar 2025 00:08:23 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=E4=BF=AE=E5=A4=8D=E9=87=91?= =?UTF-8?q?=E5=B8=81=E6=9B=B4=E6=96=B0=E5=BC=82=E5=B8=B8BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- database.py | 10 ++-------- farm/farm.py | 12 ++++++++---- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/database.py b/database.py index e04ce19..01f208c 100644 --- a/database.py +++ b/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 diff --git a/farm/farm.py b/farm/farm.py index 31fdc4f..16f326b 100644 --- a/farm/farm.py +++ b/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 @@ -505,11 +505,14 @@ class CFarmManager: harvestRecords: List[str] = [] isStealing = False - for(soilName, (status, info)) in zip(soilNames, soilStatuses): + 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: