diff --git a/src/lib.cpp b/src/lib.cpp index 128417f..41f76e0 100644 --- a/src/lib.cpp +++ b/src/lib.cpp @@ -16,9 +16,11 @@ enum VALIDATION_STATUS { void run() { Room room1(1, "Room 1", 1710087364, RoomStatus::IN_PROGRESS); Room room2(2, "Room 2", 1710087384, RoomStatus::ENDED); - Role role1({Action::KILL, Action::HEAL}); - std::vector actions = {Action::HEAL}; - Role role2(actions); + const Action kill = Action("kill", true); + const Action heal = Action("heal", true); + const Action vote = Action("vote", true); + Role role1({vote, kill, heal}); + Role role2({heal}); } int validateAction( @@ -26,7 +28,9 @@ int validateAction( if (!actor) { return NO_PLAYER; } - // TODO: Check if action has a target + if (action->hasTarget && !target) { + return NO_PLAYER; + } if (room->status != RoomStatus::IN_PROGRESS) { return ROOM_NOT_IN_PROGRESS; } diff --git a/src/prep/prep.cpp b/src/prep/prep.cpp index 6ef7707..7c2453d 100644 --- a/src/prep/prep.cpp +++ b/src/prep/prep.cpp @@ -8,6 +8,11 @@ int add(int a, int b) { return a + b; } +Action::Action(std::string name, bool hasTarget) { + this->name = name; + this->hasTarget = hasTarget; +} + Role::Role(std::initializer_list actions) { for (auto &a : actions) { this->actions.push_back(a); diff --git a/src/prep/prep.hh b/src/prep/prep.hh index 01969c3..6ba1ee2 100644 --- a/src/prep/prep.hh +++ b/src/prep/prep.hh @@ -18,14 +18,6 @@ enum EventType { PLAYER_STATE_CHANGE, }; -enum Action { - KILL, - VOTE, - INVESTIGATE, - HEAL, - PROTECT, -}; - enum RoomStatus { AWAITING_START, IN_PROGRESS, @@ -45,6 +37,13 @@ struct Player; struct Room; struct Event; +struct Action { + std::string name; + bool hasTarget; + + Action(std::string name, bool hasTarget); +}; + struct Role { std::vector actions;