aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/military/UnitInstance.cpp
diff options
context:
space:
mode:
author Hop311 <Hop3114@gmail.com>2024-07-19 21:35:22 +0200
committer GitHub <noreply@github.com>2024-07-19 21:35:22 +0200
commite0518bee9b4c164f40716a8033b5e207c2060c0b (patch)
tree6d2de5221d2b1945a065e0abba8198d8a052a92a /src/openvic-simulation/military/UnitInstance.cpp
parenta673f89bb2705826b1c646365eab1775727372b7 (diff)
parentd8baf57d46539da9edba5952f73089bf9a54bdaf (diff)
Merge pull request #175 from OpenVicProject/unit-work
Unit position/country/leader handling + more use of unit branch templates
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 } {}