mirror of
https://github.com/jorenchik/testing-spring-2024.git
synced 2025-10-21 20:10:36 +00:00
refactor(player): move player to separate file
This commit is contained in:
parent
9a4b8831ee
commit
b4b01c4a11
@ -10,4 +10,4 @@ struct Action {
|
||||
bool operator==(const Action &other) const;
|
||||
};
|
||||
|
||||
#endif // ACTION_HH
|
||||
#endif // !ACTION_HH
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
#include "action.hh"
|
||||
#include "player.hh"
|
||||
#include "prep/prep.hh"
|
||||
#include "role.hh"
|
||||
|
||||
|
||||
16
src/player.cc
Normal file
16
src/player.cc
Normal file
@ -0,0 +1,16 @@
|
||||
#include "player.hh"
|
||||
|
||||
#include "role.hh"
|
||||
|
||||
#include <string>
|
||||
|
||||
Player::Player(uint32_t id, std::string username, Role role, PlayerStatus status):
|
||||
id(id),
|
||||
username(username),
|
||||
role(role),
|
||||
status(status) {
|
||||
}
|
||||
|
||||
bool Player::operator==(const Player &other) const {
|
||||
return this->id == other.id;
|
||||
}
|
||||
26
src/player.hh
Normal file
26
src/player.hh
Normal file
@ -0,0 +1,26 @@
|
||||
#ifndef PLAYER_HH
|
||||
#define PLAYER_HH
|
||||
|
||||
#include "role.hh"
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
enum PlayerStatus {
|
||||
Kicked,
|
||||
Alive,
|
||||
Dead,
|
||||
VotedOut,
|
||||
};
|
||||
|
||||
struct Player {
|
||||
uint32_t id;
|
||||
std::string username;
|
||||
Role role;
|
||||
PlayerStatus status;
|
||||
|
||||
Player(uint32_t id, std::string username, Role role, PlayerStatus status);
|
||||
bool operator==(const Player &other) const;
|
||||
};
|
||||
|
||||
#endif // !PLAYER_HH
|
||||
@ -5,17 +5,6 @@
|
||||
#include <cstdint>
|
||||
#include <initializer_list>
|
||||
|
||||
Player::Player(uint32_t id, std::string username, Role role, PlayerStatus playerStatus):
|
||||
id(id),
|
||||
username(username),
|
||||
role(role),
|
||||
playerStatus(playerStatus) {
|
||||
}
|
||||
|
||||
bool Player::operator==(const Player &other) const {
|
||||
return this->id == other.id;
|
||||
}
|
||||
|
||||
Room::Room(
|
||||
uint32_t id, std::string title, uint32_t utcTimestampCreatedAt, RoomStatus status, std::vector<Player> players):
|
||||
id(id),
|
||||
|
||||
@ -21,27 +21,9 @@ enum RoomStatus {
|
||||
ENDED,
|
||||
};
|
||||
|
||||
enum PlayerStatus {
|
||||
KICKED,
|
||||
ALIVE,
|
||||
DEAD,
|
||||
VOTED_OUT,
|
||||
};
|
||||
|
||||
struct Player;
|
||||
struct Room;
|
||||
struct Event;
|
||||
|
||||
struct Player {
|
||||
uint32_t id;
|
||||
std::string username;
|
||||
Role role;
|
||||
PlayerStatus playerStatus;
|
||||
|
||||
Player(uint32_t id, std::string username, Role role, PlayerStatus playerStatus);
|
||||
bool operator==(const Player &other) const;
|
||||
};
|
||||
|
||||
struct Room {
|
||||
uint32_t id;
|
||||
std::string title;
|
||||
|
||||
@ -12,4 +12,4 @@ struct Role {
|
||||
Role(std::vector<Action> actions);
|
||||
};
|
||||
|
||||
#endif // ROLE_HH
|
||||
#endif // !ROLE_HH
|
||||
|
||||
Loading…
Reference in New Issue
Block a user