aboutsummaryrefslogtreecommitdiff
path: root/frontend/cmd/equip.cpp
blob: b8caad81b2051c724cfa22c61284986b65650ea8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include "backend/ListIterator.h"
#include "backend/Dungeon.h"
#include "backend/Exception.h"

#include "../GameController.h"
#include "../util.h"

using namespace std;

void GameController::cmd_equip(string & target_name) {
	Player & player = this->dungeon->get_player();

	auto it = find_if_range(player.inventory.range(), by_name_case_insensitive(target_name));
	if (!it)
		throw Exception("object \"%s\" niet gevonden", target_name.c_str());

	Object & object = **it;
	player.equip(&object);
	player.inventory.remove(&object);
	this->dungeon->update();
}