Skip to content

Commit

Permalink
装备选择逻辑改动,及增加“水上机”类别装备 (#33)
Browse files Browse the repository at this point in the history
* <add> 通过 ship_type_forbidden 属性过滤可用装备

* <add> 允许选择水上机(部分航战、轻航可用)

* <data> 为装备数据添加“禁用舰种” (ship_type_forbidden) 属性

* <data> 装备数据增加水上机

* 替换 {namecode} 模板

* python 依赖丢失

* <add> 增加按钮,单独重置设置,但不清空舰队数据

* 航战使用官方缩写 BBV
  • Loading branch information
WavinFlag authored Sep 18, 2024
1 parent ede5029 commit 1289b37
Show file tree
Hide file tree
Showing 11 changed files with 1,078 additions and 55 deletions.
36 changes: 30 additions & 6 deletions prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,22 @@ def load_image(typ, name):
load_phrases_dict({'武藏': [['wǔ'], ['zàng']]})


def namecode_repl(m: re.Match):
s_id = m.group(1)
item = namecode.get(s_id)
if item is not None:
name = item['name']
return name
opt_text = m.group(2)
if opt_text is not None:
return opt_text
return m.group(0)

def replace_namecode_template(input: str):
output = re.sub(r'\{namecode:(\d+)(?::([^}]*))?\}', namecode_repl, input)
return output


def get_trans_info(grp):
"""获取改造信息
Expand Down Expand Up @@ -202,7 +218,7 @@ def get_match_name(name):
def get_skills(skill_ids):
results = []
for skill_id in skill_ids:
buff = buffcfg['buff_%s' % skill_id]
# buff = buffcfg['buff_%s' % skill_id]
# print(skill_id)
skillt = skill_template[str(skill_id)]
# print('skill_template', skillt)
Expand All @@ -215,9 +231,9 @@ def get_skills(skill_ids):
results.append(
{
'id': skill_id,
'name': skillt['name'],
'name': replace_namecode_template(skillt['name']),
'type': skillt['type'],
'desc': desc,
'desc': replace_namecode_template(desc),
}
)
return results
Expand Down Expand Up @@ -376,13 +392,16 @@ def load_equip_template():
7,
8,
9,
# 水上机12
12,
)
name_rarity_map = {}
result = {}
for key in list(base_map):
assert len(base_map[key]) > 1
base_map[key].sort()
edata = equip_data[str(key)]
edata2 = equip_template[str(key)]
name = edata['name']
if edata['type'] not in TARGET_EQUIP_TYPES:
continue
Expand All @@ -402,6 +421,7 @@ def load_equip_template():
'rarity': edata['rarity'],
'tech': edata['tech'],
'cd': wp_prop['reload_max'],
'ship_type_forbidden': edata2['ship_type_forbidden'],
}

# 单独处理几个特殊装备
Expand All @@ -419,6 +439,7 @@ def load_equip_template():
]

ebase = equip_data['2240']
ebase2 = equip_template['2240']
assert base_map[2240][-1] == '2251', base_map[2240]
for plus in range(12):
# 链式装弹机 +0~11
Expand All @@ -432,6 +453,7 @@ def load_equip_template():
'max': '2251',
'rarity': ebase['rarity'],
'tech': ebase['tech'],
'ship_type_forbidden': ebase2['ship_type_forbidden'],
"buffs": [
{
"type": "ReloadAdd",
Expand All @@ -444,6 +466,7 @@ def load_equip_template():
# 归航信标; 高性能火控雷达; 航空整备小组
for key in (680, 1260, 3940):
edata = equip_data[str(key)]
edata2 = equip_template[str(key)]
result[edata['name']] = {
'id': key,
'icon': edata['icon'],
Expand All @@ -452,6 +475,7 @@ def load_equip_template():
'max': base_map[key][-1],
'rarity': edata['rarity'],
'tech': edata['tech'],
'ship_type_forbidden': edata2['ship_type_forbidden'],
}

result['归航信标']['type'] = 101
Expand Down Expand Up @@ -523,11 +547,11 @@ def main():

ship_result = load_ship_template()
print(len(ship_result))
Path('vue/public/data/ships.json').write_text(tojson(ship_result))
Path('vue/public/data/ships.json').write_text(tojson(ship_result), newline='\n')
equip_result = load_equip_template()
print(len(equip_result))
Path('vue/public/data/equips.json').write_text(tojson(equip_result))
Path('vue/public/data/version.txt').write_text(new_version + '\n')
Path('vue/public/data/equips.json').write_text(tojson(equip_result), newline='\n')
Path('vue/public/data/version.txt').write_text(new_version)


if __name__ == '__main__':
Expand Down
5 changes: 3 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
httpx
pypinyin
pyyaml
requests
wikitextparser
pypinyin
pyyaml
Loading

0 comments on commit 1289b37

Please sign in to comment.