blob: 25a375f390d083ed91d55f5b4a144f891f329689 (
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
26
27
28
29
30
31
32
33
|
#include "backend/print.h"
#include "backend/ListIterator.h"
#include "../GameController.h"
#include "../strings.h"
using namespace std;
FollowupAction GameController::cmd_equip(string & target_name) {
for (Object * object : this->player.inventory) {
if (str_lower(object->get_name().c_str()) != str_lower(target_name)) continue;
WeaponObject * weapon = dynamic_cast<WeaponObject *>(object);
if (weapon != nullptr) {
this->player.inventory.remove(weapon);
this->player.equip(weapon);
return FollowupAction::UPDATE;
}
ArmorObject * armor = dynamic_cast<ArmorObject *>(object);
if (armor != nullptr) {
this->player.inventory.remove(armor);
this->player.equip(armor);
return FollowupAction::UPDATE;
}
lprtf("Object %s is niet draagbaar.\n", target_name.c_str());
return FollowupAction::NONE;
}
lprtf("Object \"%s\" niet gevonden.\n", target_name.c_str());
return FollowupAction::NONE;
}
|