aboutsummaryrefslogtreecommitdiff
path: root/frontend/cmd
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-10-30 15:27:59 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-10-30 15:27:59 +0100
commita3c1ba7b49e4c5901d7c9dd917049744ad20fc96 (patch)
tree66750c2c740aca751f47c2896985d2b79f6f7806 /frontend/cmd
parent6dfa3fb34fb0a2ea028fd46e77296e26b092fb99 (diff)
enemy loading kinda works
Diffstat (limited to 'frontend/cmd')
-rw-r--r--frontend/cmd/query.cpp14
-rw-r--r--frontend/cmd/search.cpp16
2 files changed, 27 insertions, 3 deletions
diff --git a/frontend/cmd/query.cpp b/frontend/cmd/query.cpp
index e1e45a1..23d2a42 100644
--- a/frontend/cmd/query.cpp
+++ b/frontend/cmd/query.cpp
@@ -1,5 +1,6 @@
#include "backend/Location.h"
#include "backend/Object.h"
+#include "backend/Enemy.h"
#include "../Player.h"
#include "../print.h"
@@ -43,7 +44,18 @@ FollowupAction Player::cmd_query(string &) {
lprtf("\n");
}
- // TODO: enemies
+ {
+ lprtf("Vijanden: ");
+ size_t enemies = 0;
+ for (Enemy * enemy : this->location.get_enemies()) {
+ if (enemies > 0) lprtf(", ");
+ lprtf("%s", enemy->get_name());
+ enemies++;
+ }
+ if (enemies == 0)
+ lprtf("(geen)");
+ lprtf("\n");
+ }
return FollowupAction::NONE;
}
diff --git a/frontend/cmd/search.cpp b/frontend/cmd/search.cpp
index 4646ddc..67b0bf1 100644
--- a/frontend/cmd/search.cpp
+++ b/frontend/cmd/search.cpp
@@ -1,9 +1,21 @@
#include "../Player.h"
+#include "../print.h"
+
+#include "backend/Location.h"
using namespace std;
-FollowupAction Player::cmd_search(string & argv) {
- // TODO
+FollowupAction Player::cmd_search(string &) {
+ bool found = false;
+ for (Object * object : this->location.get_objects()) {
+ if (object->get_hidden() == false) continue;
+ if (!found) lprtf("Je vindt:\n");
+ lprtf("- %s\n", object->get_displayname());
+ object->set_hidden(false);
+ found = true;
+ }
+ if (!found)
+ lprtf("Je hebt niks gevonden.\n");
return FollowupAction::UPDATE;
}