This commit is contained in:
2026-07-06 18:30:50 +08:00
parent 2b1c27c36c
commit cee25b63e1
17 changed files with 102 additions and 837 deletions
+9 -3
View File
@@ -9,13 +9,17 @@ core.basic.character 包
"""
import importlib
import logging
from api.core.exception import ResponseException
from .jade import Jade
from .calc_equip import CalcEquipMixin
from .calc_carry import CalcCarryMixin
from .calc_buffer import CalcBufferMixin
from .info import CharacterInfoMixin
logger = logging.getLogger('dcalc.character')
class Character(CalcEquipMixin, CalcCarryMixin, CalcBufferMixin, CharacterInfoMixin):
"""
@@ -28,15 +32,17 @@ class Character(CalcEquipMixin, CalcCarryMixin, CalcBufferMixin, CharacterInfoMi
def createCharacter(alter: str, equVersion: str = '0') -> 'Character':
character: Character = None
module_name = 'core.character.' + alter
if equVersion is None or equVersion == '':
equVersion = '0'
try:
character = importlib.import_module(module_name).classChange(equVersion)
except Exception as ex:
print(ex)
print('create character ' + module_name + ' error.')
logger.exception('create character failed alter=%s equVersion=%s module=%s', alter, equVersion, module_name)
raise ResponseException(f'职业加载失败: {alter}') from ex
if character is None:
logger.error('create character returned None alter=%s equVersion=%s module=%s', alter, equVersion, module_name)
raise ResponseException(f'职业加载失败: {alter}')
return character
+3 -4
View File
@@ -5,15 +5,14 @@ import json
import re
from typing import Any, Literal, TYPE_CHECKING
from .formula import 武器冷却惩罚
from database.connect import BACKEND_DIR, get_redis_client
from database.connect import get_redis_client
from api.core.Redis import get_redis_info
from api.utils.openapi_data import logical_skill_detail_path
from api.utils.openapi_data import OPENAPI_CUSTOM_CN_PATH, logical_skill_detail_path
if TYPE_CHECKING:
from core.basic.character import Character
characterLv = 115 + 5
OPENAPI_DIR = BACKEND_DIR / 'openapi'
def _identity(value: Any) -> Any:
@@ -22,7 +21,7 @@ def _identity(value: Any) -> Any:
@cache
def _load_custom_cn() -> list[dict[str, Any]]:
with (OPENAPI_DIR / 'custom_cn.json').open(encoding='utf-8') as f:
with OPENAPI_CUSTOM_CN_PATH.open(encoding='utf-8') as f:
return json.load(f)