Jetpack documentation 1.0.0
Loading...
Searching...
No Matches
ServerClient.hpp
1/*
2** EPITECH PROJECT, 2025
3** jetpack
4** File description:
5** The Client.hpp
6*/
13#ifndef CLIENT_HPP_
14 #define CLIENT_HPP_
15
16 #include "server/Server.hpp"
17
18namespace Jetpack {
24 public:
25 /* Constructor and destructor */
26
33 Client(int socket_fd, struct sockaddr_in client_addr, double start_y_pos);
37 ~Client();
42 Client(const Client &);
48 Client &operator=(const Client &);
49
50
51
52 /* Getter and Setter for client information */
53
58 const std::string &getNextCommand() const;
63 void setNextCommand(const std::string &nextCommand);
68 const int &getSocketFd() const;
73 const struct sockaddr_in &getClientAddr() const;
74
75
76
77 /* Getter and Setter for client player */
78
83 const std::string &getPseudo() const;
88 void setPseudo(const std::string &pseudo);
93 const std::array<double, 2> &getPosition() const;
98 void setPosition(const std::array<double, 2> &position);
103 const std::size_t &getScore() const;
108 void setScore(std::size_t score);
113 const bool &isAlive() const;
118 void setAlive(bool alive);
123 const bool &useJetpack() const;
128 void setJetpack(bool jetpack);
133 const double &getSpeed() const;
138 void setSpeed(double speed);
143 std::vector<std::array<std::size_t, 2>> &getCoinsList();
144
145
146
147 private:
148 std::string _next_command; /* The next command to be executed */
149 const int _socket_fd; /* The socket file descriptor */
150 const struct sockaddr_in _client_addr; /* The address of the client */
151
152 std::string _pseudo; /* The pseudo of the client */
153 std::array<double, 2> _position = {0.0, 0.0}; /* The position of the client */
154 std::size_t _score = 0; /* The score of the client */
155 bool _alive = true; /* The live status of the client */
156 bool _jetpack = false; /* The jetpack status of the client */
157 double _speed = 0.0; /* The speed of the client */
158 std::vector<std::array<std::size_t, 2>> _coins_list; /* The list of coins collected by the client */
159 };
160}
161
162#endif /* CLIENT_HPP_ */
The Server.hpp.
A class that represents a client connected to the server.
Definition ServerClient.hpp:23
void setPosition(const std::array< double, 2 > &position)
Sets the position of the client.
Definition ServerClient.cpp:143
Client(int socket_fd, struct sockaddr_in client_addr, double start_y_pos)
Constructor for Client class.
Definition ServerClient.cpp:22
const std::size_t & getScore() const
Gets the score of the client.
Definition ServerClient.cpp:152
void setPseudo(const std::string &pseudo)
Sets the pseudo of the client.
Definition ServerClient.cpp:125
const std::string & getPseudo() const
Gets the pseudo of the client.
Definition ServerClient.cpp:116
void setAlive(bool alive)
Sets the alive status of the client.
Definition ServerClient.cpp:179
const std::string & getNextCommand() const
Gets the next command to be executed.
Definition ServerClient.cpp:80
~Client()
Destructor for Client class.
Definition ServerClient.cpp:33
void setJetpack(bool jetpack)
Sets the jetpack status of the client.
Definition ServerClient.cpp:199
const double & getSpeed() const
Gets the speed of the client.
Definition ServerClient.cpp:208
const struct sockaddr_in & getClientAddr() const
Gets the client address.
Definition ServerClient.cpp:107
void setSpeed(double speed)
Sets the speed of the client.
Definition ServerClient.cpp:217
Client & operator=(const Client &)
Assignment operator for Client class.
Definition ServerClient.cpp:61
void setScore(std::size_t score)
Sets the score of the client.
Definition ServerClient.cpp:161
void setNextCommand(const std::string &nextCommand)
Sets the next command to be executed.
Definition ServerClient.cpp:89
const std::array< double, 2 > & getPosition() const
Gets the position of the client.
Definition ServerClient.cpp:134
const bool & isAlive() const
Gets the alive status of the client.
Definition ServerClient.cpp:170
const bool & useJetpack() const
Gets the jetpack status of the client.
Definition ServerClient.cpp:190
const int & getSocketFd() const
Gets the socket file descriptor.
Definition ServerClient.cpp:98
std::vector< std::array< std::size_t, 2 > > & getCoinsList()
Gets the list of coins collected by the client.
Definition ServerClient.cpp:226