diff options
| author | Felix Morgner <felix.morgner@gmail.com> | 2025-04-30 11:07:25 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@gmail.com> | 2025-04-30 11:07:25 +0200 |
| commit | adaba10aa7d8e504d3d10bfda42cb79b3ade459e (patch) | |
| tree | 98ac5394d509cc8cfa337afca3b74f60e6cf0b6c | |
| parent | 3e68879c7901384913c03bd587b248a3fd79d9ff (diff) | |
| download | turns-adaba10aa7d8e504d3d10bfda42cb79b3ade459e.tar.xz turns-adaba10aa7d8e504d3d10bfda42cb79b3ade459e.zip | |
core: add getters and setters for Participant
| -rw-r--r-- | core/include/turns/core/participant.hpp | 22 | ||||
| -rw-r--r-- | core/src/participant.cpp | 50 | ||||
| -rw-r--r-- | ui/tests/participant_editor.cpp | 2 |
3 files changed, 68 insertions, 6 deletions
diff --git a/core/include/turns/core/participant.hpp b/core/include/turns/core/participant.hpp index 2c02b1b..d2f2035 100644 --- a/core/include/turns/core/participant.hpp +++ b/core/include/turns/core/participant.hpp @@ -24,11 +24,23 @@ namespace turns::core auto operator<=>(Participant const & other) const noexcept -> std::partial_ordering; - auto property_disposition(this auto && self); - auto property_is_active(this auto && self); - auto property_is_defeated(this auto && self); - auto property_name(this auto && self); - auto property_priority(this auto && self); + [[nodiscard]] auto get_disposition() const -> disposition; + [[nodiscard]] auto get_is_active() const -> bool; + [[nodiscard]] auto get_is_defeated() const -> bool; + [[nodiscard]] auto get_name() const -> Glib::ustring; + [[nodiscard]] auto get_priority() const -> float; + + auto set_disposition(disposition value) -> void; + auto set_is_active(bool value) -> void; + auto set_is_defeated(bool value) -> void; + auto set_name(Glib::ustring const & value) -> void; + auto set_priority(float value) -> void; + + [[nodiscard]] auto property_disposition(this auto && self); + [[nodiscard]] auto property_is_active(this auto && self); + [[nodiscard]] auto property_is_defeated(this auto && self); + [[nodiscard]] auto property_name(this auto && self); + [[nodiscard]] auto property_priority(this auto && self); auto serialize() -> nlohmann::json; diff --git a/core/src/participant.cpp b/core/src/participant.cpp index d4b3835..343d461 100644 --- a/core/src/participant.cpp +++ b/core/src/participant.cpp @@ -53,6 +53,56 @@ namespace turns::core return m_priority <=> other.m_priority; } + auto Participant::get_disposition() const -> disposition + { + return m_disposition.get_value(); + } + + auto Participant::get_is_active() const -> bool + { + return m_is_active.get_value(); + } + + auto Participant::get_is_defeated() const -> bool + { + return m_is_defeated.get_value(); + } + + auto Participant::get_name() const -> Glib::ustring + { + return m_name.get_value(); + } + + auto Participant::get_priority() const -> float + { + return m_priority.get_value(); + } + + auto Participant::set_disposition(disposition value) -> void + { + return m_disposition.set_value(value); + } + + auto Participant::set_is_active(bool value) -> void + { + return m_is_active.set_value(value); + } + + auto Participant::set_is_defeated(bool value) -> void + { + return m_is_defeated.set_value(value); + } + + auto Participant::set_name(Glib::ustring const & value) -> void + { + return m_name.set_value(value); + } + + auto Participant::set_priority(float value) -> void + { + return m_priority.set_value(value); + } + auto Participant::serialize() -> nlohmann::json { return nlohmann::json{ diff --git a/ui/tests/participant_editor.cpp b/ui/tests/participant_editor.cpp index d222598..0d2ab13 100644 --- a/ui/tests/participant_editor.cpp +++ b/ui/tests/participant_editor.cpp @@ -70,7 +70,7 @@ namespace turns::ui::tests auto locale = GENERATE("en_US.UTF-8", "de_CH.UTF-8"); setlocale(LC_ALL, locale); - auto participant = core::participant::create("Qibi Babblebranch", 12, core::disposition::neutral); + auto participant = core::Participant::create("Qibi Babblebranch", 12, core::disposition::neutral); auto instance = std::make_shared<ParticipantEditor>(participant); auto window = Gtk::Window{}; |
