🐛 修复若干个已知BUG
🐛 修复我的农场会导致报错的BUG 🐛 修复初始等级为1的BUG
This commit is contained in:
parent
98ae76560b
commit
46fecc7684
@ -17,6 +17,7 @@ __plugin_meta__ = PluginMetadata(
|
||||
usage="""
|
||||
你也要种地?
|
||||
指令:
|
||||
at 开通农场
|
||||
我的农场
|
||||
我的农场币
|
||||
种子商店
|
||||
@ -28,6 +29,7 @@ __plugin_meta__ = PluginMetadata(
|
||||
我的作物
|
||||
出售作物 [作物/种子名称] [数量]
|
||||
偷菜 at
|
||||
开垦
|
||||
购买农场币 [数量] 金币转换农场币比率是 1 : 2
|
||||
""".strip(),
|
||||
extra=PluginExtraData(
|
||||
|
||||
101
command.py
101
command.py
@ -43,6 +43,7 @@ diuse_farm = on_alconna(
|
||||
Subcommand("harvest", help_text="收获"),
|
||||
Subcommand("eradicate", help_text="铲除"),
|
||||
Subcommand("my-plant", help_text="我的作物"),
|
||||
# Subcommand("reclamation", help_text="开垦"),
|
||||
Subcommand("sell-plant", Args["name?", str]["num?", int], help_text="出售作物"),
|
||||
Subcommand("stealing", Args["target?", At], help_text="偷菜"),
|
||||
Subcommand("buy-point", Args["num?", int], help_text="购买农场币"),
|
||||
@ -58,7 +59,7 @@ async def _(session: Uninfo):
|
||||
point = await g_pSqlManager.getUserPointByUid(uid)
|
||||
|
||||
if point < 0:
|
||||
await MessageUtils.build_message("尚未开通农场").send()
|
||||
await MessageUtils.build_message("尚未开通农场,快at我发送 开通农场 开通吧").send()
|
||||
return None
|
||||
|
||||
image = await g_pFarmManager.drawFarmByUid(uid)
|
||||
@ -77,7 +78,7 @@ async def _(session: Uninfo):
|
||||
point = await g_pSqlManager.getUserPointByUid(uid)
|
||||
|
||||
if point < 0:
|
||||
await MessageUtils.build_message("尚未开通农场").send()
|
||||
await MessageUtils.build_message("尚未开通农场,快at我发送 开通农场 开通吧").send()
|
||||
return None
|
||||
|
||||
await MessageUtils.build_message(f"你的当前农场币为: {point}").send(reply_to=True)
|
||||
@ -95,7 +96,7 @@ async def _(session: Uninfo):
|
||||
point = await g_pSqlManager.getUserPointByUid(uid)
|
||||
|
||||
if point < 0:
|
||||
await MessageUtils.build_message("尚未开通农场").send()
|
||||
await MessageUtils.build_message("尚未开通农场,快at我发送 开通农场 开通吧").send()
|
||||
return None
|
||||
|
||||
image = await g_pShopManager.getSeedShopImage()
|
||||
@ -119,7 +120,7 @@ async def _(session: Uninfo, name: Match[str], num: Query[int] = AlconnaQuery("n
|
||||
point = await g_pSqlManager.getUserPointByUid(uid)
|
||||
|
||||
if point < 0:
|
||||
await MessageUtils.build_message("尚未开通农场").send()
|
||||
await MessageUtils.build_message("尚未开通农场,快at我发送 开通农场 开通吧").send()
|
||||
return None
|
||||
|
||||
result = await g_pShopManager.buySeed(uid, name.result, num.result)
|
||||
@ -138,7 +139,7 @@ async def _(session: Uninfo):
|
||||
point = await g_pSqlManager.getUserPointByUid(uid)
|
||||
|
||||
if point < 0:
|
||||
await MessageUtils.build_message("尚未开通农场").send()
|
||||
await MessageUtils.build_message("尚未开通农场,快at我发送 开通农场 开通吧").send()
|
||||
return None
|
||||
|
||||
result = await g_pFarmManager.getUserSeedByUid(uid)
|
||||
@ -162,7 +163,7 @@ async def _(session: Uninfo, name: Match[str], num: Query[int] = AlconnaQuery("n
|
||||
point = await g_pSqlManager.getUserPointByUid(uid)
|
||||
|
||||
if point < 0:
|
||||
await MessageUtils.build_message("尚未开通农场").send()
|
||||
await MessageUtils.build_message("尚未开通农场,快at我发送 开通农场 开通吧").send()
|
||||
return None
|
||||
|
||||
result = await g_pFarmManager.sowing(uid, name.result, num.result)
|
||||
@ -182,7 +183,7 @@ async def _(session: Uninfo):
|
||||
point = await g_pSqlManager.getUserPointByUid(uid)
|
||||
|
||||
if point < 0:
|
||||
await MessageUtils.build_message("尚未开通农场").send()
|
||||
await MessageUtils.build_message("尚未开通农场,快at我发送 开通农场 开通吧").send()
|
||||
return None
|
||||
|
||||
result = await g_pFarmManager.harvest(uid)
|
||||
@ -201,7 +202,7 @@ async def _(session: Uninfo):
|
||||
point = await g_pSqlManager.getUserPointByUid(uid)
|
||||
|
||||
if point < 0:
|
||||
await MessageUtils.build_message("尚未开通农场").send()
|
||||
await MessageUtils.build_message("尚未开通农场,快at我发送 开通农场 开通吧").send()
|
||||
return None
|
||||
|
||||
result = await g_pFarmManager.eradicate(uid)
|
||||
@ -221,12 +222,32 @@ async def _(session: Uninfo):
|
||||
point = await g_pSqlManager.getUserPointByUid(uid)
|
||||
|
||||
if point < 0:
|
||||
await MessageUtils.build_message("尚未开通农场").send()
|
||||
await MessageUtils.build_message("尚未开通农场,快at我发送 开通农场 开通吧").send()
|
||||
return None
|
||||
|
||||
result = await g_pFarmManager.getUserPlantByUid(uid)
|
||||
await MessageUtils.build_message(result).send(reply_to=True)
|
||||
|
||||
# diuse_farm.shortcut(
|
||||
# "开垦",
|
||||
# command="我的农场",
|
||||
# arguments=["reclamation"],
|
||||
# prefix=True,
|
||||
# )
|
||||
|
||||
# @diuse_farm.assign("reclamation")
|
||||
# async def _(session: Uninfo):
|
||||
# uid = str(session.user.id)
|
||||
# point = await g_pSqlManager.getUserPointByUid(uid)
|
||||
|
||||
# if point < 0:
|
||||
# await MessageUtils.build_message("尚未开通农场,快at我发送 开通农场 开通吧").send()
|
||||
# return None
|
||||
|
||||
# result = await g_pFarmManager.getUserPlantByUid(uid)
|
||||
# await MessageUtils.build_message(result).send(reply_to=True)
|
||||
|
||||
|
||||
diuse_farm.shortcut(
|
||||
"出售作物(?P<name>.*?)",
|
||||
command="我的农场",
|
||||
@ -245,12 +266,41 @@ async def _(session: Uninfo, name: Match[str], num: Query[int] = AlconnaQuery("n
|
||||
point = await g_pSqlManager.getUserPointByUid(uid)
|
||||
|
||||
if point < 0:
|
||||
await MessageUtils.build_message("尚未开通农场").send()
|
||||
await MessageUtils.build_message("尚未开通农场,快at我发送 开通农场 开通吧").send()
|
||||
return None
|
||||
|
||||
result = await g_pShopManager.sellPlantByUid(uid, name.result, num.result)
|
||||
await MessageUtils.build_message(result).send(reply_to=True)
|
||||
|
||||
diuse_farm.shortcut(
|
||||
"偷菜",
|
||||
command="我的农场",
|
||||
arguments=["stealing"],
|
||||
prefix=True,
|
||||
)
|
||||
|
||||
@diuse_farm.assign("stealing")
|
||||
async def _(session: Uninfo, target: Match[At]):
|
||||
uid = str(session.user.id)
|
||||
point = await g_pSqlManager.getUserPointByUid(uid)
|
||||
|
||||
if point < 0:
|
||||
await MessageUtils.build_message("尚未开通农场,快at我发送 开通农场 开通吧").send()
|
||||
return None
|
||||
|
||||
if not target.available:
|
||||
await MessageUtils.build_message("请在指令后跟需要at的人").finish(reply_to=True)
|
||||
|
||||
tar = target.result
|
||||
point = await g_pSqlManager.getUserPointByUid(tar.target)
|
||||
|
||||
if point < 0:
|
||||
await MessageUtils.build_message("尚未开通农场,快at我发送 开通农场 开通吧").send()
|
||||
return None
|
||||
|
||||
result = await g_pFarmManager.stealing(uid, tar.target)
|
||||
await MessageUtils.build_message(result).send(reply_to=True)
|
||||
|
||||
diuse_farm.shortcut(
|
||||
"购买农场币(.*?)",
|
||||
command="我的农场",
|
||||
@ -269,37 +319,8 @@ async def _(session: Uninfo, num: Query[int] = AlconnaQuery("num", 0)):
|
||||
point = await g_pSqlManager.getUserPointByUid(uid)
|
||||
|
||||
if point < 0:
|
||||
await MessageUtils.build_message("尚未开通农场").send()
|
||||
await MessageUtils.build_message("尚未开通农场,快at我发送 开通农场 开通吧").send()
|
||||
return None
|
||||
|
||||
result = await g_pFarmManager.buyPointByUid(uid, num.result)
|
||||
await MessageUtils.build_message(result).send(reply_to=True)
|
||||
|
||||
diuse_farm.shortcut(
|
||||
"偷菜",
|
||||
command="我的农场",
|
||||
arguments=["stealing"],
|
||||
prefix=True,
|
||||
)
|
||||
|
||||
@diuse_farm.assign("stealing")
|
||||
async def _(session: Uninfo, target: Match[At]):
|
||||
uid = str(session.user.id)
|
||||
point = await g_pSqlManager.getUserPointByUid(uid)
|
||||
|
||||
if point < 0:
|
||||
await MessageUtils.build_message("尚未开通农场").send()
|
||||
return None
|
||||
|
||||
if not target.available:
|
||||
await MessageUtils.build_message("请在指令后跟需要at的人").finish(reply_to=True)
|
||||
|
||||
tar = target.result
|
||||
point = await g_pSqlManager.getUserPointByUid(tar.target)
|
||||
|
||||
if point < 0:
|
||||
await MessageUtils.build_message("尚未开通农场").send()
|
||||
return None
|
||||
|
||||
result = await g_pFarmManager.stealing(uid, tar.target)
|
||||
await MessageUtils.build_message(result).send(reply_to=True)
|
||||
|
||||
@ -1,12 +1,13 @@
|
||||
{
|
||||
"level":
|
||||
{
|
||||
"1": 0,
|
||||
"2": 50,
|
||||
"3": 75,
|
||||
"4": 125,
|
||||
"5": 185,
|
||||
"6": 200,
|
||||
"0": 0,
|
||||
"1": 50,
|
||||
"2": 75,
|
||||
"3": 125,
|
||||
"4": 185,
|
||||
"5": 200,
|
||||
"6": 250,
|
||||
"7": 275,
|
||||
"8": 350,
|
||||
"9": 500,
|
||||
|
||||
@ -144,7 +144,7 @@ class CSqlManager:
|
||||
if not await cls.executeDB(userSoilInfo):
|
||||
return False
|
||||
|
||||
return True
|
||||
return "开通农场成功"
|
||||
|
||||
@classmethod
|
||||
async def getUserInfoByUid(cls, uid: str) -> dict:
|
||||
@ -324,7 +324,7 @@ class CSqlManager:
|
||||
|
||||
async with cls.m_pDB.execute(f"SELECT soil FROM user WHERE uid = '{uid}'") as cursor:
|
||||
async for row in cursor:
|
||||
if row[0] == None or len(row[0]) <= 0:
|
||||
if not row[0]:
|
||||
return 0
|
||||
else:
|
||||
return int(row[0])
|
||||
|
||||
18
farm/farm.py
18
farm/farm.py
@ -4,7 +4,6 @@ from datetime import date, datetime
|
||||
from io import StringIO
|
||||
from typing import Dict, List, Tuple
|
||||
|
||||
from Python311.Lib.PIL.ImImagePlugin import number
|
||||
from zhenxun.models.user_console import UserConsole
|
||||
from zhenxun.services.log import logger
|
||||
from zhenxun.utils._build_image import BuildImage
|
||||
@ -72,7 +71,7 @@ class CFarmManager:
|
||||
y = soilPos[str(index + 1)]['y']
|
||||
|
||||
#如果土地已经到达对应等级
|
||||
if index > soilUnlock:
|
||||
if index < soilUnlock:
|
||||
await img.paste(soil, (x, y))
|
||||
|
||||
isPlant, plant, isRipe= await cls.drawSoilPlant(uid, f"soil{str(index + 1)}")
|
||||
@ -273,8 +272,6 @@ class CFarmManager:
|
||||
# 更新种子数量
|
||||
num -= 1
|
||||
plantDict[name] -= 1
|
||||
if plantDict[name] == 0:
|
||||
del plantDict[name]
|
||||
|
||||
# 更新数据库
|
||||
await g_pSqlManager.updateUserSoilStatusByPlantName(uid, soilName, name)
|
||||
@ -443,7 +440,7 @@ class CFarmManager:
|
||||
else:
|
||||
sell = "不可以"
|
||||
|
||||
number = count * int(plantInfo['price'])
|
||||
number = int(count) * plantInfo['price']
|
||||
|
||||
data_list.append(
|
||||
[
|
||||
@ -570,5 +567,16 @@ class CFarmManager:
|
||||
|
||||
return "\n".join(harvestRecords)
|
||||
|
||||
# @classmethod
|
||||
# async def reclamation(cls, uid: str) -> str:
|
||||
|
||||
# userInfo = await g_pSqlManager.getUserInfoByUid(uid)
|
||||
# level = await g_pSqlManager.getUserLevelByUid(uid)
|
||||
|
||||
# rec = g_pJsonManager["reclamation"] # type: ignore
|
||||
|
||||
# if not rec[f"{userInfo["soil"] + 1}"] == None
|
||||
|
||||
# return ""
|
||||
|
||||
g_pFarmManager = CFarmManager()
|
||||
|
||||
@ -93,7 +93,7 @@ class CShopManager:
|
||||
return "购买出错!请检查需购买的种子名称!"
|
||||
|
||||
|
||||
level = g_pSqlManager.getUserLevelByUid(uid)
|
||||
level = await g_pSqlManager.getUserLevelByUid(uid)
|
||||
|
||||
if level < plantInfo['level']:
|
||||
return "你的等级不够哦,努努力吧"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user