commit
0024bb22f5
53
command.py
53
command.py
@ -96,9 +96,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,
|
||||
@ -200,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()
|
||||
|
||||
@ -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.getSeedShopImage(page, 0, 1)
|
||||
else:
|
||||
image = await g_pShopManager.getSeedShopImage(filterKey, page, 1)
|
||||
|
||||
await MessageUtils.build_message(image).send()
|
||||
|
||||
43
farm/shop.py
43
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:
|
||||
@ -33,7 +35,6 @@ class CShopManager:
|
||||
"-",
|
||||
"种子名称",
|
||||
"农场币",
|
||||
"点券",
|
||||
"解锁等级",
|
||||
"果实单价",
|
||||
"收获经验",
|
||||
@ -46,14 +47,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)
|
||||
@ -78,7 +98,6 @@ class CShopManager:
|
||||
icon,
|
||||
plant["name"], # 种子名称
|
||||
plant["buy"], # 农场币种子单价
|
||||
plant["vipBuy"], # 点券种子单价
|
||||
plant["level"], # 解锁等级
|
||||
plant["price"], # 果实单价
|
||||
plant["experience"], # 收获经验
|
||||
@ -88,6 +107,8 @@ class CShopManager:
|
||||
sell, # 是否可上架交易行
|
||||
]
|
||||
)
|
||||
if isVip:
|
||||
dataList[-1][2] = plant["vipBuy"] # 点券种子单价
|
||||
|
||||
# 页码标题
|
||||
title = f"种子商店 页数: {page}/{pageCount}"
|
||||
|
||||
Binary file not shown.
@ -528,7 +528,7 @@
|
||||
<div class="decoration decoration-2"></div>
|
||||
|
||||
<div class="feature-header">
|
||||
<div class="feature-name">播种</div>
|
||||
<div class="feature-name">出售作物</div>
|
||||
</div>
|
||||
|
||||
<div class="parameters-section">
|
||||
@ -548,7 +548,7 @@
|
||||
<div class="logic-section">
|
||||
<div class="logic-title">操作提示</div>
|
||||
<div class="logic-content">
|
||||
• 不填写作物名将售卖仓库种全部作物
|
||||
• 不填写作物名将售卖仓库种全部作物<br>
|
||||
• 填作物名不填数量将指定作物全部出售
|
||||
</div>
|
||||
</div>
|
||||
@ -666,6 +666,110 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="feature-box">
|
||||
<div class="decoration decoration-1"></div>
|
||||
<div class="decoration decoration-2"></div>
|
||||
|
||||
<div class="feature-header">
|
||||
<div class="feature-name">作物加锁</div>
|
||||
</div>
|
||||
|
||||
<div class="parameters-section">
|
||||
<div class="section-title">参数列表</div>
|
||||
<div class="parameters-list">
|
||||
<div class="parameter-item optional-param">
|
||||
<span class="param-badge required-badge">必填</span>
|
||||
<span class="param-description">地块ID</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="logic-section">
|
||||
<div class="logic-title">操作提示</div>
|
||||
<div class="logic-content">
|
||||
• 地块ID通过农场详述获取
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="feature-box">
|
||||
<div class="decoration decoration-1"></div>
|
||||
<div class="decoration decoration-2"></div>
|
||||
|
||||
<div class="feature-header">
|
||||
<div class="feature-name">作物解锁</div>
|
||||
</div>
|
||||
|
||||
<div class="parameters-section">
|
||||
<div class="section-title">参数列表</div>
|
||||
<div class="parameters-list">
|
||||
<div class="parameter-item optional-param">
|
||||
<span class="param-badge required-badge">必填</span>
|
||||
<span class="param-description">地块ID</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="logic-section">
|
||||
<div class="logic-title">操作提示</div>
|
||||
<div class="logic-content">
|
||||
• 地块ID通过农场详述获取
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="feature-box">
|
||||
<div class="decoration decoration-1"></div>
|
||||
<div class="decoration decoration-2"></div>
|
||||
|
||||
<div class="feature-header">
|
||||
<div class="feature-name">我的点券</div>
|
||||
</div>
|
||||
|
||||
<div class="parameters-section">
|
||||
<div class="section-title">参数列表</div>
|
||||
<div class="parameters-list">
|
||||
<div class="parameter-item optional-param">
|
||||
<span class="param-badge required-badge">必填</span>
|
||||
<span class="param-description">地块ID</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="logic-section">
|
||||
<div class="logic-title">操作提示</div>
|
||||
<div class="logic-content">
|
||||
• 地块ID通过农场详述获取
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="feature-box">
|
||||
<div class="decoration decoration-1"></div>
|
||||
<div class="decoration decoration-2"></div>
|
||||
|
||||
<div class="feature-header">
|
||||
<div class="feature-name">点券兑换</div>
|
||||
</div>
|
||||
|
||||
<div class="parameters-section">
|
||||
<div class="section-title">参数列表</div>
|
||||
<div class="parameters-list">
|
||||
<div class="parameter-item optional-param">
|
||||
<span class="param-badge required-badge">必填</span>
|
||||
<span class="param-description">地块ID</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="logic-section">
|
||||
<div class="logic-title">操作提示</div>
|
||||
<div class="logic-content">
|
||||
• 地块ID通过农场详述获取
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user