From 798948dbe6f012e194f053c4e862cf697f30b793 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Fri, 1 Nov 2024 10:18:22 +0100 Subject: more WIP (move some Player things to backend) --- frontend/cmd/get.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'frontend/cmd/get.cpp') diff --git a/frontend/cmd/get.cpp b/frontend/cmd/get.cpp index 359a5c5..652e989 100644 --- a/frontend/cmd/get.cpp +++ b/frontend/cmd/get.cpp @@ -1,4 +1,6 @@ -#include "../Player.h" +#include + +#include "../GameController.h" #include "../strings.h" #include "backend/print.h" @@ -7,12 +9,14 @@ using namespace std; -FollowupAction Player::cmd_get(string & target_name) { +FollowupAction GameController::cmd_get(string & target_name) { + Location & location = this->player.get_location(); unique_ptr target = nullptr; - for (Object * object : this->location.get_visible_objects()) { + + for (Object * object : location.get_visible_objects()) { if (str_lower(object->get_name().c_str()) != str_lower(target_name)) continue; target = unique_ptr(object); - this->location.remove_visible_object(object); + location.remove_visible_object(object); break; } if (target == nullptr) { @@ -24,14 +28,14 @@ FollowupAction Player::cmd_get(string & target_name) { GoldObject * gold = dynamic_cast(target.get()); if (gold != nullptr) { int count = gold->get_count(); - this->gold += count; + this->player.gold += count; lprtf("Je bent %d goudstuk%s rijker.\n", count, count == 1 ? "" : "ken"); return FollowupAction::NONE; } // other objects go in the inventory lprtf("Je voegt %s toe aan je bezit.\n", target->get_name().c_str()); - this->inventory.push_back(std::move(target)); + this->player.inventory.push_back(target.release()); return FollowupAction::NONE; } -- cgit v1.2.3