rft: 重构battle_data

This commit is contained in:
status102
2026-03-27 15:25:36 +08:00
parent 83ce081ac5
commit a9e6d53672
3 changed files with 38 additions and 1 deletions

View File

@@ -375,6 +375,7 @@ struct OperProps
std::string name_jp;
std::string name_kr;
std::string name_tw;
std::string name_display;
Role role = Role::Unknown;
std::array<std::string, 3> ranges;
int rarity = 0; // 稀有度 1-6

View File

@@ -12,6 +12,9 @@ bool asst::BattleDataConfig::parse(const json::value& json)
m_ranges.clear();
m_opers.clear();
m_drones_confusing.clear();
m_opers.clear();
m_chars.clear();
m_ranges.clear();
for (const auto& [id, char_data_json] : json.at("chars").as_object()) {
std::shared_ptr<battle::OperProps> data_ptr = std::make_shared<battle::OperProps>();
data_ptr->id = id;

View File

@@ -929,11 +929,14 @@ bool update_battle_chars_info(const fs::path& official_dir, const fs::path& over
json::value char_new_data;
for (auto& [data, name] : chars_json) {
if (data.get(id, "name", "_unavailable_") != "_unavailable_") {
char_new_data[name] = data.get(id, "name", char_data["name"].as_string());
if (data.get(id, "name", "_unavailable_") == "_unavailable_") {
}
else {
char_new_data[name + "_unavailable"] = true;
}
}
char_new_data["name_display"] = char_new_data["name"];
char_new_data["profession"] = char_data["profession"];
const std::string& default_range = char_data.get("phases", 0, "rangeId", "0-1");
@@ -974,6 +977,7 @@ bool update_battle_chars_info(const fs::path& official_dir, const fs::path& over
Amiya_data["name_jp"] = "アーミヤ-WARRIOR";
Amiya_data["name_kr"] = "아미야-WARRIOR";
Amiya_data["name_tw"] = "阿米婭-WARRIOR";
Amiya_data["name_display"] = "阿米娅-WARRIOR";
Amiya_data["profession"] = "WARRIOR";
Amiya_data["rangeId"] = json::array { "1-1", "1-1", "1-1" };
Amiya_data["rarity"] = 5;
@@ -986,6 +990,7 @@ bool update_battle_chars_info(const fs::path& official_dir, const fs::path& over
Amiya_data3["name_jp"] = "アーミヤ-MEDIC";
Amiya_data3["name_kr"] = "아미야-MEDIC";
Amiya_data3["name_tw"] = "阿米婭-MEDIC";
Amiya_data3["name_display"] = "阿米娅-MEDIC";
Amiya_data3["profession"] = "MEDIC";
Amiya_data3["rangeId"] = json::array { "3-1", "3-3", "3-3" };
Amiya_data3["rarity"] = 5;
@@ -997,6 +1002,34 @@ bool update_battle_chars_info(const fs::path& official_dir, const fs::path& over
ofs << result.format() << '\n';
ofs.close();
std::vector<std::pair<std::string, std::string>> overseas_paths = {
{ "name_en", "global/YoStarEN/resource/battle_data.json" },
{ "name_jp", "global/YoStarJP/resource/battle_data.json" },
{ "name_kr", "global/YoStarKR/resource/battle_data.json" },
{ "name_tw", "global/txwy/resource/battle_data.json" },
};
for (const auto& [client_name, path] : overseas_paths) {
json::value overseas_result;
overseas_result["ranges"] = result["ranges"];
auto& overseas_chars = overseas_result["chars"];
for (auto& [id, char_data] : chars.as_object()) {
auto name_opt = char_data.find<std::string>(client_name);
if (!name_opt) {
continue;
}
auto data = char_data;
data.emplace("name_display", *name_opt);
overseas_chars.emplace(id, std::move(data));
}
const auto& overseas_file = output_dir / path;
std::ofstream overseas_ofs(overseas_file, std::ios::out);
overseas_ofs << overseas_result.format() << '\n';
overseas_ofs.close();
}
return true;
}