Merge branches 'Beta' and 'Beta' of https://github.com/Shu-Ying/zhenxun_plugin_farm into Beta
This commit is contained in:
commit
1be91147c1
53
command.py
53
command.py
@ -93,9 +93,10 @@ diuse_farm = on_alconna(
|
|||||||
Subcommand("change-name", Args["name?", str], help_text="更改农场名"),
|
Subcommand("change-name", Args["name?", str], help_text="更改农场名"),
|
||||||
Subcommand("sign-in", help_text="农场签到"),
|
Subcommand("sign-in", help_text="农场签到"),
|
||||||
Subcommand("admin-up", Args["num?", int], 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("my-vipPoint", help_text="我的点券"),
|
||||||
Subcommand("farm-help", help_text="农场帮助"),
|
Subcommand("farm-help", help_text="农场帮助"),
|
||||||
|
Subcommand("vipSeed-shop", Args["res?", MultiVar(str)], help_text="种子商店"),
|
||||||
),
|
),
|
||||||
priority=5,
|
priority=5,
|
||||||
block=True,
|
block=True,
|
||||||
@ -209,9 +210,9 @@ async def _(session: Uninfo, res: Match[tuple[str, ...]]):
|
|||||||
page = int(raw[1])
|
page = int(raw[1])
|
||||||
|
|
||||||
if filterKey is None:
|
if filterKey is None:
|
||||||
image = await g_pShopManager.getSeedShopImage(page)
|
image = await g_pShopManager.getSeedShopImage(page, 0, 0)
|
||||||
else:
|
else:
|
||||||
image = await g_pShopManager.getSeedShopImage(filterKey, page)
|
image = await g_pShopManager.getSeedShopImage(filterKey, page, 0)
|
||||||
|
|
||||||
await MessageUtils.build_message(image).send()
|
await MessageUtils.build_message(image).send()
|
||||||
|
|
||||||
@ -748,3 +749,49 @@ async def _(session: Uninfo):
|
|||||||
image = BuildImage(background=savePath)
|
image = BuildImage(background=savePath)
|
||||||
|
|
||||||
await MessageUtils.build_message(image).send(reply_to=True)
|
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
core/shop.py
43
core/shop.py
@ -9,7 +9,9 @@ from ..utils.tool import g_pToolManager
|
|||||||
|
|
||||||
class CShopManager:
|
class CShopManager:
|
||||||
@classmethod
|
@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:
|
Args:
|
||||||
@ -34,7 +36,6 @@ class CShopManager:
|
|||||||
"-",
|
"-",
|
||||||
"种子名称",
|
"种子名称",
|
||||||
"农场币",
|
"农场币",
|
||||||
"点券",
|
|
||||||
"解锁等级",
|
"解锁等级",
|
||||||
"果实单价",
|
"果实单价",
|
||||||
"收获经验",
|
"收获经验",
|
||||||
@ -47,14 +48,33 @@ class CShopManager:
|
|||||||
# 查询所有可购买作物,并根据筛选关键字过滤
|
# 查询所有可购买作物,并根据筛选关键字过滤
|
||||||
plants = await g_pDBService.plant.listPlants()
|
plants = await g_pDBService.plant.listPlants()
|
||||||
filteredPlants = []
|
filteredPlants = []
|
||||||
for plant in plants:
|
|
||||||
# 跳过未解锁购买的种子
|
# 如果是点券商店
|
||||||
if plant["isBuy"] == 0:
|
if isVip:
|
||||||
continue
|
columnName[2] = "点券"
|
||||||
# 字符串筛选
|
for plant in plants:
|
||||||
if filterStr and filterStr not in plant["name"]:
|
# 只留下点券购买的种子
|
||||||
continue
|
if plant["isVip"] == 0:
|
||||||
filteredPlants.append(plant)
|
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)
|
totalCount = len(filteredPlants)
|
||||||
@ -79,7 +99,6 @@ class CShopManager:
|
|||||||
icon,
|
icon,
|
||||||
plant["name"], # 种子名称
|
plant["name"], # 种子名称
|
||||||
plant["buy"], # 农场币种子单价
|
plant["buy"], # 农场币种子单价
|
||||||
plant["vipBuy"], # 点券种子单价
|
|
||||||
plant["level"], # 解锁等级
|
plant["level"], # 解锁等级
|
||||||
plant["price"], # 果实单价
|
plant["price"], # 果实单价
|
||||||
plant["experience"], # 收获经验
|
plant["experience"], # 收获经验
|
||||||
@ -89,6 +108,8 @@ class CShopManager:
|
|||||||
sell, # 是否可上架交易行
|
sell, # 是否可上架交易行
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
if isVip:
|
||||||
|
dataList[-1][2] = plant["vipBuy"] # 点券种子单价
|
||||||
|
|
||||||
# 页码标题
|
# 页码标题
|
||||||
title = f"种子商店 页数: {page}/{pageCount}"
|
title = f"种子商店 页数: {page}/{pageCount}"
|
||||||
|
|||||||
Binary file not shown.
@ -528,7 +528,7 @@
|
|||||||
<div class="decoration decoration-2"></div>
|
<div class="decoration decoration-2"></div>
|
||||||
|
|
||||||
<div class="feature-header">
|
<div class="feature-header">
|
||||||
<div class="feature-name">播种</div>
|
<div class="feature-name">出售作物</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="parameters-section">
|
<div class="parameters-section">
|
||||||
@ -548,7 +548,7 @@
|
|||||||
<div class="logic-section">
|
<div class="logic-section">
|
||||||
<div class="logic-title">操作提示</div>
|
<div class="logic-title">操作提示</div>
|
||||||
<div class="logic-content">
|
<div class="logic-content">
|
||||||
• 不填写作物名将售卖仓库种全部作物
|
• 不填写作物名将售卖仓库种全部作物<br>
|
||||||
• 填作物名不填数量将指定作物全部出售
|
• 填作物名不填数量将指定作物全部出售
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -666,6 +666,110 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</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>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user