mirror of
https://github.com/PaiGramTeam/SIMNet.git
synced 2024-11-16 12:02:17 +00:00
✨ Support zzz calculator character detail
This commit is contained in:
parent
9839a06bb8
commit
ed7c061d82
@ -1,4 +1,5 @@
|
|||||||
from typing import List
|
import re
|
||||||
|
from typing import List, Optional, Dict
|
||||||
|
|
||||||
from pydantic import Field
|
from pydantic import Field
|
||||||
|
|
||||||
@ -6,6 +7,12 @@ from simnet.models.base import APIModel
|
|||||||
from simnet.models.zzz.character import ZZZPartialCharacter
|
from simnet.models.zzz.character import ZZZPartialCharacter
|
||||||
|
|
||||||
|
|
||||||
|
def desc_to_html(desc: str) -> str:
|
||||||
|
output_text = re.sub(r"<color=(#[0-9a-fA-F]{6})>", r'<span style="color: \1">', desc)
|
||||||
|
output_text = output_text.replace("</color>", "</span>")
|
||||||
|
return output_text
|
||||||
|
|
||||||
|
|
||||||
class ZZZCalculatorWeaponProperty(APIModel):
|
class ZZZCalculatorWeaponProperty(APIModel):
|
||||||
|
|
||||||
property_name: str
|
property_name: str
|
||||||
@ -45,6 +52,10 @@ class ZZZCalculatorAvatarSkill(APIModel):
|
|||||||
skill_type: int
|
skill_type: int
|
||||||
items: List[ZZZCalculatorAvatarSkillItem]
|
items: List[ZZZCalculatorAvatarSkillItem]
|
||||||
|
|
||||||
|
@property
|
||||||
|
def level_str(self) -> str:
|
||||||
|
return str(self.level).zfill(2)
|
||||||
|
|
||||||
|
|
||||||
class ZZZCalculatorAvatarRank(APIModel):
|
class ZZZCalculatorAvatarRank(APIModel):
|
||||||
|
|
||||||
@ -55,14 +66,62 @@ class ZZZCalculatorAvatarRank(APIModel):
|
|||||||
is_unlocked: bool
|
is_unlocked: bool
|
||||||
|
|
||||||
|
|
||||||
|
class ZZZCalculatorEquipSuit(APIModel):
|
||||||
|
|
||||||
|
suit_id: int
|
||||||
|
name: str
|
||||||
|
own: int
|
||||||
|
desc1: str
|
||||||
|
desc2: str
|
||||||
|
|
||||||
|
@property
|
||||||
|
def desc1_html(self) -> str:
|
||||||
|
return desc_to_html(self.desc1)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def desc2_html(self) -> str:
|
||||||
|
return desc_to_html(self.desc2)
|
||||||
|
|
||||||
|
|
||||||
|
class ZZZCalculatorEquipment(APIModel):
|
||||||
|
|
||||||
|
id: int
|
||||||
|
level: int
|
||||||
|
name: str
|
||||||
|
icon: str
|
||||||
|
rarity: str
|
||||||
|
properties: List[ZZZCalculatorWeaponProperty]
|
||||||
|
main_properties: List[ZZZCalculatorWeaponProperty]
|
||||||
|
equip_suit: ZZZCalculatorEquipSuit
|
||||||
|
equipment_type: int
|
||||||
|
|
||||||
|
|
||||||
class ZZZCalculatorCharacter(ZZZPartialCharacter):
|
class ZZZCalculatorCharacter(ZZZPartialCharacter):
|
||||||
|
|
||||||
equip: List
|
equip: List[ZZZCalculatorEquipment]
|
||||||
weapon: ZZZCalculatorWeapon
|
weapon: Optional[ZZZCalculatorWeapon]
|
||||||
properties: List[ZZZCalculatorAvatarProperty]
|
properties: List[ZZZCalculatorAvatarProperty]
|
||||||
skills: List[ZZZCalculatorAvatarSkill]
|
skills: List[ZZZCalculatorAvatarSkill]
|
||||||
ranks: List[ZZZCalculatorAvatarRank]
|
ranks: List[ZZZCalculatorAvatarRank]
|
||||||
|
|
||||||
|
@property
|
||||||
|
def equip_map(self) -> Dict[str, Optional[ZZZCalculatorEquipment]]:
|
||||||
|
data: Dict[str, Optional[ZZZCalculatorEquipment]] = {str(equip.equipment_type): equip for equip in self.equip}
|
||||||
|
for i in range(1, 7):
|
||||||
|
if str(i) not in data:
|
||||||
|
data[str(i)] = None
|
||||||
|
return data
|
||||||
|
|
||||||
|
@property
|
||||||
|
def equip_suits(self) -> List[ZZZCalculatorEquipSuit]:
|
||||||
|
data = []
|
||||||
|
for equip in self.equip:
|
||||||
|
if equip.equip_suit in data:
|
||||||
|
continue
|
||||||
|
data.append(equip.equip_suit)
|
||||||
|
data.sort(key=lambda x: x.own, reverse=True)
|
||||||
|
return data
|
||||||
|
|
||||||
|
|
||||||
class ZZZCalculatorCharacterDetails(APIModel):
|
class ZZZCalculatorCharacterDetails(APIModel):
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user