diff options
author | Joel Machens <ajmach6@gmail.com> | 2023-10-15 19:39:11 +0200 |
---|---|---|
committer | Joel Machens <ajmach6@gmail.com> | 2023-10-15 19:44:33 +0200 |
commit | af4758d399a75485b9adfeb3058a526eec3c8a4d (patch) | |
tree | 401556d0b45378c670b9101606a4fd98a207de27 /src/openvic-simulation/military/LeaderTrait.hpp | |
parent | 3249e21104bab6002676abe00450e7bd3f682303 (diff) |
Implement Leader Trait Loading
Diffstat (limited to 'src/openvic-simulation/military/LeaderTrait.hpp')
-rw-r--r-- | src/openvic-simulation/military/LeaderTrait.hpp | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/src/openvic-simulation/military/LeaderTrait.hpp b/src/openvic-simulation/military/LeaderTrait.hpp new file mode 100644 index 0000000..f4445f6 --- /dev/null +++ b/src/openvic-simulation/military/LeaderTrait.hpp @@ -0,0 +1,72 @@ +#pragma once + +#include <cstdint> +#include <string_view> +#include "openvic-simulation/types/IdentifierRegistry.hpp" +#include "openvic-simulation/types/fixed_point/FixedPoint.hpp" +#include "openvic-simulation/dataloader/NodeTools.hpp" +#include "openvic-simulation/Modifier.hpp" + +namespace OpenVic { + struct LeaderTraitManager; + + enum class trait_type_t { + PERSONALITY, + BACKGROUND + }; + + struct LeaderTrait : HasIdentifier { + friend struct LeaderTraitManager; + + private: + + const trait_type_t type; + /* + * Allowed modifiers for leaders: + * attack - integer + * defence - integer + * morale - % + * organisation - % + * reconnaissance - % + * speed - % + * attrition - %, negative is good + * experience - % + * reliability - decimal, mil gain or loss for associated POPs + */ + const ModifierValue modifiers; + + LeaderTrait(std::string_view new_identifier, trait_type_t new_type, ModifierValue new_modifiers); + + public: + LeaderTrait(LeaderTrait&&) = default; + + trait_type_t get_trait_type() const; + bool is_personality_trait() const; + bool is_background_trait() const; + ModifierValue get_modifiers() const; + }; + + struct LeaderTraitManager { + private: + IdentifierRegistry<LeaderTrait> leader_traits; + const std::set<std::string, std::less<void>> allowed_modifiers = { + "attack", + "defence", + "morale", + "organisation", + "reconnaissance", + "speed", + "attrition", + "experience", + "reliability" + }; + + public: + LeaderTraitManager(); + + bool add_leader_trait(std::string_view identifier, trait_type_t type, ModifierValue modifiers); + IDENTIFIER_REGISTRY_ACCESSORS(leader_trait) + + bool load_leader_traits_file(ModifierManager& modifier_manager, ast::NodeCPtr root); + }; +} // namespace OpenVic |