🚧完成计算部分

This commit is contained in:
qwerdvd 2023-05-12 20:05:39 +08:00
parent 26c867d493
commit 38d6848313
4 changed files with 67 additions and 16 deletions

View File

@ -19,7 +19,10 @@ async def draw_char_info_img(raw_mes: str, sr_uid: str, url: Optional[str]):
async def cal_char_info(char_data: dict):
await Character(char_data).get_equipment_info()
char = Character(char_data)
await char.get_equipment_info()
await char.get_char_attribute_bonus()
await char.get_relic_info()
async def get_char_data(

View File

@ -1,8 +1,10 @@
import json
from typing import Dict, Tuple
from collections import Counter
from mpmath import mp
from ...utils.map.SR_MAP_PATH import EquipmentID2AbilityProperty
from ...utils.map.SR_MAP_PATH import RelicSetSkill, EquipmentID2AbilityProperty
mp.dps = 14
@ -62,6 +64,61 @@ class Character:
self.add_attr[property_type] += value
else:
self.add_attr[property_type] = value
async def get_char_attribute_bonus(self):
attribute_bonus = self.attribute_bonus
for bonus in attribute_bonus:
status_add = bonus['statusAdd']
bonus_property = status_add['property']
value = status_add['value']
if bonus_property in self.add_attr:
self.add_attr[bonus_property] += value
else:
self.add_attr[bonus_property] = value
async def get_relic_info(self):
# 计算圣遗物效果
set_id_list = []
for relic in self.char_relic:
print(json.dumps(relic, ensure_ascii=False))
set_id_list.append(relic['SetId'])
# 处理主属性
relic_property = relic['MainAffix']['Property']
property_value = mp.mpf(relic['MainAffix']['Value'])
if relic_property in self.add_attr:
self.add_attr[relic_property] = str(
mp.mpf(self.add_attr[relic_property]) + property_value
)
else:
self.add_attr[relic_property] = str(property_value)
# 处理副词条
for sub in relic['SubAffixList']:
sub_property = sub['Property']
sub_value = mp.mpf(sub['Value'])
if sub_property in self.add_attr:
self.add_attr[sub_property] = str(
mp.mpf(self.add_attr[sub_property]) + sub_value
)
else:
self.add_attr[sub_property] = str(sub_value)
# 处理套装属性
set_id_dict = dict(Counter(set_id_list))
for set_id, count in set_id_dict.items():
set_property = ''
if 2 <= count < 4:
set_property = RelicSetSkill[str(set_id)]['2']['Property']
set_value = mp.mpf(RelicSetSkill[str(set_id)]['2']['Value'])
if count == 4 and RelicSetSkill[str(set_id)]['4'] != {}:
set_property = RelicSetSkill[str(set_id)]['4']['Property']
set_value = mp.mpf(RelicSetSkill[str(set_id)]['4']['Value'])
if set_property != '':
if set_property in self.add_attr:
self.add_attr[set_property] = str(
mp.mpf(self.add_attr[set_property]) + set_value
)
else:
self.add_attr[set_property] = str(set_value)
print(self.base_attributes)
print(self.add_attr)
@ -91,17 +148,3 @@ async def p2v(power: str, power_plus: int) -> Tuple[float, float]:
power_value = float(power)
return power_percent, power_value
# async def get_artifacts_value(raw_data: Dict) -> List[str]:
# # 计算圣遗物效果
# all_effects = []
# for equip in raw_data['equipList']:
# statNmae = equip['reliquaryMainstat']['statName']
# statValue = equip['reliquaryMainstat']['statValue']
# all_effects.append(await text_to_effect(statNmae, statValue))
# for sub in equip['reliquarySubstats']:
# sub_name = sub['statName']
# sub_value = sub['statValue']
# all_effects.append(await text_to_effect(sub_name, sub_value))
# return all_effects

View File

@ -25,6 +25,7 @@ avatarId2Rarity_fileName = f'avatarId2Rarity_mapping_{version}.json'
EquipmentID2AbilityProperty_fileName = (
f'EquipmentID2AbilityProperty_mapping_{version}.json'
)
RelicSetSkill_fileName = f'RelicSetSkill_mapping_{version}.json'
class TS(TypedDict):
@ -80,3 +81,6 @@ with open(
EquipmentID2AbilityProperty = msgjson.decode(
f.read(), type=Dict[str, Dict[str, List]]
)
with open(MAP / RelicSetSkill_fileName, 'r', encoding='UTF-8') as f:
RelicSetSkill = msgjson.decode(f.read(), type=Dict[str, dict])

View File

@ -0,0 +1 @@
{"101": {"2": {"Property": "HealRatioBase", "Value": 0.0999999985238072}, "4": {}}, "102": {"2": {"Property": "AttackAddedRatio", "Value": 0.11999999822856863}, "4": {"Property": "SpeedAddedRatio", "Value": 0.059999999114284316}}, "103": {"2": {"Property": "DefenceAddedRatio", "Value": 0.1499999977857108}, "4": {}}, "104": {"2": {"Property": "IceAddedRatio", "Value": 0.0999999985238072}, "4": {}}, "105": {"2": {"Property": "PhysicalAddedRatio", "Value": 0.0999999985238072}, "4": {}}, "106": {"2": {}, "4": {}}, "107": {"2": {"Property": "FireAddedRatio", "Value": 0.0999999985238072}, "4": {}}, "108": {"2": {"Property": "QuantumAddedRatio", "Value": 0.0999999985238072}, "4": {}}, "109": {"2": {"Property": "ThunderAddedRatio", "Value": 0.0999999985238072}, "4": {}}, "110": {"2": {"Property": "WindAddedRatio", "Value": 0.0999999985238072}, "4": {}}, "111": {"2": {"Property": "BreakDamageAddedRatioBase", "Value": 0.15999999763809153}, "4": {"Property": "BreakDamageAddedRatioBase", "Value": 0.15999999763809153}}, "112": {"2": {"Property": "ImaginaryAddedRatio", "Value": 0.0999999985238072}, "4": {}}, "301": {"2": {"Property": "AttackAddedRatio", "Value": 0.11999999822856863}}, "302": {"2": {"Property": "HPAddedRatio", "Value": 0.11999999822856863}}, "303": {"2": {"Property": "StatusProbabilityBase", "Value": 0.0999999985238072}}, "304": {"2": {"Property": "DefenceAddedRatio", "Value": 0.1499999977857108}}, "305": {"2": {"Property": "CriticalDamageBase", "Value": 0.15999999763809153}}, "306": {"2": {"Property": "CriticalChanceBase", "Value": 0.07999999881904576}}, "307": {"2": {"Property": "BreakDamageAddedRatioBase", "Value": 0.15999999763809153}}, "308": {"2": {"Property": "SPRatioBase", "Value": 0.0499999992619036}}}