✨ 新增收获逻辑

✨ 新增播种逻辑
✨ 新增绘制作物逻辑
This commit is contained in:
2025-03-20 18:06:38 +08:00
parent b1788f42c2
commit 59bb2068df
7 changed files with 454 additions and 151 deletions
+74 -38
View File
@@ -35,14 +35,12 @@ diuse_farm = on_alconna(
"我的农场",
Option("--all", action=store_true),
Subcommand("my-point", help_text="我的农场币"),
Subcommand("plant-shop", help_text="种子商店"),
Subcommand("buy-plant", Args["name?", str]["num?", int], help_text="购买种子"),
Subcommand("my-plant", help_text="我的种子"),
Subcommand("my-props", help_text="我的农场道具"),
Subcommand("seed-shop", help_text="种子商店"),
Subcommand("buy-seed", Args["name?", str]["num?", int], help_text="购买种子"),
Subcommand("my-seed", help_text="我的种子"),
Subcommand("sowing", Args["name?", str]["num?", int], help_text="播种"),
Subcommand("buy", Args["name?", str]["num?", int], help_text="购买道具"),
Subcommand("use", Args["name?", str]["num?", int], help_text="使用道具"),
Subcommand("gold-list", Args["num?", int], help_text="金币排行"),
Subcommand("harvest", help_text="收获"),
Subcommand("my-plant", help_text="我的作物")
),
priority=5,
rule=to_me(),
@@ -82,11 +80,11 @@ async def _(session: Uninfo):
diuse_farm.shortcut(
"种子商店",
command="我的农场",
arguments=["plant-shop"],
arguments=["seed-shop"],
prefix=True,
)
@diuse_farm.assign("plant-shop")
@diuse_farm.assign("seed-shop")
async def _(session: Uninfo):
uid = str(session.user.id)
point = await g_pSqlManager.getUserPointByUid(uid)
@@ -95,17 +93,17 @@ async def _(session: Uninfo):
await MessageUtils.build_message("尚未开通农场").send()
return None
image = await g_pShopManager.getPlantShopImage()
image = await g_pShopManager.getSeedShopImage()
await MessageUtils.build_message(image).send()
diuse_farm.shortcut(
"购买种子(?P<name>.*?)",
command="我的农场",
arguments=["buy-plant", "{name}"],
arguments=["buy-seed", "{name}"],
prefix=True,
)
@diuse_farm.assign("buy-plant")
@diuse_farm.assign("buy-seed")
async def _(session: Uninfo, name: Match[str], num: Query[int] = AlconnaQuery("num", 1),):
if not name.available:
await MessageUtils.build_message(
@@ -119,12 +117,75 @@ async def _(session: Uninfo, name: Match[str], num: Query[int] = AlconnaQuery("n
await MessageUtils.build_message("尚未开通农场").send()
return None
result = await g_pShopManager.buyPlant(uid, name.result, num.result)
result = await g_pShopManager.buySeed(uid, name.result, num.result)
await MessageUtils.build_message(result).send(reply_to=True)
diuse_farm.shortcut(
"我的种子",
command="我的农场",
arguments=["my-seed"],
prefix=True,
)
@diuse_farm.assign("my-seed")
async def _(session: Uninfo):
uid = str(session.user.id)
point = await g_pSqlManager.getUserPointByUid(uid)
if point < 0:
await MessageUtils.build_message("尚未开通农场").send()
return None
result = await g_pFarmManager.getUserSeedByUid(uid)
await MessageUtils.build_message(result).send(reply_to=True)
diuse_farm.shortcut(
"播种(?P<name>.*?)",
command="我的农场",
arguments=["sowing", "{name}"],
prefix=True,
)
@diuse_farm.assign("sowing")
async def _(session: Uninfo, name: Match[str], num: Query[int] = AlconnaQuery("num", 1),):
if not name.available:
await MessageUtils.build_message(
"请在指令后跟需要播种的种子名称"
).finish(reply_to=True)
uid = str(session.user.id)
point = await g_pSqlManager.getUserPointByUid(uid)
if point < 0:
await MessageUtils.build_message("尚未开通农场").send()
return None
result = await g_pFarmManager.sowing(uid, name.result, num.result)
await MessageUtils.build_message(result).send(reply_to=True)
diuse_farm.shortcut(
"收获",
command="我的农场",
arguments=["harvest"],
prefix=True,
)
@diuse_farm.assign("harvest")
async def _(session: Uninfo):
uid = str(session.user.id)
point = await g_pSqlManager.getUserPointByUid(uid)
if point < 0:
await MessageUtils.build_message("尚未开通农场").send()
return None
result = await g_pFarmManager.harvest(uid)
await MessageUtils.build_message(result).send(reply_to=True)
diuse_farm.shortcut(
"我的作物",
command="我的农场",
arguments=["my-plant"],
prefix=True,
)
@@ -140,28 +201,3 @@ async def _(session: Uninfo):
result = await g_pFarmManager.getUserPlantByUid(uid)
await MessageUtils.build_message(result).send(reply_to=True)
diuse_farm.shortcut(
"播种(?P<name>.*?)",
command="我的农场",
arguments=["sowing", "{name}"],
prefix=True,
)
async def _(session: Uninfo, name: Match[str], num: Query[int] = AlconnaQuery("num", 1),):
if not name.available:
await MessageUtils.build_message(
"请在指令后跟需要播种的种子名称"
).finish(reply_to=True)
uid = str(session.user.id)
point = await g_pSqlManager.getUserPointByUid(uid)
if point < 0:
await MessageUtils.build_message("尚未开通农场").send()
return None
return None
# result = await g_pShopManager.buyPlant(uid, name.result, num.result)
# await MessageUtils.build_message(result).send(reply_to=True)