-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
121 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
** EPITECH PROJECT, 2022 | ||
** Bomberman | ||
** File description: | ||
** User | ||
*/ | ||
|
||
#include "User.hpp" | ||
|
||
namespace game | ||
{ | ||
User::User(size_t id, int gamepadId) : _profile(id), _gamepadId(gamepadId) { setAvailable(false); } | ||
|
||
void User::setKeyboard() { _gamepadId = -1; } | ||
|
||
bool User::isKeyboard() const { return _gamepadId < 0; } | ||
|
||
void User::setGamepadId(int id) { _gamepadId = id; } | ||
|
||
int User::getGamepadId() const { return _gamepadId; } | ||
|
||
void User::setId(size_t id) { _profile.load(id); } | ||
|
||
size_t User::getId() const { return _profile.getId(); } | ||
|
||
void User::setAvailable(bool available) { _available = available; } | ||
|
||
bool User::isAvailable() const { return _available; } | ||
} // namespace game |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
** EPITECH PROJECT, 2022 | ||
** Bomberman | ||
** File description: | ||
** User | ||
*/ | ||
|
||
#ifndef GAME_USER_HPP_ | ||
#define GAME_USER_HPP_ | ||
|
||
#include "settings/Profile.hpp" | ||
|
||
namespace game | ||
{ | ||
class User { | ||
public: | ||
User(size_t id = 0, int gamepadId = -1); | ||
~User() = default; | ||
|
||
void setKeyboard(); | ||
bool isKeyboard() const; | ||
|
||
void setGamepadId(int id); | ||
int getGamepadId() const; | ||
|
||
void setId(size_t id); | ||
size_t getId() const; | ||
|
||
void setAvailable(bool available); | ||
bool isAvailable() const; | ||
|
||
private: | ||
int _gamepadId; | ||
bool _available; | ||
settings::Profile _profile; | ||
}; | ||
} // namespace game | ||
|
||
#endif /* !GAME_USER_HPP_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
** EPITECH PROJECT, 2022 | ||
** Bomberman | ||
** File description: | ||
** Users | ||
*/ | ||
|
||
#include "Users.hpp" | ||
|
||
namespace game | ||
{ | ||
Users::Users() | ||
{ | ||
for (size_t i = 0; i < UserId::PlayerCount; i++) | ||
_users[i].setId(i); | ||
} | ||
|
||
User &Users::operator[](UserId id) { return _users[id]; } | ||
|
||
const User &Users::operator[](UserId id) const { return _users[id]; } | ||
|
||
} // namespace game |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
** EPITECH PROJECT, 2022 | ||
** Bomberman | ||
** File description: | ||
** Users | ||
*/ | ||
|
||
#ifndef GAME_USERS_HPP_ | ||
#define GAME_USERS_HPP_ | ||
|
||
#include "User.hpp" | ||
#include "ecs/resource/Resource.hpp" | ||
|
||
namespace game | ||
{ | ||
class Users : public ecs::Resource { | ||
public: | ||
enum UserId { Player1, Player2, Player3, Player4, PlayerCount }; | ||
|
||
Users(); | ||
~Users() = default; | ||
|
||
const User &operator[](UserId id) const; | ||
User &operator[](UserId id); | ||
|
||
private: | ||
User _users[UserId::PlayerCount]; | ||
}; | ||
} // namespace game | ||
|
||
#endif /* !GAME_USERS_HPP_ */ |