@@ -1281,59 +1281,62 @@ async def serlize_reward(self, reward_list: List[InventoryInfo], target: Union[I
12811281 result .append (f"{ db .get_inventory_name_san (target )} x0({ self .data .get_inventory (target )} )" )
12821282 return '\n ' .join (result ) if result else "无"
12831283
1284- async def serialize_unit_info (self , unit_data : Union [UnitData , UnitDataLight ]) -> Tuple [bool , str ]:
1285- info = []
1286- ok = True
1287- def add_info (prefix , cur , expect = None ):
1288- if expect :
1289- nonlocal ok
1290- info .append (f'{ prefix } :{ cur } /{ expect } ' )
1291- ok &= (cur == expect )
1292- else :
1293- info .append (f'{ prefix } :{ cur } ' )
1294- unit_id = unit_data .id
1295- add_info ("等级" , unit_data .unit_level , db .team_max_level )
1296- if unit_data .battle_rarity :
1297- add_info ("星级" , f"{ unit_data .battle_rarity } -{ unit_data .unit_rarity } " )
1298- else :
1299- add_info ("星级" , f"{ unit_data .unit_rarity } " )
1300- add_info ("品级" , unit_data .promotion_level , db .equip_max_rank )
1301- for id , union_burst in enumerate (unit_data .union_burst ):
1302- if union_burst .skill_level :
1303- add_info (f"ub{ id } " , union_burst .skill_level , unit_data .unit_level )
1304- for id , skill in enumerate (unit_data .main_skill ):
1305- if skill .skill_level :
1306- add_info (f"skill{ id } " , skill .skill_level , unit_data .unit_level )
1307- for id , skill in enumerate (unit_data .ex_skill ):
1308- if skill .skill_level :
1309- add_info (f"ex{ id } " , skill .skill_level , unit_data .unit_level )
1310- equip_info = []
1311- for id , equip in enumerate (unit_data .equip_slot ):
1312- equip_id = getattr (db .unit_promotion [unit_id ][unit_data .promotion_level ], f'equip_slot_{ id + 1 } ' )
1313- if not equip .is_slot :
1314- if equip_id != 999999 :
1315- equip_info .append ('-' )
1316- ok = False
1317- else :
1318- equip_info .append ('*' )
1319- else :
1320- star = db .get_equip_star_from_pt (equip_id , equip .enhancement_pt )
1321- ok &= (star == 5 )
1322- equip_info .append (str (star ))
1323- equip_info = '/' .join (equip_info )
1324- add_info ("装备" , equip_info )
1325-
1326- for id , equip in enumerate (unit_data .unique_equip_slot ):
1327- equip_slot = id + 1
1328- have_unique = (equip_slot in db .unit_unique_equip and unit_id in db .unit_unique_equip [equip_slot ])
1329- max_level = 0 if not have_unique else db .unique_equipment_max_level [equip_slot ]
1330- if have_unique :
1331- if not equip .is_slot :
1332- add_info (f"专武{ id } " , '-' , max_level )
1333- else :
1334- add_info (f"专武{ id } " , db .get_unique_equip_level_from_pt (equip_slot , equip .enhancement_pt ), max_level )
1335-
1336- return ok , ' ' .join (info )
1284+ def unit_info_to_dict (self , unit_id : int ) -> Dict :
1285+ unit_data = {
1286+ "星级" : "无" ,
1287+ "等级" : "无" ,
1288+ "品级" : "无" ,
1289+ "装备" : "无" ,
1290+ "UB" : 0 ,
1291+ "S1" : 0 ,
1292+ "S2" : 0 ,
1293+ "EX" : 0 ,
1294+ "剧情" : "无" ,
1295+ "专武1" : "无" ,
1296+ "专武2" : "无" ,
1297+ "普碎数" : "无" ,
1298+ "金碎数" : "无" ,
1299+ }
1300+
1301+ read_story = set (self .data .read_story_ids )
1302+ if unit_id in self .data .unit :
1303+ unitinfo = self .data .unit [unit_id ]
1304+ rank = f"R{ unitinfo .promotion_level } "
1305+ equip = '' .join ('-' if not solt .is_slot else str (solt .enhancement_level ) for solt in unitinfo .equip_slot )
1306+ kizuna_unit = set ()
1307+ for story in db .chara2story [unit_id ]:
1308+ if story .story_id in db .story_detail :
1309+ kizuna_unit .add (db .story_detail [story .story_id ].requirement_id )
1310+
1311+ love = []
1312+ for other in kizuna_unit :
1313+ if other not in db .unlock_unit_condition : continue
1314+ unit_name = db .get_unit_name (other )
1315+ other_id = other // 100
1316+ love_level = self .data .unit_love_data [other_id ].love_level if other_id in self .data .unit_love_data else 0
1317+ unit_story = [story .story_id for story in db .unit_story if story .story_group_id == other_id ]
1318+ total_storys = len (unit_story )
1319+ read_storys = len ([story for story in unit_story if story in read_story ])
1320+ love .append (f"{ unit_name } 好感{ love_level } ({ read_storys } /{ total_storys } )" )
1321+ love_str = '\n ' .join (love ) if love else "无"
1322+
1323+ unit_data .update ({
1324+ "星级" : f"{ unitinfo .unit_rarity } ★" ,
1325+ "等级" : unitinfo .unit_level ,
1326+ "品级" : rank ,
1327+ "装备" : equip ,
1328+ "UB" : unitinfo .union_burst [0 ].skill_level if unitinfo .union_burst else "无" ,
1329+ "S1" : unitinfo .main_skill [0 ].skill_level if unitinfo .main_skill else "无" ,
1330+ "S2" : unitinfo .main_skill [1 ].skill_level if len (unitinfo .main_skill ) > 1 else "无" ,
1331+ "EX" : unitinfo .ex_skill [0 ].skill_level if unitinfo .ex_skill else "无" ,
1332+ "剧情" : love_str ,
1333+ "专武1" : "未实装" if not unitinfo .unique_equip_slot else "无" if not unitinfo .unique_equip_slot [0 ].is_slot else unitinfo .unique_equip_slot [0 ].enhancement_level ,
1334+ "专武2" : "未实装" if len (unitinfo .unique_equip_slot ) < 2 else "无" if not unitinfo .unique_equip_slot [1 ].is_slot else unitinfo .unique_equip_slot [1 ].enhancement_level ,
1335+ "普碎数" : self .data .get_inventory ((eInventoryType .Item , db .unit_to_memory [unit_id ])) if unit_id in db .unit_to_memory else "无" ,
1336+ "金碎数" : self .data .get_inventory ((eInventoryType .Item , db .unit_to_pure_memory [unit_id ])) if unit_id in db .unit_to_pure_memory else "无" ,
1337+ })
1338+
1339+ return unit_data
13371340
13381341 async def recover_challenge (self , quest : int ):
13391342 req = QuestRecoverChallengeRequest ()
0 commit comments