feat: 自动更新器添加版本号

This commit is contained in:
MistEO
2023-05-11 14:39:31 +08:00
parent 1974a5d7a4
commit a93f7bd910
6 changed files with 82 additions and 1 deletions

View File

@@ -0,0 +1,6 @@
{
"gacha": {
"pool": "Great Axe and Pen Nib",
"time": 1673611200
}
}

View File

@@ -0,0 +1,6 @@
{
"gacha": {
"pool": "戦斧と万年筆",
"time": 1673575200
}
}

View File

@@ -0,0 +1,6 @@
{
"gacha": {
"pool": "그레이트 액스와 펜닙",
"time": 1673575200
}
}

View File

@@ -0,0 +1,6 @@
{
"gacha": {
"pool": "海蝕",
"time": 1675150200
}
}

6
resource/version.json Normal file
View File

@@ -0,0 +1,6 @@
{
"gacha": {
"pool": "真理孑然",
"time": 1682913600
}
}

View File

@@ -66,6 +66,8 @@ bool check_roguelike_replace_for_overseas(const std::filesystem::path& input_dir
const std::filesystem::path& base_dir,
const std::filesystem::path& output_dir);
bool update_version_info(const std::filesystem::path& input_dir, const std::filesystem::path& output_dir);
int main([[maybe_unused]] int argc, char** argv)
{
const char* str_exec_path = argv[0];
@@ -163,7 +165,7 @@ int main([[maybe_unused]] int argc, char** argv)
}
// gamedata 繁中不更新了,自己下载一下
std::string gamedata_tw_exec = cur_path.string() + "/gamedata-tw.exe";
std::string gamedata_tw_exec = "\"" + cur_path.string() + "/gamedata-tw.exe" + "\"";
if (!std::filesystem::exists(gamedata_tw_exec)) {
std::string download_zhtw = "curl --ssl-no-revoke "
"https://raw.githubusercontent.com/MaaAssistantArknights/"
@@ -233,6 +235,22 @@ int main([[maybe_unused]] int argc, char** argv)
}
}
std::cout << "------------Update version info------------" << std::endl;
if (!update_version_info(arkbot_res_dir / "gamedata" / "excel", resource_dir)) {
std::cerr << "Update version info failed" << std::endl;
return -1;
}
for (const auto& [in, out] : global_dirs) {
std::cout << "------------Update version info for " << out << "------------" << std::endl;
if (!update_version_info(game_data_dir / in / "gamedata" / "excel",
resource_dir / "global" / out / "resource")) {
std::cerr << "Update version info failed" << std::endl;
return -1;
}
}
std::cout << "------------All success------------" << std::endl;
return 0;
}
@@ -1010,3 +1028,36 @@ bool check_roguelike_replace_for_overseas(const std::filesystem::path& input_dir
return true;
}
bool update_version_info(const std::filesystem::path& input_dir, const std::filesystem::path& output_dir)
{
const auto json_path = input_dir / "gacha_table.json";
auto gacha_json_opt = json::open(json_path);
if (!gacha_json_opt) {
std::cerr << "faild to parse " << json_path;
return false;
}
auto& gacha_json = *gacha_json_opt;
uint64_t time = 0;
std::string pool;
for (auto& gacha_info : gacha_json["gachaPoolClient"].as_array()) {
if (gacha_info["gachaRuleType"].as_string() != "LIMITED") {
continue;
}
auto cur_time = gacha_info["openTime"].as_unsigned_long_long();
if (time < cur_time) {
time = cur_time;
pool = gacha_info["gachaPoolName"].as_string();
}
}
json::value result;
result["gacha"]["time"] = time;
result["gacha"]["pool"] = pool;
std::ofstream ofs(output_dir / "version.json", std::ios::out);
ofs << result.format(true) << std::endl;
return true;
}