From 198ee3a71f09b3ec055e1a4c0e1712d4ea08a3e6 Mon Sep 17 00:00:00 2001 From: CMHopeSunshine <277073121@qq.com> Date: Thu, 8 Sep 2022 17:51:51 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E4=BF=AE=E5=A4=8D`=E5=8E=9F=E7=A5=9E?= =?UTF-8?q?=E6=97=A5=E5=8E=86`=E6=9D=83=E9=99=90=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E5=92=8C`ysa`=E6=9C=AA=E7=9F=A5=E5=88=B6=E5=9B=BE=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugins/Genshin_Calendar/__init__.py | 11 +++--- LittlePaimon/plugins/Paimon_Gacha_Log/draw.py | 6 +-- .../plugins/Paimon_Info/draw_character_bag.py | 38 ++++++++++--------- 3 files changed, 29 insertions(+), 26 deletions(-) diff --git a/LittlePaimon/plugins/Genshin_Calendar/__init__.py b/LittlePaimon/plugins/Genshin_Calendar/__init__.py index 4121fe2..cb4e3ee 100644 --- a/LittlePaimon/plugins/Genshin_Calendar/__init__.py +++ b/LittlePaimon/plugins/Genshin_Calendar/__init__.py @@ -1,15 +1,12 @@ -from typing import Union - from nonebot import get_bot, on_command -from nonebot.adapters.onebot.v11 import MessageEvent, MessageSegment, GROUP_ADMIN -from nonebot.permission import SUPERUSER +from nonebot.adapters.onebot.v11 import MessageEvent, MessageSegment from nonebot.plugin import PluginMetadata from .generate import * from LittlePaimon.utils.message import CommandObjectID, CommandSwitch, CommandTime from LittlePaimon.utils import scheduler, logger from LittlePaimon.database.models import GeneralSub -from LittlePaimon import DRIVER +from LittlePaimon import DRIVER, SUPERUSERS __plugin_meta__ = PluginMetadata( name="原神日历", @@ -26,7 +23,7 @@ __plugin_meta__ = PluginMetadata( }, ) -calendar = on_command('原神日历', aliases={'原神日程', '活动日历'}, permission=SUPERUSER | GROUP_ADMIN, priority=10, block=True) +calendar = on_command('原神日历', aliases={'原神日程', '活动日历'}, priority=10, block=True) @calendar.handle() @@ -35,6 +32,8 @@ async def _(event: MessageEvent, sub_id=CommandObjectID(), switch=CommandSwitch( im = await generate_day_schedule('cn') await calendar.finish(MessageSegment.image(im)) else: + if event.sender.role not in ['admin', 'owner'] or event.user_id not in SUPERUSERS: + await calendar.finish('你没有权限管理原神日历订阅') sub_data = {'sub_id': sub_id, 'sub_type': event.message_type, 'sub_event': '原神日历'} if event.message_type == 'guild': diff --git a/LittlePaimon/plugins/Paimon_Gacha_Log/draw.py b/LittlePaimon/plugins/Paimon_Gacha_Log/draw.py index 0e3e31e..6d83bf9 100644 --- a/LittlePaimon/plugins/Paimon_Gacha_Log/draw.py +++ b/LittlePaimon/plugins/Paimon_Gacha_Log/draw.py @@ -175,9 +175,9 @@ async def draw_gacha_log(user_id: str, uid: str, nickname: Optional[str], signat await img.text(str(total_five_star_count), (789, 884), 286, fm.get('bahnschrift_regular', 48), '#040404', 'center') four_star_detail = await draw_four_star_detail(list(data4.values())) if total_five_star_count: - chara_pool_per = round(len(data5['角色祈愿']) / total_five_star_count * 100, 3) - weapon_pool_per = round(len(data5['武器祈愿']) / total_five_star_count * 100, 3) - new_pool_per = round((len(data5['常驻祈愿']) + len(data5['新手祈愿'])) / total_five_star_count * 100, 3) + chara_pool_per = round(len(data5['角色祈愿']) / total_five_star_count * 100, 1) + weapon_pool_per = round(len(data5['武器祈愿']) / total_five_star_count * 100, 1) + new_pool_per = round((len(data5['常驻祈愿']) + len(data5['新手祈愿'])) / total_five_star_count * 100, 1) now_used_width = 56 pers = [chara_pool_per, weapon_pool_per, new_pool_per] i = 0 diff --git a/LittlePaimon/plugins/Paimon_Info/draw_character_bag.py b/LittlePaimon/plugins/Paimon_Info/draw_character_bag.py index b3a1803..32c3a19 100644 --- a/LittlePaimon/plugins/Paimon_Info/draw_character_bag.py +++ b/LittlePaimon/plugins/Paimon_Info/draw_character_bag.py @@ -40,23 +40,27 @@ def sort_characters(characters: List[Character]) -> List[Character]: 圣遗物每级0.5/0.8/1分,每个两件套20分,四件套60分,最后按降序排序 """ for chara in characters: - chara.score = chara.level * (0.8 if chara.rarity == 4 else 1) + chara.fetter * 3 - if chara.talents: - for talent in chara.talents: - chara.score += talent.level * (5 if talent.level <= 6 else 8) - chara.score += len(chara.constellation) * (15 if chara.rarity == 4 else 50) - if chara.weapon: - chara.score += chara.weapon.level * ( - 0.6 if chara.weapon.rarity <= 3 else 0.8 if chara.weapon.rarity == 4 else 1) - chara.score += chara.weapon.affix_level * ( - 10 if chara.weapon.rarity <= 3 else 20 if chara.weapon.rarity == 4 else 50) - if chara.artifacts: - suit = GenshinTools.get_artifact_suit(chara.artifacts) - chara.suit = suit - chara.score += 60 if len(suit) == 2 and suit[0] == suit[1] else 20 * len(suit) - for artifact in chara.artifacts: - chara.score += artifact.level * (0.5 if artifact.rarity <= 3 else 0.8 if artifact.rarity == 4 else 1) - else: + try: + chara.score = chara.level * (0.8 if chara.rarity == 4 else 1) + chara.fetter * 3 + if chara.talents: + for talent in chara.talents: + chara.score += talent.level * (5 if talent.level <= 6 else 8) + chara.score += len(chara.constellation) * (15 if chara.rarity == 4 else 50) + if chara.weapon: + chara.score += chara.weapon.level * ( + 0.6 if chara.weapon.rarity <= 3 else 0.8 if chara.weapon.rarity == 4 else 1) + chara.score += chara.weapon.affix_level * ( + 10 if chara.weapon.rarity <= 3 else 20 if chara.weapon.rarity == 4 else 50) + if chara.artifacts: + suit = GenshinTools.get_artifact_suit(chara.artifacts) + chara.suit = suit + chara.score += 60 if len(suit) == 2 and suit[0] == suit[1] else 20 * len(suit) + for artifact in chara.artifacts: + chara.score += artifact.level * (0.5 if artifact.rarity <= 3 else 0.8 if artifact.rarity == 4 else 1) + else: + chara.suit = [] + except Exception: + chara.score = 0 chara.suit = [] return sorted(characters, key=lambda x: x.score, reverse=True)