This commit is contained in:
2026-04-01 13:12:43 +08:00
parent 7299ea20e3
commit 00e1147e8e
4 changed files with 128 additions and 114 deletions
+47 -61
View File
@@ -13,7 +13,7 @@ from core.basic.equipment import get_equipment, EquEffect, Equ
# from core.basic.equipment import equipments # from core.basic.equipment import equipments
# from core.basic.skill import Skill, ActiveSkill, PassiveSkill # from core.basic.skill import Skill, ActiveSkill, PassiveSkill
from .formula import 增幅计算, 强化技攻, 武器强化计算, 精通计算, 获取唤醒属性, 获取基础属性, 耳环计算, 左右计算, 锻造计算 from .formula import 增幅计算, 强化技攻, 武器强化计算, 精通计算, 获取唤醒属性, 获取基础属性, 耳环计算, 左右计算, 锻造计算
from .roleinfo import CharacterEquipInfo, get_key_by_value from .roleinfo import CharacterEquipInfo, get_key_by_value, CharacterOathInfo
# from .property import 精通计算, 角色基础, CharacterInfo # from .property import 精通计算, 角色基础, CharacterInfo
@@ -127,6 +127,8 @@ class Character(CharacterProperty):
"""装备版本""" """装备版本"""
charEquipInfo: dict[str, 'CharacterEquipInfo'] charEquipInfo: dict[str, 'CharacterEquipInfo']
"""装备打造信息""" """装备打造信息"""
charOathInfo: list['CharacterOathInfo']
"""誓约打造信息"""
equ_effect: list['EquEffect'] = [] equ_effect: list['EquEffect'] = []
"""装备效果列表""" """装备效果列表"""
equ_options: dict[str, int] = {} equ_options: dict[str, int] = {}
@@ -420,21 +422,26 @@ class Character(CharacterProperty):
def GetWeaponType(self) -> tuple[str, str]: def GetWeaponType(self) -> tuple[str, str]:
"""获取武器类型""" """获取武器类型"""
weapon = self.charEquipInfo["武器"].equInfo weapon = self.charEquipInfo['武器'].equInfo
if weapon is None: if weapon is None:
return None, None return None, None
else: else:
return weapon.itemDetailType, weapon.categorize return weapon.itemDetailType, weapon.categorize
# endregion # endregion
# region 计算相关 # region 计算相关
def SetDetail(self, info: dict[str, dict]) -> None: def SetDetail(self, info: dict[str, dict]) -> None:
self.charEquipInfo = {} self.charEquipInfo = {}
self.charOathInfo = []
self.bindAwake = info.get('bindAwake', 50) self.bindAwake = info.get('bindAwake', 50)
"""打造信息导入""" """打造信息导入"""
for key in info['equips']: for key in info['equips']:
# 导入部位打造信息、装备信息、贴膜信息 # 导入部位打造信息、装备信息、贴膜信息
self.charEquipInfo[key] = CharacterEquipInfo(info['equips'][key], self.equVersion, key) self.charEquipInfo[key] = CharacterEquipInfo(info['equips'][key], self.equVersion, key)
for key in info['oaths']:
# 导入誓约打造信息、誓约信息
self.charOathInfo.append(CharacterOathInfo(info['oaths'][key], self.equVersion, key))
def getInfo(self): def getInfo(self):
"""返回到前端信息""" """返回到前端信息"""
@@ -480,7 +487,7 @@ class Character(CharacterProperty):
'hasUP': skill.hasUP, 'hasUP': skill.hasUP,
'upType': skill.upType, 'upType': skill.upType,
'uuid': skill.uuid, 'uuid': skill.uuid,
'vps': [{"name":i["name"],"desc":i["desc"]} for i in skill.vps], 'vps': [{'name': i['name'], 'desc': i['desc']} for i in skill.vps],
} }
) )
info['skills'] = skillInfo info['skills'] = skillInfo
@@ -500,7 +507,7 @@ class Character(CharacterProperty):
info['suits'] = suits info['suits'] = suits
info['stones'] = stones info['stones'] = stones
key = '辅助' if self.buffer else '输出' key = '辅助' if self.buffer else '输出'
info['enchants'] = list(filter(lambda x: key in x["categorize"], equInfos.enchants)) info['enchants'] = list(filter(lambda x: key in x['categorize'], equInfos.enchants))
info['emblems'] = [i for i in equInfos.emblems] info['emblems'] = [i for i in equInfos.emblems]
info['avatar'] = equInfos.funs.get_dress_list(skill_clothes) info['avatar'] = equInfos.funs.get_dress_list(skill_clothes)
info['jades'] = equInfos.jades info['jades'] = equInfos.jades
@@ -581,7 +588,7 @@ class Character(CharacterProperty):
module = sys.modules[self.moduleName] module = sys.modules[self.moduleName]
for name in dir(module): for name in dir(module):
memberClass = getattr(module, name) memberClass = getattr(module, name)
if isinstance(memberClass, type) and memberClass.__name__.startswith("Skill"): if isinstance(memberClass, type) and memberClass.__name__.startswith('Skill'):
skill = memberClass(char=self) skill = memberClass(char=self)
self.skills_dict[skill.name] = skill self.skills_dict[skill.name] = skill
self.skills.append(skill) self.skills.append(skill)
@@ -819,32 +826,23 @@ class Character(CharacterProperty):
def calc_sundry(self, sundry: dict): def calc_sundry(self, sundry: dict):
"""计算杂项效果""" """计算杂项效果"""
funs = get_equipment(self.equVersion).funs funs = get_equipment(self.equVersion).funs
funs.execture("sundry_0")(self, funs.execture('sundry_0')(
sundry.get("medal_rarity", 0), self,
sundry.get("medal_reinforce", 0), sundry.get('medal_rarity', 0),
[sundry.get("medal_gem_0", 0), sundry.get("medal_gem_1", 0), sundry.get("medal_gem_2", 0), sundry.get("medal_gem_3", 0)], sundry.get('medal_reinforce', 0),
[sundry.get('medal_gem_0', 0), sundry.get('medal_gem_1', 0), sundry.get('medal_gem_2', 0), sundry.get('medal_gem_3', 0)],
) )
funs.execture("sundry_6")(self, funs.execture('sundry_6')(self, sundry.get('adventure', 1))
sundry.get("adventure", 1) funs.execture('sundry_5')(self, sundry.get('fog', 1))
) funs.execture('sundry_7')(self, sundry.get('marriage_house', 0), sundry.get('marriage_ring', 0))
funs.execture("sundry_5")(self, funs.execture('sundry_9')(self, sundry.get('contract', 0))
sundry.get("fog", 1) funs.execture('sundry_10')(
) self,
funs.execture("sundry_7")(self, sundry.get('collection_type', 0),
sundry.get("marriage_house", 0), sundry.get('collection_num_0', 0),
sundry.get("marriage_ring", 0) sundry.get('collection_num_1', 0),
)
funs.execture("sundry_9")(self,
sundry.get("contract", 0)
)
funs.execture("sundry_10")(self,
sundry.get("collection_type", 0),
sundry.get("collection_num_0", 0),
sundry.get("collection_num_1", 0),
)
funs.execture("sundry_13")(self,
sundry.get("costume_card", 0)
) )
funs.execture('sundry_13')(self, sundry.get('costume_card', 0))
pass pass
def calc(self, setInfo: dict[str, dict]): def calc(self, setInfo: dict[str, dict]):
@@ -883,18 +881,11 @@ class Character(CharacterProperty):
self.输出类型 = '魔法百分比' self.输出类型 = '魔法百分比'
else: else:
self.输出类型 = '物理百分比' self.输出类型 = '物理百分比'
skillInfos = self.calc_carry_skills(setInfo.get("DSB", False),setInfo.get("BUFF", False)) skillInfos = self.calc_carry_skills(setInfo.get('DSB', False), setInfo.get('BUFF', False))
info = self.get_carry_info() info = self.get_carry_info()
return { return {'uuid': uuid1().hex, 'skills': skillInfos, 'info': info, 'suits': suit, 'buffer': self.buffer}
'uuid': uuid1().hex,
'skills': skillInfos,
'info': info,
'suits': suit,
'buffer':self.buffer
}
# 技能影响角色的属性,如属强、抗性等 # 技能影响角色的属性,如属强、抗性等
# region 输出计算项 # region 输出计算项
def calc_damage_ration(self, DSB: bool, BUFF: bool): def calc_damage_ration(self, DSB: bool, BUFF: bool):
@@ -963,18 +954,7 @@ class Character(CharacterProperty):
for i in skillInfos: for i in skillInfos:
i['damage'] = ratio_char_skill * i['data'] * i['ratio'] / 100 i['damage'] = ratio_char_skill * i['data'] * i['ratio'] / 100
for i in self.equ_effect: for i in self.equ_effect:
skillInfos.append( skillInfos.append({'name': i.name, 'icon': i.icon, 'lv': 0, 'data': i.data, 'ratio': 10.0, 'cd': i.cd, 'damage': ratuio_equ_skill * i.data * 10 * self.EquEffectRatio / 100, 'mode': ''})
{
'name': i.name,
'icon': i.icon,
'lv': 0,
'data': i.data,
'ratio': 10.0,
'cd': i.cd,
'damage': ratuio_equ_skill * i.data * 10 * self.EquEffectRatio / 100,
'mode':''
}
)
# 合并相同 name、cd、damage 的项 # 合并相同 name、cd、damage 的项
# merged = {} # merged = {}
# for skill in skillInfos: # for skill in skillInfos:
@@ -1006,7 +986,7 @@ class Character(CharacterProperty):
else: else:
value = getattr(self, attr) value = getattr(self, attr)
if attr == 'SkillAttack': if attr == 'SkillAttack':
value *= (self.jade_effect.SkillAttack + 1) value *= self.jade_effect.SkillAttack + 1
if attr == 'AttackP': if attr == 'AttackP':
value += self.jade_effect.AttackP value += self.jade_effect.AttackP
info.append( info.append(
@@ -1017,6 +997,7 @@ class Character(CharacterProperty):
) )
pass pass
return info return info
# endregion # endregion
# region 辅助计算项 # region 辅助计算项
@@ -1056,15 +1037,17 @@ class Character(CharacterProperty):
if i.buffType == 'awake' and self.bindAwake == 50: if i.buffType == 'awake' and self.bindAwake == 50:
pass pass
else: else:
skillInfos.append({ skillInfos.append(
"name":i.name, {
"cd":value4, 'name': i.name,
"icon":i.icon, 'cd': value4,
"lv": i.lv, 'icon': i.icon,
'lv': i.lv,
# 对自己的加成 三攻 力智 伤害直接加成 # 对自己的加成 三攻 力智 伤害直接加成
"buff":[value, value1, value2, value3], 'buff': [value, value1, value2, value3],
"type":i.type 'type': i.type,
}) }
)
return skillInfos return skillInfos
def get_buffer_info(self): def get_buffer_info(self):
@@ -1073,11 +1056,14 @@ class Character(CharacterProperty):
for attr in attrs: for attr in attrs:
temp = getattr(CharacterInfo, attr) temp = getattr(CharacterInfo, attr)
value = getattr(self, attr) value = getattr(self, attr)
info.append({ info.append(
{
'name': temp.name, 'name': temp.name,
'value': temp.value(value), 'value': temp.value(value),
}) }
)
return info return info
# endregion # endregion
# endregion # endregion
+16 -6
View File
@@ -2,15 +2,19 @@ import importlib
from database.models import EmblemData, OathData, OathSuitData, OathSuitSkillData, PrimerData, Session, EquData, StoneData, SuitData, EnchantData, JadeData from database.models import EmblemData, OathData, OathSuitData, OathSuitSkillData, PrimerData, Session, EquData, StoneData, SuitData, EnchantData, JadeData
from database.connect import get_db_engine as get_engine from database.connect import get_db_engine as get_engine
def parse_to_number_list(info: str, default: list[float] = [0]) -> list[float]: def parse_to_number_list(info: str, default: list[float] = [0]) -> list[float]:
return default if not info else [float(i) for i in info.split(',')] return default if not info else [float(i) for i in info.split(',')]
def parse_to_string_list(info: str, default: list[str] = ['']) -> list[str]: def parse_to_string_list(info: str, default: list[str] = ['']) -> list[str]:
return default if not info else [i for i in info.split(',')] return default if not info else [i for i in info.split(',')]
def parse_to_int_list(info: str, default: list[int] = [0]) -> list[int]: def parse_to_int_list(info: str, default: list[int] = [0]) -> list[int]:
return default if not info else [int(i) for i in info.split(',')] return default if not info else [int(i) for i in info.split(',')]
class Equ: class Equ:
id: str id: str
name: str name: str
@@ -51,6 +55,7 @@ class Equ:
temp[attr] = value[min(adaptation, len(value) - 1)] if isinstance(value, list) else value temp[attr] = value[min(adaptation, len(value) - 1)] if isinstance(value, list) else value
return Equ(**temp) return Equ(**temp)
class Suit: class Suit:
id: int id: int
suitId: int suitId: int
@@ -67,6 +72,7 @@ class Suit:
def __init__(self, **kwargs): def __init__(self, **kwargs):
self.__dict__.update(kwargs) self.__dict__.update(kwargs)
class Equipments: class Equipments:
def __init__(self, version='0'): def __init__(self, version='0'):
self.version = version self.version = version
@@ -90,6 +96,8 @@ class Equipments:
self.init_stones() self.init_stones()
self.init_emblem() self.init_emblem()
self.init_jades() self.init_jades()
self.init_oaths()
self.init_oath_suits()
self.engine.dispose() self.engine.dispose()
def init_equs(self): def init_equs(self):
@@ -189,7 +197,6 @@ class Equipments:
db_list_1 = session.query(OathData).all() db_list_1 = session.query(OathData).all()
db_list_2 = session.query(PrimerData).all() db_list_2 = session.query(PrimerData).all()
keys = [key for key in OathData.__dict__.keys() if key[0].isupper()] keys = [key for key in OathData.__dict__.keys() if key[0].isupper()]
print(keys)
for item in db_list_1 + db_list_2: for item in db_list_1 + db_list_2:
max_adaptation = 0 max_adaptation = 0
item.id = str(item.id) item.id = str(item.id)
@@ -232,13 +239,12 @@ class Equipments:
pass pass
pass pass
def init_func(self): def init_func(self):
"""根据装备版本加载装备效果""" """根据装备版本加载装备效果"""
try: try:
funs = importlib.import_module(f"core.equipment.version_{self.version}") funs = importlib.import_module(f'core.equipment.version_{self.version}')
except Exception: except Exception:
funs = importlib.import_module("core.equipment.version_0") funs = importlib.import_module('core.equipment.version_0')
return funs return funs
def get_suit_info(self, suitId: str | int, point: int = 0, count: int = 0) -> list[Suit]: def get_suit_info(self, suitId: str | int, point: int = 0, count: int = 0) -> list[Suit]:
@@ -273,6 +279,7 @@ class Equipments:
result[suit.count] = suit result[suit.count] = suit
return list(result.values()) return list(result.values())
class EquEffect: class EquEffect:
name: str = '' name: str = ''
"""装备技能名称""" """装备技能名称"""
@@ -289,6 +296,7 @@ class EquEffect:
self.cd = cd self.cd = cd
self.data = data self.data = data
class Oath: class Oath:
id: str id: str
name: str name: str
@@ -348,6 +356,7 @@ class OathSuitSkill:
def __init__(self, **kwargs): def __init__(self, **kwargs):
self.__dict__.update(kwargs) self.__dict__.update(kwargs)
class OathSuit: class OathSuit:
id: int id: int
key: str key: str
@@ -368,12 +377,13 @@ class OathSuit:
global equ0 global equ0
equ0 = Equipments("0") equ0 = Equipments('0')
def get_equipment(version: str = '0') -> Equipments: def get_equipment(version: str = '0') -> Equipments:
# print('加载装备信息') # print('加载装备信息')
try: try:
temp = eval(f"equ{version}".format(version)) temp = eval(f'equ{version}'.format(version))
except Exception: except Exception:
temp = equ0 temp = equ0
return temp return temp
+25 -5
View File
@@ -1,7 +1,7 @@
from enum import Enum from enum import Enum
from typing import Union from typing import Union
from core.basic.equipment import Equ, get_equipment from core.basic.equipment import Equ, get_equipment, Oath
class CharacterEquipInfo: class CharacterEquipInfo:
@@ -33,9 +33,9 @@ class CharacterEquipInfo:
"""秘宝精度""" """秘宝精度"""
def __init__(self, info={}, equVerison=0, part='') -> None: def __init__(self, info={}, equVerison=0, part='') -> None:
info["fusion"] = info.get("fusion", None) info['fusion'] = info.get('fusion', None)
info["precision"] = info.get("precision", 0) info['precision'] = info.get('precision', 0)
info["weaponFusion"] = info.get("weaponFusion", None) info['weaponFusion'] = info.get('weaponFusion', None)
self.__dict__.update(info) self.__dict__.update(info)
equ = get_equipment(equVerison).equ_dict.get(self.id, None) equ = get_equipment(equVerison).equ_dict.get(self.id, None)
fusion = get_equipment(equVerison).stone_dict.get(self.fusion, None) fusion = get_equipment(equVerison).stone_dict.get(self.fusion, None)
@@ -43,7 +43,7 @@ class CharacterEquipInfo:
self.equInfo = equ.adapt(self.adaptation) self.equInfo = equ.adapt(self.adaptation)
self.adaptation = min(self.adaptation, self.equInfo.max_adaptation) self.adaptation = min(self.adaptation, self.equInfo.max_adaptation)
if part == '副武器' and equ.itemType == '武器': if part == '副武器' and equ.itemType == '武器':
self.equInfo.itemType = "副武器" self.equInfo.itemType = '副武器'
else: else:
self.equInfo = None self.equInfo = None
if fusion is not None and (fusion.itemType == part or fusion.itemDetailType == part): if fusion is not None and (fusion.itemType == part or fusion.itemDetailType == part):
@@ -52,6 +52,26 @@ class CharacterEquipInfo:
self.fusionInfo = None self.fusionInfo = None
class CharacterOathInfo:
id: str
"""誓约ID"""
adaptation: int
"""调适等级"""
oathInfo: Union['Oath', None]
"""誓约信息"""
def __init__(self, info={}, equVerison=0, position='') -> None:
self.__dict__.update(info)
self.id = str(self.id)
oath = get_equipment(equVerison).oath_dict.get(self.id, None)
print(position, oath)
if oath is not None and position in oath.position:
self.oathInfo = oath.adapt(self.adaptation)
self.adaptation = min(self.adaptation, self.oathInfo.max_adaptation)
else:
self.oathInfo = None
class CharacterWeaponInfo(CharacterEquipInfo): class CharacterWeaponInfo(CharacterEquipInfo):
refine: int refine: int
"""锻造等级""" """锻造等级"""
+8 -10
View File
@@ -1,11 +1,9 @@
from core.basic.equipment import Equipments from core.basic.character import createCharacter
equ = Equipments("0")
equ.init_oath_suits() char = createCharacter('GF.gunner_female.spitfire_female')
item = equ.oath_suits[3]
for i in range(1, 7): char.calc_init({'oaths': {'0': {'id': '2010201', 'adaptation': 3}, '11': {'id': '2050200', 'adaptation': 0}}, 'equips': {}})
print(f"Lv{i}:")
print(equ.oath_suits[i])
for skill in equ.oath_suits[i]['skills']: for oath in char.charOathInfo:
print(skill.__dict__) print(oath.id, oath.adaptation, oath.oathInfo.position, oath.oathInfo.max_adaptation, oath.oathInfo.Point)
print("------------------")