16 std::cout <<
"SHOOT " << msg.
id;
22 std::cout <<
"KILL " << msg.
id;
25 std::cout <<
"MOVE " << msg.
id;
28 std::cout <<
"STATUS ";
32 std::cout <<
"ON GOING";
35 std::cout <<
"VICTORY";
38 std::cout <<
"DEFEAT";
45 std::cout << std::endl;
62 std::vector<std::optional<int>> v1 = {97, 98, std::nullopt, 99, 100};
63 std::vector<std::optional<char>> v2 = {
'a',
'b',
'o',
'c', std::nullopt};
67 for (
auto &&[num, letter] : z) {
69 throw std::runtime_error(
"Zipper is not zipping.");
72 catch(std::exception& e)
74 std::cout <<
"Test Failed" << std::endl;
75 std::cerr <<
"Exception caught: " << e.what() << std::endl;
78 std::cout <<
"Test OK" << std::endl;
84 std::vector<std::optional<int>> v1 = {97, 98, std::nullopt, 99, 100};
85 std::vector<std::optional<char>> v2 = {
'a',
'b',
'o',
'c', std::nullopt};
89 for (
auto &&[idx, num, letter] : z) {
91 throw std::runtime_error(
"IndexedZipper is not zipping.");
94 catch(
const std::exception& e)
96 std::cout <<
"Test Failed" << std::endl;
97 std::cerr <<
"Exception caught: " << e.what() << std::endl;
100 std::cout <<
"Test OK" << std::endl;
110 }
catch (std::exception &e) {
111 std::cout <<
"Test Failed" << std::endl;
112 std::cerr <<
"Exception caught: " << e.what() << std::endl;
115 std::cout <<
"Test OK" << std::endl;
123 throw std::runtime_error(
"Registry not initialized");
125 }
catch (std::exception &e) {
126 std::cout <<
"Test Failed" << std::endl;
127 std::cerr <<
"Exception caught: " << e.what() << std::endl;
130 std::cout <<
"Test OK" << std::endl;
138 }
catch (std::exception &e) {
139 std::cout <<
"Test Failed" << std::endl;
140 std::cerr <<
"Exception caught: " << e.what() << std::endl;
143 std::cout <<
"Test OK" << std::endl;
151 throw std::runtime_error(
"Game not initialized");
153 }
catch (std::exception &e) {
154 std::cout <<
"Test Failed" << std::endl;
155 std::cerr <<
"Exception caught: " << e.what() << std::endl;
158 std::cout <<
"Test OK" << std::endl;
166 throw std::runtime_error(
"Game not initialized");
169 for (
auto a : list) {
170 std::istringstream iss = std::istringstream(a);
174 }
catch (std::exception &e) {
175 std::cout <<
"Test Failed" << std::endl;
176 std::cerr <<
"Exception caught: " << e.what() << std::endl;
179 std::cout <<
"Test OK" << std::endl;
186 std::ostringstream oss;
190 throw std::runtime_error(
"Game not initialized");
196 for (
auto a : list) {
197 std::istringstream iss = std::istringstream(a);
201 }
catch (std::exception &e) {
202 std::cout <<
"Test Failed" << std::endl;
203 std::cerr <<
"Exception caught: " << e.what() << std::endl;
206 std::cout <<
"Test OK" << std::endl;
216 std::ostringstream oss;
224 for (
int i = 0; i <= 60; i++) {
227 for (
auto event : events) {
228 std::cout <<
"frame " << i <<
": ";
229 std::istringstream iss(event);
234 }
catch (std::exception &e) {
235 std::cout <<
"Test Failed" << std::endl;
236 std::cerr <<
"Exception caught: " << e.what() << std::endl;
239 std::cout <<
"Test OK" << std::endl;
GameMessage deserialize(std::istringstream &is)
Deserializes a GameMessage object from a binary stream.
void serialize(const GameMessage &message, std::ostringstream &os)
Serializes a GameMessage object into a binary stream.
@ P_SHOOT
Represents a player shooting event.
@ P_CONNECT
Represents a connecting player event.
@ P_DAMAGE
Represents a damage event.
@ P_KILL
Represents a kill event.
@ P_STATUS
Represents a status event.
@ P_SPAWN
Represents a spawn event.
@ P_MOVE
Represents a movement event.
int test_get_game_event(void)
Test retrieving game events from the Game instance.
int test_stress(void)
Test for stress and performance.
int test_indexed_zipper(void)
Test the functionality of the IndexedZipper class.
int test_create_registry(void)
Test function for creating a registry.
int test_zipper(void)
Test the functionality of the Zipper class.
int test_send_msg(void)
Test sending a message to the Game instance.
int test_run_systems(void)
Test function for running systems within the registry.
void printMessage(GameMessage &msg)
int test_create_game(void)
Test function for creating a game.
int test_run_update(void)
Test function for running the game's update cycle.
void cleanup(void)
Cleans up any resources or states after tests.
A utility class for dispatching and handling game events.
Represents the main game logic and state management.
std::forward_list< std::string > getGameEvents(void)
Retrieves game messages.
void update(float _deltaTime)
Updates the game state for the current frame.
void onServerEventReceived(std::string &event)
Handles an event received from server.
Combines multiple containers into a single iterable unit, iterating over corresponding elements from ...
A thread-safe queue for storing and managing GameMessage objects.
Manages entities and their associated components, enabling the creation, deletion,...
void run_systems()
Executes all registered systems.
Combines multiple containers into a single iterable unit, iterating over corresponding elements from ...
A structure representing a game message.
messageType type
The type of message (e.g., SPAWN, MOVE, etc.).
messageInfo msg
Additional information about the event (status, asset ID, and coordinates).
std::size_t id
The unique identifier for the entity or object involved in the event.
uint8_t status
Status of the event (e.g., success or failure).
coord coords
Coordinates associated with the event, such as the position of an entity.
int asset_id
ID representing the game asset related to the event (e.g., entity or object).