mirror of
https://github.com/jorenchik/testing-spring-2024.git
synced 2025-10-21 20:10:36 +00:00
refactor(role): move role to separate file
This commit is contained in:
parent
f9e6644ebc
commit
9a4b8831ee
@ -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;
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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),
|
||||
|
||||
@ -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
10
src/role.cc
Normal 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
15
src/role.hh
Normal 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
|
||||
Loading…
Reference in New Issue
Block a user