diff --git a/command.py b/command.py index f9b6e1c..e156f41 100644 --- a/command.py +++ b/command.py @@ -8,6 +8,7 @@ from nonebot_plugin_uninfo import Uninfo from nonebot_plugin_waiter import waiter from zhenxun.services.log import logger +from zhenxun.utils.depends import UserName from zhenxun.utils.message import MessageUtils from .database import g_pSqlManager @@ -68,13 +69,13 @@ diuse_farm = on_alconna( ) @diuse_farm.assign("$main") -async def _(session: Uninfo): +async def _(session: Uninfo, nickname: str = UserName()): uid = str(session.user.id) if await isRegisteredByUid(uid) == False: return - image = await g_pFarmManager.drawFarmByUid(uid) + image = await g_pFarmManager.drawFarmByUid(uid, nickname) await MessageUtils.build_message(image).send(reply_to=True) diuse_farm.shortcut( diff --git a/farm/farm.py b/farm/farm.py index ac2ec2b..552a6bd 100644 --- a/farm/farm.py +++ b/farm/farm.py @@ -13,6 +13,7 @@ from zhenxun.services.log import logger from zhenxun.utils._build_image import BuildImage from zhenxun.utils.enum import GoldHandle from zhenxun.utils.image_utils import ImageTemplate +from zhenxun.utils.platform import PlatformUtils from ..config import g_pJsonManager, g_sResourcePath from ..database import g_pSqlManager @@ -50,7 +51,7 @@ class CFarmManager: return f"充值{point}农场币成功,手续费{tax}金币,当前农场币:{number}" @classmethod - async def drawFarmByUid(cls, uid: str) -> bytes: + async def drawFarmByUid(cls, uid: str, name: str) -> bytes: """绘制用户农场 Args: @@ -59,7 +60,7 @@ class CFarmManager: Returns: bytes: 返回绘制结果 """ - img = BuildImage(background = g_sResourcePath / "background/background.png") + img = BuildImage(background = g_sResourcePath / "background/background.jpg") soilSize = g_pJsonManager.m_pSoil['size'] @@ -113,34 +114,31 @@ class CFarmManager: await img.paste(expansion, (x + soilSize[0] // 2 - expansion.width // 2, y + soilSize[1] // 2 - expansion.height)) - #绘制背景信息 - #小屋 - hut = BuildImage(background = g_sResourcePath / "background/hut.png") - await hut.resize(0, 600, 661) - await img.paste(hut, (1700, 100)) - - #犬舍 - kennel = BuildImage(background = g_sResourcePath / "background/kennel.png") - await img.paste(kennel, (300, 750)) - - #交易 - trade = BuildImage(background = g_sResourcePath / "background/trade.png") - await img.paste(trade, (555, 510)) - - #魔法 - magic = BuildImage(background = g_sResourcePath / "background/magic.png") - await img.paste(magic, (850, 450)) - - #信箱 - mailbox = BuildImage(background = g_sResourcePath / "background/mailbox.png") - await img.paste(mailbox, (800, 550)) - - #渔场 - fisheries = BuildImage(background = g_sResourcePath / "background/fisheries.png") - await img.paste(fisheries, (1120, 1000)) - #左上角绘制用户信息 - await img.resize(0.5) + #头像 + image = await PlatformUtils.get_user_avatar(uid, "qq") + + if image: + avatar = BuildImage(background = image) + + await img.paste(avatar, (125, 85)) + + #头像框 + frame = BuildImage(background = g_sResourcePath / "background/frame.png") + await img.paste(frame, (75, 44)) + + #用户名 + nameImg = await BuildImage.build_text_image(name) + await img.paste(nameImg, (300, 100)) + + #经验值 + + #金币 + + #点券 + + + # await img.resize(0.4) return img.pic2bytes() @classmethod diff --git a/farm/shop.py b/farm/shop.py index a7a37e2..6d7dde8 100644 --- a/farm/shop.py +++ b/farm/shop.py @@ -1,6 +1,5 @@ import math -from Python311.Lib._pytest.mark.structures import istestfunc from zhenxun.services.log import logger from zhenxun.utils._build_image import BuildImage from zhenxun.utils.image_utils import ImageTemplate diff --git a/resource/background/background.jpg b/resource/background/background.jpg new file mode 100644 index 0000000..3f8f9fa Binary files /dev/null and b/resource/background/background.jpg differ diff --git a/resource/background/background.png b/resource/background/background.png index b2c5683..deefad1 100644 Binary files a/resource/background/background.png and b/resource/background/background.png differ diff --git a/resource/background/fisheries.png b/resource/background/fisheries.png deleted file mode 100644 index b667060..0000000 Binary files a/resource/background/fisheries.png and /dev/null differ diff --git a/resource/background/hut.png b/resource/background/hut.png deleted file mode 100644 index 81d166a..0000000 Binary files a/resource/background/hut.png and /dev/null differ diff --git a/resource/background/info.png b/resource/background/info.png deleted file mode 100644 index 7847b21..0000000 Binary files a/resource/background/info.png and /dev/null differ diff --git a/resource/background/kennel.png b/resource/background/kennel.png deleted file mode 100644 index c1d8484..0000000 Binary files a/resource/background/kennel.png and /dev/null differ diff --git a/resource/background/magic.png b/resource/background/magic.png deleted file mode 100644 index 4dd467f..0000000 Binary files a/resource/background/magic.png and /dev/null differ diff --git a/resource/background/mailbox.png b/resource/background/mailbox.png deleted file mode 100644 index 3a73ec7..0000000 Binary files a/resource/background/mailbox.png and /dev/null differ diff --git a/resource/background/trade.png b/resource/background/trade.png deleted file mode 100644 index 421ad13..0000000 Binary files a/resource/background/trade.png and /dev/null differ