mirror of
https://github.com/PaiGramTeam/PaiGramMetadata.git
synced 2024-11-21 22:48:05 +00:00
🐛 Fix default config from weapon and artifact
This commit is contained in:
parent
c5d0360cca
commit
6c3349411e
@ -366,7 +366,8 @@
|
|||||||
"full_rate": 0.0
|
"full_rate": 0.0
|
||||||
},
|
},
|
||||||
"CalamityQueller": {
|
"CalamityQueller": {
|
||||||
"stack": 6.0
|
"stack": 6.0,
|
||||||
|
"backend_rate": 0.0
|
||||||
},
|
},
|
||||||
"StaffOfHoma": {
|
"StaffOfHoma": {
|
||||||
"be50_rate": 0.0
|
"be50_rate": 0.0
|
||||||
@ -1900,7 +1901,8 @@
|
|||||||
"rate": 1.0
|
"rate": 1.0
|
||||||
},
|
},
|
||||||
"KeyOfKhajNisut": {
|
"KeyOfKhajNisut": {
|
||||||
"stack": 3.0
|
"stack": 3.0,
|
||||||
|
"rate": 0.5
|
||||||
},
|
},
|
||||||
"ToukabouShigure": {
|
"ToukabouShigure": {
|
||||||
"rate": 0.5
|
"rate": 0.5
|
||||||
@ -2156,7 +2158,8 @@
|
|||||||
"rate": 1.0
|
"rate": 1.0
|
||||||
},
|
},
|
||||||
"KeyOfKhajNisut": {
|
"KeyOfKhajNisut": {
|
||||||
"stack": 3.0
|
"stack": 3.0,
|
||||||
|
"rate": 0.5
|
||||||
},
|
},
|
||||||
"WolfFang": {
|
"WolfFang": {
|
||||||
"e_stack": 1.0,
|
"e_stack": 1.0,
|
||||||
|
@ -26,5 +26,8 @@ class Artifact:
|
|||||||
self.artifacts = artifacts
|
self.artifacts = artifacts
|
||||||
self.artifact_config_map = artifact_config_map
|
self.artifact_config_map = artifact_config_map
|
||||||
|
|
||||||
|
def get_by_name(self, name: str) -> ArtifactModel:
|
||||||
|
return self.artifact_config_map.get(name)
|
||||||
|
|
||||||
|
|
||||||
artifact = Artifact()
|
artifact = Artifact()
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
import json
|
import json
|
||||||
from typing import Dict, Any
|
from typing import Dict, Any
|
||||||
|
|
||||||
|
from .artifact import artifact
|
||||||
from .character import character
|
from .character import character
|
||||||
from .models import CharacterDamage, CharacterSkill, CharacterConfig, WeaponConfig
|
from .models import CharacterDamage, CharacterConfig, WeaponConfig
|
||||||
from .skill_data import SkillData
|
from .skill_data import SkillData
|
||||||
|
from .weapon import weapon
|
||||||
|
|
||||||
|
|
||||||
class Data:
|
class Data:
|
||||||
@ -11,6 +13,7 @@ class Data:
|
|||||||
self.file_name = "GenshinDamageRule.json"
|
self.file_name = "GenshinDamageRule.json"
|
||||||
self.file_data: Dict[str, CharacterDamage] = self.load()
|
self.file_data: Dict[str, CharacterDamage] = self.load()
|
||||||
self.patch_character()
|
self.patch_character()
|
||||||
|
self.add_new_default_config()
|
||||||
|
|
||||||
def load(self) -> Dict[str, CharacterDamage]:
|
def load(self) -> Dict[str, CharacterDamage]:
|
||||||
with open(self.file_name, "r", encoding="utf-8") as f:
|
with open(self.file_name, "r", encoding="utf-8") as f:
|
||||||
@ -39,6 +42,33 @@ class Data:
|
|||||||
skill.index
|
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]:
|
def dump(self) -> Dict[str, Dict]:
|
||||||
new_data = {}
|
new_data = {}
|
||||||
for k, v in self.file_data.items():
|
for k, v in self.file_data.items():
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import json
|
import json
|
||||||
from typing import Dict
|
from typing import Dict, Optional
|
||||||
|
|
||||||
from .assets import assets, locale
|
from .assets import assets, locale
|
||||||
from .models import Weapon as WeaponModel, WeaponConfig
|
from .models import Weapon as WeaponModel, WeaponConfig
|
||||||
@ -8,6 +8,7 @@ from .models import Weapon as WeaponModel, WeaponConfig
|
|||||||
class Weapon:
|
class Weapon:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
weapon_map: Dict[str, WeaponModel] = {}
|
weapon_map: Dict[str, WeaponModel] = {}
|
||||||
|
weapon_name_map: Dict[str, WeaponModel] = {}
|
||||||
for value in assets.weapon.values():
|
for value in assets.weapon.values():
|
||||||
if not value["configs"]:
|
if not value["configs"]:
|
||||||
continue
|
continue
|
||||||
@ -22,7 +23,13 @@ class Weapon:
|
|||||||
temp = weapon_map.get(value["t"], [])
|
temp = weapon_map.get(value["t"], [])
|
||||||
temp.append(weapon_)
|
temp.append(weapon_)
|
||||||
weapon_map[value["t"]] = temp
|
weapon_map[value["t"]] = temp
|
||||||
|
weapon_name_map[value["name"]] = weapon_
|
||||||
self.weapon_map = weapon_map
|
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()
|
weapon = Weapon()
|
||||||
|
Loading…
Reference in New Issue
Block a user