mirror of
https://github.com/PaiGramTeam/PamGram.git
synced 2024-11-16 03:55:26 +00:00
🐛 Fix mihomo models update
This commit is contained in:
parent
c11d01779c
commit
95797cf57b
@ -12,32 +12,32 @@ from utils.enkanetwork import RedisCache
|
||||
from modules.playercards.file import PlayerCardsFile
|
||||
|
||||
|
||||
class Behavior(BaseModel):
|
||||
BehaviorID: int
|
||||
Level: int
|
||||
class SkillTreePoint(BaseModel):
|
||||
pointId: int
|
||||
level: int
|
||||
|
||||
|
||||
class Equipment(BaseModel):
|
||||
ID: Optional[int] = 0
|
||||
Level: Optional[int] = 0
|
||||
Promotion: Optional[int] = 3
|
||||
tid: Optional[int] = 0
|
||||
level: Optional[int] = 0
|
||||
promotion: Optional[int] = 3
|
||||
"""星级"""
|
||||
Rank: Optional[int] = 0
|
||||
rank: Optional[int] = 0
|
||||
"""叠影"""
|
||||
|
||||
|
||||
class SubAffix(BaseModel):
|
||||
Cnt: Optional[int] = 1
|
||||
Step: Optional[int] = 0
|
||||
SubAffixID: int
|
||||
cnt: Optional[int] = 1
|
||||
step: Optional[int] = 0
|
||||
affixId: int
|
||||
|
||||
|
||||
class Relic(BaseModel):
|
||||
ID: int
|
||||
Level: Optional[int] = 0
|
||||
MainAffixID: int
|
||||
RelicSubAffix: Optional[List[SubAffix]]
|
||||
Type: int
|
||||
tid: int
|
||||
level: Optional[int] = 0
|
||||
mainAffixId: int
|
||||
subAffixList: Optional[List[SubAffix]]
|
||||
type: int
|
||||
|
||||
|
||||
class Property(BaseModel):
|
||||
@ -56,42 +56,42 @@ class Property(BaseModel):
|
||||
|
||||
|
||||
class Avatar(BaseModel):
|
||||
AvatarID: int
|
||||
BehaviorList: List[Behavior]
|
||||
EquipmentID: Optional[Equipment]
|
||||
Level: int
|
||||
Promotion: Optional[int] = 4
|
||||
Rank: Optional[int] = 0
|
||||
RelicList: Optional[List[Relic]]
|
||||
avatarId: int
|
||||
skillTreeList: List[SkillTreePoint]
|
||||
equipment: Optional[Equipment]
|
||||
level: int
|
||||
promotion: Optional[int] = 4
|
||||
rank: Optional[int] = 0
|
||||
relicList: Optional[List[Relic]]
|
||||
property: Optional[List[Property]]
|
||||
|
||||
|
||||
class ChallengeData(BaseModel):
|
||||
class ChallengeInfo(BaseModel):
|
||||
MazeGroupID: Optional[int]
|
||||
MazeGroupIndex: Optional[int]
|
||||
PreMazeGroupIndex: Optional[int]
|
||||
|
||||
|
||||
class PlayerSpaceInfo(BaseModel):
|
||||
AchievementCount: Optional[int] = 0
|
||||
AvatarCount: Optional[int] = 0
|
||||
ChallengeData: ChallengeData
|
||||
LightConeCount: Optional[int] = 0
|
||||
PassAreaProgress: Optional[int] = 0
|
||||
class RecordInfo(BaseModel):
|
||||
achievementCount: Optional[int] = 0
|
||||
avatarCount: Optional[int] = 0
|
||||
challengeInfo: ChallengeInfo
|
||||
equipmentCount: Optional[int] = 0
|
||||
maxRogueChallengeScore: Optional[int] = 0
|
||||
|
||||
|
||||
class PlayerInfo(BaseModel):
|
||||
Birthday: Optional[int]
|
||||
CurFriendCount: Optional[int]
|
||||
AvatarList: List[Avatar]
|
||||
HeadIconID: Optional[int]
|
||||
IsDisplayAvatarList: bool
|
||||
Level: int
|
||||
NickName: str
|
||||
PlayerSpaceInfo: PlayerSpaceInfo
|
||||
Signature: Optional[str]
|
||||
UID: int
|
||||
WorldLevel: Optional[int]
|
||||
platform: Optional[str]
|
||||
friendCount: Optional[int]
|
||||
avatarList: List[Avatar]
|
||||
headIcon: Optional[int]
|
||||
isDisplayAvatar: bool
|
||||
level: int
|
||||
worldLevel: Optional[int]
|
||||
nickname: str
|
||||
recordInfo: RecordInfo
|
||||
signature: Optional[str]
|
||||
uid: int
|
||||
|
||||
|
||||
class PlayerCardsError(Exception):
|
||||
@ -151,7 +151,7 @@ class PlayerCards:
|
||||
error_code = data.get("ErrCode", 0)
|
||||
if error_code:
|
||||
raise PlayerCardsError(f"请求异常,错误代码 {error_code}")
|
||||
data = data.get("PlayerDetailInfo", {})
|
||||
data = data.get("detailInfo", {})
|
||||
props = await self.get_property(uid)
|
||||
data = await self.player_cards_file.merge_info(uid, data, props)
|
||||
await self.cache.set(uid, data)
|
||||
@ -171,15 +171,15 @@ class PlayerCards:
|
||||
return 101
|
||||
|
||||
def get_affix(self, relic: Relic, main: bool = True, sub: bool = True) -> List[EquipmentsStats]:
|
||||
affix = self.get_affix_by_id(relic.ID)
|
||||
affix = self.get_affix_by_id(relic.tid)
|
||||
if not affix:
|
||||
return []
|
||||
main_affix = affix.main_affix[str(relic.MainAffixID)]
|
||||
main_affix = affix.main_affix[str(relic.mainAffixId)]
|
||||
datas = (
|
||||
[
|
||||
EquipmentsStats(
|
||||
prop_id=main_affix.property,
|
||||
prop_value=main_affix.get_value(relic.Level),
|
||||
prop_value=main_affix.get_value(relic.level),
|
||||
)
|
||||
]
|
||||
if main
|
||||
@ -187,13 +187,13 @@ class PlayerCards:
|
||||
)
|
||||
if not sub:
|
||||
return datas
|
||||
if relic.RelicSubAffix:
|
||||
for sub_a in relic.RelicSubAffix:
|
||||
sub_affix = affix.sub_affix[str(sub_a.SubAffixID)]
|
||||
if relic.subAffixList:
|
||||
for sub_a in relic.subAffixList:
|
||||
sub_affix = affix.sub_affix[str(sub_a.affixId)]
|
||||
datas.append(
|
||||
EquipmentsStats(
|
||||
prop_id=sub_affix.property,
|
||||
prop_value=sub_affix.get_value(sub_a.Step, sub_a.Cnt),
|
||||
prop_value=sub_affix.get_value(sub_a.step, sub_a.cnt),
|
||||
)
|
||||
)
|
||||
return datas
|
||||
|
@ -61,30 +61,34 @@ class PlayerCardsFile:
|
||||
data: Dict,
|
||||
props: Dict,
|
||||
) -> Dict:
|
||||
assistAvatarDetail = "assistAvatarDetail"
|
||||
avatarId = "avatarId"
|
||||
avatarDetailList = "avatarDetailList"
|
||||
avatarList = "avatarList"
|
||||
async with self._lock:
|
||||
old_data = await self.load_history_info(uid)
|
||||
if old_data is None:
|
||||
old_data = {}
|
||||
avatars = []
|
||||
avatar_ids = []
|
||||
assist_avatar = data.get("AssistAvatar", None)
|
||||
assist_avatar = data.get(assistAvatarDetail, None)
|
||||
if assist_avatar:
|
||||
avatars.append(assist_avatar)
|
||||
avatar_ids.append(assist_avatar.get("AvatarID", 0))
|
||||
for avatar in data.get("DisplayAvatarList", []):
|
||||
if avatar.get("AvatarID", 0) in avatar_ids:
|
||||
avatar_ids.append(assist_avatar.get(avatarId, 0))
|
||||
for avatar in data.get(avatarDetailList, []):
|
||||
if avatar.get(avatarId, 0) in avatar_ids:
|
||||
continue
|
||||
avatars.append(avatar)
|
||||
avatar_ids.append(avatar.get("AvatarID", 0))
|
||||
data["AvatarList"] = avatars
|
||||
if "AssistAvatar" in data:
|
||||
del data["AssistAvatar"]
|
||||
if "DisplayAvatarList" in data:
|
||||
del data["DisplayAvatarList"]
|
||||
for i in old_data.get("AvatarList", []):
|
||||
if i.get("AvatarID", 0) not in avatar_ids:
|
||||
data["AvatarList"].append(i)
|
||||
for i in data["AvatarList"]:
|
||||
i["property"] = props.get(i.get("AvatarID", 0), [])
|
||||
avatar_ids.append(avatar.get(avatarId, 0))
|
||||
data[avatarList] = avatars
|
||||
if assistAvatarDetail in data:
|
||||
del data[assistAvatarDetail]
|
||||
if avatarDetailList in data:
|
||||
del data[avatarDetailList]
|
||||
for i in old_data.get(avatarList, []):
|
||||
if i.get(avatarId, 0) not in avatar_ids:
|
||||
data[avatarList].append(i)
|
||||
for i in data[avatarList]:
|
||||
i["property"] = props.get(i.get(avatarId, 0), [])
|
||||
await self.save_json(self.get_file_path(uid), data)
|
||||
return data
|
||||
|
@ -112,7 +112,7 @@ class PlayerCards(Plugin):
|
||||
await message.reply_text("未查询到您所绑定的账号信息,请先绑定账号", reply_markup=InlineKeyboardMarkup(buttons))
|
||||
return
|
||||
data = await self._load_history(uid)
|
||||
if data is None or len(data.AvatarList) == 0:
|
||||
if data is None or len(data.avatarList) == 0:
|
||||
if isinstance(self.kitsune, str):
|
||||
photo = self.kitsune
|
||||
else:
|
||||
@ -158,8 +158,8 @@ class PlayerCards(Plugin):
|
||||
if reply_message.photo:
|
||||
self.kitsune = reply_message.photo[-1].file_id
|
||||
return
|
||||
for characters in data.AvatarList:
|
||||
if idToRole(characters.AvatarID) == ch_name:
|
||||
for characters in data.avatarList:
|
||||
if idToRole(characters.avatarId) == ch_name:
|
||||
break
|
||||
else:
|
||||
await message.reply_text(f"角色展柜中未找到 {ch_name} ,请检查角色是否存在于角色展柜中,或者等待角色数据更新后重试")
|
||||
@ -208,7 +208,7 @@ class PlayerCards(Plugin):
|
||||
if isinstance(data, str):
|
||||
await callback_query.answer(text=data, show_alert=True)
|
||||
return
|
||||
if data.AvatarList is None:
|
||||
if data.avatarList is None:
|
||||
await message.delete()
|
||||
await callback_query.answer("请先将角色加入到角色展柜并允许查看角色详情后再使用此功能,如果已经添加了角色,请等待角色数据更新后重试", show_alert=True)
|
||||
return
|
||||
@ -273,7 +273,7 @@ class PlayerCards(Plugin):
|
||||
if isinstance(data, str):
|
||||
await message.reply_text(data)
|
||||
return
|
||||
if data.AvatarList is None:
|
||||
if data.avatarList is None:
|
||||
await message.delete()
|
||||
await callback_query.answer("请先将角色加入到角色展柜并允许查看角色详情后再使用此功能,如果已经添加了角色,请等待角色数据更新后重试", show_alert=True)
|
||||
return
|
||||
@ -282,8 +282,8 @@ class PlayerCards(Plugin):
|
||||
await message.edit_reply_markup(reply_markup=InlineKeyboardMarkup(buttons))
|
||||
await callback_query.answer(f"已切换到第 {page} 页", show_alert=False)
|
||||
return
|
||||
for characters in data.AvatarList:
|
||||
if idToRole(characters.AvatarID) == result:
|
||||
for characters in data.avatarList:
|
||||
if idToRole(characters.avatarId) == result:
|
||||
break
|
||||
else:
|
||||
await message.delete()
|
||||
@ -308,14 +308,14 @@ class PlayerCards(Plugin):
|
||||
"""生成按钮"""
|
||||
buttons = []
|
||||
|
||||
if data.AvatarList:
|
||||
if data.avatarList:
|
||||
buttons = [
|
||||
InlineKeyboardButton(
|
||||
idToRole(value.AvatarID),
|
||||
callback_data=f"get_player_card|{user_id}|{uid}|{idToRole(value.AvatarID)}",
|
||||
idToRole(value.avatarId),
|
||||
callback_data=f"get_player_card|{user_id}|{uid}|{idToRole(value.avatarId)}",
|
||||
)
|
||||
for value in data.AvatarList
|
||||
if value.AvatarID
|
||||
for value in data.avatarList
|
||||
if value.avatarId
|
||||
]
|
||||
all_buttons = [buttons[i : i + 4] for i in range(0, len(buttons), 4)]
|
||||
send_buttons = all_buttons[(page - 1) * 3 : page * 3]
|
||||
@ -360,13 +360,13 @@ class PlayerCards(Plugin):
|
||||
生成渲染所需数据
|
||||
"""
|
||||
characters_data = []
|
||||
for idx, character in enumerate(data.AvatarList):
|
||||
cid = character.AvatarID
|
||||
for idx, character in enumerate(data.avatarList):
|
||||
cid = character.avatarId
|
||||
try:
|
||||
characters_data.append(
|
||||
{
|
||||
"level": character.Level,
|
||||
"constellation": character.Rank,
|
||||
"level": character.level,
|
||||
"constellation": character.rank,
|
||||
"icon": self.assets_service.avatar.square(cid).as_uri(),
|
||||
}
|
||||
)
|
||||
@ -375,9 +375,9 @@ class PlayerCards(Plugin):
|
||||
if idx > 3:
|
||||
break
|
||||
return {
|
||||
"uid": data.UID,
|
||||
"level": data.Level or 0,
|
||||
"signature": data.Signature or "",
|
||||
"uid": data.uid,
|
||||
"level": data.level or 0,
|
||||
"signature": data.signature or "",
|
||||
"characters": characters_data,
|
||||
}
|
||||
|
||||
@ -471,16 +471,16 @@ class RenderTemplate:
|
||||
|
||||
weapon = None
|
||||
weapon_detail = None
|
||||
if self.character.EquipmentID and self.character.EquipmentID.ID:
|
||||
weapon = self.character.EquipmentID
|
||||
weapon_detail = self.wiki_service.light_cone.get_by_id(self.character.EquipmentID.ID)
|
||||
if self.character.equipment and self.character.equipment.tid:
|
||||
weapon = self.character.equipment
|
||||
weapon_detail = self.wiki_service.light_cone.get_by_id(self.character.equipment.tid)
|
||||
skills = [0, 0, 0, 0, 0]
|
||||
for index in range(5):
|
||||
skills[index] = self.character.BehaviorList[index].Level
|
||||
skills[index] = self.character.skillTreeList[index].level
|
||||
data = {
|
||||
"uid": self.uid,
|
||||
"character": self.character,
|
||||
"character_detail": self.wiki_service.character.get_by_id(self.character.AvatarID),
|
||||
"character_detail": self.wiki_service.character.get_by_id(self.character.avatarId),
|
||||
"weapon": weapon,
|
||||
"weapon_detail": weapon_detail,
|
||||
# 圣遗物评分
|
||||
@ -505,27 +505,27 @@ class RenderTemplate:
|
||||
|
||||
async def cache_images(self):
|
||||
c = self.character
|
||||
cid = c.AvatarID
|
||||
cid = c.avatarId
|
||||
data = {
|
||||
"banner_url": self.assets_service.avatar.gacha(cid).as_uri(),
|
||||
"skills": [i.as_uri() for i in self.assets_service.avatar.skills(cid)][:-1],
|
||||
"constellations": [i.as_uri() for i in self.assets_service.avatar.eidolons(cid)],
|
||||
"equipment": "",
|
||||
}
|
||||
if c.EquipmentID and c.EquipmentID.ID:
|
||||
data["equipment"] = self.assets_service.light_cone.icon(c.EquipmentID.ID).as_uri()
|
||||
if c.equipment and c.equipment.tid:
|
||||
data["equipment"] = self.assets_service.light_cone.icon(c.equipment.tid).as_uri()
|
||||
return data
|
||||
|
||||
def find_artifacts(self) -> List[Artifact]:
|
||||
"""在 equipments 数组中找到圣遗物,并转换成带有分数的 model。equipments 数组包含圣遗物和武器"""
|
||||
|
||||
stats = ArtifactStatsTheory(idToRole(self.character.AvatarID))
|
||||
stats = ArtifactStatsTheory(idToRole(self.character.avatarId))
|
||||
|
||||
def substat_score(s: EquipmentsStats) -> float:
|
||||
return stats.theory(s)
|
||||
|
||||
def fix_equipment(e: Relic) -> Dict:
|
||||
rid = e.ID
|
||||
rid = e.tid
|
||||
affix = self.client.get_affix_by_id(rid)
|
||||
relic_set = self.wiki_service.relic.get_by_id(affix.set_id)
|
||||
try:
|
||||
@ -536,13 +536,13 @@ class RenderTemplate:
|
||||
"id": rid,
|
||||
"name": relic_set.name,
|
||||
"icon": icon,
|
||||
"level": e.Level,
|
||||
"level": e.level,
|
||||
"rank": affix.rarity,
|
||||
"main_sub": self.client.get_affix(e, True, False)[0],
|
||||
"sub": self.client.get_affix(e, False, True),
|
||||
}
|
||||
|
||||
relic_list = self.character.RelicList or []
|
||||
relic_list = self.character.relicList or []
|
||||
return [
|
||||
Artifact(
|
||||
equipment=fix_equipment(e),
|
||||
|
@ -3,7 +3,7 @@
|
||||
{% for item in images.constellations %}
|
||||
<div
|
||||
class="w-16 h-16 flex items-center justify-center bg-contain bg-no-repeat bg-center
|
||||
{%- if loop.index > character.Rank %} grayscale opacity-75 {% endif %}"
|
||||
{%- if loop.index > character.rank %} grayscale opacity-75 {% endif %}"
|
||||
style="background-image: url('img/talent-{{ character_detail.element.name | lower }}.png')"
|
||||
>
|
||||
<img src="{{ item }}" alt="" class="w-8 h-8" />
|
||||
|
@ -74,7 +74,7 @@
|
||||
class="flex flex-row justify-end text-2xl text-shadow space-x-6"
|
||||
>
|
||||
<div>UID {{ uid }}</div>
|
||||
<div>Lv.{{ character.Level }}</div>
|
||||
<div>Lv.{{ character.level }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -6,11 +6,11 @@
|
||||
<div class="text-2xl">{{ weapon_detail.name }}</div>
|
||||
<div class="star star-{{ weapon_detail.rarity }}"></div>
|
||||
<div class="flex space-x-3 items-center">
|
||||
<div class="italic">Lv.{{ weapon.Level }}</div>
|
||||
<div class="italic">Lv.{{ weapon.level }}</div>
|
||||
<div
|
||||
class="rounded px-2 text-base {% if weapon.Rank == 5 %} bg-red-600 {% else %} bg-gray-600 {% endif %}"
|
||||
class="rounded px-2 text-base {% if weapon.rank == 5 %} bg-red-600 {% else %} bg-gray-600 {% endif %}"
|
||||
>
|
||||
精{{ weapon.Rank }}
|
||||
精{{ weapon.rank }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user