mirror of
https://github.com/jorenchik/testing-spring-2024.git
synced 2025-10-21 20:10:36 +00:00
refactor(action): move action to separate file
This commit is contained in:
parent
acf1bcc2c7
commit
f9e6644ebc
10
src/action.cc
Normal file
10
src/action.cc
Normal 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
13
src/action.hh
Normal 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
|
||||
@ -1,3 +1,4 @@
|
||||
#include "action.hh"
|
||||
#include "prep/prep.hh"
|
||||
|
||||
bool playerBelongsToRoom(Player *player, Room *room);
|
||||
|
||||
@ -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)) {
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user