aboutsummaryrefslogtreecommitdiff
path: root/src/headless
diff options
context:
space:
mode:
author hop311 <hop3114@gmail.com>2024-09-06 23:58:20 +0200
committer hop311 <hop3114@gmail.com>2024-09-08 18:24:57 +0200
commitb5407c8794c4626d010bd0856a146095daa1042d (patch)
tree19baa8e48c1cf6d2d3b0c152b47f16daa9745a21 /src/headless
parentdd65fa7dd431264caa08d083cb3a94922a4084d5 (diff)
Add country ranking system + great/secondary powers
Diffstat (limited to 'src/headless')
-rw-r--r--src/headless/main.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/headless/main.cpp b/src/headless/main.cpp
index fcb5e8d..21e9f7c 100644
--- a/src/headless/main.cpp
+++ b/src/headless/main.cpp
@@ -52,6 +52,34 @@ static bool run_headless(Dataloader::path_vector_t const& roots, bool run_tests)
// This triggers a gamestate update
ret &= game_manager.update_clock();
+ // TODO - REMOVE TEST CODE
+ Logger::info("===== Ranking system test... =====");
+ if (game_manager.get_instance_manager()) {
+ const auto print_ranking_list = [](std::string_view title, std::vector<CountryInstance*> const& countries) -> void {
+ std::string text;
+ for (CountryInstance const* country : countries) {
+ text += StringUtils::append_string_views(
+ "\n ", country->get_identifier(),
+ " - Total #", std::to_string(country->get_total_rank()), " (", country->get_total_score().to_string(1),
+ "), Prestige #", std::to_string(country->get_prestige_rank()), " (", country->get_prestige().to_string(1),
+ "), Industry #", std::to_string(country->get_industrial_rank()), " (", country->get_industrial_power().to_string(1),
+ "), Military #", std::to_string(country->get_military_rank()), " (", country->get_military_power().to_string(1), ")"
+ );
+ }
+ Logger::info(title, ":", text);
+ };
+
+ CountryInstanceManager const& country_instance_manager =
+ game_manager.get_instance_manager()->get_country_instance_manager();
+
+ print_ranking_list("Great Powers", country_instance_manager.get_great_powers());
+ print_ranking_list("Secondary Powers", country_instance_manager.get_secondary_powers());
+ print_ranking_list("All countries", country_instance_manager.get_total_ranking());
+ } else {
+ Logger::error("Instance manager not available!");
+ ret = false;
+ }
+
return ret;
}