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
+74 -88
View File
@@ -13,7 +13,7 @@ from core.basic.equipment import get_equipment, EquEffect, Equ
# from core.basic.equipment import equipments
# from core.basic.skill import Skill, ActiveSkill, PassiveSkill
from .formula import 增幅计算, 强化技攻, 武器强化计算, 精通计算, 获取唤醒属性, 获取基础属性, 耳环计算, 左右计算, 锻造计算
from .roleinfo import CharacterEquipInfo, get_key_by_value
from .roleinfo import CharacterEquipInfo, get_key_by_value, CharacterOathInfo
# from .property import 精通计算, 角色基础, CharacterInfo
@@ -117,7 +117,7 @@ class Character(CharacterProperty):
# endregion
BindAwake : int
BindAwake: int
"""绑定觉醒等级"""
skills: list['Skill'] = []
# """技能列表"""
@@ -127,6 +127,8 @@ class Character(CharacterProperty):
"""装备版本"""
charEquipInfo: dict[str, 'CharacterEquipInfo']
"""装备打造信息"""
charOathInfo: list['CharacterOathInfo']
"""誓约打造信息"""
equ_effect: list['EquEffect'] = []
"""装备效果列表"""
equ_options: dict[str, int] = {}
@@ -231,7 +233,7 @@ class Character(CharacterProperty):
temp = 获取基础属性(self.角色, self.职业)
唤醒 = 获取唤醒属性()
for index, i in enumerate([get_key_by_value(i) for i in ['力量', '体力', '智力', '精神']]):
setattr(self, i, getattr(self,i) + temp[index] + 唤醒)
setattr(self, i, getattr(self, i) + temp[index] + 唤醒)
# 角色属性抗性
pass
# 角色异常抗性
@@ -420,21 +422,26 @@ class Character(CharacterProperty):
def GetWeaponType(self) -> tuple[str, str]:
"""获取武器类型"""
weapon = self.charEquipInfo["武器"].equInfo
weapon = self.charEquipInfo['武器'].equInfo
if weapon is None:
return None,None
return None, None
else:
return weapon.itemDetailType,weapon.categorize
return weapon.itemDetailType, weapon.categorize
# endregion
# region 计算相关
def SetDetail(self, info: dict[str, dict]) -> None:
self.charEquipInfo = {}
self.charOathInfo = []
self.bindAwake = info.get('bindAwake', 50)
"""打造信息导入"""
for key in info['equips']:
# 导入部位打造信息、装备信息、贴膜信息
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):
"""返回到前端信息"""
@@ -480,7 +487,7 @@ class Character(CharacterProperty):
'hasUP': skill.hasUP,
'upType': skill.upType,
'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
@@ -500,7 +507,7 @@ class Character(CharacterProperty):
info['suits'] = suits
info['stones'] = stones
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['avatar'] = equInfos.funs.get_dress_list(skill_clothes)
info['jades'] = equInfos.jades
@@ -581,7 +588,7 @@ class Character(CharacterProperty):
module = sys.modules[self.moduleName]
for name in dir(module):
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)
self.skills_dict[skill.name] = skill
self.skills.append(skill)
@@ -660,8 +667,8 @@ class Character(CharacterProperty):
# 太初积分以上,每超过70点数增加1%技能攻击力
if self.max_point >= 2550:
skillAttack = (self.max_point - 2550) // 70 * 0.01
buffer = (self.max_point - 2550) // 70 * 100
self.SetStatus(SkillAttack=skillAttack,Buffer=buffer)
buffer = (self.max_point - 2550) // 70 * 100
self.SetStatus(SkillAttack=skillAttack, Buffer=buffer)
return res
def calc_equs(self):
@@ -748,7 +755,7 @@ class Character(CharacterProperty):
fun(self)
pass
def calc_weapon(self,cur:CharacterEquipInfo):
def calc_weapon(self, cur: CharacterEquipInfo):
# 锻造独立计算
value = 锻造计算(115, '史诗', cur.refine)
self.SetStatus(AtkI=value)
@@ -776,7 +783,7 @@ class Character(CharacterProperty):
continue
for key in self.防具精通属性:
value = 精通计算(115, equ.rarity, reinforce, equ.itemDetailType, self.防具类型,self.buffer,key)
value = 精通计算(115, equ.rarity, reinforce, equ.itemDetailType, self.防具类型, self.buffer, key)
key = get_key_by_value(key)
setattr(self, key, getattr(self, key) + value)
# 115增幅强化品级固定史诗
@@ -811,40 +818,31 @@ class Character(CharacterProperty):
funs = get_equipment(self.equVersion).funs
for key in jades:
jade = jades[key]
fun = funs.execture(f'jade_{jade.get("id",0)}')
fun = funs.execture(f'jade_{jade.get("id", 0)}')
if fun is not None:
fun(self,jade.get('value', 0))
fun(self, jade.get('value', 0))
pass
def calc_sundry(self, sundry: dict):
"""计算杂项效果"""
funs = get_equipment(self.equVersion).funs
funs.execture("sundry_0")(self,
sundry.get("medal_rarity", 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_0')(
self,
sundry.get('medal_rarity', 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,
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_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_6')(self, 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_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))
pass
def calc(self, setInfo: dict[str, dict]):
@@ -883,21 +881,14 @@ class Character(CharacterProperty):
self.输出类型 = '魔法百分比'
else:
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()
return {
'uuid': uuid1().hex,
'skills': skillInfos,
'info': info,
'suits': suit,
'buffer':self.buffer
}
return {'uuid': uuid1().hex, 'skills': skillInfos, 'info': info, 'suits': suit, 'buffer': self.buffer}
# 技能影响角色的属性,如属强、抗性等
# region 输出计算项
def calc_damage_ration(self,DSB:bool,BUFF:bool):
def calc_damage_ration(self, DSB: bool, BUFF: bool):
"""计算属性系数"""
# 计算最终属性
# 力/智 攻击力 攻击力%(特效不吃这部分)
@@ -937,7 +928,7 @@ class Character(CharacterProperty):
ratio_9 = 1.0 * self.ElementIncrease
return (ratio_0, ratio_1, ratio_2, ratio_3, ratio_4, ratio_5, ratio_6, ratio_7, ratio_8, ratio_9)
def calc_carry_skills(self,DSB:bool,BUFF:bool):
def calc_carry_skills(self, DSB: bool, BUFF: bool):
skillInfos = []
for i in self.skills:
if i.damage and i.lv > 0:
@@ -957,24 +948,13 @@ class Character(CharacterProperty):
'type': i.type,
}
)
ratios = self.calc_damage_ration(DSB,BUFF)
ratios = self.calc_damage_ration(DSB, BUFF)
ratio_char_skill = ratios[0] * ratios[1] * ratios[2] * ratios[3] * ratios[4] * ratios[5] * ratios[6] * ratios[7] * ratios[8] * ratios[9] / 1000
ratuio_equ_skill = ratios[0] * ratios[1] * ratios[3] * ratios[4] * ratios[6] * ratios[7] * ratios[8] * ratios[9] / 1000
for i in skillInfos:
i['damage'] = ratio_char_skill * i['data'] * i['ratio'] / 100
for i in self.equ_effect:
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':''
}
)
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、cd、damage 的项
# merged = {}
# for skill in skillInfos:
@@ -997,7 +977,7 @@ class Character(CharacterProperty):
if self.输出类型 == '魔法固伤':
attrs.extend(['INT', 'AtkI'])
info = []
attrs.extend(['Attack', 'AttackP', 'SkillAttack','EquEffectRatio', 'ElementDB'])
attrs.extend(['Attack', 'AttackP', 'SkillAttack', 'EquEffectRatio', 'ElementDB'])
for attr in attrs:
temp = getattr(CharacterInfo, attr)
if attr.startswith('Atk'):
@@ -1006,7 +986,7 @@ class Character(CharacterProperty):
else:
value = getattr(self, attr)
if attr == 'SkillAttack':
value *= (self.jade_effect.SkillAttack + 1)
value *= self.jade_effect.SkillAttack + 1
if attr == 'AttackP':
value += self.jade_effect.AttackP
info.append(
@@ -1017,9 +997,10 @@ class Character(CharacterProperty):
)
pass
return info
# endregion
#region 辅助计算项
# region 辅助计算项
def calc_buffer_skills(self):
skillInfos = []
@@ -1028,10 +1009,10 @@ class Character(CharacterProperty):
# 增益量
buffer_power = self.Buffer * self.BufferP
# buff系数
buff_ratio_new = (main / 2993 +1) * (buffer_power / 4800 + 1) if buffer_power > 0 else 0
buff_ratio_new = (main / 2993 + 1) * (buffer_power / 4800 + 1) if buffer_power > 0 else 0
buff_ratio_old = main / 2993 + 1
# 觉醒系数
awake_ratio_new = ((main + 7500) / 7500 + 1) *((buffer_power + 68000) / 8500 + 1) if buffer_power > 0 else 0
awake_ratio_new = ((main + 7500) / 7500 + 1) * ((buffer_power + 68000) / 8500 + 1) if buffer_power > 0 else 0
awake_ratio_old = main / 7500 + 1
for i in self.skills:
if i.lv > 0 and i.hasUP and i.up is not None and i.up > 0:
@@ -1042,42 +1023,47 @@ class Character(CharacterProperty):
value = info[0]
# buff技能
if i.buffType == 'buff' or i.buffType == 'buffSub':
value1 = (info[1][0] + info[1][2])*info[1][1]*buff_ratio_old + info[1][0]*buff_ratio_new
value2 = (info[2][0] + info[2][2])*info[2][1]*buff_ratio_old + info[2][0]*buff_ratio_new
value1 = (info[1][0] + info[1][2]) * info[1][1] * buff_ratio_old + info[1][0] * buff_ratio_new
value2 = (info[2][0] + info[2][2]) * info[2][1] * buff_ratio_old + info[2][0] * buff_ratio_new
# 觉醒技能
elif i.buffType == 'awake' or i.buffType == 'awakeSub':
value1 = (info[1][0] + info[1][2])*info[1][1]*awake_ratio_old + info[1][0]*awake_ratio_new
value2 = (info[2][0] + info[2][2])*info[2][1]*awake_ratio_old + info[2][0]*awake_ratio_new
value1 = (info[1][0] + info[1][2]) * info[1][1] * awake_ratio_old + info[1][0] * awake_ratio_new
value2 = (info[2][0] + info[2][2]) * info[2][1] * awake_ratio_old + info[2][0] * awake_ratio_new
else:
value1 = (info[1][0] + info[1][2])*info[1][1]
value2 = (info[2][0] + info[2][2])*info[2][1]
value1 = (info[1][0] + info[1][2]) * info[1][1]
value2 = (info[2][0] + info[2][2]) * info[2][1]
value3 = info[3]
value4 = info[4]
if i.buffType == 'awake' and self.bindAwake == 50:
pass
else:
skillInfos.append({
"name":i.name,
"cd":value4,
"icon":i.icon,
"lv": i.lv,
# 对自己的加成 三攻 力智 伤害直接加成
"buff":[value, value1, value2, value3],
"type":i.type
})
skillInfos.append(
{
'name': i.name,
'cd': value4,
'icon': i.icon,
'lv': i.lv,
# 对自己的加成 三攻 力智 伤害直接加成
'buff': [value, value1, value2, value3],
'type': i.type,
}
)
return skillInfos
def get_buffer_info(self):
attrs = [get_key_by_value(self.适用属性),'Buffer','BufferP']
attrs = [get_key_by_value(self.适用属性), 'Buffer', 'BufferP']
info = []
for attr in attrs:
temp = getattr(CharacterInfo, attr)
value = getattr(self, attr)
info.append({
'name': temp.name,
'value': temp.value(value),
})
info.append(
{
'name': temp.name,
'value': temp.value(value),
}
)
return info
# endregion
# endregion
+19 -9
View File
@@ -1,16 +1,20 @@
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
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(',')]
def parse_to_string_list(info: str, default: list[str] = ['']) -> list[str]:
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]:
return default if not info else [int(i) for i in info.split(',')]
class Equ:
id: str
name: str
@@ -51,6 +55,7 @@ class Equ:
temp[attr] = value[min(adaptation, len(value) - 1)] if isinstance(value, list) else value
return Equ(**temp)
class Suit:
id: int
suitId: int
@@ -67,6 +72,7 @@ class Suit:
def __init__(self, **kwargs):
self.__dict__.update(kwargs)
class Equipments:
def __init__(self, version='0'):
self.version = version
@@ -90,6 +96,8 @@ class Equipments:
self.init_stones()
self.init_emblem()
self.init_jades()
self.init_oaths()
self.init_oath_suits()
self.engine.dispose()
def init_equs(self):
@@ -189,7 +197,6 @@ class Equipments:
db_list_1 = session.query(OathData).all()
db_list_2 = session.query(PrimerData).all()
keys = [key for key in OathData.__dict__.keys() if key[0].isupper()]
print(keys)
for item in db_list_1 + db_list_2:
max_adaptation = 0
item.id = str(item.id)
@@ -199,7 +206,7 @@ class Equipments:
value = parse_to_number_list(getattr(item, attr))
max_adaptation = max(max_adaptation, len(value) - 1)
setattr(item, attr, value)
for attr in ['wearUrl','position','suit']:
for attr in ['wearUrl', 'position', 'suit']:
value = [] if getattr(item, attr) is None else getattr(item, attr).split(',')
setattr(item, attr, value)
oath_dict = {k: v for k, v in item.__dict__.items() if not k.startswith('_')}
@@ -232,13 +239,12 @@ class Equipments:
pass
pass
def init_func(self):
"""根据装备版本加载装备效果"""
try:
funs = importlib.import_module(f"core.equipment.version_{self.version}")
funs = importlib.import_module(f'core.equipment.version_{self.version}')
except Exception:
funs = importlib.import_module("core.equipment.version_0")
funs = importlib.import_module('core.equipment.version_0')
return funs
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
return list(result.values())
class EquEffect:
name: str = ''
"""装备技能名称"""
@@ -280,7 +287,7 @@ class EquEffect:
"""技能图标"""
cd: float = 0
"""技能冷却时间"""
data:float = 0
data: float = 0
"""伤害量"""
def __init__(self, name: str, icon: str, cd: float, data: float):
@@ -289,6 +296,7 @@ class EquEffect:
self.cd = cd
self.data = data
class Oath:
id: str
name: str
@@ -348,6 +356,7 @@ class OathSuitSkill:
def __init__(self, **kwargs):
self.__dict__.update(kwargs)
class OathSuit:
id: int
key: str
@@ -368,12 +377,13 @@ class OathSuit:
global equ0
equ0 = Equipments("0")
equ0 = Equipments('0')
def get_equipment(version: str = '0') -> Equipments:
# print('加载装备信息')
try:
temp = eval(f"equ{version}".format(version))
temp = eval(f'equ{version}'.format(version))
except Exception:
temp = equ0
return temp
+27 -7
View File
@@ -1,7 +1,7 @@
from enum import Enum
from typing import Union
from core.basic.equipment import Equ, get_equipment
from core.basic.equipment import Equ, get_equipment, Oath
class CharacterEquipInfo:
@@ -29,13 +29,13 @@ class CharacterEquipInfo:
"""装备信息"""
fusionInfo: Union['Equ', None]
"""贴膜信息"""
precision:float
precision: float
"""秘宝精度"""
def __init__(self, info={}, equVerison=0, part='') -> None:
info["fusion"] = info.get("fusion", None)
info["precision"] = info.get("precision", 0)
info["weaponFusion"] = info.get("weaponFusion", None)
info['fusion'] = info.get('fusion', None)
info['precision'] = info.get('precision', 0)
info['weaponFusion'] = info.get('weaponFusion', None)
self.__dict__.update(info)
equ = get_equipment(equVerison).equ_dict.get(self.id, None)
fusion = get_equipment(equVerison).stone_dict.get(self.fusion, None)
@@ -43,7 +43,7 @@ class CharacterEquipInfo:
self.equInfo = equ.adapt(self.adaptation)
self.adaptation = min(self.adaptation, self.equInfo.max_adaptation)
if part == '副武器' and equ.itemType == '武器':
self.equInfo.itemType = "副武器"
self.equInfo.itemType = '副武器'
else:
self.equInfo = None
if fusion is not None and (fusion.itemType == part or fusion.itemDetailType == part):
@@ -52,6 +52,26 @@ class CharacterEquipInfo:
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):
refine: int
"""锻造等级"""
@@ -104,7 +124,7 @@ class CharacterAttributes(Enum):
AttackP = '攻击强化%'
mapping = {value.value : key for key, value in CharacterAttributes.__members__.items()}
mapping = {value.value: key for key, value in CharacterAttributes.__members__.items()}
def get_key_by_value(value: str) -> str:
+8 -10
View File
@@ -1,11 +1,9 @@
from core.basic.equipment import Equipments
equ = Equipments("0")
from core.basic.character import createCharacter
equ.init_oath_suits()
item = equ.oath_suits[3]
for i in range(1, 7):
print(f"Lv{i}:")
print(equ.oath_suits[i])
for skill in equ.oath_suits[i]['skills']:
print(skill.__dict__)
print("------------------")
char = createCharacter('GF.gunner_female.spitfire_female')
char.calc_init({'oaths': {'0': {'id': '2010201', 'adaptation': 3}, '11': {'id': '2050200', 'adaptation': 0}}, 'equips': {}})
for oath in char.charOathInfo:
print(oath.id, oath.adaptation, oath.oathInfo.position, oath.oathInfo.max_adaptation, oath.oathInfo.Point)