aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/military/UnitInstance.cpp
diff options
context:
space:
mode:
author hop311 <hop3114@gmail.com>2024-07-19 00:25:38 +0200
committer hop311 <hop3114@gmail.com>2024-07-19 00:26:27 +0200
commitd8baf57d46539da9edba5952f73089bf9a54bdaf (patch)
tree6d2de5221d2b1945a065e0abba8198d8a052a92a /src/openvic-simulation/military/UnitInstance.cpp
parenta673f89bb2705826b1c646365eab1775727372b7 (diff)
Unit position/country/leader handling + more use of unit branch templatesunit-work
Diffstat (limited to 'src/openvic-simulation/military/UnitInstance.cpp')
-rw-r--r--src/openvic-simulation/military/UnitInstance.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/openvic-simulation/military/UnitInstance.cpp b/src/openvic-simulation/military/UnitInstance.cpp
index 1f49205..d9f12b9 100644
--- a/src/openvic-simulation/military/UnitInstance.cpp
+++ b/src/openvic-simulation/military/UnitInstance.cpp
@@ -2,6 +2,22 @@
using namespace OpenVic;
+template<UnitType::branch_t Branch>
+UnitInstance<Branch>::UnitInstance(std::string_view new_unit_name, _UnitType const& new_unit_type)
+ : unit_name { new_unit_name },
+ unit_type { new_unit_type },
+ organisation { new_unit_type.get_default_organisation() },
+ morale { 0 },
+ strength { new_unit_type.get_max_strength() } {}
+
+template<UnitType::branch_t Branch>
+void UnitInstance<Branch>::set_unit_name(std::string_view new_unit_name) {
+ unit_name = new_unit_name;
+}
+
+template struct OpenVic::UnitInstance<UnitType::branch_t::LAND>;
+template struct OpenVic::UnitInstance<UnitType::branch_t::NAVAL>;
+
UnitInstanceBranched<UnitType::branch_t::LAND>::UnitInstanceBranched(
std::string_view new_name, RegimentType const& new_regiment_type, Pop* new_pop
) : UnitInstance { new_name, new_regiment_type }, pop { new_pop } {}