From feb02ecc18c727985a2aff9686ccd8fad04dc512 Mon Sep 17 00:00:00 2001 From: milerius Date: Fri, 13 Sep 2019 18:14:18 +0200 Subject: [PATCH] feat(event): add event module with start and quit game events --- modules/CMakeLists.txt | 1 + modules/event/CMakeLists.txt | 36 +++++++++++++++++++ .../event/antara.event.quit.game.tests.cpp | 36 +++++++++++++++++++ .../gaming/event/antara.event.tests.cpp | 18 ++++++++++ .../antara/gaming/event/quit.game.event.cpp | 25 +++++++++++++ .../antara/gaming/event/quit.game.event.hpp | 26 ++++++++++++++ .../antara/gaming/event/start.game.event.hpp | 25 +++++++++++++ 7 files changed, 167 insertions(+) create mode 100644 modules/event/CMakeLists.txt create mode 100644 modules/event/antara/gaming/event/antara.event.quit.game.tests.cpp create mode 100644 modules/event/antara/gaming/event/antara.event.tests.cpp create mode 100644 modules/event/antara/gaming/event/quit.game.event.cpp create mode 100644 modules/event/antara/gaming/event/quit.game.event.hpp create mode 100644 modules/event/antara/gaming/event/start.game.event.hpp diff --git a/modules/CMakeLists.txt b/modules/CMakeLists.txt index 0d115dc2..97114343 100644 --- a/modules/CMakeLists.txt +++ b/modules/CMakeLists.txt @@ -1,3 +1,4 @@ add_subdirectory(core) +add_subdirectory(event) add_subdirectory(timer) add_subdirectory(ecs) \ No newline at end of file diff --git a/modules/event/CMakeLists.txt b/modules/event/CMakeLists.txt new file mode 100644 index 00000000..6611d178 --- /dev/null +++ b/modules/event/CMakeLists.txt @@ -0,0 +1,36 @@ +## shared sources between the module and his unit tests +add_library(antara_event_shared_sources INTERFACE) +target_sources(antara_event_shared_sources INTERFACE antara/gaming/event/quit.game.event.cpp) +target_include_directories(antara_event_shared_sources INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) +target_link_libraries(antara_event_shared_sources INTERFACE antara::default_settings) +add_library(antara::event_shared_sources ALIAS antara_event_shared_sources) + + +##! module definition +add_library(antara_event OBJECT) +target_link_libraries(antara_event PUBLIC antara::event_shared_sources) +add_library(antara::event ALIAS antara_event) + +##! antara event tests +add_executable(antara_event_tests) +target_sources(antara_event_tests PUBLIC + antara/gaming/event/antara.event.tests.cpp + antara/gaming/event/antara.event.quit.game.tests.cpp) +target_link_libraries(antara_event_tests PRIVATE doctest PUBLIC antara::event_shared_sources) +set_target_properties(antara_event_tests + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/unit_tests" + ) +target_enable_coverage(antara_event_tests) + +if (EMSCRIPTEN) + message(STATUS "Emscripten detected") + if (ENABLE_HTML_COMPILATION) + message(STATUS "Html compilation enabled") + set_target_properties(antara_event_tests PROPERTIES LINK_FLAGS "-s FORCE_FILESYSTEM=1 -s EXIT_RUNTIME=1" + SUFFIX ".html") + else () + message(STATUS "Local js compilation") + set_target_properties(antara_event_tests PROPERTIES LINK_FLAGS "-s FORCE_FILESYSTEM=1 -s NODERAWFS=1 -s EXIT_RUNTIME=1") + endif () +endif () \ No newline at end of file diff --git a/modules/event/antara/gaming/event/antara.event.quit.game.tests.cpp b/modules/event/antara/gaming/event/antara.event.quit.game.tests.cpp new file mode 100644 index 00000000..ae1c2929 --- /dev/null +++ b/modules/event/antara/gaming/event/antara.event.quit.game.tests.cpp @@ -0,0 +1,36 @@ +/****************************************************************************** + * Copyright © 2013-2019 The Komodo Platform Developers. * + * * + * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * + * the top-level directory of this distribution for the individual copyright * + * holder information and the developer policies on copyright and licensing. * + * * + * Unless otherwise agreed in a custom licensing agreement, no part of the * + * Komodo Platform software, including this file may be copied, modified, * + * propagated or distributed except according to the terms contained in the * + * LICENSE file * + * * + * Removal or modification of this copyright notice is prohibited. * + * * + ******************************************************************************/ + +#include +#include "antara/gaming/event/quit.game.event.hpp" + +namespace antara::gaming::event::tests +{ + TEST_SUITE("quit game event") + { + TEST_CASE("default constructible") + { + quit_game q_event{}; + CHECK_EQ(q_event.return_value_, 0); + } + + TEST_CASE("constructible with a value") + { + quit_game q_event{-1}; + CHECK_EQ(q_event.return_value_, -1); + } + } +} \ No newline at end of file diff --git a/modules/event/antara/gaming/event/antara.event.tests.cpp b/modules/event/antara/gaming/event/antara.event.tests.cpp new file mode 100644 index 00000000..caa05e4d --- /dev/null +++ b/modules/event/antara/gaming/event/antara.event.tests.cpp @@ -0,0 +1,18 @@ +/****************************************************************************** + * Copyright © 2013-2019 The Komodo Platform Developers. * + * * + * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * + * the top-level directory of this distribution for the individual copyright * + * holder information and the developer policies on copyright and licensing. * + * * + * Unless otherwise agreed in a custom licensing agreement, no part of the * + * Komodo Platform software, including this file may be copied, modified, * + * propagated or distributed except according to the terms contained in the * + * LICENSE file * + * * + * Removal or modification of this copyright notice is prohibited. * + * * + ******************************************************************************/ + +#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN +#include \ No newline at end of file diff --git a/modules/event/antara/gaming/event/quit.game.event.cpp b/modules/event/antara/gaming/event/quit.game.event.cpp new file mode 100644 index 00000000..880ec15d --- /dev/null +++ b/modules/event/antara/gaming/event/quit.game.event.cpp @@ -0,0 +1,25 @@ +/****************************************************************************** + * Copyright © 2013-2019 The Komodo Platform Developers. * + * * + * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * + * the top-level directory of this distribution for the individual copyright * + * holder information and the developer policies on copyright and licensing. * + * * + * Unless otherwise agreed in a custom licensing agreement, no part of the * + * Komodo Platform software, including this file may be copied, modified, * + * propagated or distributed except according to the terms contained in the * + * LICENSE file * + * * + * Removal or modification of this copyright notice is prohibited. * + * * + ******************************************************************************/ + +#include "antara/gaming/event/quit.game.event.hpp" + +namespace antara::gaming::event +{ + quit_game::quit_game(int return_value) noexcept : return_value_(return_value) + { + + } +} \ No newline at end of file diff --git a/modules/event/antara/gaming/event/quit.game.event.hpp b/modules/event/antara/gaming/event/quit.game.event.hpp new file mode 100644 index 00000000..64d7305d --- /dev/null +++ b/modules/event/antara/gaming/event/quit.game.event.hpp @@ -0,0 +1,26 @@ +/****************************************************************************** + * Copyright © 2013-2019 The Komodo Platform Developers. * + * * + * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * + * the top-level directory of this distribution for the individual copyright * + * holder information and the developer policies on copyright and licensing. * + * * + * Unless otherwise agreed in a custom licensing agreement, no part of the * + * Komodo Platform software, including this file may be copied, modified, * + * propagated or distributed except according to the terms contained in the * + * LICENSE file * + * * + * Removal or modification of this copyright notice is prohibited. * + * * + ******************************************************************************/ + +#pragma once + +namespace antara::gaming::event +{ + struct quit_game + { + explicit quit_game(int return_value = 0) noexcept; + int return_value_; + }; +} \ No newline at end of file diff --git a/modules/event/antara/gaming/event/start.game.event.hpp b/modules/event/antara/gaming/event/start.game.event.hpp new file mode 100644 index 00000000..9f652023 --- /dev/null +++ b/modules/event/antara/gaming/event/start.game.event.hpp @@ -0,0 +1,25 @@ +/****************************************************************************** + * Copyright © 2013-2019 The Komodo Platform Developers. * + * * + * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * + * the top-level directory of this distribution for the individual copyright * + * holder information and the developer policies on copyright and licensing. * + * * + * Unless otherwise agreed in a custom licensing agreement, no part of the * + * Komodo Platform software, including this file may be copied, modified, * + * propagated or distributed except according to the terms contained in the * + * LICENSE file * + * * + * Removal or modification of this copyright notice is prohibited. * + * * + ******************************************************************************/ + +#pragma once + +namespace antara::gaming::event +{ + struct start_game + { + start_game() noexcept = default; + }; +} \ No newline at end of file