Skip to content

Commit

Permalink
feat(event): add event module with start and quit game events
Browse files Browse the repository at this point in the history
  • Loading branch information
Milerius committed Sep 13, 2019
1 parent 7c0a1d4 commit feb02ec
Show file tree
Hide file tree
Showing 7 changed files with 167 additions and 0 deletions.
1 change: 1 addition & 0 deletions modules/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
add_subdirectory(core)
add_subdirectory(event)
add_subdirectory(timer)
add_subdirectory(ecs)
36 changes: 36 additions & 0 deletions modules/event/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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 ()
36 changes: 36 additions & 0 deletions modules/event/antara/gaming/event/antara.event.quit.game.tests.cpp
Original file line number Diff line number Diff line change
@@ -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 <doctest/doctest.h>
#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);
}
}
}
18 changes: 18 additions & 0 deletions modules/event/antara/gaming/event/antara.event.tests.cpp
Original file line number Diff line number Diff line change
@@ -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 <doctest/doctest.h>
25 changes: 25 additions & 0 deletions modules/event/antara/gaming/event/quit.game.event.cpp
Original file line number Diff line number Diff line change
@@ -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)
{

}
}
26 changes: 26 additions & 0 deletions modules/event/antara/gaming/event/quit.game.event.hpp
Original file line number Diff line number Diff line change
@@ -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_;
};
}
25 changes: 25 additions & 0 deletions modules/event/antara/gaming/event/start.game.event.hpp
Original file line number Diff line number Diff line change
@@ -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;
};
}

0 comments on commit feb02ec

Please sign in to comment.