27 #include "eng3d/log.hpp"
28 #include "eng3d/rand.hpp"
49 std::vector<NationId> attacker_ids;
50 for(
auto& other_nation : world.nations) {
51 if(&other_nation ==
this || &other_nation == &nation)
continue;
53 const auto& relation = world.get_relation(other_nation.get_id(), *
this);
54 if(relation.is_allied() || other_nation.is_puppeted_by(*
this))
55 attacker_ids.push_back(other_nation);
57 attacker_ids.push_back(*
this);
63 std::vector<NationId> defender_ids;
64 for(
auto& other_nation : world.nations) {
65 if(&other_nation ==
this || &other_nation == &nation)
continue;
67 auto it = std::find(attacker_ids.begin(), attacker_ids.end(), other_nation);
68 if(it != attacker_ids.end())
continue;
70 const auto& relation = world.get_relation(other_nation.get_id(), nation);
71 if(relation.is_allied() || other_nation.is_puppeted_by(nation))
72 defender_ids.push_back(other_nation);
74 defender_ids.push_back(nation);
77 for(
auto attacker_id : attacker_ids) {
78 for(
auto defender_id : defender_ids) {
79 assert(attacker_id != defender_id);
81 auto& attacker = world.nations[attacker_id];
82 auto& defender = world.nations[defender_id];
83 if(attacker.puppet_master_id == defender_id)
84 attacker.is_puppeted =
false;
85 else if(defender.puppet_master_id == attacker_id)
86 defender.is_puppeted =
false;
89 auto& relation = world.get_relation(defender_id, attacker_id);
90 relation.has_war =
true;
91 relation.alliance = 0.f;
92 relation.relation = -1.f;
97 for(
const auto& attacker_id : attacker_ids) {
98 auto& attacker = world.nations[attacker_id];
102 for(
const auto& defender_id : defender_ids) {
103 auto& defender = world.nations[defender_id];
110 if(relation.has_war)
return false;
123 return world.provinces[lhs].total_pops() < world.provinces[rhs].total_pops();
158 if(province.
owner_id == this->get_id())
return;
160 auto& provinces = world.nations[province.
owner_id].owned_provinces;
161 std::erase(provinces, province);
167 world.province_manager.mark_province_owner_changed(province);
174 auto& provinces = world.nations[province.
controller_id].controlled_provinces;
175 std::erase(provinces, province);
181 world.province_manager.mark_province_control_changed(province);
183 if (province.
owner_id != this->get_id()) {
187 for(
auto& pop : province.
pops)
188 pop.militancy += 0.1f;
191 for(
auto& building : province.
buildings) {
192 building.budget = 0.f;
193 building.production_scale = 0.f;
197 for(
auto& pop : province.
pops)
207 float new_research = 0.f;
210 for(
const auto& pop : province.pops)
211 new_research += pop.size * pop.literacy;
212 if(new_research && !province.is_populated())
213 new_research /= province.pops.size();
215 return new_research / 100.f;
234 for(
const auto& nation : world.nations)
235 if(&nation !=
this &&
is_ally(nation))
246 return subideology.economic.capitalism >= 0.f ? true :
false;
TechnologyId focus_tech_id
std::vector< ProvinceId > controlled_provinces
float get_tax(const Pop &pop) const
Gets the total tax applied to a POP depending on their "wealth" (not exactly like that,...
std::vector< Nation::ClientHint > client_hints
bool is_ally(const Nation &nation) const
void set_policy(const Policies &policies)
Enacts a policy on a nation.
void give_province(Province &province)
Gives this nation a specified province (for example on a treaty)
bool is_accepted_language(const Language &language) const
Checks if a LANGUAGE is part of one of our accepted languages.
SubideologyId subideology_id
bool can_directly_control_factories() const
std::vector< float > language_acceptance
std::vector< float > research
const Ideology::Subideology & get_subideology() const
void control_province(Province &province)
float get_research_points() const
bool is_accepted_religion(const Religion &relgion) const
Checks if a RELIGION is part of one of our accepted relgion.
void get_allies(std::function< void(const Nation &)> fn) const
bool can_research(const Technology &tech) const
std::vector< ProvinceId > owned_provinces
void change_research_focus(const Technology &tech)
bool is_enemy(const Nation &nation) const
void declare_war(Nation &nation, std::vector< TreatyClause::BaseClause * > clauses=std::vector< TreatyClause::BaseClause * >())
Declare war.
std::vector< float > religion_discrim
void auto_relocate_capital()
Automatically relocates the capital of a nation to another province Use this when a treaty makes a na...
const Nation::ClientHint & get_client_hint() const
A single province, which is used to simulate economy in a "bulk-tiles" way instead of doing economica...
std::array< Pop, 7 > pops
void cancel_construction_project()
std::vector< Building > buildings
Nation::Relation & get_relation(NationId a, NationId b)
static World & get_instance()
void debug(const std::string_view category, const std::string_view msg)
constexpr Id get_id() const
Hints for the client on how to display the nation.
std::vector< TechnologyId > req_technologies