Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Research field for Stats object #4091

Merged
merged 1 commit into from
Oct 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/wzapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4522,6 +4522,35 @@ nlohmann::json wzapi::constructStatsObject()
structbase[psStats->name.toUtf8()] = std::move(strct);
}
stats["Building"] = std::move(structbase);

//== * ```Research``` Researches
nlohmann::json researchbase = nlohmann::json::object();
for (int j = 0; j < asResearch.size(); j++)
{
RESEARCH *psStats = &asResearch[j];
nlohmann::json res = nlohmann::json::object();
res["Id"] = psStats->id;
nlohmann::json reqs = nlohmann::json::array();
for (int k = 0; k < psStats->pPRList.size(); k++)
{
reqs.push_back(asResearch[psStats->pPRList[k]].id);
}
res["Requires"] = reqs;
nlohmann::json resstrcts = nlohmann::json::array();
for (int k = 0; k < psStats->pStructureResults.size(); k++)
{
resstrcts.push_back(asStructureStats[psStats->pStructureResults[k]].id);
}
res["ResultStructures"] = resstrcts;
nlohmann::json rescomps = nlohmann::json::array();
for (int k = 0; k < psStats->componentResults.size(); k++)
{
rescomps.push_back(psStats->componentResults[k]->id);
}
res["ResultComponents"] = rescomps;
researchbase[psStats->name.toUtf8()] = std::move(res);
}
stats["Research"] = std::move(researchbase);
}
return stats;
}
Expand Down
Loading