Symphony Of Empires
trade.hpp
Go to the documentation of this file.
1 // Symphony of Empires
2 // Copyright (C) 2021, Symphony of Empires contributors
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <https://www.gnu.org/licenses/>.
16 //
17 // ----------------------------------------------------------------------------
18 // Name:
19 // server/trade.hpp
20 //
21 // Abstract:
22 // Does some important stuff.
23 // ----------------------------------------------------------------------------
24 
25 #pragma once
26 
27 #include <vector>
28 #include "objects.hpp"
29 #include "province.hpp"
30 
31 class World;
32 
33 namespace Economy {
34  struct Trade final {
35  void recalculate(const World& world);
36 
37  struct Vertex {
38  constexpr Vertex(float _cost, ProvinceId _key) : cost{_cost}, key{_key}
39  {
40 
41  }
42  ~Vertex() = default;
43  float cost = 0.f;
45  };
46 
47  float get_trade_cost(const Province& province1, const Province& province2, glm::vec2 world_size) const;
48 
52  std::vector<ProvinceId> cost_eval;
53  std::vector<std::vector<float>> trade_costs;
54  private:
55  inline void initialize(const World& world);
56  std::vector<std::vector<Vertex>> neighbours;
57  };
58 }
A single province, which is used to simulate economy in a "bulk-tiles" way instead of doing economica...
Definition: province.hpp:48
Definition: world.hpp:114
constexpr Vertex(float _cost, ProvinceId _key)
Definition: trade.hpp:38
ProvinceId key
Definition: trade.hpp:44
float get_trade_cost(const Province &province1, const Province &province2, glm::vec2 world_size) const
Definition: trade.cpp:73
std::vector< ProvinceId > cost_eval
Cost-evaluatable provinces, we discard sea and ocean provinces from this formula to save space and ti...
Definition: trade.hpp:52
std::vector< std::vector< float > > trade_costs
Definition: trade.hpp:53
void recalculate(const World &world)
Definition: trade.cpp:38