diff --git a/src/headless/main.cpp b/src/headless/main.cpp index b1a82df0..fbc8ed3e 100644 --- a/src/headless/main.cpp +++ b/src/headless/main.cpp @@ -90,44 +90,44 @@ static bool run_headless(Dataloader::path_vector_t const& roots, bool run_tests) 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 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(); - - std::vector const& great_powers = country_instance_manager.get_great_powers(); - print_ranking_list("Great Powers", great_powers); - print_ranking_list("Secondary Powers", country_instance_manager.get_secondary_powers()); - print_ranking_list("All countries", country_instance_manager.get_total_ranking()); - - Logger::info("===== RGO test... ====="); - for (size_t i = 0; i < std::min(3, great_powers.size()); ++i) { - CountryInstance const& great_power = *great_powers[i]; - ProvinceInstance const* const capital_province = great_power.get_capital(); - if (capital_province == nullptr) { - Logger::warning(great_power.get_identifier(), " has no capital ProvinceInstance set."); - } else { - print_rgo(*capital_province); - } - } - } else { - Logger::error("Instance manager not available!"); - ret = false; - } + // Logger::info("===== Ranking system test... ====="); + // if (game_manager.get_instance_manager()) { + // const auto print_ranking_list = [](std::string_view title, std::vector 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(); + + // std::vector const& great_powers = country_instance_manager.get_great_powers(); + // print_ranking_list("Great Powers", great_powers); + // print_ranking_list("Secondary Powers", country_instance_manager.get_secondary_powers()); + // print_ranking_list("All countries", country_instance_manager.get_total_ranking()); + + // Logger::info("===== RGO test... ====="); + // for (size_t i = 0; i < std::min(3, great_powers.size()); ++i) { + // CountryInstance const& great_power = *great_powers[i]; + // ProvinceInstance const* const capital_province = great_power.get_capital(); + // if (capital_province == nullptr) { + // Logger::warning(great_power.get_identifier(), " has no capital ProvinceInstance set."); + // } else { + // print_rgo(*capital_province); + // } + // } + // } else { + // Logger::error("Instance manager not available!"); + // ret = false; + // } return ret; } diff --git a/src/openvic-simulation/country/CountryInstance.cpp b/src/openvic-simulation/country/CountryInstance.cpp index d1b61992..05837d33 100644 --- a/src/openvic-simulation/country/CountryInstance.cpp +++ b/src/openvic-simulation/country/CountryInstance.cpp @@ -832,7 +832,6 @@ bool CountryInstance::apply_history_to_country(CountryHistoryEntry const& entry, invention.get_chance().execute(instance_manager, this, this) > 0 ) { ret &= unlock_invention(invention); - // Logger::info("Unlocked invention ", invention.get_identifier(), " for country ", get_identifier()); } } diff --git a/src/openvic-simulation/scripts/Condition.cpp b/src/openvic-simulation/scripts/Condition.cpp index e2730704..82df0dde 100644 --- a/src/openvic-simulation/scripts/Condition.cpp +++ b/src/openvic-simulation/scripts/Condition.cpp @@ -1286,23 +1286,18 @@ bool ConditionManager::setup_conditions(DefinitionManager const& definition_mana ret &= add_condition( "any_neighbor_country", _parse_condition_node_list_callback, - _execute_condition_node_unimplemented - /*_execute_condition_node_convert_scope( + _execute_condition_node_convert_scope( _execute_condition_node_list_multi_scope_callback< - expect_true, require_any, std::vector, CountryInstance const* + expect_true, require_any, ordered_set const&, CountryInstance const* >( []( Condition const& condition, InstanceManager const& instance_manager, CountryInstance const* current_scope, scope_t this_scope, scope_t from_scope - ) -> std::vector { - std::vector neighbouring_country_scopes; - - // TODO - fill neighbouring_country_scopes with pointers to countries neighbouring *current_scope - - return neighbouring_country_scopes; + ) -> ordered_set const& { + return current_scope->get_neighbouring_countries(); } ) - )*/ + ) ); ret &= add_condition( "any_owned_province", @@ -2185,6 +2180,7 @@ bool ConditionManager::setup_conditions(DefinitionManager const& definition_mana "industrial_score", // This doesn't seem to work with regular country identifiers, they're treated as 0 _parse_condition_node_value_callback, + // TODO - THIS | FROM cases (could use _execute_condition_node_value_or_this_or_from_callback ???) _execute_condition_node_cast_argument_callback( _execute_condition_node_convert_scope( []( @@ -2316,7 +2312,14 @@ bool ConditionManager::setup_conditions(DefinitionManager const& definition_mana "is_ideology_enabled", // The wiki says this can only be used at COUNTRY and PROVINCE scopes but I see no reason why it can't be global _parse_condition_node_value_callback, - _execute_condition_node_unimplemented + _execute_condition_node_cast_argument_callback( + []( + Condition const& condition, InstanceManager const& instance_manager, scope_t current_scope, scope_t this_scope, + scope_t from_scope, Ideology const* argument + ) -> bool { + return instance_manager.get_politics_instance_manager().is_ideology_unlocked(*argument); + } + ) ); ret &= add_condition( "is_independant", // paradox typo @@ -2486,9 +2489,19 @@ bool ConditionManager::setup_conditions(DefinitionManager const& definition_mana _execute_condition_node_unimplemented ); ret &= add_condition( + // This uses the British spelling, unlike the "any_neighbor_[country|province]" conditions which use the US spelling "neighbour", _parse_condition_node_value_callback, - _execute_condition_node_unimplemented + _execute_condition_node_value_or_cast_this_or_from_callback( + _execute_condition_node_convert_scope( + []( + Condition const& condition, InstanceManager const& instance_manager, CountryInstance const* current_scope, + CountryInstance const* value + ) -> bool { + return current_scope->is_neighbour(*value); + } + ) + ) ); ret &= add_condition( "num_of_allies",