diff --git a/command.py b/command.py index 50d0f66..09a33aa 100644 --- a/command.py +++ b/command.py @@ -93,9 +93,10 @@ 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="农场帮助"), + Subcommand("vipSeed-shop", Args["res?", MultiVar(str)], help_text="种子商店"), ), priority=5, block=True, @@ -209,9 +210,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() @@ -748,3 +749,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.getSeedShopImage(page, 0, 1) + else: + image = await g_pShopManager.getSeedShopImage(filterKey, page, 1) + + await MessageUtils.build_message(image).send() diff --git a/core/shop.py b/core/shop.py index 1f1a318..aff4302 100644 --- a/core/shop.py +++ b/core/shop.py @@ -9,7 +9,9 @@ from ..utils.tool import g_pToolManager 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: @@ -34,7 +36,6 @@ class CShopManager: "-", "种子名称", "农场币", - "点券", "解锁等级", "果实单价", "收获经验", @@ -47,14 +48,33 @@ class CShopManager: # 查询所有可购买作物,并根据筛选关键字过滤 plants = await g_pDBService.plant.listPlants() filteredPlants = [] - for plant in plants: - # 跳过未解锁购买的种子 - 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) @@ -79,7 +99,6 @@ class CShopManager: icon, plant["name"], # 种子名称 plant["buy"], # 农场币种子单价 - plant["vipBuy"], # 点券种子单价 plant["level"], # 解锁等级 plant["price"], # 果实单价 plant["experience"], # 收获经验 @@ -89,6 +108,8 @@ class CShopManager: sell, # 是否可上架交易行 ] ) + if isVip: + dataList[-1][2] = plant["vipBuy"] # 点券种子单价 # 页码标题 title = f"种子商店 页数: {page}/{pageCount}" diff --git a/resource/db/plant.db b/resource/db/plant.db index 7597ade..f9f0150 100644 Binary files a/resource/db/plant.db and b/resource/db/plant.db differ 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 @@