refactor(action): move action to separate file

This commit is contained in:
Kristofers Solo 2024-03-14 00:36:06 +02:00
parent acf1bcc2c7
commit f9e6644ebc
5 changed files with 24 additions and 17 deletions

10
src/action.cc Normal file
View File

@ -0,0 +1,10 @@
#include "action.hh"
Action::Action(std::string name, bool has_target) {
this->name = name;
this->has_target = has_target;
}
bool Action::operator==(const Action &other) const {
return this->name == other.name;
}

13
src/action.hh Normal file
View File

@ -0,0 +1,13 @@
#ifndef ACTION_HH
#define ACTION_HH
#include <string>
struct Action {
std::string name;
bool has_target;
Action(std::string name, bool has_target);
bool operator==(const Action &other) const;
};
#endif // ACTION_HH

View File

@ -1,3 +1,4 @@
#include "action.hh"
#include "prep/prep.hh"
bool playerBelongsToRoom(Player *player, Room *room);

View File

@ -5,15 +5,6 @@
#include <cstdint>
#include <initializer_list>
Action::Action(std::string name, bool hasTarget) {
this->name = name;
this->hasTarget = hasTarget;
}
bool Action::operator==(const Action &other) const {
return this->name == other.name;
}
Role::Role(std::initializer_list<Action> actions): Role(std::vector<Action>(actions)) {
}

View File

@ -33,14 +33,6 @@ struct Player;
struct Room;
struct Event;
struct Action {
std::string name;
bool hasTarget;
Action(std::string name, bool hasTarget);
bool operator==(const Action &other) const;
};
struct Role {
std::vector<Action> actions;