commit
f16c1c5ab0
@ -58,6 +58,12 @@ __plugin_meta__ = PluginMetadata(
|
||||
help="金币兑换农场币的倍数 默认值为: 2倍",
|
||||
default_value="2",
|
||||
),
|
||||
RegisterConfig(
|
||||
key="点券兑换倍数",
|
||||
value="2000",
|
||||
help="农场币兑换点券的倍数 比例为2000:1",
|
||||
default_value="2000",
|
||||
),
|
||||
RegisterConfig(
|
||||
key="手续费",
|
||||
value="0.2",
|
||||
|
||||
49
command.py
49
command.py
@ -94,6 +94,8 @@ 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("my-vipPoint", help_text="我的点券")
|
||||
),
|
||||
priority=5,
|
||||
block=True,
|
||||
@ -646,3 +648,50 @@ async def _(session: Uninfo, num: Query[int] = AlconnaQuery("num", 0)):
|
||||
return
|
||||
|
||||
await g_pDBService.userSoil.nextPhase(uid, num.result)
|
||||
|
||||
|
||||
diuse_farm.shortcut(
|
||||
"农场币换点券(.*?)",
|
||||
command="我的农场",
|
||||
arguments=["point-to-vipPoint"],
|
||||
prefix=True,
|
||||
)
|
||||
|
||||
|
||||
@diuse_farm.assign("point-to-vipPoint")
|
||||
async def _(session: Uninfo, num: Query[int] = AlconnaQuery("num", 0)):
|
||||
if num.result <= 0:
|
||||
await MessageUtils.build_message("请在指令后跟需要购买点券的数量").finish(
|
||||
reply_to=True
|
||||
)
|
||||
|
||||
uid = str(session.user.id)
|
||||
|
||||
if not await g_pToolManager.isRegisteredByUid(uid):
|
||||
return
|
||||
|
||||
result = await g_pFarmManager.pointToVipPointByUid(uid, num.result)
|
||||
await MessageUtils.build_message(result).send(reply_to=True)
|
||||
|
||||
|
||||
diuse_farm.shortcut(
|
||||
"我的点券",
|
||||
command="我的农场",
|
||||
arguments=["my-vipPoint"],
|
||||
prefix=True,
|
||||
)
|
||||
|
||||
|
||||
@diuse_farm.assign("my-vipPoint")
|
||||
async def _(session: Uninfo):
|
||||
uid = str(session.user.id)
|
||||
vipPoint = await g_pDBService.user.getUserVipPointByUid(uid)
|
||||
|
||||
if not await g_pToolManager.isRegisteredByUid(uid):
|
||||
return
|
||||
|
||||
await MessageUtils.build_message(
|
||||
g_sTranslation["basic"]["vipPoint"].format(vipPoint=vipPoint)
|
||||
).send(reply_to=True)
|
||||
|
||||
|
||||
|
||||
@ -34,6 +34,7 @@ g_sTranslation = {
|
||||
"basic": {
|
||||
"notFarm": "尚未开通农场,快at我发送 开通农场 开通吧 🌱🚜",
|
||||
"point": "你的当前农场币为: {point} 🌾💰",
|
||||
"vipPoint": "你的当前点券为: {vipPoint} 🌾💰",
|
||||
},
|
||||
"register": {
|
||||
"success": "✅ 农场开通成功!\n💼 初始资金:{point}农场币 🥳🎉",
|
||||
|
||||
26
farm/farm.py
26
farm/farm.py
@ -1148,5 +1148,31 @@ class CFarmManager:
|
||||
text=g_sTranslation["soilInfo"][soilLevelText],
|
||||
)
|
||||
|
||||
@classmethod
|
||||
async def pointToVipPointByUid(cls, uid: str, num: int) -> str:
|
||||
"""农场币兑换点券
|
||||
num:用户传参,即将兑换的点券
|
||||
pro:兑换倍数;兑换倍数乘以num即为需要消耗的农场币
|
||||
"""
|
||||
if num <= 0:
|
||||
return "点券兑换数量必须大于0"
|
||||
|
||||
pro = int(Config.get_config("zhenxun_plugin_farm", "点券兑换倍数"))
|
||||
pro *= num
|
||||
|
||||
point = await g_pDBService.user.getUserPointByUid(uid)
|
||||
if point < pro:
|
||||
return f"你的农场币不足,当前农场币为{point},兑换还需要{pro - point}农场币"
|
||||
|
||||
point -= pro
|
||||
await g_pDBService.user.updateUserPointByUid(uid, int(point))
|
||||
|
||||
p = await g_pDBService.user.getUserVipPointByUid(uid)
|
||||
number = num + p
|
||||
|
||||
await g_pDBService.user.updateUserVipPointByUid(uid, int(number))
|
||||
|
||||
return f"兑换{num}点券成功,当前点券:{number},当前农场币:{point}"
|
||||
|
||||
|
||||
g_pFarmManager = CFarmManager()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user