From d8daa3e045ca2f41edcbed533bc5a9fef1363a17 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Wed, 30 Oct 2024 20:31:18 +0100 Subject: print to backend --- frontend/cmd/cheat.cpp | 3 ++- frontend/cmd/get.cpp | 7 +++---- frontend/cmd/go.cpp | 2 +- frontend/cmd/help.cpp | 3 ++- frontend/cmd/query.cpp | 5 ++--- frontend/cmd/search.cpp | 9 ++++----- frontend/cmd/view.cpp | 3 ++- 7 files changed, 16 insertions(+), 16 deletions(-) (limited to 'frontend/cmd') diff --git a/frontend/cmd/cheat.cpp b/frontend/cmd/cheat.cpp index aeed5f4..7a020a3 100644 --- a/frontend/cmd/cheat.cpp +++ b/frontend/cmd/cheat.cpp @@ -1,5 +1,6 @@ +#include "backend/print.h" + #include "../Player.h" -#include "../print.h" using namespace std; diff --git a/frontend/cmd/get.cpp b/frontend/cmd/get.cpp index 12c3353..8aa2d75 100644 --- a/frontend/cmd/get.cpp +++ b/frontend/cmd/get.cpp @@ -1,7 +1,7 @@ #include "../Player.h" #include "../strings.h" -#include "../print.h" +#include "backend/print.h" #include "backend/GoldObject.h" #include "backend/Location.h" @@ -9,11 +9,10 @@ using namespace std; FollowupAction Player::cmd_get(string & target_name) { unique_ptr target = nullptr; - for (Object * object : this->location.get_objects()) { - if (object->get_hidden() == true) continue; + for (Object * object : this->location.get_visible_objects()) { if (str_lower(object->get_name().c_str()) != str_lower(target_name)) continue; target = unique_ptr(object); - this->location.remove_object(object); + this->location.remove_visible_object(object); break; } if (target == nullptr) { diff --git a/frontend/cmd/go.cpp b/frontend/cmd/go.cpp index 624bf6c..9565e99 100644 --- a/frontend/cmd/go.cpp +++ b/frontend/cmd/go.cpp @@ -1,7 +1,7 @@ #include "backend/Location.h" +#include "backend/print.h" #include "../Player.h" -#include "../print.h" #include "../strings.h" using namespace std; diff --git a/frontend/cmd/help.cpp b/frontend/cmd/help.cpp index e614f28..b655a45 100644 --- a/frontend/cmd/help.cpp +++ b/frontend/cmd/help.cpp @@ -1,4 +1,5 @@ -#include "../print.h" +#include "backend/print.h" + #include "../Player.h" using namespace std; diff --git a/frontend/cmd/query.cpp b/frontend/cmd/query.cpp index acd6cee..19f2584 100644 --- a/frontend/cmd/query.cpp +++ b/frontend/cmd/query.cpp @@ -1,9 +1,9 @@ #include "backend/Location.h" #include "backend/Object.h" #include "backend/Enemy.h" +#include "backend/print.h" #include "../Player.h" -#include "../print.h" using namespace std; @@ -21,8 +21,7 @@ FollowupAction Player::cmd_query(string &) { { lprtf("Zichtbare objecten: "); size_t objects = 0; - for (Object * obj : this->location.get_objects()) { - if (obj->get_hidden() == true) continue; + for (Object * obj : this->location.get_visible_objects()) { if (objects > 0) lprtf(", "); lprtf("%s", obj->get_displayname().c_str()); objects++; diff --git a/frontend/cmd/search.cpp b/frontend/cmd/search.cpp index 67b0bf1..f10709a 100644 --- a/frontend/cmd/search.cpp +++ b/frontend/cmd/search.cpp @@ -1,17 +1,16 @@ #include "../Player.h" -#include "../print.h" +#include "backend/print.h" #include "backend/Location.h" using namespace std; FollowupAction Player::cmd_search(string &) { bool found = false; - for (Object * object : this->location.get_objects()) { - if (object->get_hidden() == false) continue; + for (Object * object : this->location.get_hidden_objects()) { if (!found) lprtf("Je vindt:\n"); - lprtf("- %s\n", object->get_displayname()); - object->set_hidden(false); + lprtf("- %s\n", object->get_displayname().c_str()); + this->location.unhide_object(object); found = true; } if (!found) diff --git a/frontend/cmd/view.cpp b/frontend/cmd/view.cpp index b9d179b..a252715 100644 --- a/frontend/cmd/view.cpp +++ b/frontend/cmd/view.cpp @@ -1,7 +1,8 @@ -#include "../print.h" #include "../Player.h" #include "../strings.h" +#include "backend/print.h" + using namespace std; FollowupAction Player::cmd_view(string & target) { -- cgit v1.2.3