diff --git a/GenshinDamageRule.json b/GenshinDamageRule.json index 45a3d76..8830b99 100644 --- a/GenshinDamageRule.json +++ b/GenshinDamageRule.json @@ -366,7 +366,8 @@ "full_rate": 0.0 }, "CalamityQueller": { - "stack": 6.0 + "stack": 6.0, + "backend_rate": 0.0 }, "StaffOfHoma": { "be50_rate": 0.0 @@ -1900,7 +1901,8 @@ "rate": 1.0 }, "KeyOfKhajNisut": { - "stack": 3.0 + "stack": 3.0, + "rate": 0.5 }, "ToukabouShigure": { "rate": 0.5 @@ -2156,7 +2158,8 @@ "rate": 1.0 }, "KeyOfKhajNisut": { - "stack": 3.0 + "stack": 3.0, + "rate": 0.5 }, "WolfFang": { "e_stack": 1.0, diff --git a/src/damage/artifact.py b/src/damage/artifact.py index 5eb19b8..9b5db2f 100644 --- a/src/damage/artifact.py +++ b/src/damage/artifact.py @@ -26,5 +26,8 @@ class Artifact: self.artifacts = artifacts self.artifact_config_map = artifact_config_map + def get_by_name(self, name: str) -> ArtifactModel: + return self.artifact_config_map.get(name) + artifact = Artifact() diff --git a/src/damage/data.py b/src/damage/data.py index 1eae9f5..9064c3d 100644 --- a/src/damage/data.py +++ b/src/damage/data.py @@ -1,9 +1,11 @@ import json from typing import Dict, Any +from .artifact import artifact from .character import character -from .models import CharacterDamage, CharacterSkill, CharacterConfig, WeaponConfig +from .models import CharacterDamage, CharacterConfig, WeaponConfig from .skill_data import SkillData +from .weapon import weapon class Data: @@ -11,6 +13,7 @@ class Data: self.file_name = "GenshinDamageRule.json" self.file_data: Dict[str, CharacterDamage] = self.load() self.patch_character() + self.add_new_default_config() def load(self) -> Dict[str, CharacterDamage]: with open(self.file_name, "r", encoding="utf-8") as f: @@ -39,6 +42,33 @@ class Data: skill.index ] + def add_new_default_config(self): + # 版本更新时,自动添加新的默认配置。只处理 config_weapon artifact_config + self.add_new_default_config_weapon() + self.add_new_default_config_artifact() + + def add_new_default_config_weapon(self): + for c_name, v in self.file_data.items(): + if v.config_weapon: + for w_name, w_value in v.config_weapon.items(): + w = weapon.get_by_name(w_name) + if not w: + continue + for config in w.config: + if config.name not in w_value: + w_value[config.name] = config.default + + def add_new_default_config_artifact(self): + for c_name, v in self.file_data.items(): + if v.artifact_config: + for a_name, a_value in v.artifact_config.items(): + a = artifact.get_by_name(a_name) + if not a: + continue + for config in a.config: + if config.name not in a_value: + a_value[config.name] = config.default + def dump(self) -> Dict[str, Dict]: new_data = {} for k, v in self.file_data.items(): diff --git a/src/damage/weapon.py b/src/damage/weapon.py index 0c14d80..af6957d 100644 --- a/src/damage/weapon.py +++ b/src/damage/weapon.py @@ -1,5 +1,5 @@ import json -from typing import Dict +from typing import Dict, Optional from .assets import assets, locale from .models import Weapon as WeaponModel, WeaponConfig @@ -8,6 +8,7 @@ from .models import Weapon as WeaponModel, WeaponConfig class Weapon: def __init__(self): weapon_map: Dict[str, WeaponModel] = {} + weapon_name_map: Dict[str, WeaponModel] = {} for value in assets.weapon.values(): if not value["configs"]: continue @@ -22,7 +23,13 @@ class Weapon: temp = weapon_map.get(value["t"], []) temp.append(weapon_) weapon_map[value["t"]] = temp + weapon_name_map[value["name"]] = weapon_ self.weapon_map = weapon_map + self.weapon_name_map = weapon_name_map + + def get_by_name(self, name: str) -> Optional[WeaponModel]: + # 通过内部名称获取武器,例如 MistsplitterReforged + return self.weapon_name_map.get(name) weapon = Weapon()