#include "../Player.h" #include "../strings.h" #include "backend/print.h" #include "backend/GoldObject.h" #include "backend/Location.h" using namespace std; FollowupAction Player::cmd_get(string & target_name) { unique_ptr target = nullptr; 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_visible_object(object); break; } if (target == nullptr) { lprtf("Object \"%s\" niet gevonden\n", target_name.c_str()); return FollowupAction::NONE; } // gold objects are collected and (implicitly) destroyed GoldObject * gold = dynamic_cast(target.get()); if (gold != nullptr) { int count = gold->get_count(); this->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_displayname().c_str()); this->inventory.push_back(std::move(target)); return FollowupAction::NONE; }