From 46fecc768495c71d92ea554cfef618495f560780 Mon Sep 17 00:00:00 2001 From: Art_Sakura <1754798088@qq.com> Date: Fri, 21 Mar 2025 23:34:19 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=E4=BF=AE=E5=A4=8D=E8=8B=A5?= =?UTF-8?q?=E5=B9=B2=E4=B8=AA=E5=B7=B2=E7=9F=A5BUG=20=F0=9F=90=9B=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=88=91=E7=9A=84=E5=86=9C=E5=9C=BA=E4=BC=9A?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E6=8A=A5=E9=94=99=E7=9A=84BUG=20=F0=9F=90=9B?= =?UTF-8?q?=20=E4=BF=AE=E5=A4=8D=E5=88=9D=E5=A7=8B=E7=AD=89=E7=BA=A7?= =?UTF-8?q?=E4=B8=BA1=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __init__.py | 2 + command.py | 101 ++++++++++++++++++++++++++++------------------ config/level.json | 13 +++--- database.py | 4 +- farm/farm.py | 18 ++++++--- farm/shop.py | 2 +- 6 files changed, 86 insertions(+), 54 deletions(-) diff --git a/__init__.py b/__init__.py index 23d56ec..9ff19c7 100644 --- a/__init__.py +++ b/__init__.py @@ -17,6 +17,7 @@ __plugin_meta__ = PluginMetadata( usage=""" 你也要种地? 指令: + at 开通农场 我的农场 我的农场币 种子商店 @@ -28,6 +29,7 @@ __plugin_meta__ = PluginMetadata( 我的作物 出售作物 [作物/种子名称] [数量] 偷菜 at + 开垦 购买农场币 [数量] 金币转换农场币比率是 1 : 2 """.strip(), extra=PluginExtraData( diff --git a/command.py b/command.py index 7491521..e2da46d 100644 --- a/command.py +++ b/command.py @@ -43,6 +43,7 @@ diuse_farm = on_alconna( Subcommand("harvest", help_text="收获"), Subcommand("eradicate", help_text="铲除"), Subcommand("my-plant", help_text="我的作物"), + # Subcommand("reclamation", help_text="开垦"), Subcommand("sell-plant", Args["name?", str]["num?", int], help_text="出售作物"), Subcommand("stealing", Args["target?", At], help_text="偷菜"), Subcommand("buy-point", Args["num?", int], help_text="购买农场币"), @@ -58,7 +59,7 @@ async def _(session: Uninfo): point = await g_pSqlManager.getUserPointByUid(uid) if point < 0: - await MessageUtils.build_message("尚未开通农场").send() + await MessageUtils.build_message("尚未开通农场,快at我发送 开通农场 开通吧").send() return None image = await g_pFarmManager.drawFarmByUid(uid) @@ -77,7 +78,7 @@ async def _(session: Uninfo): point = await g_pSqlManager.getUserPointByUid(uid) if point < 0: - await MessageUtils.build_message("尚未开通农场").send() + await MessageUtils.build_message("尚未开通农场,快at我发送 开通农场 开通吧").send() return None await MessageUtils.build_message(f"你的当前农场币为: {point}").send(reply_to=True) @@ -95,7 +96,7 @@ async def _(session: Uninfo): point = await g_pSqlManager.getUserPointByUid(uid) if point < 0: - await MessageUtils.build_message("尚未开通农场").send() + await MessageUtils.build_message("尚未开通农场,快at我发送 开通农场 开通吧").send() return None image = await g_pShopManager.getSeedShopImage() @@ -119,7 +120,7 @@ async def _(session: Uninfo, name: Match[str], num: Query[int] = AlconnaQuery("n point = await g_pSqlManager.getUserPointByUid(uid) if point < 0: - await MessageUtils.build_message("尚未开通农场").send() + await MessageUtils.build_message("尚未开通农场,快at我发送 开通农场 开通吧").send() return None result = await g_pShopManager.buySeed(uid, name.result, num.result) @@ -138,7 +139,7 @@ async def _(session: Uninfo): point = await g_pSqlManager.getUserPointByUid(uid) if point < 0: - await MessageUtils.build_message("尚未开通农场").send() + await MessageUtils.build_message("尚未开通农场,快at我发送 开通农场 开通吧").send() return None result = await g_pFarmManager.getUserSeedByUid(uid) @@ -162,7 +163,7 @@ async def _(session: Uninfo, name: Match[str], num: Query[int] = AlconnaQuery("n point = await g_pSqlManager.getUserPointByUid(uid) if point < 0: - await MessageUtils.build_message("尚未开通农场").send() + await MessageUtils.build_message("尚未开通农场,快at我发送 开通农场 开通吧").send() return None result = await g_pFarmManager.sowing(uid, name.result, num.result) @@ -182,7 +183,7 @@ async def _(session: Uninfo): point = await g_pSqlManager.getUserPointByUid(uid) if point < 0: - await MessageUtils.build_message("尚未开通农场").send() + await MessageUtils.build_message("尚未开通农场,快at我发送 开通农场 开通吧").send() return None result = await g_pFarmManager.harvest(uid) @@ -201,7 +202,7 @@ async def _(session: Uninfo): point = await g_pSqlManager.getUserPointByUid(uid) if point < 0: - await MessageUtils.build_message("尚未开通农场").send() + await MessageUtils.build_message("尚未开通农场,快at我发送 开通农场 开通吧").send() return None result = await g_pFarmManager.eradicate(uid) @@ -221,12 +222,32 @@ async def _(session: Uninfo): point = await g_pSqlManager.getUserPointByUid(uid) if point < 0: - await MessageUtils.build_message("尚未开通农场").send() + await MessageUtils.build_message("尚未开通农场,快at我发送 开通农场 开通吧").send() return None result = await g_pFarmManager.getUserPlantByUid(uid) await MessageUtils.build_message(result).send(reply_to=True) +# diuse_farm.shortcut( +# "开垦", +# command="我的农场", +# arguments=["reclamation"], +# prefix=True, +# ) + +# @diuse_farm.assign("reclamation") +# async def _(session: Uninfo): +# uid = str(session.user.id) +# point = await g_pSqlManager.getUserPointByUid(uid) + +# if point < 0: +# await MessageUtils.build_message("尚未开通农场,快at我发送 开通农场 开通吧").send() +# return None + +# result = await g_pFarmManager.getUserPlantByUid(uid) +# await MessageUtils.build_message(result).send(reply_to=True) + + diuse_farm.shortcut( "出售作物(?P.*?)", command="我的农场", @@ -245,12 +266,41 @@ async def _(session: Uninfo, name: Match[str], num: Query[int] = AlconnaQuery("n point = await g_pSqlManager.getUserPointByUid(uid) if point < 0: - await MessageUtils.build_message("尚未开通农场").send() + await MessageUtils.build_message("尚未开通农场,快at我发送 开通农场 开通吧").send() return None result = await g_pShopManager.sellPlantByUid(uid, name.result, num.result) await MessageUtils.build_message(result).send(reply_to=True) +diuse_farm.shortcut( + "偷菜", + command="我的农场", + arguments=["stealing"], + prefix=True, +) + +@diuse_farm.assign("stealing") +async def _(session: Uninfo, target: Match[At]): + uid = str(session.user.id) + point = await g_pSqlManager.getUserPointByUid(uid) + + if point < 0: + await MessageUtils.build_message("尚未开通农场,快at我发送 开通农场 开通吧").send() + return None + + if not target.available: + await MessageUtils.build_message("请在指令后跟需要at的人").finish(reply_to=True) + + tar = target.result + point = await g_pSqlManager.getUserPointByUid(tar.target) + + if point < 0: + await MessageUtils.build_message("尚未开通农场,快at我发送 开通农场 开通吧").send() + return None + + result = await g_pFarmManager.stealing(uid, tar.target) + await MessageUtils.build_message(result).send(reply_to=True) + diuse_farm.shortcut( "购买农场币(.*?)", command="我的农场", @@ -269,37 +319,8 @@ async def _(session: Uninfo, num: Query[int] = AlconnaQuery("num", 0)): point = await g_pSqlManager.getUserPointByUid(uid) if point < 0: - await MessageUtils.build_message("尚未开通农场").send() + await MessageUtils.build_message("尚未开通农场,快at我发送 开通农场 开通吧").send() return None result = await g_pFarmManager.buyPointByUid(uid, num.result) await MessageUtils.build_message(result).send(reply_to=True) - -diuse_farm.shortcut( - "偷菜", - command="我的农场", - arguments=["stealing"], - prefix=True, -) - -@diuse_farm.assign("stealing") -async def _(session: Uninfo, target: Match[At]): - uid = str(session.user.id) - point = await g_pSqlManager.getUserPointByUid(uid) - - if point < 0: - await MessageUtils.build_message("尚未开通农场").send() - return None - - if not target.available: - await MessageUtils.build_message("请在指令后跟需要at的人").finish(reply_to=True) - - tar = target.result - point = await g_pSqlManager.getUserPointByUid(tar.target) - - if point < 0: - await MessageUtils.build_message("尚未开通农场").send() - return None - - result = await g_pFarmManager.stealing(uid, tar.target) - await MessageUtils.build_message(result).send(reply_to=True) diff --git a/config/level.json b/config/level.json index 50166c8..7f8a501 100644 --- a/config/level.json +++ b/config/level.json @@ -1,12 +1,13 @@ { "level": { - "1": 0, - "2": 50, - "3": 75, - "4": 125, - "5": 185, - "6": 200, + "0": 0, + "1": 50, + "2": 75, + "3": 125, + "4": 185, + "5": 200, + "6": 250, "7": 275, "8": 350, "9": 500, diff --git a/database.py b/database.py index d6b2e8c..e04ce19 100644 --- a/database.py +++ b/database.py @@ -144,7 +144,7 @@ class CSqlManager: if not await cls.executeDB(userSoilInfo): return False - return True + return "开通农场成功" @classmethod async def getUserInfoByUid(cls, uid: str) -> dict: @@ -324,7 +324,7 @@ class CSqlManager: async with cls.m_pDB.execute(f"SELECT soil FROM user WHERE uid = '{uid}'") as cursor: async for row in cursor: - if row[0] == None or len(row[0]) <= 0: + if not row[0]: return 0 else: return int(row[0]) diff --git a/farm/farm.py b/farm/farm.py index ec6c339..31fdc4f 100644 --- a/farm/farm.py +++ b/farm/farm.py @@ -4,7 +4,6 @@ from datetime import date, datetime from io import StringIO from typing import Dict, List, Tuple -from Python311.Lib.PIL.ImImagePlugin import number from zhenxun.models.user_console import UserConsole from zhenxun.services.log import logger from zhenxun.utils._build_image import BuildImage @@ -72,7 +71,7 @@ class CFarmManager: y = soilPos[str(index + 1)]['y'] #如果土地已经到达对应等级 - if index > soilUnlock: + if index < soilUnlock: await img.paste(soil, (x, y)) isPlant, plant, isRipe= await cls.drawSoilPlant(uid, f"soil{str(index + 1)}") @@ -273,8 +272,6 @@ class CFarmManager: # 更新种子数量 num -= 1 plantDict[name] -= 1 - if plantDict[name] == 0: - del plantDict[name] # 更新数据库 await g_pSqlManager.updateUserSoilStatusByPlantName(uid, soilName, name) @@ -443,7 +440,7 @@ class CFarmManager: else: sell = "不可以" - number = count * int(plantInfo['price']) + number = int(count) * plantInfo['price'] data_list.append( [ @@ -570,5 +567,16 @@ class CFarmManager: return "\n".join(harvestRecords) + # @classmethod + # async def reclamation(cls, uid: str) -> str: + + # userInfo = await g_pSqlManager.getUserInfoByUid(uid) + # level = await g_pSqlManager.getUserLevelByUid(uid) + + # rec = g_pJsonManager["reclamation"] # type: ignore + + # if not rec[f"{userInfo["soil"] + 1}"] == None + + # return "" g_pFarmManager = CFarmManager() diff --git a/farm/shop.py b/farm/shop.py index de156d9..5ab3e54 100644 --- a/farm/shop.py +++ b/farm/shop.py @@ -93,7 +93,7 @@ class CShopManager: return "购买出错!请检查需购买的种子名称!" - level = g_pSqlManager.getUserLevelByUid(uid) + level = await g_pSqlManager.getUserLevelByUid(uid) if level < plantInfo['level']: return "你的等级不够哦,努努力吧"