R-Type  2
Doom but in better
Loading...
Searching...
No Matches
ToString.cpp
Go to the documentation of this file.
1/*
2** EPITECH PROJECT, 2024
3** rtype (Workspace)
4** File description:
5** ToString.cpp
6*/
7
14#include "Recoded/ToString.hpp"
15
16const std::string Recoded::myToString(bool value)
17{
18 if (value) {
19 return "true";
20 }
21 return "false";
22};
23
24const std::string Recoded::myToString(const ActiveScreen &item)
25{
26 switch (item) {
28 return "LOADING";
29 break;
31 return "MENU";
32 break;
34 return "GAME";
35 break;
37 return "DEMO";
38 break;
40 return "EXIT";
41 break;
43 return "UNKNOWN";
44 break;
46 return "SETTINGS";
47 break;
49 return "GAME OVER";
50 break;
52 return "GAME WON";
53 break;
55 return "BOSS FIGHT";
56 break;
58 return "CONNECTION FAILED";
59 break;
61 return "CONNECTION ADDRESS";
62 break;
64 return "LOBBY LIST";
65 break;
67 return "LOBBY ROOM";
68 break;
69 default:
70 return "UNKNOWN";
71 break;
72 };
73};
74
76{
77 std::string indent = "";
78 std::string result = indent + "Package: {\n";
79 result += indent + "- GraphicID: " + Recoded::myToString(item.GraphicID) + "\n";
80 result += indent + "- EntityID: " + Recoded::myToString(item.EntityID) + "\n";
81 result += indent + "- posx: " + Recoded::myToString(item.posx) + "\n";
82 result += indent + "- posy: " + Recoded::myToString(item.posy) + "\n";
83 result += indent + "}\n";
84 return result;
85}
86
88{
90 return "PLAYER";
91 }
93 return "ENEMY";
94 }
96 return "LASER_ENEMY";
97 }
98
100 return "LASER_PLAYER";
101 }
102 return "UNKNOWN";
103};
104
106{
107 std::string indent = "";
108 std::string result = indent + "ECSPackage: {\n";
109 result += indent + "- EntityID: " + Recoded::myToString(item.EntityID) + "\n";
110 result += indent + "- posx: " + Recoded::myToString(item.posx) + "\n";
111 result += indent + "- posy: " + Recoded::myToString(item.posy) + "\n";
112 result += indent + "}\n";
113 return result;
114}
115
117{
118 std::string indent = "";
119 std::string result = indent + "EntityActions: {\n";
120 result += indent + "- type: " + Recoded::myToString(item.type) + "\n";
121 result += indent + "- posx: " + Recoded::myToString(item.posx) + "\n";
122 result += indent + "- posy: " + Recoded::myToString(item.posy) + "\n";
123 result += indent + "}\n";
124 return result;
125}
126
128{
130 return "MOVE";
131 }
133 return "SHOOT";
134 }
135 return "UNKNOWN";
136}
137
139{
141 return "None";
142 }
144 return "Circle";
145 }
147 return "Convex";
148 }
150 return "Rectangle";
151 }
152 return "Unknown";
153}
154
156{
158 return "Connect";
159 }
161 return "Disconnect";
162 }
164 return "Move";
165 }
167 return "Shoot";
168 }
170 return "Spawn";
171 }
173 return "Kill";
174 }
176 return "Damage";
177 }
179 return "Status";
180 }
182 return "Error";
183 }
184 return "Unknown";
185}
186
188{
189 std::string indent = "";
190 std::string node(messageInfo.username, 9);
191 std::string result = indent + "struct MessageInfo: {\n";
192 result += indent + "- status: " + Recoded::myToString(messageInfo.status) + "\n";
193 result += indent + "- asset_id: " + Recoded::myToString(messageInfo.assetId) + "\n";
194 result += indent + "- username: " + node + "\n";
195 result += indent + "- coords: " + Recoded::myToString(messageInfo.coords) + "\n";
196 result += indent + "}\n";
197 return result;
198}
199
200const std::string Recoded::myToString(const GUI::Network::MessageNode &messageNode)
201{
202 std::string indent = "";
203 std::string result = indent + "struct MessageNode: {\n";
204 result += indent + "- type: " + Recoded::myToString(messageNode.type) + "\n";
205 result += indent + "- id: " + Recoded::myToString(messageNode.id) + "\n";
206 result += indent + "- info: {\n" + Recoded::myToString(messageNode.info) + "}\n";
207 result += indent + "}\n";
208 return result;
209}
210
ActiveScreen
This is the enum class in charge of the window switcher code. This enum allows the mainloop of the pr...
messageType
Enum representing the different types of game messages.
Provides custom string conversion functions as alternatives to std::to_string.
ActiveShape
Enum representing different types of shapes managed by the ShapeComponent.
@ NONE
No shape initialized.
MessageType
Enum for the different message types in the UDP protocol.
const std::string myToString(const Rect< RectType > &rectangle)
Converts a Rect<T> object to its string representation.
Definition Rect.hpp:223
A structure containing information about a game message.
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.
char username[9]
Username of player connecting.