From eecf4b1e666211a13afa56f93477c55e8fd01621 Mon Sep 17 00:00:00 2001 From: HampusM Date: Thu, 2 Jun 2022 19:51:54 +0200 Subject: feat: implement game of life --- src/interfaces/cell_helper.hpp | 37 +++++++++++++++++++++++++++++++++++++ src/interfaces/game.hpp | 2 +- src/interfaces/input.hpp | 4 ++-- src/interfaces/matrix.hpp | 11 +---------- src/interfaces/statusline.hpp | 2 ++ 5 files changed, 43 insertions(+), 13 deletions(-) create mode 100644 src/interfaces/cell_helper.hpp (limited to 'src/interfaces') diff --git a/src/interfaces/cell_helper.hpp b/src/interfaces/cell_helper.hpp new file mode 100644 index 0000000..141d905 --- /dev/null +++ b/src/interfaces/cell_helper.hpp @@ -0,0 +1,37 @@ +#pragma once + +#include "interfaces/matrix.hpp" + +#include "engine/data/vector2.hpp" + +#include + +#include +#include + +// NOLINTNEXTLINE(cppcoreguidelines-special-member-functions) +class ICellHelper +{ +public: + virtual ~ICellHelper() noexcept = default; + + [[nodiscard]] virtual auto is_cell_dying(const Vector2 &cell_pos) const noexcept + -> bool = 0; + + [[nodiscard]] virtual auto + get_birth_cell_positions(const std::list &cell_positions) const noexcept + -> std::list = 0; + + /* + [[nodiscard]] virtual auto + find_neighbour_cells(const Vector2 &cell_pos) const noexcept + -> std::list = 0; + */ + + [[nodiscard]] virtual auto find_neighbours(const Vector2 &cell_pos) const noexcept + -> std::list = 0; +}; + +template +using ICellHelperFactory = + yacppdic::Factory(const IMatrix &matrix)>; diff --git a/src/interfaces/game.hpp b/src/interfaces/game.hpp index e205fae..b6d7f36 100644 --- a/src/interfaces/game.hpp +++ b/src/interfaces/game.hpp @@ -24,4 +24,4 @@ public: using IGameFactory = yacppdic::Factory( const std::shared_ptr &scene, const std::shared_ptr &cursor_controller, - const std::shared_ptr user_input_observer)>; + const std::shared_ptr &user_input_observer)>; diff --git a/src/interfaces/input.hpp b/src/interfaces/input.hpp index c2ecefb..3558363 100644 --- a/src/interfaces/input.hpp +++ b/src/interfaces/input.hpp @@ -13,9 +13,9 @@ public: virtual void listen() noexcept = 0; - virtual bool is_key_pressed(Key key) noexcept = 0; + virtual auto is_key_pressed(Key key) noexcept -> bool = 0; - virtual Key get_currently_pressed_key() const noexcept = 0; + [[nodiscard]] virtual auto get_currently_pressed_key() const noexcept -> Key = 0; virtual void clear_currently_pressed() noexcept = 0; }; diff --git a/src/interfaces/matrix.hpp b/src/interfaces/matrix.hpp index 5a01943..010138f 100644 --- a/src/interfaces/matrix.hpp +++ b/src/interfaces/matrix.hpp @@ -9,15 +9,10 @@ #include template +// NOLINTNEXTLINE(cppcoreguidelines-special-member-functions) class IMatrix { public: - IMatrix() noexcept = default; - - IMatrix(const IMatrix &matrix) noexcept = default; - - IMatrix(IMatrix &&matrix) noexcept = default; - virtual ~IMatrix() noexcept = default; virtual void fill(Element element) noexcept = 0; @@ -33,10 +28,6 @@ public: [[nodiscard]] virtual auto begin() const noexcept -> MatrixIterator = 0; [[nodiscard]] virtual auto end() const noexcept -> MatrixIterator = 0; - - auto operator=(const IMatrix &matrix) noexcept -> IMatrix & = default; - - auto operator=(IMatrix &&matrix) noexcept -> IMatrix & = default; }; template diff --git a/src/interfaces/statusline.hpp b/src/interfaces/statusline.hpp index 2fefa6d..a71699e 100644 --- a/src/interfaces/statusline.hpp +++ b/src/interfaces/statusline.hpp @@ -15,6 +15,8 @@ enum StatusLineSection D = 3, E = 4, F = 5, + G = 6, + H = 7 }; // NOLINTNEXTLINE(cppcoreguidelines-special-member-functions) -- cgit v1.2.3-18-g5258