mirror of
https://github.com/jorenchik/testing-spring-2024.git
synced 2025-10-21 20:10:36 +00:00
feat: target player bool for action
Added validation logic that checks for target player if needed.
This commit is contained in:
parent
ee12e48a86
commit
9a7bc42db6
12
src/lib.cpp
12
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<Action> 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;
|
||||
}
|
||||
|
||||
@ -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<Action> actions) {
|
||||
for (auto &a : actions) {
|
||||
this->actions.push_back(a);
|
||||
|
||||
@ -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<Action> actions;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user