From fea8ca928756ffc8b11c58ce5c96af64dfed9e2d Mon Sep 17 00:00:00 2001 From: Mualamx Date: Mon, 13 Oct 2025 00:46:12 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=8E=A8=20=E4=BF=AE=E6=94=B9=E9=83=A8?= =?UTF-8?q?=E5=88=86html=EF=BC=8C=E6=B7=BB=E5=8A=A0=E7=82=B9=E5=88=B8?= =?UTF-8?q?=E4=BD=9C=E7=89=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- command.py | 2 +- resource/db/plant.db | Bin 36864 -> 36864 bytes resource/html/help.html | 108 +++++++++++++++++++++++++++++++++++++++- 3 files changed, 107 insertions(+), 3 deletions(-) diff --git a/command.py b/command.py index fd6f37d..a490a48 100644 --- a/command.py +++ b/command.py @@ -96,7 +96,7 @@ diuse_farm = on_alconna( Subcommand("change-name", Args["name?", str], help_text="更改农场名"), Subcommand("sign-in", help_text="农场签到"), Subcommand("admin-up", Args["num?", int], help_text="农场下阶段"), - Subcommand("point-to-vipPoint", Args["num?", int], help_text="农场币换点券"), + Subcommand("point-to-vipPoint", Args["num?", int], help_text="点券兑换"), Subcommand("my-vipPoint", help_text="我的点券"), Subcommand("farm-help", help_text="农场帮助"), ), diff --git a/resource/db/plant.db b/resource/db/plant.db index 7597ade2d05f8feebdd464ff5e3175c52302f4ea..f9f0150f8a3f0bcef1182dc3b93d4bc802175bab 100644 GIT binary patch delta 876 zcmZozz|^pSX@WHGBnAcsPAF!YsA0}HX=B0?ejXtq) zH~*Gr5#ad93*=cc%%99|kj1%?F^^G$;SrEmWuU6&(4H&GAkWCb$;iRT$jQj*&dI^a z0R+!??|;5~(u+y^QzW?+B_=@6=A&wRFF%ah$R<0ZJ| zk#%Ha)$wFUHHwPat z_eCyWZhdZB?ig-Ao+9onzPns^xwrDXis7s0-OF{3KaIzaU!E&t@-zbl6D}P-3EpO&$=pA9uW`@eGvwRI z&&l_hPnjo%cL~2Mm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8Q;SZV#=)RE(xs7yFhk11r(A3M@G| zNWM2nC0xwGLGp;o1F)2%Dz@ApSiU(g`+?5IdzBLew~kE(6y{>f>>#*h>4YoT(w0Sp f<*<^gXB?ThFwaHey?c4@1x-;jezWuZzzgYbJXWO} diff --git a/resource/html/help.html b/resource/html/help.html index db64177..d900a58 100644 --- a/resource/html/help.html +++ b/resource/html/help.html @@ -528,7 +528,7 @@
-
播种
+
出售作物
@@ -548,7 +548,7 @@
操作提示
- • 不填写作物名将售卖仓库种全部作物 + • 不填写作物名将售卖仓库种全部作物
• 填作物名不填数量将指定作物全部出售
@@ -666,6 +666,110 @@
+ +
+
+
+ +
+
作物加锁
+
+ +
+
参数列表
+
+
+ 必填 + 地块ID +
+
+
+ +
+
操作提示
+
+ • 地块ID通过农场详述获取 +
+
+
+ +
+
+
+ +
+
作物解锁
+
+ +
+
参数列表
+
+
+ 必填 + 地块ID +
+
+
+ +
+
操作提示
+
+ • 地块ID通过农场详述获取 +
+
+
+ +
+
+
+ +
+
我的点券
+
+ +
+
参数列表
+
+
+ 必填 + 地块ID +
+
+
+ +
+
操作提示
+
+ • 地块ID通过农场详述获取 +
+
+
+ +
+
+
+ +
+
点券兑换
+
+ +
+
参数列表
+
+
+ 必填 + 地块ID +
+
+
+ +
+
操作提示
+
+ • 地块ID通过农场详述获取 +
+
+
From 698f8036942718c90e371c29bde2eb9ef526d804 Mon Sep 17 00:00:00 2001 From: Mualamx Date: Wed, 15 Oct 2025 01:26:33 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E2=9C=A8=20=E6=B7=BB=E5=8A=A0=E7=82=B9?= =?UTF-8?q?=E5=88=B8=E5=95=86=E5=BA=97=EF=BC=8C=E4=B8=8E=E7=A7=8D=E5=AD=90?= =?UTF-8?q?=E5=95=86=E5=BA=97=E5=88=86=E5=BC=80=E6=98=BE=E7=A4=BA=E5=AF=B9?= =?UTF-8?q?=E5=BA=94=E7=A7=8D=E5=AD=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- command.py | 47 ++++++++++++++++++++++++ farm/shop.py | 100 +++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 145 insertions(+), 2 deletions(-) diff --git a/command.py b/command.py index a490a48..5549c72 100644 --- a/command.py +++ b/command.py @@ -99,6 +99,7 @@ diuse_farm = on_alconna( Subcommand("point-to-vipPoint", Args["num?", int], help_text="点券兑换"), Subcommand("my-vipPoint", help_text="我的点券"), Subcommand("farm-help", help_text="农场帮助"), + Subcommand("vipSeed-shop", Args["res?", MultiVar(str)], help_text="种子商店"), ), priority=5, block=True, @@ -713,3 +714,49 @@ async def _(session: Uninfo): image = BuildImage(background=savePath) await MessageUtils.build_message(image).send(reply_to=True) + + +diuse_farm.shortcut( + "点券商店(.*?)", + command="我的农场", + arguments=["vipSeed-shop"], + prefix=True, +) + + +@diuse_farm.assign("vipSeed-shop") +async def _(session: Uninfo, res: Match[tuple[str, ...]]): + uid = str(session.user.id) + + if not await g_pToolManager.isRegisteredByUid(uid): + return + + if res.result is inspect._empty: + raw = [] + else: + raw = res.result + + filterKey: str | int | None = None + page: int = 1 + + if len(raw) >= 1 and raw[0] is not None: + first = raw[0] + if isinstance(first, str) and first.isdigit(): + page = int(first) + else: + filterKey = first + + if ( + len(raw) >= 2 + and raw[1] is not None + and isinstance(raw[1], str) + and raw[1].isdigit() + ): + page = int(raw[1]) + + if filterKey is None: + image = await g_pShopManager.getVipSeedShopImage(page) + else: + image = await g_pShopManager.getVipSeedShopImage(filterKey, page) + + await MessageUtils.build_message(image).send() diff --git a/farm/shop.py b/farm/shop.py index e1a8b00..d73bb38 100644 --- a/farm/shop.py +++ b/farm/shop.py @@ -33,7 +33,6 @@ class CShopManager: "-", "种子名称", "农场币", - "点券", "解锁等级", "果实单价", "收获经验", @@ -47,6 +46,9 @@ class CShopManager: plants = await g_pDBService.plant.listPlants() filteredPlants = [] for plant in plants: + # 只留下农场币购买的种子 + if plant["isVip"] == 1: + continue # 跳过未解锁购买的种子 if plant["isBuy"] == 0: continue @@ -78,7 +80,6 @@ class CShopManager: icon, plant["name"], # 种子名称 plant["buy"], # 农场币种子单价 - plant["vipBuy"], # 点券种子单价 plant["level"], # 解锁等级 plant["price"], # 果实单价 plant["experience"], # 收获经验 @@ -227,5 +228,100 @@ class CShopManager: name=name, point=totalPoint, num=currentPoint + totalPoint ) + @classmethod + async def getVipSeedShopImage(cls, filterKey: str | int = 1, num: int = 1) -> bytes: + """获取点券商店页面 + + Args: + filterKey (str|int): + - 字符串: 根据关键字筛选种子名称 + - 整数: 翻至对应页(无筛选) + num (int, optional): 当 filterKey 为字符串时,用于指定页码。Defaults to 1. + + Returns: + bytes: 返回商店图片bytes + """ + # 解析参数:区分筛选关键字和页码 + filterStr = None + if isinstance(filterKey, int): + page = filterKey + else: + filterStr = filterKey + page = num + + # 表头定义 + columnName = [ + "-", + "种子名称", + "点券", + "解锁等级", + "果实单价", + "收获经验", + "收获数量", + "成熟时间(小时)", + "收获次数", + "是否可以上架交易行", + ] + + # 查询所有可购买作物,并根据筛选关键字过滤 + plants = await g_pDBService.plant.listPlants() + filteredPlants = [] + for plant in plants: + # 只留下点券购买的种子 + if plant["isVip"] == 0: + continue + # 跳过未解锁购买的种子 + if plant["isBuy"] == 0: + continue + # 字符串筛选 + if filterStr and filterStr not in plant["name"]: + continue + filteredPlants.append(plant) + + # 计算分页 + totalCount = len(filteredPlants) + pageCount = math.ceil(totalCount / 15) if totalCount else 1 + startIndex = (page - 1) * 15 + pageItems = filteredPlants[startIndex : startIndex + 15] + + # 构建数据行 + dataList = [] + for plant in pageItems: + # 图标处理 + icon = "" + iconPath = g_sResourcePath / f"plant/{plant['name']}/icon.png" + if iconPath.exists(): + icon = (iconPath, 33, 33) + + # 交易行标记 + sell = "可以" if plant["sell"] else "不可以" + + dataList.append( + [ + icon, + plant["name"], # 种子名称 + plant["vipBuy"], # 点券种子单价 + plant["level"], # 解锁等级 + plant["price"], # 果实单价 + plant["experience"], # 收获经验 + plant["harvest"], # 收获数量 + plant["time"], # 成熟时间(小时) + plant["crop"], # 收获次数 + sell, # 是否可上架交易行 + ] + ) + + # 页码标题 + title = f"种子商店 页数: {page}/{pageCount}" + + # 渲染表格并返回图片bytes + result = await ImageTemplate.table_page( + title, + "购买示例:@小真寻 购买种子 澳洲青苹果 5", + columnName, + dataList, + ) + return result.pic2bytes() + g_pShopManager = CShopManager() From 9da91ff3d4ceaea049edd9d4d9a3ff3f4c1ec4b8 Mon Sep 17 00:00:00 2001 From: Mualamx Date: Thu, 16 Oct 2025 01:02:33 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E2=9C=A8=20=E5=AE=9E=E7=8E=B0=E7=82=B9?= =?UTF-8?q?=E5=88=B8=E5=95=86=E5=BA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- command.py | 8 +-- farm/shop.py | 139 ++++++++++++--------------------------------------- 2 files changed, 36 insertions(+), 111 deletions(-) diff --git a/command.py b/command.py index 5549c72..d5d6b1b 100644 --- a/command.py +++ b/command.py @@ -201,9 +201,9 @@ async def _(session: Uninfo, res: Match[tuple[str, ...]]): page = int(raw[1]) if filterKey is None: - image = await g_pShopManager.getSeedShopImage(page) + image = await g_pShopManager.getSeedShopImage(page, 0, 0) else: - image = await g_pShopManager.getSeedShopImage(filterKey, page) + image = await g_pShopManager.getSeedShopImage(filterKey, page, 0) await MessageUtils.build_message(image).send() @@ -755,8 +755,8 @@ async def _(session: Uninfo, res: Match[tuple[str, ...]]): page = int(raw[1]) if filterKey is None: - image = await g_pShopManager.getVipSeedShopImage(page) + image = await g_pShopManager.getSeedShopImage(page, 0, 1) else: - image = await g_pShopManager.getVipSeedShopImage(filterKey, page) + image = await g_pShopManager.getSeedShopImage(filterKey, page, 1) await MessageUtils.build_message(image).send() diff --git a/farm/shop.py b/farm/shop.py index d73bb38..de0ceb7 100644 --- a/farm/shop.py +++ b/farm/shop.py @@ -8,7 +8,9 @@ from ..dbService import g_pDBService class CShopManager: @classmethod - async def getSeedShopImage(cls, filterKey: str | int = 1, num: int = 1) -> bytes: + async def getSeedShopImage( + cls, filterKey: str | int = 1, num: int = 1, isVip: int = 0 + ) -> bytes: """获取商店页面 Args: @@ -45,17 +47,33 @@ class CShopManager: # 查询所有可购买作物,并根据筛选关键字过滤 plants = await g_pDBService.plant.listPlants() filteredPlants = [] - for plant in plants: - # 只留下农场币购买的种子 - if plant["isVip"] == 1: - continue - # 跳过未解锁购买的种子 - if plant["isBuy"] == 0: - continue - # 字符串筛选 - if filterStr and filterStr not in plant["name"]: - continue - filteredPlants.append(plant) + + # 如果是点券商店 + if isVip: + columnName[2] = "点券" + for plant in plants: + # 只留下点券购买的种子 + if plant["isVip"] == 0: + continue + # 跳过未解锁购买的种子 + if plant["isBuy"] == 0: + continue + # 字符串筛选 + if filterStr and filterStr not in plant["name"]: + continue + filteredPlants.append(plant) + else: + for plant in plants: + # 只留下农场币购买的种子 + if plant["isVip"] == 1: + continue + # 跳过未解锁购买的种子 + if plant["isBuy"] == 0: + continue + # 字符串筛选 + if filterStr and filterStr not in plant["name"]: + continue + filteredPlants.append(plant) # 计算分页 totalCount = len(filteredPlants) @@ -89,6 +107,8 @@ class CShopManager: sell, # 是否可上架交易行 ] ) + if isVip: + dataList[-1][2] = plant["vipBuy"] # 点券种子单价 # 页码标题 title = f"种子商店 页数: {page}/{pageCount}" @@ -228,100 +248,5 @@ class CShopManager: name=name, point=totalPoint, num=currentPoint + totalPoint ) - @classmethod - async def getVipSeedShopImage(cls, filterKey: str | int = 1, num: int = 1) -> bytes: - """获取点券商店页面 - - Args: - filterKey (str|int): - - 字符串: 根据关键字筛选种子名称 - - 整数: 翻至对应页(无筛选) - num (int, optional): 当 filterKey 为字符串时,用于指定页码。Defaults to 1. - - Returns: - bytes: 返回商店图片bytes - """ - # 解析参数:区分筛选关键字和页码 - filterStr = None - if isinstance(filterKey, int): - page = filterKey - else: - filterStr = filterKey - page = num - - # 表头定义 - columnName = [ - "-", - "种子名称", - "点券", - "解锁等级", - "果实单价", - "收获经验", - "收获数量", - "成熟时间(小时)", - "收获次数", - "是否可以上架交易行", - ] - - # 查询所有可购买作物,并根据筛选关键字过滤 - plants = await g_pDBService.plant.listPlants() - filteredPlants = [] - for plant in plants: - # 只留下点券购买的种子 - if plant["isVip"] == 0: - continue - # 跳过未解锁购买的种子 - if plant["isBuy"] == 0: - continue - # 字符串筛选 - if filterStr and filterStr not in plant["name"]: - continue - filteredPlants.append(plant) - - # 计算分页 - totalCount = len(filteredPlants) - pageCount = math.ceil(totalCount / 15) if totalCount else 1 - startIndex = (page - 1) * 15 - pageItems = filteredPlants[startIndex : startIndex + 15] - - # 构建数据行 - dataList = [] - for plant in pageItems: - # 图标处理 - icon = "" - iconPath = g_sResourcePath / f"plant/{plant['name']}/icon.png" - if iconPath.exists(): - icon = (iconPath, 33, 33) - - # 交易行标记 - sell = "可以" if plant["sell"] else "不可以" - - dataList.append( - [ - icon, - plant["name"], # 种子名称 - plant["vipBuy"], # 点券种子单价 - plant["level"], # 解锁等级 - plant["price"], # 果实单价 - plant["experience"], # 收获经验 - plant["harvest"], # 收获数量 - plant["time"], # 成熟时间(小时) - plant["crop"], # 收获次数 - sell, # 是否可上架交易行 - ] - ) - - # 页码标题 - title = f"种子商店 页数: {page}/{pageCount}" - - # 渲染表格并返回图片bytes - result = await ImageTemplate.table_page( - title, - "购买示例:@小真寻 购买种子 澳洲青苹果 5", - columnName, - dataList, - ) - return result.pic2bytes() - g_pShopManager = CShopManager()