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.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
@@ -127,6 +127,8 @@ class Character(CharacterProperty):
"""装备版本"""
charEquipInfo: dict[str, 'CharacterEquipInfo']
"""装备打造信息"""
charOathInfo: list['CharacterOathInfo']
"""誓约打造信息"""
equ_effect: list['EquEffect'] = []
"""装备效果列表"""
equ_options: dict[str, int] = {}
@@ -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
else:
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)
@@ -819,32 +826,23 @@ class Character(CharacterProperty):
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,18 +881,11 @@ 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):
@@ -963,18 +954,7 @@ class Character(CharacterProperty):
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:
@@ -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,6 +997,7 @@ class Character(CharacterProperty):
)
pass
return info
# endregion
# region 辅助计算项
@@ -1056,15 +1037,17 @@ class Character(CharacterProperty):
if i.buffType == 'awake' and self.bindAwake == 50:
pass
else:
skillInfos.append({
"name":i.name,
"cd":value4,
"icon":i.icon,
"lv": i.lv,
skillInfos.append(
{
'name': i.name,
'cd': value4,
'icon': i.icon,
'lv': i.lv,
# 对自己的加成 三攻 力智 伤害直接加成
"buff":[value, value1, value2, value3],
"type":i.type
})
'buff': [value, value1, value2, value3],
'type': i.type,
}
)
return skillInfos
def get_buffer_info(self):
@@ -1073,11 +1056,14 @@ class Character(CharacterProperty):
for attr in attrs:
temp = getattr(CharacterInfo, attr)
value = getattr(self, attr)
info.append({
info.append(
{
'name': temp.name,
'value': temp.value(value),
})
}
)
return info
# 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.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)
@@ -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 = ''
"""装备技能名称"""
@@ -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
+25 -5
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:
@@ -33,9 +33,9 @@ class CharacterEquipInfo:
"""秘宝精度"""
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
"""锻造等级"""
+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)