Skip to content

Commit

Permalink
chore: 更改队伍配装数据json格式规范,以兼容未来版本
Browse files Browse the repository at this point in the history
  • Loading branch information
weiduhuo committed Nov 1, 2023
1 parent 455018f commit 6c7582a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
6 changes: 3 additions & 3 deletions utils/relic.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ def __init__(self, title=_("崩坏:星穹铁道")):
"""在打印遗器信息时的小数精度"""

# 读取json文件,仅初始化时检查格式规范
self.relics_data = read_json_file(RELIC_FILE_NAME, schema = RELIC_SCHEMA)
self.loadout_data = read_json_file(LOADOUT_FILE_NAME, schema = LOADOUT_SCHEMA)
self.team_data = read_json_file(TEAM_FILE_NAME, schema = TEAM_SCHEMA)
self.relics_data: Dict[str, Dict[str, Any]] = read_json_file(RELIC_FILE_NAME, schema = RELIC_SCHEMA)
self.loadout_data: Dict[str, Dict[str, List[str]]] = read_json_file(LOADOUT_FILE_NAME, schema = LOADOUT_SCHEMA)
self.team_data: Dict[str, Dict[str, Any]] = read_json_file(TEAM_FILE_NAME, schema = TEAM_SCHEMA)
log.info(_("遗器数据载入完成"))
log.info(_(f"共载入 {len(list(self.relics_data.keys()))} 件遗器数据"))

Expand Down
32 changes: 24 additions & 8 deletions utils/relic_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
BASE_STATS_TIER[i][10:10] = [BASE_STATS_TIER[i][10]] * 6 # 复制属性伤害


RELIC_SCHEMA = { # 遗器数据集
RELIC_SCHEMA = {
"type": "object",
"additionalProperties": { # [主键]遗器哈希值 (由其键值遗器数据自动生成)
"type": "object",
Expand Down Expand Up @@ -150,7 +150,7 @@
}}
"""遗器数据json格式规范"""

LOADOUT_SCHEMA = { # 人物遗器配装数据集
LOADOUT_SCHEMA = {
"type": "object",
"additionalProperties": { # [主键]人物名称 (以OCR结果为准)
"type": "object",
Expand All @@ -162,16 +162,32 @@
}}}
"""人物配装数据json格式规范"""

TEAM_SCHEMA = { # 队伍遗器配装数据集
"type": "object",
TEAM_SCHEMA_PART = {
"additionalProperties": { # [主键]队伍名称 (自定义)
"type": "object",
"additionalProperties": { # [外键]队伍成员名称 (以OCR结果为准)
"type": "string" # [外键]各队伍成员的配装名称
"properties": {
"team_members": { # 队伍成员 (无序,1-4人)
"type": "object",
"additionalProperties": { # [外键]队伍成员名称 (以OCR结果为准)
"type": "string" # [外键]各队伍成员的配装名称
},
"minProperties": 1,
"maxProperties": 4
},
# 【可扩展】如"visible","ordered"等其他队伍属性
},
"minProperties": 1,
"maxProperties": 4
"required": ["team_members"], # 需包含遗器的全部固有属性
"additionalProperties": False
}}
TEAM_SCHEMA = {
"type": "object",
"properties": {
"compatible": # [主键]非互斥队伍组别 (默认,不可更改)
TEAM_SCHEMA_PART,
},
"additionalProperties": # [主键]互斥队伍组别名称 (自定义,例如用于忘却之庭上下半配队)【待扩展】
TEAM_SCHEMA_PART,
}
"""队伍配装数据json格式规范"""

RELIC_DATA_FILTER = ["pre_ver_hash"]
Expand Down

0 comments on commit 6c7582a

Please sign in to comment.