aboutsummaryrefslogtreecommitdiff
path: root/frontend/cmd/put.cpp
blob: 5460b0242a380c83273eb913bfe77ab1bb287621 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <algorithm>

#include "../Player.h"
#include "../strings.h"

#include "backend/print.h"
#include "backend/Location.h"

using namespace std;

FollowupAction Player::cmd_put(string & target_name) {
	auto el = find_if(this->inventory.begin(), this->inventory.end(), [target_name](const auto & object) -> bool {
		return str_lower(object->get_name().c_str()) == str_lower(target_name);
	});
	if (el == this->inventory.end()) {
		lprtf("Object \"%s\" niet gevonden.\n", target_name.c_str());
		return FollowupAction::NONE;
	}

	lprtf("Je legt %s neer op de locatie %s.\n", (*el)->get_displayname().c_str(), this->location.get_name().c_str());
	this->location.add_visible_object((*el).release());
	this->inventory.erase(el);
	return FollowupAction::NONE;
}