Merge branch 'mx' into Beta
This commit is contained in:
commit
4841ceb871
@ -58,6 +58,12 @@ __plugin_meta__ = PluginMetadata(
|
|||||||
help="金币兑换农场币的倍数 默认值为: 2倍",
|
help="金币兑换农场币的倍数 默认值为: 2倍",
|
||||||
default_value="2",
|
default_value="2",
|
||||||
),
|
),
|
||||||
|
RegisterConfig(
|
||||||
|
key="点券兑换倍数",
|
||||||
|
value="2000",
|
||||||
|
help="农场币兑换点券的倍数 比例为2000:1",
|
||||||
|
default_value="2000",
|
||||||
|
),
|
||||||
RegisterConfig(
|
RegisterConfig(
|
||||||
key="手续费",
|
key="手续费",
|
||||||
value="0.2",
|
value="0.2",
|
||||||
|
|||||||
73
command.py
73
command.py
@ -94,6 +94,9 @@ 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("my-vipPoint", help_text="我的点券"),
|
||||||
|
Subcommand("mx-change", Args["num?", int], help_text="mx管理员变更农场币"),
|
||||||
),
|
),
|
||||||
priority=5,
|
priority=5,
|
||||||
block=True,
|
block=True,
|
||||||
@ -646,3 +649,73 @@ async def _(session: Uninfo, num: Query[int] = AlconnaQuery("num", 0)):
|
|||||||
return
|
return
|
||||||
|
|
||||||
await g_pDBService.userSoil.nextPhase(uid, num.result)
|
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)
|
||||||
|
|
||||||
|
|
||||||
|
diuse_farm.shortcut(
|
||||||
|
"mx管理员变更农场币(.*?)",
|
||||||
|
command="我的农场",
|
||||||
|
arguments=["mx-change"],
|
||||||
|
prefix=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@diuse_farm.assign("mx-change")
|
||||||
|
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
|
||||||
|
|
||||||
|
await g_pDBService.user.updateUserPointByUid(uid, int(num.result))
|
||||||
|
message = f"伟大的米线大人把你的农场币变更为: {num.result} 农场币"
|
||||||
|
await MessageUtils.build_message(message).send(reply_to=True)
|
||||||
|
|||||||
@ -34,6 +34,7 @@ g_sTranslation = {
|
|||||||
"basic": {
|
"basic": {
|
||||||
"notFarm": "尚未开通农场,快at我发送 开通农场 开通吧 🌱🚜",
|
"notFarm": "尚未开通农场,快at我发送 开通农场 开通吧 🌱🚜",
|
||||||
"point": "你的当前农场币为: {point} 🌾💰",
|
"point": "你的当前农场币为: {point} 🌾💰",
|
||||||
|
"vipPoint": "你的当前点券为: {vipPoint} 🌾💰",
|
||||||
},
|
},
|
||||||
"register": {
|
"register": {
|
||||||
"success": "✅ 农场开通成功!\n💼 初始资金:{point}农场币 🥳🎉",
|
"success": "✅ 农场开通成功!\n💼 初始资金:{point}农场币 🥳🎉",
|
||||||
|
|||||||
22
farm/farm.py
22
farm/farm.py
@ -1148,5 +1148,27 @@ class CFarmManager:
|
|||||||
text=g_sTranslation["soilInfo"][soilLevelText],
|
text=g_sTranslation["soilInfo"][soilLevelText],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
async def pointToVipPointByUid(cls, uid: str, num: int) -> str:
|
||||||
|
if num <= 0:
|
||||||
|
return "点券兑换数量必须大于0"
|
||||||
|
|
||||||
|
pro = float(Config.get_config("zhenxun_plugin_farm", "点券兑换倍数"))
|
||||||
|
pro *= float(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 = float(num) + p
|
||||||
|
|
||||||
|
await g_pDBService.user.updateUserVipPointByUid(uid, int(number))
|
||||||
|
|
||||||
|
return f"兑换{num}点券成功,当前点券:{number},当前农场币:{point}"
|
||||||
|
|
||||||
|
|
||||||
g_pFarmManager = CFarmManager()
|
g_pFarmManager = CFarmManager()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user