refactor(role): move role to separate file

This commit is contained in:
Kristofers Solo 2024-03-14 00:40:35 +02:00
parent f9e6644ebc
commit 9a4b8831ee
6 changed files with 28 additions and 14 deletions

View File

@ -1,5 +1,7 @@
#include "action.hh"
#include <string>
Action::Action(std::string name, bool has_target) {
this->name = name;
this->has_target = has_target;

View File

@ -1,5 +1,6 @@
#include "action.hh"
#include "prep/prep.hh"
#include "role.hh"
bool playerBelongsToRoom(Player *player, Room *room);
bool actionBelongsToRole(Role *role, const Action *action);

View File

@ -5,12 +5,6 @@
#include <cstdint>
#include <initializer_list>
Role::Role(std::initializer_list<Action> actions): Role(std::vector<Action>(actions)) {
}
Role::Role(std::vector<Action> actions): actions(actions) {
}
Player::Player(uint32_t id, std::string username, Role role, PlayerStatus playerStatus):
id(id),
username(username),

View File

@ -28,18 +28,10 @@ enum PlayerStatus {
VOTED_OUT,
};
struct Role;
struct Player;
struct Room;
struct Event;
struct Role {
std::vector<Action> actions;
Role(std::initializer_list<Action> actions);
Role(std::vector<Action> actions);
};
struct Player {
uint32_t id;
std::string username;

10
src/role.cc Normal file
View File

@ -0,0 +1,10 @@
#include "role.hh"
#include <initializer_list>
#include <vector>
Role::Role(std::initializer_list<Action> actions): Role(std::vector<Action>(actions)) {
}
Role::Role(std::vector<Action> actions): actions(actions) {
}

15
src/role.hh Normal file
View File

@ -0,0 +1,15 @@
#ifndef ROLE_HH
#define ROLE_HH
#include "action.hh"
#include <initializer_list>
#include <vector>
struct Role {
std::vector<Action> actions;
Role(std::initializer_list<Action> actions);
Role(std::vector<Action> actions);
};
#endif // ROLE_HH