refactor(modules): move files to modules dir

This commit is contained in:
Kristofers Solo 2024-03-14 01:43:19 +02:00
parent 9f0b32ed8c
commit 6ed14fd2c0
20 changed files with 46 additions and 31 deletions

View File

@ -9,13 +9,13 @@ project(
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
add_subdirectory(src/ccunit) add_subdirectory(src/cppunit)
add_subdirectory(src/prep) add_subdirectory(src/modules)
add_executable(main src/main.cc) add_executable(main src/main.cc)
add_library(lib src/lib.cc src/lib.hh) add_library(lib src/lib.cc src/lib.hh src/validation.cc src/validation.hh)
target_link_libraries(main PUBLIC lib) target_link_libraries(main PUBLIC lib)
target_link_libraries(lib PUBLIC prepLib) target_link_libraries(lib PUBLIC modules)
target_include_directories(main PUBLIC "${PROJECT_BINARY_DIR}" target_include_directories(main PUBLIC "${PROJECT_BINARY_DIR}"
"${PROJECT_SOURCE_DIR}/prep") "${PROJECT_SOURCE_DIR}/prep")
target_include_directories(lib PUBLIC "${PROJECT_BINARY_DIR}" target_include_directories(lib PUBLIC "${PROJECT_BINARY_DIR}"

View File

@ -1 +1 @@
add_library(ccunit ccunit.cc ccunit.hh) add_library(cppunit cppunit.cc cppunit.hh)

View File

@ -1 +1 @@
#include "validation.hh" #include "./validation.hh"

View File

@ -1,4 +1,4 @@
#include "lib.hh" #include "./lib.hh"
#include <stdlib.h> #include <stdlib.h>

View File

@ -0,0 +1,14 @@
add_library(
modules
action.cc
action.hh
event.cc
event.hh
player.cc
player.hh
role.cc
role.hh
room.cc
room.hh
time.cc
time.hh)

View File

@ -1,4 +1,4 @@
#include "action.hh" #include "./action.hh"
#include <string> #include <string>

View File

@ -1,7 +1,7 @@
#include "event.hh" #include "./event.hh"
#include "action.hh" #include "./action.hh"
#include "time.hh" #include "./time.hh"
#include <initializer_list> #include <initializer_list>
#include <string> #include <string>

View File

@ -1,7 +1,7 @@
#ifndef EVENT_HH #ifndef EVENT_HH
#define EVENT_HH #define EVENT_HH
#include "action.hh" #include "./action.hh"
#include <cstdint> #include <cstdint>
#include <ctime> #include <ctime>
@ -16,7 +16,7 @@ namespace event {
RoomStateChange, RoomStateChange,
PlayerStateChange, PlayerStateChange,
}; };
} } // namespace event
struct Event { struct Event {
std::string title; std::string title;

View File

@ -1,6 +1,6 @@
#include "player.hh" #include "./player.hh"
#include "role.hh" #include "./role.hh"
#include <string> #include <string>

View File

@ -1,7 +1,7 @@
#ifndef PLAYER_HH #ifndef PLAYER_HH
#define PLAYER_HH #define PLAYER_HH
#include "role.hh" #include "./role.hh"
#include <cstdint> #include <cstdint>
#include <string> #include <string>
@ -13,7 +13,7 @@ namespace player {
Dead, Dead,
VotedOut, VotedOut,
}; };
} } // namespace player
struct Player { struct Player {
uint32_t id; uint32_t id;

View File

@ -1,4 +1,4 @@
#include "role.hh" #include "./role.hh"
#include <initializer_list> #include <initializer_list>
#include <vector> #include <vector>

View File

@ -1,15 +1,15 @@
#ifndef ROLE_HH #ifndef ROLE_HH
#define ROLE_HH #define ROLE_HH
#include "action.hh" #include "./action.hh"
#include <initializer_list> #include <initializer_list>
#include <vector> #include <vector>
struct Role { struct Role {
std::vector<Action> actions; std::vector<Action> actions;
Role(std::initializer_list<Action> actions);
Role(std::vector<Action> actions); Role(std::vector<Action> actions);
Role(std::initializer_list<Action> actions);
}; };
#endif // !ROLE_HH #endif // !ROLE_HH

View File

@ -1,6 +1,6 @@
#include "room.hh" #include "./room.hh"
#include "time.hh" #include "./time.hh"
#include <cstdint> #include <cstdint>
#include <initializer_list> #include <initializer_list>

View File

@ -1,7 +1,7 @@
#ifndef ROOM_HH #ifndef ROOM_HH
#define ROOM_HH #define ROOM_HH
#include "player.hh" #include "./player.hh"
#include <cstdint> #include <cstdint>
#include <ctime> #include <ctime>
@ -16,7 +16,7 @@ namespace room {
Stopped, Stopped,
Ended, Ended,
}; };
} } // namespace room
struct Room { struct Room {
uint32_t id; uint32_t id;

View File

@ -1 +0,0 @@
add_library(prepLib prep.cc prep.hh timeUtils.cc timeUtils.hh)

View File

@ -1,6 +1,6 @@
#include "validation.hh" #include "./validation.hh"
#include "room.hh" #include "modules/room.hh"
#include <algorithm> #include <algorithm>

View File

@ -1,9 +1,11 @@
#ifndef VALIDATION_HH #ifndef VALIDATION_HH
#define VALIDATION_HH #define VALIDATION_HH
#include "event.hh" #include "modules/event.hh"
#include "player.hh" #include "modules/player.hh"
#include "room.hh" #include "modules/room.hh"
#include <vector>
namespace validation { namespace validation {
enum Status { enum Status {
@ -19,7 +21,7 @@ namespace validation {
NoRelatedEvents, NoRelatedEvents,
ActionValid, ActionValid,
}; };
} } // namespace validation
int validateAction(Player *actor, const Action *action, Room *room, std::vector<Event> *relatedEvents, Player *target); int validateAction(Player *actor, const Action *action, Room *room, std::vector<Event> *relatedEvents, Player *target);