aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/headless/main.cpp4
-rw-r--r--src/openvic-simulation/GameManager.cpp70
-rw-r--r--src/openvic-simulation/GameManager.hpp19
-rw-r--r--src/openvic-simulation/Modifier.hpp2
-rw-r--r--src/openvic-simulation/dataloader/Dataloader.cpp33
-rw-r--r--src/openvic-simulation/dataloader/Dataloader.hpp3
-rw-r--r--src/openvic-simulation/dataloader/NodeTools.hpp40
-rw-r--r--src/openvic-simulation/economy/Good.cpp17
-rw-r--r--src/openvic-simulation/economy/Good.hpp4
-rw-r--r--src/openvic-simulation/map/Building.hpp2
-rw-r--r--src/openvic-simulation/map/Map.cpp2
-rw-r--r--src/openvic-simulation/map/Province.cpp2
-rw-r--r--src/openvic-simulation/map/Province.hpp2
-rw-r--r--src/openvic-simulation/politics/Ideology.hpp8
-rw-r--r--src/openvic-simulation/politics/Issue.cpp6
-rw-r--r--src/openvic-simulation/politics/Issue.hpp10
-rw-r--r--src/openvic-simulation/pop/Pop.cpp16
-rw-r--r--src/openvic-simulation/pop/Pop.hpp7
-rw-r--r--src/openvic-simulation/testing/Requirement.cpp15
-rw-r--r--src/openvic-simulation/testing/Requirement.hpp33
-rw-r--r--src/openvic-simulation/testing/TestScript.cpp31
-rw-r--r--src/openvic-simulation/testing/TestScript.hpp30
-rw-r--r--src/openvic-simulation/testing/Testing.cpp43
-rw-r--r--src/openvic-simulation/testing/Testing.hpp44
-rw-r--r--src/openvic-simulation/testing/test_scripts/A_001_file_tests.cpp179
-rw-r--r--src/openvic-simulation/testing/test_scripts/A_002_economy_tests.cpp499
-rw-r--r--src/openvic-simulation/testing/test_scripts/A_003_military_unit_tests.cpp19
-rw-r--r--src/openvic-simulation/testing/test_scripts/A_004_networking_tests.cpp19
-rw-r--r--src/openvic-simulation/testing/test_scripts/A_005_nation_tests.cpp19
-rw-r--r--src/openvic-simulation/testing/test_scripts/A_006_politics_tests.cpp19
-rw-r--r--src/openvic-simulation/types/IdentifierRegistry.hpp18
-rw-r--r--src/openvic-simulation/types/Vector.cpp2
-rw-r--r--src/openvic-simulation/units/Unit.cpp24
-rw-r--r--src/openvic-simulation/units/Unit.hpp11
34 files changed, 1153 insertions, 99 deletions
diff --git a/src/headless/main.cpp b/src/headless/main.cpp
index dfaf654..011c465 100644
--- a/src/headless/main.cpp
+++ b/src/headless/main.cpp
@@ -1,6 +1,7 @@
#include <openvic-simulation/GameManager.hpp>
#include <openvic-simulation/dataloader/Dataloader.hpp>
#include <openvic-simulation/utility/Logger.hpp>
+#include <openvic-simulation/testing/Testing.hpp>
using namespace OpenVic;
@@ -51,6 +52,9 @@ static bool headless_load(Dataloader::path_vector_t const& roots) {
ret = false;
}
+ Testing testing { game_manager };
+ std::cout << "\nTesting loaded\n" << std::endl;
+
return ret;
}
diff --git a/src/openvic-simulation/GameManager.cpp b/src/openvic-simulation/GameManager.cpp
index 5067a65..e314593 100644
--- a/src/openvic-simulation/GameManager.cpp
+++ b/src/openvic-simulation/GameManager.cpp
@@ -1,15 +1,77 @@
#include "GameManager.hpp"
#include "openvic-simulation/utility/Logger.hpp"
-#include "units/Unit.hpp"
using namespace OpenVic;
GameManager::GameManager(state_updated_func_t state_updated_callback)
- : unit_manager { good_manager },
- clock { [this]() { tick(); }, [this]() { update_state(); } },
+ : clock { [this]() { tick(); }, [this]() { update_state(); } },
state_updated { state_updated_callback } {}
+Map& GameManager::get_map() {
+ return map;
+}
+
+Map const& GameManager::get_map() const {
+ return map;
+}
+
+BuildingManager& GameManager::get_building_manager() {
+ return building_manager;
+}
+
+BuildingManager const& GameManager::get_building_manager() const {
+ return building_manager;
+}
+
+GoodManager& GameManager::get_good_manager() {
+ return good_manager;
+}
+
+GoodManager const& GameManager::get_good_manager() const {
+ return good_manager;
+}
+
+PopManager& GameManager::get_pop_manager() {
+ return pop_manager;
+}
+
+PopManager const& GameManager::get_pop_manager() const {
+ return pop_manager;
+}
+
+IdeologyManager& GameManager::get_ideology_manager() {
+ return ideology_manager;
+}
+
+IdeologyManager const& GameManager::get_ideology_manager() const {
+ return ideology_manager;
+}
+
+IssueManager& GameManager::get_issue_manager() {
+ return issue_manager;
+}
+
+IssueManager const& GameManager::get_issue_manager() const {
+ return issue_manager;
+}
+
+UnitManager& GameManager::get_unit_manager() {
+ return unit_manager;
+}
+
+UnitManager const& GameManager::get_unit_manager() const {
+ return unit_manager;
+}
+
+GameAdvancementHook& GameManager::get_clock() {
+ return clock;
+}
+
+GameAdvancementHook const& GameManager::get_clock() const {
+ return clock;
+}
+
void GameManager::set_needs_update() {
needs_update = true;
}
@@ -123,7 +185,7 @@ bool GameManager::load_hardcoded_defines() {
using building_type_t = std::tuple<std::string, Building::level_t, Timespan>;
const std::vector<building_type_t> building_types {
- { "building_fort", 4, 8 }, { "building_naval_base", 6, 15 }, { "building_railroad", 5, 10 }
+ { "building_fort", 4, 8 }, { "building_naval_base", 6, 15 }, { "building_railroad", 5, 10 } // Move this to building.hpp
};
for (building_type_t const& type : building_types)
ret &= building_manager.add_building_type(std::get<0>(type), std::get<1>(type), std::get<2>(type));
diff --git a/src/openvic-simulation/GameManager.hpp b/src/openvic-simulation/GameManager.hpp
index fa61eaf..9d0c6cd 100644
--- a/src/openvic-simulation/GameManager.hpp
+++ b/src/openvic-simulation/GameManager.hpp
@@ -14,6 +14,7 @@ namespace OpenVic {
struct GameManager {
using state_updated_func_t = std::function<void()>;
+ private:
Map map;
BuildingManager building_manager;
GoodManager good_manager;
@@ -23,7 +24,6 @@ namespace OpenVic {
UnitManager unit_manager;
GameAdvancementHook clock;
- private:
time_t session_start; /* SS-54, as well as allowing time-tracking */
Date today;
state_updated_func_t state_updated;
@@ -36,6 +36,23 @@ namespace OpenVic {
public:
GameManager(state_updated_func_t state_updated_callback);
+ Map& get_map();
+ Map const& get_map() const;
+ BuildingManager& get_building_manager();
+ BuildingManager const& get_building_manager() const;
+ GoodManager& get_good_manager();
+ GoodManager const& get_good_manager() const;
+ PopManager& get_pop_manager();
+ PopManager const& get_pop_manager() const;
+ IdeologyManager& get_ideology_manager();
+ IdeologyManager const& get_ideology_manager() const;
+ IssueManager& get_issue_manager();
+ IssueManager const& get_issue_manager() const;
+ UnitManager& get_unit_manager();
+ UnitManager const& get_unit_manager() const;
+ GameAdvancementHook& get_clock();
+ GameAdvancementHook const& get_clock() const;
+
bool setup();
Date const& get_today() const;
diff --git a/src/openvic-simulation/Modifier.hpp b/src/openvic-simulation/Modifier.hpp
index acdadfe..a5213eb 100644
--- a/src/openvic-simulation/Modifier.hpp
+++ b/src/openvic-simulation/Modifier.hpp
@@ -17,7 +17,7 @@ namespace OpenVic {
// TODO - format/precision, e.g. 80% vs 0.8 vs 0.800, 2 vs 2.0 vs 200%
ModifierEffect(const std::string_view new_identifier, bool new_positive_good);
-
+
public:
ModifierEffect(ModifierEffect&&) = default;
diff --git a/src/openvic-simulation/dataloader/Dataloader.cpp b/src/openvic-simulation/dataloader/Dataloader.cpp
index 7cd955d..1bdbf7a 100644
--- a/src/openvic-simulation/dataloader/Dataloader.cpp
+++ b/src/openvic-simulation/dataloader/Dataloader.cpp
@@ -7,7 +7,6 @@
#include "openvic-simulation/GameManager.hpp"
#include "openvic-simulation/utility/Logger.hpp"
-#include "units/Unit.hpp"
using namespace OpenVic;
using namespace OpenVic::NodeTools;
@@ -156,18 +155,18 @@ bool Dataloader::_load_pop_types(PopManager& pop_manager, fs::path const& pop_ty
return ret;
}
-bool Dataloader::_load_units(UnitManager& unit_manager, fs::path const& units_directory) const {
+bool Dataloader::_load_units(GameManager& game_manager, fs::path const& units_directory) const {
const bool ret = apply_to_files_in_dir(units_directory, ".txt",
- [&unit_manager](fs::path const& file) -> bool {
- return unit_manager.load_unit_file(_parse_defines(file).get_file_node());
+ [&game_manager](fs::path const& file) -> bool {
+ return game_manager.get_unit_manager().load_unit_file(game_manager.get_good_manager(), _parse_defines(file).get_file_node());
}
);
- unit_manager.lock_units();
+ game_manager.get_unit_manager().lock_units();
return ret;
}
bool Dataloader::_load_map_dir(GameManager& game_manager, fs::path const& map_directory) const {
- Map& map = game_manager.map;
+ Map& map = game_manager.get_map();
static const fs::path defaults_filename = "default.map";
static const std::string default_definitions = "definition.csv";
@@ -241,7 +240,7 @@ bool Dataloader::_load_map_dir(GameManager& game_manager, fs::path const& map_di
ret = false;
}
- if (!map.load_province_positions(game_manager.building_manager, _parse_defines(lookup_file(map_directory / positions)).get_file_node())) {
+ if (!map.load_province_positions(game_manager.get_building_manager(), _parse_defines(lookup_file(map_directory / positions)).get_file_node())) {
Logger::error("Failed to load province positions file!");
ret = false;
}
@@ -273,35 +272,35 @@ bool Dataloader::load_defines(GameManager& game_manager) const {
bool ret = true;
- if (!game_manager.good_manager.load_goods_file(_parse_defines(lookup_file(goods_file)).get_file_node())) {
+ if (!game_manager.get_good_manager().load_goods_file(_parse_defines(lookup_file(goods_file)).get_file_node())) {
Logger::error("Failed to load goods!");
ret = false;
}
- if (!_load_pop_types(game_manager.pop_manager, pop_type_directory)) {
+ if (!_load_pop_types(game_manager.get_pop_manager(), pop_type_directory)) {
Logger::error("Failed to load pop types!");
ret = false;
}
- if (!game_manager.pop_manager.culture_manager.load_graphical_culture_type_file(_parse_defines(lookup_file(graphical_culture_type_file)).get_file_node())) {
+ if (!game_manager.get_pop_manager().get_culture_manager().load_graphical_culture_type_file(_parse_defines(lookup_file(graphical_culture_type_file)).get_file_node())) {
Logger::error("Failed to load graphical culture types!");
ret = false;
}
- if (!game_manager.pop_manager.culture_manager.load_culture_file(_parse_defines(lookup_file(culture_file)).get_file_node())) {
+ if (!game_manager.get_pop_manager().get_culture_manager().load_culture_file(_parse_defines(lookup_file(culture_file)).get_file_node())) {
Logger::error("Failed to load cultures!");
ret = false;
}
- if (!game_manager.pop_manager.religion_manager.load_religion_file(_parse_defines(lookup_file(religion_file)).get_file_node())) {
+ if (!game_manager.get_pop_manager().get_religion_manager().load_religion_file(_parse_defines(lookup_file(religion_file)).get_file_node())) {
Logger::error("Failed to load religions!");
ret = false;
}
- if (!game_manager.ideology_manager.load_ideology_file(_parse_defines(lookup_file(ideology_file)).get_file_node())) {
+ if (!game_manager.get_ideology_manager().load_ideology_file(_parse_defines(lookup_file(ideology_file)).get_file_node())) {
Logger::error("Failed to load ideologies!");
ret = false;
}
- if (!game_manager.issue_manager.load_issues_file(_parse_defines(lookup_file(issues_file)).get_file_node())) {
+ if (!game_manager.get_issue_manager().load_issues_file(_parse_defines(lookup_file(issues_file)).get_file_node())) {
Logger::error("Failed to load issues!");
ret = false;
}
- if (!_load_units(game_manager.unit_manager, units_directory)) {
+ if (!_load_units(game_manager, units_directory)) {
Logger::error("Failed to load units!");
ret = false;
}
@@ -316,9 +315,9 @@ bool Dataloader::load_defines(GameManager& game_manager) const {
bool Dataloader::load_pop_history(GameManager& game_manager, fs::path const& path) const {
return apply_to_files_in_dir(path, ".txt",
[&game_manager](fs::path const& file) -> bool {
- return _parse_defines_callback(game_manager.map.expect_province_dictionary(
+ return _parse_defines_callback(game_manager.get_map().expect_province_dictionary(
[&game_manager](Province& province, ast::NodeCPtr value) -> bool {
- return province.load_pop_list(game_manager.pop_manager, value);
+ return province.load_pop_list(game_manager.get_pop_manager(), value);
}
))(file);
}
diff --git a/src/openvic-simulation/dataloader/Dataloader.hpp b/src/openvic-simulation/dataloader/Dataloader.hpp
index 9e15102..e935091 100644
--- a/src/openvic-simulation/dataloader/Dataloader.hpp
+++ b/src/openvic-simulation/dataloader/Dataloader.hpp
@@ -5,7 +5,6 @@
#include <vector>
#include "openvic-simulation/dataloader/NodeTools.hpp"
-#include "units/Unit.hpp"
namespace OpenVic {
namespace fs = std::filesystem;
@@ -22,7 +21,7 @@ namespace OpenVic {
path_vector_t roots;
bool _load_pop_types(PopManager& pop_manager, fs::path const& pop_type_directory) const;
- bool _load_units(UnitManager& unit_manager, fs::path const& units_directory) const;
+ bool _load_units(GameManager& unit_manager, fs::path const& units_directory) const;
bool _load_map_dir(GameManager& game_manager, fs::path const& map_directory) const;
public:
diff --git a/src/openvic-simulation/dataloader/NodeTools.hpp b/src/openvic-simulation/dataloader/NodeTools.hpp
index 5c22e11..e49cab6 100644
--- a/src/openvic-simulation/dataloader/NodeTools.hpp
+++ b/src/openvic-simulation/dataloader/NodeTools.hpp
@@ -138,6 +138,14 @@ namespace OpenVic {
}
template<typename T>
+ callback_t<T&&> move_variable_callback(T& var) {
+ return [&var](T&& val) -> bool {
+ var = std::move(val);
+ return true;
+ };
+ }
+
+ template<typename T>
requires requires(T& t) {
t += T {};
}
@@ -159,31 +167,33 @@ namespace OpenVic {
};
}
- template<typename I, typename T>
- requires(std::integral<I>, std::integral<T>)
- callback_t<I> _assign_variable_callback_int(const std::string_view name, T& var) {
- return [&var, name](I val) -> bool {
- if (std::numeric_limits<T>::lowest() <= val && val <= std::numeric_limits<T>::max()) {
+ template<typename T>
+ requires(std::integral<T>)
+ callback_t<uint64_t> assign_variable_callback_uint(const std::string_view name, T& var) {
+ return [&var, name](uint64_t val) -> bool {
+ if (val <= static_cast<uint64_t>(std::numeric_limits<T>::max())) {
var = val;
return true;
}
- Logger::error("Invalid ", name, ": ", val, " (valid range: [",
- static_cast<int64_t>(std::numeric_limits<T>::lowest()), ", ",
+ Logger::error("Invalid ", name, ": ", val, " (valid range: [0, ",
static_cast<uint64_t>(std::numeric_limits<T>::max()), "])");
return false;
};
}
template<typename T>
- requires(std::integral<T>)
- callback_t<uint64_t> assign_variable_callback_uint(const std::string_view name, T& var) {
- return _assign_variable_callback_int<uint64_t>(name, var);
- }
-
- template<typename T>
- requires(std::integral<T>)
+ requires(std::signed_integral<T>)
callback_t<int64_t> assign_variable_callback_int(const std::string_view name, T& var) {
- return _assign_variable_callback_int<int64_t>(name, var);
+ return [&var, name](int64_t val) -> bool {
+ if (static_cast<int64_t>(std::numeric_limits<T>::lowest()) <= val && val <= static_cast<int64_t>(std::numeric_limits<T>::max())) {
+ var = val;
+ return true;
+ }
+ Logger::error("Invalid ", name, ": ", val, " (valid range: [",
+ static_cast<int64_t>(std::numeric_limits<T>::lowest()), ", ",
+ static_cast<int64_t>(std::numeric_limits<T>::max()), "])");
+ return false;
+ };
}
template<typename T>
diff --git a/src/openvic-simulation/economy/Good.cpp b/src/openvic-simulation/economy/Good.cpp
index 027fb5f..943db00 100644
--- a/src/openvic-simulation/economy/Good.cpp
+++ b/src/openvic-simulation/economy/Good.cpp
@@ -3,9 +3,6 @@
#include <cassert>
#include <map>
#include <string_view>
-#include "dataloader/NodeTools.hpp"
-#include "openvic-dataloader/v2script/AbstractSyntaxTree.hpp"
-#include "types/fixed_point/FixedPoint.hpp"
using namespace OpenVic;
using namespace OpenVic::NodeTools;
@@ -137,17 +134,3 @@ bool GoodManager::load_goods_file(ast::NodeCPtr root) {
lock_goods();
return ret;
}
-
-node_callback_t GoodManager::expect_goods_map(callback_t<std::map<Good const*, fixed_point_t>> cb) {
- return [this, cb](ast::NodeCPtr node) -> bool {
- std::map<Good const*, fixed_point_t> goods_map;
- bool res = expect_good_dictionary([&goods_map](const Good & key, ast::NodeCPtr value) -> bool {
- fixed_point_t good_value;
- bool res = expect_fixed_point((assign_variable_callback(good_value)))(value);
- goods_map.emplace(&key, good_value);
- return res;
- })(node);
- res &= cb(goods_map);
- return res;
- };
-} \ No newline at end of file
diff --git a/src/openvic-simulation/economy/Good.hpp b/src/openvic-simulation/economy/Good.hpp
index df92525..792336d 100644
--- a/src/openvic-simulation/economy/Good.hpp
+++ b/src/openvic-simulation/economy/Good.hpp
@@ -1,8 +1,6 @@
#pragma once
-#include "openvic-simulation/dataloader/NodeTools.hpp"
#include "openvic-simulation/types/IdentifierRegistry.hpp"
-#include "openvic-dataloader/v2script/AbstractSyntaxTree.hpp"
namespace OpenVic {
struct GoodManager;
@@ -76,7 +74,5 @@ namespace OpenVic {
void reset_to_defaults();
bool load_goods_file(ast::NodeCPtr root);
-
- NodeTools::node_callback_t expect_goods_map(NodeTools::callback_t<std::map<Good const*, fixed_point_t>> cb);
};
}
diff --git a/src/openvic-simulation/map/Building.hpp b/src/openvic-simulation/map/Building.hpp
index d36dfd4..d9b9e5e 100644
--- a/src/openvic-simulation/map/Building.hpp
+++ b/src/openvic-simulation/map/Building.hpp
@@ -73,7 +73,7 @@ namespace OpenVic {
struct BuildingManager {
private:
- IdentifierRegistry<BuildingType> building_types;
+ IdentifierRegistry<BuildingType> building_types; // TODO: This needs a getter
public:
BuildingManager();
diff --git a/src/openvic-simulation/map/Map.cpp b/src/openvic-simulation/map/Map.cpp
index 5082906..6cafb57 100644
--- a/src/openvic-simulation/map/Map.cpp
+++ b/src/openvic-simulation/map/Map.cpp
@@ -517,7 +517,7 @@ bool Map::_generate_province_adjacencies() {
}
return false;
};
-
+
for (size_t y = 0; y < height; ++y) {
for (size_t x = 0; x < width; ++x) {
Province* cur = get_province_by_index(province_shape_image[x + y * width].index);
diff --git a/src/openvic-simulation/map/Province.cpp b/src/openvic-simulation/map/Province.cpp
index 6ec17b1..c1e96e9 100644
--- a/src/openvic-simulation/map/Province.cpp
+++ b/src/openvic-simulation/map/Province.cpp
@@ -140,7 +140,7 @@ void Province::tick(Date const& today) {
building.tick(today);
}
-Province::adjacency_t::adjacency_t(Province const* province, distance_t distance, flags_t flags)
+Province::adjacency_t::adjacency_t(Province const* province, distance_t distance, flags_t flags)
: province { province }, distance { distance }, flags { flags } {
assert(province != nullptr);
}
diff --git a/src/openvic-simulation/map/Province.hpp b/src/openvic-simulation/map/Province.hpp
index 370d05c..0a4aa46 100644
--- a/src/openvic-simulation/map/Province.hpp
+++ b/src/openvic-simulation/map/Province.hpp
@@ -18,7 +18,7 @@ namespace OpenVic {
using index_t = uint16_t;
using life_rating_t = int8_t;
using distance_t = uint16_t;
- using flags_t = uint16_t;
+ using flags_t = uint16_t;
struct adjacency_t {
friend struct Province;
diff --git a/src/openvic-simulation/politics/Ideology.hpp b/src/openvic-simulation/politics/Ideology.hpp
index f5ed5f1..e9989c8 100644
--- a/src/openvic-simulation/politics/Ideology.hpp
+++ b/src/openvic-simulation/politics/Ideology.hpp
@@ -1,8 +1,6 @@
#pragma once
-#include "types/Date.hpp"
-#include "types/IdentifierRegistry.hpp"
-#include "dataloader/NodeTools.hpp"
+#include "openvic-simulation/types/IdentifierRegistry.hpp"
namespace OpenVic {
struct IdeologyManager;
@@ -12,7 +10,7 @@ namespace OpenVic {
private:
IdeologyGroup(const std::string_view new_identifier);
-
+
public:
IdeologyGroup(IdeologyGroup&&) = default;
};
@@ -45,7 +43,7 @@ namespace OpenVic {
public:
IdeologyManager();
-
+
bool add_ideology_group(const std::string_view identifier);
IDENTIFIER_REGISTRY_ACCESSORS(IdeologyGroup, ideology_group)
diff --git a/src/openvic-simulation/politics/Issue.cpp b/src/openvic-simulation/politics/Issue.cpp
index 926eade..67b3783 100644
--- a/src/openvic-simulation/politics/Issue.cpp
+++ b/src/openvic-simulation/politics/Issue.cpp
@@ -12,10 +12,10 @@ IssueGroup const& Issue::get_group() const {
return group;
}
-ReformType::ReformType(const std::string_view new_identifier, bool uncivilised)
+ReformType::ReformType(const std::string_view new_identifier, bool uncivilised)
: HasIdentifier { new_identifier }, uncivilised { uncivilised } {}
-ReformGroup::ReformGroup(const std::string_view identifier, ReformType const& type, bool ordered, bool administrative)
+ReformGroup::ReformGroup(const std::string_view identifier, ReformType const& type, bool ordered, bool administrative)
: IssueGroup { identifier }, type { type }, ordered { ordered }, administrative { administrative } {}
ReformType const& ReformGroup::get_type() const {
@@ -151,7 +151,7 @@ bool IssueManager::_load_reform(size_t& ordinal, const std::string_view identifi
bool IssueManager::load_issues_file(ast::NodeCPtr root) {
size_t expected_issue_groups = 0;
size_t expected_reform_groups = 0;
- bool ret = expect_dictionary_reserve_length(reform_types,
+ bool ret = expect_dictionary_reserve_length(reform_types,
[this, &expected_issue_groups, &expected_reform_groups](std::string_view key, ast::NodeCPtr value) -> bool {
if (key == "party_issues")
return expect_length(add_variable_callback(expected_issue_groups))(value);
diff --git a/src/openvic-simulation/politics/Issue.hpp b/src/openvic-simulation/politics/Issue.hpp
index 4b096ee..66e8d1a 100644
--- a/src/openvic-simulation/politics/Issue.hpp
+++ b/src/openvic-simulation/politics/Issue.hpp
@@ -15,7 +15,7 @@ namespace OpenVic {
protected:
IssueGroup(const std::string_view identifier);
-
+
public:
IssueGroup(IssueGroup&&) = default;
};
@@ -46,7 +46,7 @@ namespace OpenVic {
//in vanilla education, military and economic reforms are hardcoded to true and the rest to false
ReformType(const std::string_view new_identifier, bool uncivilised);
-
+
public:
ReformType(ReformType&&) = default;
};
@@ -61,7 +61,7 @@ namespace OpenVic {
const bool administrative;
ReformGroup(const std::string_view identifier, ReformType const& type, bool ordered, bool administrative);
-
+
public:
ReformGroup(ReformGroup&&) = default;
ReformType const& get_type() const;
@@ -87,7 +87,7 @@ namespace OpenVic {
ReformType const& get_type() const;
size_t get_ordinal() const;
};
-
+
//Issue manager - holds the registries
struct IssueManager {
private:
@@ -117,7 +117,7 @@ namespace OpenVic {
bool add_reform_group(const std::string_view identifier, ReformType const* type, bool ordered, bool administrative);
IDENTIFIER_REGISTRY_ACCESSORS(ReformGroup, reform_group)
-
+
bool add_reform(const std::string_view identifier, ReformGroup const* group, size_t ordinal);
IDENTIFIER_REGISTRY_ACCESSORS(Reform, reform)
diff --git a/src/openvic-simulation/pop/Pop.cpp b/src/openvic-simulation/pop/Pop.cpp
index 96b17fc..d74c6cf 100644
--- a/src/openvic-simulation/pop/Pop.cpp
+++ b/src/openvic-simulation/pop/Pop.cpp
@@ -101,6 +101,22 @@ bool PopType::get_is_slave() const {
PopManager::PopManager() : pop_types { "pop types" } {}
+CultureManager& PopManager::get_culture_manager() {
+ return culture_manager;
+}
+
+CultureManager const& PopManager::get_culture_manager() const {
+ return culture_manager;
+}
+
+ReligionManager& PopManager::get_religion_manager() {
+ return religion_manager;
+}
+
+ReligionManager const& PopManager::get_religion_manager() const {
+ return religion_manager;
+}
+
bool PopManager::add_pop_type(const std::string_view identifier, colour_t colour, PopType::strata_t strata, PopType::sprite_t sprite,
Pop::pop_size_t max_size, Pop::pop_size_t merge_max_size, bool state_capital_only, bool demote_migrant, bool is_artisan, bool is_slave) {
if (identifier.empty()) {
diff --git a/src/openvic-simulation/pop/Pop.hpp b/src/openvic-simulation/pop/Pop.hpp
index 1dc1d32..85d4504 100644
--- a/src/openvic-simulation/pop/Pop.hpp
+++ b/src/openvic-simulation/pop/Pop.hpp
@@ -82,12 +82,17 @@ namespace OpenVic {
private:
IdentifierRegistry<PopType> pop_types;
- public:
CultureManager culture_manager;
ReligionManager religion_manager;
+ public:
PopManager();
+ CultureManager& get_culture_manager();
+ CultureManager const& get_culture_manager() const;
+ ReligionManager& get_religion_manager();
+ ReligionManager const& get_religion_manager() const;
+
bool add_pop_type(const std::string_view identifier, colour_t new_colour, PopType::strata_t strata, PopType::sprite_t sprite,
Pop::pop_size_t max_size, Pop::pop_size_t merge_max_size, bool state_capital_only, bool demote_migrant,
bool is_artisan, bool is_slave);
diff --git a/src/openvic-simulation/testing/Requirement.cpp b/src/openvic-simulation/testing/Requirement.cpp
new file mode 100644
index 0000000..4c46f00
--- /dev/null
+++ b/src/openvic-simulation/testing/Requirement.cpp
@@ -0,0 +1,15 @@
+#include <testing/Requirement.hpp>
+
+using namespace OpenVic;
+
+// Getters
+std::string Requirement::get_id() { return id; }
+std::string Requirement::get_text() { return text; }
+std::string Requirement::get_acceptance_criteria() { return acceptance_criteria; }
+bool Requirement::get_pass() { return pass; }
+
+// Setters
+void Requirement::set_id(std::string in_id) { id = in_id; }
+void Requirement::set_text(std::string in_text) { text = in_text; }
+void Requirement::set_acceptance_criteria(std::string in_acceptance_criteria) { acceptance_criteria = in_acceptance_criteria; }
+void Requirement::set_pass(bool in_pass) { pass = in_pass; }
diff --git a/src/openvic-simulation/testing/Requirement.hpp b/src/openvic-simulation/testing/Requirement.hpp
new file mode 100644
index 0000000..aeb36e7
--- /dev/null
+++ b/src/openvic-simulation/testing/Requirement.hpp
@@ -0,0 +1,33 @@
+#pragma once
+#include <string>
+
+namespace OpenVic {
+
+ class Requirement {
+
+ std::string id;
+ std::string text;
+ std::string acceptance_criteria;
+ bool pass = false; // Explicitly false to begin
+
+ public:
+
+ Requirement(std::string in_id, std::string in_text, std::string in_acceptance_criteria) {
+ id = in_id;
+ text = in_text;
+ acceptance_criteria = in_acceptance_criteria;
+ }
+
+ // Getters
+ std::string get_id();
+ std::string get_text();
+ std::string get_acceptance_criteria();
+ bool get_pass();
+
+ // Setters
+ void set_id(std::string in_id);
+ void set_text(std::string in_text);
+ void set_acceptance_criteria(std::string in_acceptance_criteria);
+ void set_pass(bool in_pass);
+ };
+}
diff --git a/src/openvic-simulation/testing/TestScript.cpp b/src/openvic-simulation/testing/TestScript.cpp
new file mode 100644
index 0000000..7652fa5
--- /dev/null
+++ b/src/openvic-simulation/testing/TestScript.cpp
@@ -0,0 +1,31 @@
+#include <testing/TestScript.hpp>
+
+using namespace OpenVic;
+
+// Getters
+std::vector<Requirement> TestScript::get_requirements() { return requirements; }
+Requirement TestScript::get_requirement_at_index(int index) { return requirements[index]; }
+Requirement TestScript::get_requirement_by_id(std::string id) {
+ for (int i = 0; i < requirements.size(); i++) {
+ if (requirements[i].get_id() == id) return requirements[i];
+ }
+ return Requirement("NULL", "NULL", "NULL");
+}
+std::vector<Requirement> TestScript::get_passed_requirements() {
+ std::vector<Requirement> passed_requirements = std::vector<Requirement>();
+ for (int i = 0; i < requirements.size(); i++) {
+ if (requirements[i].get_pass()) passed_requirements.push_back(requirements[i]);
+ }
+ return passed_requirements;
+}
+std::vector<Requirement> TestScript::get_failed_requirements() {
+ std::vector<Requirement> failed_requirements = std::vector<Requirement>();
+ for (int i = 0; i < requirements.size(); i++) {
+ if (!requirements[i].get_pass()) failed_requirements.push_back(requirements[i]);
+ }
+ return failed_requirements;
+}
+
+// Setters
+void TestScript::set_requirements(std::vector<Requirement> in_requirements) { requirements = in_requirements; }
+void TestScript::add_requirement(Requirement req) { requirements.push_back(req); }
diff --git a/src/openvic-simulation/testing/TestScript.hpp b/src/openvic-simulation/testing/TestScript.hpp
new file mode 100644
index 0000000..c41767b
--- /dev/null
+++ b/src/openvic-simulation/testing/TestScript.hpp
@@ -0,0 +1,30 @@
+#pragma once
+#include <testing/Requirement.hpp>
+#include <vector>
+
+namespace OpenVic {
+
+ class TestScript {
+
+ std::vector<Requirement> requirements = std::vector<Requirement>();
+
+ public:
+
+ // expects an overriden method that performs arbitrary code execution
+ // so that each script uniquely performs tests
+ // for both requirement adding to script and to execute code
+ virtual void add_requirements() = 0;
+ virtual void execute_script() = 0;
+
+ // Getters
+ std::vector<Requirement> get_requirements();
+ Requirement get_requirement_at_index(int index);
+ Requirement get_requirement_by_id(std::string id);
+ std::vector<Requirement> get_passed_requirements();
+ std::vector<Requirement> get_failed_requirements();
+
+ // Setters
+ void set_requirements(std::vector<Requirement> in_requirements);
+ void add_requirement(Requirement req);
+ };
+}
diff --git a/src/openvic-simulation/testing/Testing.cpp b/src/openvic-simulation/testing/Testing.cpp
new file mode 100644
index 0000000..fcfe2cc
--- /dev/null
+++ b/src/openvic-simulation/testing/Testing.cpp
@@ -0,0 +1,43 @@
+#include <testing/Testing.hpp>
+#include <testing/TestScript.hpp>
+
+using namespace OpenVic;
+
+Testing::Testing(GameManager& g_manager)
+ : game_manager { g_manager },
+ map { g_manager.get_map() },
+ building_manager { g_manager.get_building_manager() },
+ good_manager { g_manager.get_good_manager() },
+ pop_manager { g_manager.get_pop_manager() },
+ clock { g_manager.get_clock() } {
+
+ // Constructor for the tests will add requirements
+ // Then execute the script
+ A_001_file_tests* a_001_file_tests = new A_001_file_tests();
+ test_scripts.push_back(a_001_file_tests);
+ A_002_economy_tests* a_002_economy_tests = new A_002_economy_tests();
+ test_scripts.push_back(a_002_economy_tests);
+ A_003_military_unit_tests* a_003_military_unit_tests = new A_003_military_unit_tests();
+ test_scripts.push_back(a_003_military_unit_tests);
+ A_004_networking_tests* a_004_networking_tests = new A_004_networking_tests();
+ test_scripts.push_back(a_004_networking_tests);
+ A_005_nation_tests* a_005_nation_tests = new A_005_nation_tests();
+ test_scripts.push_back(a_005_nation_tests);
+ A_006_politics_tests* a_006_politics_tests = new A_006_politics_tests();
+ test_scripts.push_back(a_006_politics_tests);
+}
+
+Testing::~Testing() {
+ for (TestScript* test_script : test_scripts) {
+ delete test_script;
+ }
+}
+
+void Testing::report_results() {
+ for (int i = 0; i < test_scripts.size(); i++) {
+
+ }
+
+ // Create Summary File
+
+}
diff --git a/src/openvic-simulation/testing/Testing.hpp b/src/openvic-simulation/testing/Testing.hpp
new file mode 100644
index 0000000..35e8a96
--- /dev/null
+++ b/src/openvic-simulation/testing/Testing.hpp
@@ -0,0 +1,44 @@
+#pragma once
+#include <testing/TestScript.hpp>
+#include <GameManager.hpp>
+#include <iostream>
+#include <vector>
+
+#include <testing/test_scripts/A_001_file_tests.cpp>
+#include <testing/test_scripts/A_002_economy_tests.cpp>
+#include <testing/test_scripts/A_003_military_unit_tests.cpp>
+#include <testing/test_scripts/A_004_networking_tests.cpp>
+#include <testing/test_scripts/A_005_nation_tests.cpp>
+#include <testing/test_scripts/A_006_politics_tests.cpp>
+
+namespace OpenVic {
+
+ class Testing {
+
+ public:
+ GameManager& game_manager;
+ Map& map;
+ BuildingManager& building_manager;
+ GoodManager& good_manager;
+ PopManager& pop_manager;
+ GameAdvancementHook& clock;
+
+ std::vector<TestScript*> test_scripts = std::vector<TestScript*>();
+
+ //// Prototype test script
+ //const BuildingType* building_type = building_manager->get_building_type_by_identifier("building_fort");
+ //std::cout << "building_fort"
+ // << " build time is " << building_type->get_build_time() << std::endl;
+ //std::cout << "building_fort"
+ // << " identifier is " << building_type->get_identifier() << std::endl;
+ //std::cout << "building_fort"
+ // << " max level is " << int(building_type->get_max_level()) << std::endl;
+ //for (const auto& good : good_manager->get_goods())
+ // std::cout << good.get_identifier() << " price = " << good.get_base_price() << std::endl;
+
+ Testing(GameManager& g_manager);
+ ~Testing();
+
+ void report_results();
+ };
+}
diff --git a/src/openvic-simulation/testing/test_scripts/A_001_file_tests.cpp b/src/openvic-simulation/testing/test_scripts/A_001_file_tests.cpp
new file mode 100644
index 0000000..2748d2d
--- /dev/null
+++ b/src/openvic-simulation/testing/test_scripts/A_001_file_tests.cpp
@@ -0,0 +1,179 @@
+# pragma once
+# include <testing/TestScript.hpp>
+
+namespace OpenVic {
+ class A_001_file_tests : public TestScript {
+
+ public:
+ A_001_file_tests() {
+ add_requirements();
+ execute_script();
+ }
+
+ void add_requirements() {
+ Requirement FS_44 = Requirement("FS_44",
+ "The icon for the Canned Food good shall be loaded from the R/art/economy/goods folder with the filename Canned Food.png",
+ "The icon for the Canned Food good has been loaded into the program");
+ add_requirement(FS_44);
+ Requirement FS_48 = Requirement("FS_48",
+ "The icon for the Coal good shall be loaded from the R/art/economy/goods folder with the filename Coal.png",
+ "The icon for the Coal good has been loaded into the program");
+ add_requirement(FS_48);
+ Requirement FS_61 = Requirement("FS_61",
+ "The icon for the Grain good shall be loaded from the R/art/economy/goods folder with the filename Grain.png",
+ "The icon for the Grain good has been loaded into the program");
+ add_requirement(FS_61);
+ Requirement FS_62 = Requirement("FS_62",
+ "The icon for the Iron good shall be loaded from the R/art/economy/goods folder with the filename Iron.png",
+ "The icon for the Iron good has been loaded into the program");
+ add_requirement(FS_62);
+ Requirement FS_63 = Requirement("FS_63",
+ "The icon for the Liquor good shall be loaded from the R/art/economy/goods folder with the filename Liquor.png",
+ "The icon for the Liquor good has been loaded into the program");
+ add_requirement(FS_63);
+ Requirement FS_67 = Requirement("FS_67",
+ "The icon for the Machine Parts good shall be loaded from the R/art/economy/goods folder with the filename Machine Parts.png",
+ "The icon for the Machine Parts good has been loaded into the program");
+ add_requirement(FS_67);
+ Requirement FS_86 = Requirement("FS_86",
+ "The icon for the Wool good shall be loaded from the R/art/economy/goods folder with the filename Wool.png",
+ "The icon for the Wool good has been loaded into the program");
+ add_requirement(FS_86);
+ Requirement FS_24 = Requirement("FS_24",
+ "All .csv files in the locale folder shall contain translation keys and translations",
+ "No errant files in locale directory");
+ add_requirement(FS_24);
+ Requirement FS_17 = Requirement("FS_17",
+ "List of available locales are loaded from R/localisation/ directory",
+ "Locales loaded correctly");
+ add_requirement(FS_17);
+ Requirement FS_333 = Requirement("FS_333",
+ "The map's provinces shall be defined by unique colours in 'R/map/provinces.bmp'",
+ "The unique colours of 'R/map/provinces.bmp' define provinces");
+ add_requirement(FS_333);
+ Requirement FS_335 = Requirement("FS_335",
+ "Unique province IDs shall be associated with their unique colours in 'R/map/definition.csv'",
+ "'R/map/definition.csv' associates every unique colour used to define a province with a unique ID");
+ add_requirement(FS_335);
+ Requirement FS_334 = Requirement("FS_334",
+ "Water provinces shall be defined by a list of their IDs in 'R/map/default.map'",
+ "'R/map/default.map' contains a list of province IDs which are used to define water provinces");
+ add_requirement(FS_334);
+ Requirement FS_338 = Requirement("FS_338",
+ "The image for the minimap background shall be loaded from the R/art/ui folder with the filename minimap.png",
+ "The image for the minimap background has been loaded into the program");
+ add_requirement(FS_338);
+ Requirement FS_343 = Requirement("FS_343",
+ "The textures making up the cosmetic terrain map shall be loaded from the R/art/terrain folder",
+ "The textures making up the cosmetic terrain map have been loaded into the program");
+ add_requirement(FS_343);
+ Requirement FS_341 = Requirement("FS_341",
+ "State areas shall be defined by lists of province IDs in 'R/map/region.txt'",
+ "'R/map/region.txt' defines state areas with lists of province IDs");
+ add_requirement(FS_341);
+ Requirement SND_10 = Requirement("SND_10",
+ "SFX shall be refered to by their filename, without the extension",
+ "Sound effects are identified by their filename without extension");
+ add_requirement(SND_10);
+ }
+
+ void execute_script() {
+ // FS_44
+ // The icon for the Canned Food good shall be loaded from the R/art/economy/goods folder with the filename Canned Food.png
+ // The icon for the Canned Food good has been loaded into the program
+
+ // TODO: Write test steps for FS_44...
+
+ // FS_48
+ // The icon for the Coal good shall be loaded from the R/art/economy/goods folder with the filename Coal.png
+ // The icon for the Coal good has been loaded into the program
+
+ // TODO: Write test steps for FS_48...
+
+ // FS_61
+ // The icon for the Grain good shall be loaded from the R/art/economy/goods folder with the filename Grain.png
+ // The icon for the Grain good has been loaded into the program
+
+ // TODO: Write test steps for FS_61...
+
+ // FS_62
+ // The icon for the Iron good shall be loaded from the R/art/economy/goods folder with the filename Iron.png
+ // The icon for the Iron good has been loaded into the program
+
+ // TODO: Write test steps for FS_62...
+
+ // FS_63
+ // The icon for the Liquor good shall be loaded from the R/art/economy/goods folder with the filename Liquor.png
+ // The icon for the Liquor good has been loaded into the program
+
+ // TODO: Write test steps for FS_63...
+
+ // FS_67
+ // The icon for the Machine Parts good shall be loaded from the R/art/economy/goods folder with the filename Machine Parts.png
+ // The icon for the Machine Parts good has been loaded into the program
+
+ // TODO: Write test steps for FS_67...
+
+ // FS_86
+ // The icon for the Wool good shall be loaded from the R/art/economy/goods folder with the filename Wool.png
+ // The icon for the Wool good has been loaded into the program
+
+ // TODO: Write test steps for FS_86...
+
+ // FS_24
+ // All .csv files in the locale folder shall contain translation keys and translations
+ // No errant files in locale directory
+
+ // TODO: Write test steps for FS_24...
+
+ // FS_17
+ // List of available locales are loaded from R/localisation/ directory
+ // Locales loaded correctly
+
+ // TODO: Write test steps for FS_17...
+
+ // FS_333
+ // The map's provinces shall be defined by unique colours in 'R/map/provinces.bmp'
+ // The unique colours of 'R/map/provinces.bmp' define provinces
+
+ // TODO: Write test steps for FS_333...
+
+ // FS_335
+ // Unique province IDs shall be associated with their unique colours in 'R/map/definition.csv'
+ // 'R/map/definition.csv' associates every unique colour used to define a province with a unique ID
+
+ // TODO: Write test steps for FS_335...
+
+ // FS_334
+ // Water provinces shall be defined by a list of their IDs in 'R/map/default.map'
+ // 'R/map/default.map' contains a list of province IDs which are used to define water provinces
+
+ // TODO: Write test steps for FS_334...
+
+ // FS_338
+ // The image for the minimap background shall be loaded from the R/art/ui folder with the filename minimap.png
+ // The image for the minimap background has been loaded into the program
+
+ // TODO: Write test steps for FS_338...
+
+ // FS_343
+ // The textures making up the cosmetic terrain map shall be loaded from the R/art/terrain folder
+ // The textures making up the cosmetic terrain map have been loaded into the program
+
+ // TODO: Write test steps for FS_343...
+
+ // FS_341
+ // State areas shall be defined by lists of province IDs in 'R/map/region.txt'
+ // 'R/map/region.txt' defines state areas with lists of province IDs
+
+ // TODO: Write test steps for FS_341...
+
+ // SND_10
+ // SFX shall be refered to by their filename, without the extension
+ // Sound effects are identified by their filename without extension
+
+ // TODO: Write test steps for SND_10...
+
+ }
+ };
+}
diff --git a/src/openvic-simulation/testing/test_scripts/A_002_economy_tests.cpp b/src/openvic-simulation/testing/test_scripts/A_002_economy_tests.cpp
new file mode 100644
index 0000000..adab342
--- /dev/null
+++ b/src/openvic-simulation/testing/test_scripts/A_002_economy_tests.cpp
@@ -0,0 +1,499 @@
+# pragma once
+# include <testing/TestScript.hpp>
+
+namespace OpenVic {
+ class A_002_economy_tests : public TestScript {
+
+ public:
+ A_002_economy_tests() {
+ add_requirements();
+ execute_script();
+ }
+
+ void add_requirements() {
+ Requirement ECON_123 = Requirement("ECON_123",
+ "The base price for Aeroplanes shall be 110",
+ "The base price of 110 for Aeroplanes can be seen in program output data");
+ add_requirement(ECON_123);
+ Requirement ECON_124 = Requirement("ECON_124",
+ "The base price for Ammunition shall be 17.5",
+ "The base price of 17.5 for Ammunition can be seen in program output data");
+ add_requirement(ECON_124);
+ Requirement ECON_125 = Requirement("ECON_125",
+ "The base price for Artillery shall be 60",
+ "The base price of 60 for Artillery can be seen in program output data");
+ add_requirement(ECON_125);
+ Requirement ECON_126 = Requirement("ECON_126",
+ "The base price for Automobiles shall be 70",
+ "The base price of 70 for Automobiles can be seen in program output data");
+ add_requirement(ECON_126);
+ Requirement ECON_127 = Requirement("ECON_127",
+ "The base price for Canned Food shall be 16",
+ "The base price of 16 for Canned Food can be seen in program output data");
+ add_requirement(ECON_127);
+ Requirement ECON_128 = Requirement("ECON_128",
+ "The base price for Cattle shall be 2",
+ "The base price of 2 for Cattle can be seen in program output data");
+ add_requirement(ECON_128);
+ Requirement ECON_129 = Requirement("ECON_129",
+ "The base price for Cement shall be 16",
+ "The base price of 16 for Cement can be seen in program output data");
+ add_requirement(ECON_129);
+ Requirement ECON_130 = Requirement("ECON_130",
+ "The base price for Clipper Convoys shall be 42",
+ "The base price of 42 for Clipper Convoys can be seen in program output data");
+ add_requirement(ECON_130);
+ Requirement ECON_131 = Requirement("ECON_131",
+ "The base price for Coal shall be 2.3",
+ "The base price of 2.3 for Coal can be seen in program output data");
+ add_requirement(ECON_131);
+ Requirement ECON_132 = Requirement("ECON_132",
+ "The base price for Coffee shall be 2.1",
+ "The base price of 2.1 for Coffee can be seen in program output data");
+ add_requirement(ECON_132);
+ Requirement ECON_133 = Requirement("ECON_133",
+ "The base price for Cotton shall be 2",
+ "The base price of 2 for Cotton can be seen in program output data");
+ add_requirement(ECON_133);
+ Requirement ECON_134 = Requirement("ECON_134",
+ "The base price for Dye shall be 12",
+ "The base price of 12 for Dye can be seen in program output data");
+ add_requirement(ECON_134);
+ Requirement ECON_135 = Requirement("ECON_135",
+ "The base price for Electric Gear shall be 16",
+ "The base price of 16 for Electric Gear can be seen in program output data");
+ add_requirement(ECON_135);
+ Requirement ECON_136 = Requirement("ECON_136",
+ "The base price for Explosives shall be 20",
+ "The base price of 20 for Explosives can be seen in program output data");
+ add_requirement(ECON_136);
+ Requirement ECON_137 = Requirement("ECON_137",
+ "The base price for Fabric shall be 1.8",
+ "The base price of 1.8 for Fabric can be seen in program output data");
+ add_requirement(ECON_137);
+ Requirement ECON_138 = Requirement("ECON_138",
+ "The base price for Fertilizer shall be 10",
+ "The base price of 10 for Fertilizer can be seen in program output data");
+ add_requirement(ECON_138);
+ Requirement ECON_139 = Requirement("ECON_139",
+ "The base price for Fish shall be 1.5",
+ "The base price of 1.5 for Fish can be seen in program output data");
+ add_requirement(ECON_139);
+ Requirement ECON_140 = Requirement("ECON_140",
+ "The base price for Fruit shall be 1.8",
+ "The base price of 1.8 for Fruit can be seen in program output data");
+ add_requirement(ECON_140);
+ Requirement ECON_141 = Requirement("ECON_141",
+ "The base price for Fuel shall be 25",
+ "The base price of 25 for Fuel can be seen in program output data");
+ add_requirement(ECON_141);
+ Requirement ECON_142 = Requirement("ECON_142",
+ "The base price for Furniture shall be 4.9",
+ "The base price of 4.9 for Furniture can be seen in program output data");
+ add_requirement(ECON_142);
+ Requirement ECON_234 = Requirement("ECON_234",
+ "The base price for Glass shall be 2.9",
+ "The base price of 2.9 for Glass can be seen in program output data");
+ add_requirement(ECON_234);
+ Requirement ECON_235 = Requirement("ECON_235",
+ "The base price for Grain shall be 2.2",
+ "The base price of 2.2 for Grain can be seen in program output data");
+ add_requirement(ECON_235);
+ Requirement ECON_236 = Requirement("ECON_236",
+ "The base price for Iron shall be 3.5",
+ "The base price of 3.5 for Iron can be seen in program output data");
+ add_requirement(ECON_236);
+ Requirement ECON_237 = Requirement("ECON_237",
+ "The base price for Liquor shall be 6.4",
+ "The base price of 6.4 for Liquor can be seen in program output data");
+ add_requirement(ECON_237);
+ Requirement ECON_238 = Requirement("ECON_238",
+ "The base price for Lumber shall be 1",
+ "The base price of 1 for Lumber can be seen in program output data");
+ add_requirement(ECON_238);
+ Requirement ECON_239 = Requirement("ECON_239",
+ "The base price for Luxury Clothes shall be 65",
+ "The base price of 65 for Luxury Clothes can be seen in program output data");
+ add_requirement(ECON_239);
+ Requirement ECON_240 = Requirement("ECON_240",
+ "The base price for Luxury Furniture shall be 59",
+ "The base price of 59 for Luxury Furniture can be seen in program output data");
+ add_requirement(ECON_240);
+ Requirement ECON_241 = Requirement("ECON_241",
+ "The base price for Machine Parts shall be 36.5",
+ "The base price of 36.5 for Machine Parts can be seen in program output data");
+ add_requirement(ECON_241);
+ Requirement ECON_242 = Requirement("ECON_242",
+ "The base price for Oil shall be 12",
+ "The base price of 12 for Oil can be seen in program output data");
+ add_requirement(ECON_242);
+ Requirement ECON_243 = Requirement("ECON_243",
+ "The base price for Opium shall be 3.2",
+ "The base price of 3.2 for Opium can be seen in program output data");
+ add_requirement(ECON_243);
+ Requirement ECON_244 = Requirement("ECON_244",
+ "The base price for Paper shall be 3.4",
+ "The base price of 3.4 for Paper can be seen in program output data");
+ add_requirement(ECON_244);
+ Requirement ECON_245 = Requirement("ECON_245",
+ "The base price for Precious Metal shall be 8",
+ "The base price of 8 for Precious Metal can be seen in program output data");
+ add_requirement(ECON_245);
+ Requirement ECON_246 = Requirement("ECON_246",
+ "The base price for Radios shall be 16",
+ "The base price of 16 for Radios can be seen in program output data");
+ add_requirement(ECON_246);
+ Requirement ECON_247 = Requirement("ECON_247",
+ "The base price for Regular Clothes shall be 5.8",
+ "The base price of 5.8 for Regular Clothes can be seen in program output data");
+ add_requirement(ECON_247);
+ Requirement ECON_248 = Requirement("ECON_248",
+ "The base price for Rubber shall be 7",
+ "The base price of 7 for Rubber can be seen in program output data");
+ add_requirement(ECON_248);
+ Requirement ECON_249 = Requirement("ECON_249",
+ "The base price for Silk shall be 10",
+ "The base price of 10 for Silk can be seen in program output data");
+ add_requirement(ECON_249);
+ Requirement ECON_250 = Requirement("ECON_250",
+ "The base price for Small Arms shall be 37",
+ "The base price of 37 for Small Arms can be seen in program output data");
+ add_requirement(ECON_250);
+ Requirement ECON_251 = Requirement("ECON_251",
+ "The base price for Steamer Convoys shall be 65",
+ "The base price of 65 for Steamer Convoys can be seen in program output data");
+ add_requirement(ECON_251);
+ Requirement ECON_252 = Requirement("ECON_252",
+ "The base price for Steel shall be 4.7",
+ "The base price of 4.7 for Steel can be seen in program output data");
+ add_requirement(ECON_252);
+ Requirement ECON_253 = Requirement("ECON_253",
+ "The base price for Sulphur shall be 6",
+ "The base price of 6 for Sulphur can be seen in program output data");
+ add_requirement(ECON_253);
+ Requirement ECON_254 = Requirement("ECON_254",
+ "The base price for Tanks shall be 98",
+ "The base price of 98 for Tanks can be seen in program output data");
+ add_requirement(ECON_254);
+ Requirement ECON_255 = Requirement("ECON_255",
+ "The base price for Tea shall be 2.6",
+ "The base price of 2.6 for Tea can be seen in program output data");
+ add_requirement(ECON_255);
+ Requirement ECON_256 = Requirement("ECON_256",
+ "The base price for Telephones shall be 16",
+ "The base price of 16 for Telephones can be seen in program output data");
+ add_requirement(ECON_256);
+ Requirement ECON_257 = Requirement("ECON_257",
+ "The base price for Timber shall be 0.9",
+ "The base price of 0.9 for Timber can be seen in program output data");
+ add_requirement(ECON_257);
+ Requirement ECON_258 = Requirement("ECON_258",
+ "The base price for Tobacco shall be 1.1",
+ "The base price of 1.1 for Tobacco can be seen in program output data");
+ add_requirement(ECON_258);
+ Requirement ECON_259 = Requirement("ECON_259",
+ "The base price for Tropical Wood shall be 5.4",
+ "The base price of 5.4 for Tropical Wood can be seen in program output data");
+ add_requirement(ECON_259);
+ Requirement ECON_260 = Requirement("ECON_260",
+ "The base price for Wine shall be 9.7",
+ "The base price of 9.7 for Wine can be seen in program output data");
+ add_requirement(ECON_260);
+ Requirement ECON_261 = Requirement("ECON_261",
+ "The base price for Wool shall be 0.7",
+ "The base price of 0.7 for Wool can be seen in program output data");
+ add_requirement(ECON_261);
+ }
+
+ void execute_script() {
+ // ECON_123
+ // The base price for Aeroplanes shall be 110
+ // The base price of 110 for Aeroplanes can be seen in program output data
+
+ // TODO: Write test steps for ECON_123...
+
+ // ECON_124
+ // The base price for Ammunition shall be 17.5
+ // The base price of 17.5 for Ammunition can be seen in program output data
+
+ // TODO: Write test steps for ECON_124...
+
+ // ECON_125
+ // The base price for Artillery shall be 60
+ // The base price of 60 for Artillery can be seen in program output data
+
+ // TODO: Write test steps for ECON_125...
+
+ // ECON_126
+ // The base price for Automobiles shall be 70
+ // The base price of 70 for Automobiles can be seen in program output data
+
+ // TODO: Write test steps for ECON_126...
+
+ // ECON_127
+ // The base price for Canned Food shall be 16
+ // The base price of 16 for Canned Food can be seen in program output data
+
+ // TODO: Write test steps for ECON_127...
+
+ // ECON_128
+ // The base price for Cattle shall be 2
+ // The base price of 2 for Cattle can be seen in program output data
+
+ // TODO: Write test steps for ECON_128...
+
+ // ECON_129
+ // The base price for Cement shall be 16
+ // The base price of 16 for Cement can be seen in program output data
+
+ // TODO: Write test steps for ECON_129...
+
+ // ECON_130
+ // The base price for Clipper Convoys shall be 42
+ // The base price of 42 for Clipper Convoys can be seen in program output data
+
+ // TODO: Write test steps for ECON_130...
+
+ // ECON_131
+ // The base price for Coal shall be 2.3
+ // The base price of 2.3 for Coal can be seen in program output data
+
+ // TODO: Write test steps for ECON_131...
+
+ // ECON_132
+ // The base price for Coffee shall be 2.1
+ // The base price of 2.1 for Coffee can be seen in program output data
+
+ // TODO: Write test steps for ECON_132...
+
+ // ECON_133
+ // The base price for Cotton shall be 2
+ // The base price of 2 for Cotton can be seen in program output data
+
+ // TODO: Write test steps for ECON_133...
+
+ // ECON_134
+ // The base price for Dye shall be 12
+ // The base price of 12 for Dye can be seen in program output data
+
+ // TODO: Write test steps for ECON_134...
+
+ // ECON_135
+ // The base price for Electric Gear shall be 16
+ // The base price of 16 for Electric Gear can be seen in program output data
+
+ // TODO: Write test steps for ECON_135...
+
+ // ECON_136
+ // The base price for Explosives shall be 20
+ // The base price of 20 for Explosives can be seen in program output data
+
+ // TODO: Write test steps for ECON_136...
+
+ // ECON_137
+ // The base price for Fabric shall be 1.8
+ // The base price of 1.8 for Fabric can be seen in program output data
+
+ // TODO: Write test steps for ECON_137...
+
+ // ECON_138
+ // The base price for Fertilizer shall be 10
+ // The base price of 10 for Fertilizer can be seen in program output data
+
+ // TODO: Write test steps for ECON_138...
+
+ // ECON_139
+ // The base price for Fish shall be 1.5
+ // The base price of 1.5 for Fish can be seen in program output data
+
+ // TODO: Write test steps for ECON_139...
+
+ // ECON_140
+ // The base price for Fruit shall be 1.8
+ // The base price of 1.8 for Fruit can be seen in program output data
+
+ // TODO: Write test steps for ECON_140...
+
+ // ECON_141
+ // The base price for Fuel shall be 25
+ // The base price of 25 for Fuel can be seen in program output data
+
+ // TODO: Write test steps for ECON_141...
+
+ // ECON_142
+ // The base price for Furniture shall be 4.9
+ // The base price of 4.9 for Furniture can be seen in program output data
+
+ // TODO: Write test steps for ECON_142...
+
+ // ECON_234
+ // The base price for Glass shall be 2.9
+ // The base price of 2.9 for Glass can be seen in program output data
+
+ // TODO: Write test steps for ECON_234...
+
+ // ECON_235
+ // The base price for Grain shall be 2.2
+ // The base price of 2.2 for Grain can be seen in program output data
+
+ // TODO: Write test steps for ECON_235...
+
+ // ECON_236
+ // The base price for Iron shall be 3.5
+ // The base price of 3.5 for Iron can be seen in program output data
+
+ // TODO: Write test steps for ECON_236...
+
+ // ECON_237
+ // The base price for Liquor shall be 6.4
+ // The base price of 6.4 for Liquor can be seen in program output data
+
+ // TODO: Write test steps for ECON_237...
+
+ // ECON_238
+ // The base price for Lumber shall be 1
+ // The base price of 1 for Lumber can be seen in program output data
+
+ // TODO: Write test steps for ECON_238...
+
+ // ECON_239
+ // The base price for Luxury Clothes shall be 65
+ // The base price of 65 for Luxury Clothes can be seen in program output data
+
+ // TODO: Write test steps for ECON_239...
+
+ // ECON_240
+ // The base price for Luxury Furniture shall be 59
+ // The base price of 59 for Luxury Furniture can be seen in program output data
+
+ // TODO: Write test steps for ECON_240...
+
+ // ECON_241
+ // The base price for Machine Parts shall be 36.5
+ // The base price of 36.5 for Machine Parts can be seen in program output data
+
+ // TODO: Write test steps for ECON_241...
+
+ // ECON_242
+ // The base price for Oil shall be 12
+ // The base price of 12 for Oil can be seen in program output data
+
+ // TODO: Write test steps for ECON_242...
+
+ // ECON_243
+ // The base price for Opium shall be 3.2
+ // The base price of 3.2 for Opium can be seen in program output data
+
+ // TODO: Write test steps for ECON_243...
+
+ // ECON_244
+ // The base price for Paper shall be 3.4
+ // The base price of 3.4 for Paper can be seen in program output data
+
+ // TODO: Write test steps for ECON_244...
+
+ // ECON_245
+ // The base price for Precious Metal shall be 8
+ // The base price of 8 for Precious Metal can be seen in program output data
+
+ // TODO: Write test steps for ECON_245...
+
+ // ECON_246
+ // The base price for Radios shall be 16
+ // The base price of 16 for Radios can be seen in program output data
+
+ // TODO: Write test steps for ECON_246...
+
+ // ECON_247
+ // The base price for Regular Clothes shall be 5.8
+ // The base price of 5.8 for Regular Clothes can be seen in program output data
+
+ // TODO: Write test steps for ECON_247...
+
+ // ECON_248
+ // The base price for Rubber shall be 7
+ // The base price of 7 for Rubber can be seen in program output data
+
+ // TODO: Write test steps for ECON_248...
+
+ // ECON_249
+ // The base price for Silk shall be 10
+ // The base price of 10 for Silk can be seen in program output data
+
+ // TODO: Write test steps for ECON_249...
+
+ // ECON_250
+ // The base price for Small Arms shall be 37
+ // The base price of 37 for Small Arms can be seen in program output data
+
+ // TODO: Write test steps for ECON_250...
+
+ // ECON_251
+ // The base price for Steamer Convoys shall be 65
+ // The base price of 65 for Steamer Convoys can be seen in program output data
+
+ // TODO: Write test steps for ECON_251...
+
+ // ECON_252
+ // The base price for Steel shall be 4.7
+ // The base price of 4.7 for Steel can be seen in program output data
+
+ // TODO: Write test steps for ECON_252...
+
+ // ECON_253
+ // The base price for Sulphur shall be 6
+ // The base price of 6 for Sulphur can be seen in program output data
+
+ // TODO: Write test steps for ECON_253...
+
+ // ECON_254
+ // The base price for Tanks shall be 98
+ // The base price of 98 for Tanks can be seen in program output data
+
+ // TODO: Write test steps for ECON_254...
+
+ // ECON_255
+ // The base price for Tea shall be 2.6
+ // The base price of 2.6 for Tea can be seen in program output data
+
+ // TODO: Write test steps for ECON_255...
+
+ // ECON_256
+ // The base price for Telephones shall be 16
+ // The base price of 16 for Telephones can be seen in program output data
+
+ // TODO: Write test steps for ECON_256...
+
+ // ECON_257
+ // The base price for Timber shall be 0.9
+ // The base price of 0.9 for Timber can be seen in program output data
+
+ // TODO: Write test steps for ECON_257...
+
+ // ECON_258
+ // The base price for Tobacco shall be 1.1
+ // The base price of 1.1 for Tobacco can be seen in program output data
+
+ // TODO: Write test steps for ECON_258...
+
+ // ECON_259
+ // The base price for Tropical Wood shall be 5.4
+ // The base price of 5.4 for Tropical Wood can be seen in program output data
+
+ // TODO: Write test steps for ECON_259...
+
+ // ECON_260
+ // The base price for Wine shall be 9.7
+ // The base price of 9.7 for Wine can be seen in program output data
+
+ // TODO: Write test steps for ECON_260...
+
+ // ECON_261
+ // The base price for Wool shall be 0.7
+ // The base price of 0.7 for Wool can be seen in program output data
+
+ // TODO: Write test steps for ECON_261...
+
+ }
+ };
+}
diff --git a/src/openvic-simulation/testing/test_scripts/A_003_military_unit_tests.cpp b/src/openvic-simulation/testing/test_scripts/A_003_military_unit_tests.cpp
new file mode 100644
index 0000000..042e94b
--- /dev/null
+++ b/src/openvic-simulation/testing/test_scripts/A_003_military_unit_tests.cpp
@@ -0,0 +1,19 @@
+# pragma once
+# include <testing/TestScript.hpp>
+
+namespace OpenVic {
+ class A_003_military_unit_tests : public TestScript {
+
+ public:
+ A_003_military_unit_tests() {
+ add_requirements();
+ execute_script();
+ }
+
+ void add_requirements() {
+ }
+
+ void execute_script() {
+ }
+ };
+}
diff --git a/src/openvic-simulation/testing/test_scripts/A_004_networking_tests.cpp b/src/openvic-simulation/testing/test_scripts/A_004_networking_tests.cpp
new file mode 100644
index 0000000..926d9b4
--- /dev/null
+++ b/src/openvic-simulation/testing/test_scripts/A_004_networking_tests.cpp
@@ -0,0 +1,19 @@
+# pragma once
+# include <testing/TestScript.hpp>
+
+namespace OpenVic {
+ class A_004_networking_tests : public TestScript {
+
+ public:
+ A_004_networking_tests() {
+ add_requirements();
+ execute_script();
+ }
+
+ void add_requirements() {
+ }
+
+ void execute_script() {
+ }
+ };
+}
diff --git a/src/openvic-simulation/testing/test_scripts/A_005_nation_tests.cpp b/src/openvic-simulation/testing/test_scripts/A_005_nation_tests.cpp
new file mode 100644
index 0000000..027f1bc
--- /dev/null
+++ b/src/openvic-simulation/testing/test_scripts/A_005_nation_tests.cpp
@@ -0,0 +1,19 @@
+# pragma once
+# include <testing/TestScript.hpp>
+
+namespace OpenVic {
+ class A_005_nation_tests : public TestScript {
+
+ public:
+ A_005_nation_tests() {
+ add_requirements();
+ execute_script();
+ }
+
+ void add_requirements() {
+ }
+
+ void execute_script() {
+ }
+ };
+}
diff --git a/src/openvic-simulation/testing/test_scripts/A_006_politics_tests.cpp b/src/openvic-simulation/testing/test_scripts/A_006_politics_tests.cpp
new file mode 100644
index 0000000..c35a827
--- /dev/null
+++ b/src/openvic-simulation/testing/test_scripts/A_006_politics_tests.cpp
@@ -0,0 +1,19 @@
+# pragma once
+# include <testing/TestScript.hpp>
+
+namespace OpenVic {
+ class A_006_politics_tests : public TestScript {
+
+ public:
+ A_006_politics_tests() {
+ add_requirements();
+ execute_script();
+ }
+
+ void add_requirements() {
+ }
+
+ void execute_script() {
+ }
+ };
+}
diff --git a/src/openvic-simulation/types/IdentifierRegistry.hpp b/src/openvic-simulation/types/IdentifierRegistry.hpp
index c79e51b..f5606f2 100644
--- a/src/openvic-simulation/types/IdentifierRegistry.hpp
+++ b/src/openvic-simulation/types/IdentifierRegistry.hpp
@@ -214,6 +214,20 @@ namespace OpenVic {
return false;
});
}
+
+ NodeTools::node_callback_t expect_item_decimal_map(NodeTools::callback_t<std::map<T const*, fixed_point_t>&&> callback) const {
+ return [this, callback](ast::NodeCPtr node) -> bool {
+ std::map<T const*, fixed_point_t> map;
+ bool ret = expect_item_dictionary([&map](T const& key, ast::NodeCPtr value) -> bool {
+ fixed_point_t val;
+ const bool ret = NodeTools::expect_fixed_point(NodeTools::assign_variable_callback(val))(value);
+ map.emplace(&key, val);
+ return ret;
+ })(node);
+ ret &= callback(std::move(map));
+ return ret;
+ };
+ }
};
#define IDENTIFIER_REGISTRY_ACCESSORS_CUSTOM_PLURAL(type, singular, plural) \
@@ -227,7 +241,9 @@ namespace OpenVic {
NodeTools::node_callback_t expect_##singular##_identifier(NodeTools::callback_t<type const&> callback) const { \
return plural.expect_item_identifier(callback); } \
NodeTools::node_callback_t expect_##singular##_dictionary(NodeTools::callback_t<type const&, ast::NodeCPtr> callback) const { \
- return plural.expect_item_dictionary(callback); }
+ return plural.expect_item_dictionary(callback); } \
+ NodeTools::node_callback_t expect_##singular##_decimal_map(NodeTools::callback_t<std::map<type const*, fixed_point_t>&&> callback) const { \
+ return plural.expect_item_decimal_map(callback); }
#define IDENTIFIER_REGISTRY_NON_CONST_ACCESSORS_CUSTOM_PLURAL(type, singular, plural) \
type* get_##singular##_by_identifier(const std::string_view identifier) { \
diff --git a/src/openvic-simulation/types/Vector.cpp b/src/openvic-simulation/types/Vector.cpp
index 27c9aa8..1c9d2f4 100644
--- a/src/openvic-simulation/types/Vector.cpp
+++ b/src/openvic-simulation/types/Vector.cpp
@@ -58,7 +58,7 @@ constexpr vec2_t<T>& vec2_t<T>::operator+=(vec2_t const& right) {
}
template<typename T>
-constexpr vec2_t<T> operator-(vec2_t<T> const& arg) {
+constexpr vec2_t<T> operator-(vec2_t<T> const& arg) {
return { -arg.x, -arg.y };
}
diff --git a/src/openvic-simulation/units/Unit.cpp b/src/openvic-simulation/units/Unit.cpp
index ebf4985..f57e0a7 100644
--- a/src/openvic-simulation/units/Unit.cpp
+++ b/src/openvic-simulation/units/Unit.cpp
@@ -170,7 +170,7 @@ fixed_point_t NavalUnit::get_torpedo_attack() const {
return torpedo_attack;
}
-UnitManager::UnitManager(GoodManager& good_manager) : good_manager { good_manager }, units { "units" } {};
+UnitManager::UnitManager() : units { "units" } {}
bool UnitManager::_check_shared_parameters(const std::string_view identifier, UNIT_PARAMS) {
if (identifier.empty()) {
@@ -211,8 +211,8 @@ bool UnitManager::add_naval_unit(const std::string_view identifier, UNIT_PARAMS,
return units.add_item(NavalUnit { identifier, UNIT_ARGS, NAVY_ARGS });
}
//TODO forgot fcking capital flag for naval units
-bool UnitManager::load_unit_file(ast::NodeCPtr root) {
- return NodeTools::expect_dictionary([this](std::string_view key, ast::NodeCPtr value) -> bool {
+bool UnitManager::load_unit_file(GoodManager const& good_manager, ast::NodeCPtr root) {
+ return NodeTools::expect_dictionary([this, &good_manager](std::string_view key, ast::NodeCPtr value) -> bool {
Unit::icon_t icon;
std::string_view category, type;
Unit::sprite_t sprite;
@@ -223,21 +223,21 @@ bool UnitManager::load_unit_file(ast::NodeCPtr root) {
//shared
bool ret = expect_dictionary_keys(ALLOW_OTHER_KEYS,
- "icon", ONE_EXACTLY, expect_uint(assign_variable_callback(icon)),
+ "icon", ONE_EXACTLY, expect_uint(assign_variable_callback_uint("unit icon", icon)),
"type", ONE_EXACTLY, expect_identifier(assign_variable_callback(category)),
"sprite", ONE_EXACTLY, expect_identifier(assign_variable_callback(sprite)),
"active", ZERO_OR_ONE, expect_bool(assign_variable_callback(active)),
"unit_type", ONE_EXACTLY, expect_identifier(assign_variable_callback(type)),
"floating_flag", ONE_EXACTLY, expect_bool(assign_variable_callback(floating_flag)),
- "priority", ONE_EXACTLY, expect_uint(assign_variable_callback(priority)),
+ "priority", ONE_EXACTLY, expect_uint(assign_variable_callback_uint("unit priority", priority)),
"max_strength", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(max_strength)),
"default_organisation", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(default_organisation)),
"maximum_speed", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(maximum_speed)),
"weighted_value", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(weighted_value)),
- "build_time", ONE_EXACTLY, expect_uint(assign_variable_callback(build_time)),
- "build_cost", ONE_EXACTLY, good_manager.expect_goods_map(assign_variable_callback(build_cost)),
- "supply_consumption", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(supply_consumption)),
- "supply_cost", ONE_EXACTLY, good_manager.expect_goods_map(assign_variable_callback(supply_cost))
+ "build_time", ONE_EXACTLY, expect_uint(assign_variable_callback_uint("unit build time", build_time)),
+ "build_cost", ONE_EXACTLY, good_manager.expect_good_decimal_map(assign_variable_callback(build_cost)),
+ "supply_consumption", ONE_EXACTLY, expect_fixed_point(move_variable_callback(supply_consumption)),
+ "supply_cost", ONE_EXACTLY, good_manager.expect_good_decimal_map(move_variable_callback(supply_cost))
)(value);
if (category == "land") {
@@ -265,7 +265,7 @@ bool UnitManager::load_unit_file(ast::NodeCPtr root) {
fixed_point_t fire_range, evasion, supply_consumption_score, hull, gun_power, colonial_points = 0, torpedo_attack = 0;
ret &= expect_dictionary_keys(ALLOW_OTHER_KEYS,
- "naval_icon", ONE_EXACTLY, expect_uint(assign_variable_callback(naval_icon)),
+ "naval_icon", ONE_EXACTLY, expect_uint(assign_variable_callback_uint("unit naval icon", naval_icon)),
"sail", ZERO_OR_ONE, expect_bool(assign_variable_callback(sail)),
"transport", ZERO_OR_ONE, expect_bool(assign_variable_callback(transport)),
"capital", ZERO_OR_ONE, expect_bool(assign_variable_callback(capital)),
@@ -273,8 +273,8 @@ bool UnitManager::load_unit_file(ast::NodeCPtr root) {
"select_sound", ZERO_OR_ONE, expect_identifier(assign_variable_callback(select_sound)),
"colonial_points", ZERO_OR_ONE, expect_fixed_point(assign_variable_callback(colonial_points)),
"can_build_overseas", ZERO_OR_ONE, expect_bool(assign_variable_callback(build_overseas)),
- "min_port_level", ONE_EXACTLY, expect_uint(assign_variable_callback(min_port_level)),
- "limit_per_port", ONE_EXACTLY, expect_int(assign_variable_callback(limit_per_port)),
+ "min_port_level", ONE_EXACTLY, expect_uint(assign_variable_callback_uint("unit min port level", min_port_level)),
+ "limit_per_port", ONE_EXACTLY, expect_int(assign_variable_callback_int("unit limit per port", limit_per_port)),
"supply_consumption_score", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(supply_consumption_score)),
"hull", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(hull)),
"gun_power", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(gun_power)),
diff --git a/src/openvic-simulation/units/Unit.hpp b/src/openvic-simulation/units/Unit.hpp
index c9d3434..507adbd 100644
--- a/src/openvic-simulation/units/Unit.hpp
+++ b/src/openvic-simulation/units/Unit.hpp
@@ -47,7 +47,7 @@ namespace OpenVic {
protected:
Unit(std::string_view identifier, std::string_view category, UNIT_PARAMS);
-
+
public:
Unit(Unit&&) = default;
@@ -98,7 +98,7 @@ namespace OpenVic {
struct NavalUnit : Unit {
friend struct UnitManager;
-
+
private:
const icon_t naval_icon;
const bool sail;
@@ -144,18 +144,17 @@ namespace OpenVic {
struct UnitManager {
private:
- GoodManager& good_manager;
IdentifierRegistry<Unit> units;
bool _check_shared_parameters(const std::string_view identifier, UNIT_PARAMS);
-
+
public:
- UnitManager(GoodManager& good_manager);
+ UnitManager();
bool add_land_unit(const std::string_view identifier, UNIT_PARAMS, LAND_PARAMS);
bool add_naval_unit(const std::string_view identifier, UNIT_PARAMS, NAVY_PARAMS);
IDENTIFIER_REGISTRY_ACCESSORS(Unit, unit)
- bool load_unit_file(ast::NodeCPtr root);
+ bool load_unit_file(GoodManager const& good_manager, ast::NodeCPtr root);
};
} \ No newline at end of file